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 17:24:14 +0100 |
commit | 9dd1b28174e590a019fa4162b6dc5a069e9af0a5 (patch) | |
tree | fbd02bcf4abd23294629e455ff3223c33cc12d02 /include | |
parent | eb583e76b016540aed3f6658a6711570e8f7214c (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)
(cherry picked from commit 2241a7fd97b8b70d2d3106ac531cc72192ad708f)
Conflicts:
desktop/inc/lib/init.hxx
desktop/source/lib/lokinteractionhandler.hxx
libreofficekit/source/gtk/lokdocview.cxx
Change-Id: I73035193c87033052921c3aad94fdc057fe81111
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 c4c174973ac7..b3b61ba52e41 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> @@ -64,6 +65,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 0f3e0f130f95..df9e211cab53 100644 --- a/include/LibreOfficeKit/LibreOfficeKit.hxx +++ b/include/LibreOfficeKit/LibreOfficeKit.hxx @@ -458,6 +458,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; |