[Libreoffice-commits] core.git: Branch 'libreoffice-5-4' - desktop/inc desktop/Library_deploymentgui.mk desktop/source officecfg/registry

Muhammet Kara muhammet.kara at pardus.org.tr
Fri Jun 9 08:25:13 UTC 2017


 desktop/Library_deploymentgui.mk                                     |    2 
 desktop/inc/dp_gui.hrc                                               |    2 
 desktop/source/deployment/gui/dp_gui_dialog.src                      |   12 ++
 desktop/source/deployment/gui/dp_gui_dialog2.cxx                     |   51 +++++++++-
 officecfg/registry/schema/org/openoffice/Office/ExtensionManager.xcs |   19 +++
 5 files changed, 83 insertions(+), 3 deletions(-)

New commits:
commit 5cae6a08a13ab0842826989eb5b840746be494a2
Author: Muhammet Kara <muhammet.kara at pardus.org.tr>
Date:   Mon May 22 11:41:20 2017 +0300

    tdf#36019: Enable/disable extension installation and removal via GUI
    
    Now extension installation and removal via the Extension Manager dialog
    can be dynamically enabled/disabled from the expert configurations.
    
    This also affects the installation by double-clicking the extension
    file in the file manager, but doesn't affect the unopkg commands.
    
    When ExtensionSecurity::DisableExtensionRemoval is set in expert configurations,
    context menu entry of 'remove' for installed extensions is also
    disabled along with the "Remove" button on the dialog.
    
    This is the combination of 4 commits from master:
    99b7c4f57d7f
    f09be32d0fcb
    99841f1fd2bf
    18cf49580846
    
    Change-Id: Ide7b8bcae750b093bcc0a98948845273611cd620
    Reviewed-on: https://gerrit.libreoffice.org/38455
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Muhammet Kara <muhammet.kara at pardus.org.tr>

diff --git a/desktop/Library_deploymentgui.mk b/desktop/Library_deploymentgui.mk
index a16b567ea5d4..0a92e54d9907 100644
--- a/desktop/Library_deploymentgui.mk
+++ b/desktop/Library_deploymentgui.mk
@@ -20,6 +20,8 @@ $(eval $(call gb_Library_use_external,deploymentgui,boost_headers))
 
 $(eval $(call gb_Library_set_precompiled_header,deploymentgui,$(SRCDIR)/desktop/inc/pch/precompiled_deploymentgui))
 
