From 43f5161991cffedabb280a6e4e388c5bcbac4f96 Mon Sep 17 00:00:00 2001 From: Ximeng Zu Date: Wed, 26 Jul 2017 11:15:26 -0500 Subject: [Android Viewer] Password support MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added password support for documents. Change-Id: Ifd9cf86894ddaf2fd5ad97510d2ac1b5850611ad Reviewed-on: https://gerrit.libreoffice.org/40458 Tested-by: Jenkins Reviewed-by: Tomaž Vajngerl Tested-by: Tomaž Vajngerl --- desktop/source/lib/lokandroid.cxx | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'desktop') diff --git a/desktop/source/lib/lokandroid.cxx b/desktop/source/lib/lokandroid.cxx index 0f807d061590..3055d38957da 100644 --- a/desktop/source/lib/lokandroid.cxx +++ b/desktop/source/lib/lokandroid.cxx @@ -85,6 +85,7 @@ struct CallbackData }; static CallbackData gCallbackData; +static CallbackData gCallbackDataLOKit; /** * Handle retrieved callback @@ -143,6 +144,45 @@ extern "C" SAL_JNI_EXPORT jobject JNICALL Java_org_libreoffice_kit_Office_docume return aHandle; } +extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Office_setDocumentPassword + (JNIEnv* pEnv, jobject aObject, jstring sUrl, jstring sPassword) +{ + LibreOfficeKit* pLibreOfficeKit = getHandle(pEnv, aObject); + + char const* pUrl = copyJavaString(pEnv, sUrl); + if (sPassword == NULL) { + pLibreOfficeKit->pClass->setDocumentPassword(pLibreOfficeKit, pUrl, nullptr); + } else { + char const* pPassword = copyJavaString(pEnv, sPassword); + pLibreOfficeKit->pClass->setDocumentPassword(pLibreOfficeKit, pUrl, pPassword); + } +} + +extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Office_setOptionalFeatures + (JNIEnv* pEnv, jobject aObject, jlong options) +{ + LibreOfficeKit* pLibreOfficeKit = getHandle(pEnv, aObject); + + uint64_t pOptions = (uint64_t)options; + + pLibreOfficeKit->pClass->setOptionalFeatures(pLibreOfficeKit, pOptions); +} + +/** Implementation of org.libreoffice.kit.Office.bindMessageCallback method */ +extern "C" SAL_JNI_EXPORT void JNICALL Java_org_libreoffice_kit_Office_bindMessageCallback + (JNIEnv* pEnv, jobject aObject) +{ + LibreOfficeKit* pLibreOfficeKit = getHandle(pEnv, aObject); + + gCallbackDataLOKit.aObject = (jobject) pEnv->NewGlobalRef(aObject); + jclass aClass = pEnv->GetObjectClass(aObject); + gCallbackDataLOKit.aClass = (jclass) pEnv->NewGlobalRef(aClass); + + gCallbackDataLOKit.aJavaCallbackMethod = pEnv->GetMethodID(aClass, "messageRetrievedLOKit", "(ILjava/lang/String;)V"); + + pLibreOfficeKit->pClass->registerCallback(pLibreOfficeKit, messageCallback, (void*) &gCallbackDataLOKit); +} + /* Document */ /** Implementation of org.libreoffice.kit.Document.bindMessageCallback method */ -- cgit