+$(eval $(call gb_Library_use_custom_headers,deploymentgui,\ officecfg/registry \ ))
+
 $(eval $(call gb_Library_use_sdk_api,deploymentgui))
 
 $(eval $(call gb_Library_use_libraries,deploymentgui,\
diff --git a/desktop/inc/dp_gui.hrc b/desktop/inc/dp_gui.hrc
index 9bb961474743..a22629cb1e7a 100644
--- a/desktop/inc/dp_gui.hrc
+++ b/desktop/inc/dp_gui.hrc
@@ -30,6 +30,8 @@
 #define RID_STR_WARNING_VERSION_GREATER                           (RID_DEPLOYMENT_GUI_START + 7)
 #define RID_STR_WARNINGBOX_VERSION_GREATER_DIFFERENT_NAMES        (RID_DEPLOYMENT_GUI_START + 8)
 #define RID_STR_WARNING_INSTALL_EXTENSION                         (RID_DEPLOYMENT_GUI_START + 9)
+#define RID_STR_WARNING_INSTALL_EXTENSION_DISABLED                (RID_DEPLOYMENT_GUI_START + 10)
+#define RID_STR_WARNING_REMOVE_EXTENSION_DISABLED                 (RID_DEPLOYMENT_GUI_START + 11)
 
 #define RID_DLG_UPDATE_NONE                 (RID_DEPLOYMENT_GUI_START + 13)
 #define RID_DLG_UPDATE_NOINSTALLABLE        (RID_DEPLOYMENT_GUI_START + 14)
diff --git a/desktop/source/deployment/gui/dp_gui_dialog.src b/desktop/source/deployment/gui/dp_gui_dialog.src
index 9078a353533a..27ebb4b7f6f1 100644
--- a/desktop/source/deployment/gui/dp_gui_dialog.src
+++ b/desktop/source/deployment/gui/dp_gui_dialog.src
@@ -113,6 +113,12 @@ String RID_STR_WARNING_INSTALL_EXTENSION
     "Click 'Cancel' to stop the installation.";
 };
 
+String RID_STR_WARNING_INSTALL_EXTENSION_DISABLED
+{
+    Text [en-US] = "Extension installation is currently disabled. "
+    "Please consult your system administrator for more information.";
+};
+
 String RID_STR_WARNING_REMOVE_EXTENSION
 {
     Text [en-US] = "You are about to remove the extension '%NAME'.\n"
@@ -120,6 +126,12 @@ String RID_STR_WARNING_REMOVE_EXTENSION
     "Click 'Cancel' to stop removing the extension.";
 };
 
+String RID_STR_WARNING_REMOVE_EXTENSION_DISABLED
+{
+    Text [en-US] = "Extension removal is currently disabled. "
+    "Please consult your system administrator for more information.";
+};
+
 String RID_STR_WARNING_REMOVE_SHARED_EXTENSION
 {
     Text [en-US] = "Make sure that no further users are working with the same "
diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx
index dc75acbb8264..ba9cc08f995b 100644
--- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx
+++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx
@@ -71,6 +71,8 @@
 #include <com/sun/star/uno/Any.hxx>
 #include <com/sun/star/uno/XComponentContext.hpp>
 
+#include <officecfg/Office/ExtensionManager.hxx>
+
 #include <map>
 #include <memory>
 #include <vector>
@@ -261,7 +263,10 @@ MENU_COMMAND ExtBoxWithBtns_Impl::ShowPopupMenu( const Point & rPos, const long
             else if ( GetEntryData( nPos )->m_eState != NOT_AVAILABLE )
                 aPopup->InsertItem( CMD_ENABLE, DialogHelper::getResourceString( RID_CTX_ITEM_ENABLE ) );
         }
-        aPopup->InsertItem( CMD_REMOVE, DialogHelper::getResourceString( RID_CTX_ITEM_REMOVE ) );
+        if (!officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionRemoval::get())
+        {
+            aPopup->InsertItem( CMD_REMOVE, DialogHelper::getResourceString( RID_CTX_ITEM_REMOVE ) );
+        }
     }
 
     if ( !GetEntryData( nPos )->m_sLicenseText.isEmpty() )
@@ -419,6 +424,17 @@ void DialogHelper::openWebBrowser( const OUString & sURL, const OUString &sTitle
 bool DialogHelper::installExtensionWarn( const OUString &rExtensionName ) const
 {
     const SolarMutexGuard guard;
+
+    // Check if extension installation is disabled in the expert configurations
+    if (officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionInstallation::get())
+    {
+        ScopedVclPtrInstance<MessageDialog> aWarn(m_pVCLWindow, getResId(RID_STR_WARNING_INSTALL_EXTENSION_DISABLED),
+                                                  VclMessageType::Warning, VclButtonsType::Ok);
+        aWarn->Execute();
+
+        return false;
+    }
+
     ScopedVclPtrInstance<MessageDialog> aInfo(m_pVCLWindow, getResId(RID_STR_WARNING_INSTALL_EXTENSION),
                                               VclMessageType::Warning, VclButtonsType::OkCancel);
 
@@ -511,6 +527,17 @@ ExtMgrDialog::ExtMgrDialog(vcl::Window *pParent, TheExtensionManager *pManager,
     m_pUpdateBtn->Hide();
 #endif
 
+    if (officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionInstallation::get())
+    {
+        m_pAddBtn->Disable();
+        m_pAddBtn->SetQuickHelpText(getResId(RID_STR_WARNING_INSTALL_EXTENSION_DISABLED));
+    }
+    if (officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionRemoval::get())
+    {
+        m_pRemoveBtn->Disable();
+        m_pRemoveBtn->SetQuickHelpText(getResId(RID_STR_WARNING_REMOVE_EXTENSION_DISABLED));
+    }
+
     m_aIdle.SetPriority(TaskPriority::LOWEST);
     m_aIdle.SetInvokeHandler( LINK( this, ExtMgrDialog, TimeOutHdl ) );
 }
@@ -739,7 +766,16 @@ void ExtMgrDialog::enableOptionsButton( bool bEnable )
 
 void ExtMgrDialog::enableRemoveButton( bool bEnable )
 {
-    m_pRemoveBtn->Enable( bEnable );
+    m_pRemoveBtn->Enable( bEnable && !officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionRemoval::get());
+
+    if (officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionRemoval::get())
+    {
+        m_pRemoveBtn->SetQuickHelpText(getResId(RID_STR_WARNING_REMOVE_EXTENSION_DISABLED));
+    }
+    else
+    {
+        m_pRemoveBtn->SetQuickHelpText("");
+    }
 }
 
 void ExtMgrDialog::enableEnableButton( bool bEnable )
@@ -804,7 +840,16 @@ IMPL_LINK( ExtMgrDialog, startProgress, void*, _bLockInterface, void )
     }
 
     m_pCancelBtn->Enable( bLockInterface );
-    m_pAddBtn->Enable( !bLockInterface );
+    m_pAddBtn->Enable( !bLockInterface && !officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionInstallation::get());
+    if (officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionInstallation::get())
+    {
+        m_pAddBtn->SetQuickHelpText(getResId(RID_STR_WARNING_INSTALL_EXTENSION_DISABLED));
+    }
+    else
+    {
+        m_pAddBtn->SetQuickHelpText("");
+    }
+
     m_pUpdateBtn->Enable( !bLockInterface && m_pExtensionBox->getItemCount() );
     m_pExtensionBox->enableButtons( !bLockInterface );
 
diff --git a/officecfg/registry/schema/org/openoffice/Office/ExtensionManager.xcs b/officecfg/registry/schema/org/openoffice/Office/ExtensionManager.xcs
index 893fd882ac37..eaf840cd90e4 100644
--- a/officecfg/registry/schema/org/openoffice/Office/ExtensionManager.xcs
+++ b/officecfg/registry/schema/org/openoffice/Office/ExtensionManager.xcs
@@ -47,6 +47,25 @@
         <value/>
       </prop>
     </group>
+    <group oor:name="ExtensionSecurity">
+      <info>
+        <desc>Holds settings related to Extension security.</desc>
+      </info>
+      <prop oor:name="DisableExtensionInstallation" oor:type="xs:boolean" oor:nillable="false">
+        <info>
+          <desc>Specifies whether to disable extension installation via the Extension Manager dialog.</desc>
+          <label>Disable Extension Installation</label>
+        </info>
+        <value>false</value>
+      </prop>
+      <prop oor:name="DisableExtensionRemoval" oor:type="xs:boolean" oor:nillable="false">
+        <info>
+          <desc>Specifies whether to disable extension removal via the Extension Manager dialog.</desc>
+          <label>Disable Extension Removal</label>
+        </info>
+        <value>false</value>
+      </prop>
+    </group>
     <group oor:name="ExtensionUpdateData">
       <info>
         <desc>Contains information about available or ignored updates for extensions."</desc>


More information about the Libreoffice-commits mailing list