1*0a1e2f0eSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3*0a1e2f0eSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4*0a1e2f0eSAndrew Rist * or more contributor license agreements. See the NOTICE file 5*0a1e2f0eSAndrew Rist * distributed with this work for additional information 6*0a1e2f0eSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7*0a1e2f0eSAndrew Rist * to you under the Apache License, Version 2.0 (the 8*0a1e2f0eSAndrew Rist * "License"); you may not use this file except in compliance 9*0a1e2f0eSAndrew Rist * with the License. You may obtain a copy of the License at 10*0a1e2f0eSAndrew Rist * 11*0a1e2f0eSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12*0a1e2f0eSAndrew Rist * 13*0a1e2f0eSAndrew Rist * Unless required by applicable law or agreed to in writing, 14*0a1e2f0eSAndrew Rist * software distributed under the License is distributed on an 15*0a1e2f0eSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16*0a1e2f0eSAndrew Rist * KIND, either express or implied. See the License for the 17*0a1e2f0eSAndrew Rist * specific language governing permissions and limitations 18*0a1e2f0eSAndrew Rist * under the License. 19*0a1e2f0eSAndrew Rist * 20*0a1e2f0eSAndrew Rist *************************************************************/ 21*0a1e2f0eSAndrew Rist 22*0a1e2f0eSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #ifndef INCLUDED_DP_GUI_DIALOG2_HXX 25cdf0e10cSrcweir #define INCLUDED_DP_GUI_DIALOG2_HXX 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "vcl/dialog.hxx" 28cdf0e10cSrcweir #include "vcl/button.hxx" 29cdf0e10cSrcweir #include "vcl/fixed.hxx" 30cdf0e10cSrcweir #include "vcl/timer.hxx" 31cdf0e10cSrcweir 32cdf0e10cSrcweir #include "svtools/fixedhyper.hxx" 33cdf0e10cSrcweir #include "svtools/prgsbar.hxx" 34cdf0e10cSrcweir #include "svtools/svmedit.hxx" 35cdf0e10cSrcweir 36cdf0e10cSrcweir #include "osl/conditn.hxx" 37cdf0e10cSrcweir #include "osl/mutex.hxx" 38cdf0e10cSrcweir 39cdf0e10cSrcweir #include "rtl/ref.hxx" 40cdf0e10cSrcweir #include "rtl/ustring.hxx" 41cdf0e10cSrcweir 42cdf0e10cSrcweir #include "cppuhelper/implbase1.hxx" 43cdf0e10cSrcweir 44cdf0e10cSrcweir #include "com/sun/star/awt/XWindow.hpp" 45cdf0e10cSrcweir #include "com/sun/star/deployment/XPackage.hpp" 46cdf0e10cSrcweir #include "com/sun/star/uno/XComponentContext.hpp" 47cdf0e10cSrcweir #include "com/sun/star/ui/dialogs/XExecutableDialog.hpp" 48cdf0e10cSrcweir #include "com/sun/star/util/XModifyListener.hpp" 49cdf0e10cSrcweir 50cdf0e10cSrcweir namespace dp_gui { 51cdf0e10cSrcweir 52cdf0e10cSrcweir //============================================================================== 53cdf0e10cSrcweir class ExtBoxWithBtns_Impl; 54cdf0e10cSrcweir class ExtensionBox_Impl; 55cdf0e10cSrcweir class TheExtensionManager; 56cdf0e10cSrcweir 57cdf0e10cSrcweir //============================================================================== 58cdf0e10cSrcweir class DialogHelper 59cdf0e10cSrcweir { 60cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext; 61cdf0e10cSrcweir Dialog* m_pVCLWindow; 62cdf0e10cSrcweir sal_uLong m_nEventID; 63cdf0e10cSrcweir bool m_bIsBusy; 64cdf0e10cSrcweir 65cdf0e10cSrcweir public: 66cdf0e10cSrcweir DialogHelper( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > &, 67cdf0e10cSrcweir Dialog *pWindow ); 68cdf0e10cSrcweir virtual ~DialogHelper(); 69cdf0e10cSrcweir 70cdf0e10cSrcweir void openWebBrowser( const ::rtl::OUString & sURL, const ::rtl::OUString & sTitle ) const; getWindow() const71cdf0e10cSrcweir Dialog* getWindow() const { return m_pVCLWindow; }; 72cdf0e10cSrcweir void PostUserEvent( const Link& rLink, void* pCaller ); clearEventID()73cdf0e10cSrcweir void clearEventID() { m_nEventID = 0; } 74cdf0e10cSrcweir 75cdf0e10cSrcweir virtual void showProgress( bool bStart ) = 0; 76cdf0e10cSrcweir virtual void updateProgress( const ::rtl::OUString &rText, 77cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::task::XAbortChannel > &xAbortChannel) = 0; 78cdf0e10cSrcweir virtual void updateProgress( const long nProgress ) = 0; 79cdf0e10cSrcweir 80cdf0e10cSrcweir virtual void updatePackageInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) = 0; 81cdf0e10cSrcweir virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, 82cdf0e10cSrcweir bool bLicenseMissing = false ) = 0; 83cdf0e10cSrcweir 84cdf0e10cSrcweir virtual void prepareChecking() = 0; 85cdf0e10cSrcweir virtual void checkEntries() = 0; 86cdf0e10cSrcweir 87cdf0e10cSrcweir static ResId getResId( sal_uInt16 nId ); 88cdf0e10cSrcweir static String getResourceString( sal_uInt16 id ); 89cdf0e10cSrcweir static bool IsSharedPkgMgr( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &); 90cdf0e10cSrcweir static bool continueOnSharedExtension( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &, 91cdf0e10cSrcweir Window *pParent, 92cdf0e10cSrcweir const sal_uInt16 nResID, 93cdf0e10cSrcweir bool &bHadWarning ); 94cdf0e10cSrcweir setBusy(const bool bBusy)95cdf0e10cSrcweir void setBusy( const bool bBusy ) { m_bIsBusy = bBusy; } isBusy() const96cdf0e10cSrcweir bool isBusy() const { return m_bIsBusy; } 97cdf0e10cSrcweir bool installExtensionWarn( const ::rtl::OUString &rExtensionURL ) const; 98cdf0e10cSrcweir bool installForAllUsers( bool &bInstallForAll ) const; 99cdf0e10cSrcweir }; 100cdf0e10cSrcweir 101cdf0e10cSrcweir //============================================================================== 102cdf0e10cSrcweir class ExtMgrDialog : public ModelessDialog, 103cdf0e10cSrcweir public DialogHelper 104cdf0e10cSrcweir { 105cdf0e10cSrcweir ExtBoxWithBtns_Impl *m_pExtensionBox; 106cdf0e10cSrcweir PushButton m_aAddBtn; 107cdf0e10cSrcweir PushButton m_aUpdateBtn; 108cdf0e10cSrcweir OKButton m_aCloseBtn; 109cdf0e10cSrcweir HelpButton m_aHelpBtn; 110cdf0e10cSrcweir FixedLine m_aDivider; 111cdf0e10cSrcweir svt::FixedHyperlink m_aGetExtensions; 112cdf0e10cSrcweir FixedText m_aProgressText; 113cdf0e10cSrcweir ProgressBar m_aProgressBar; 114cdf0e10cSrcweir CancelButton m_aCancelBtn; 115cdf0e10cSrcweir const String m_sAddPackages; 116cdf0e10cSrcweir String m_sProgressText; 117cdf0e10cSrcweir String m_sLastFolderURL; 118cdf0e10cSrcweir ::osl::Mutex m_aMutex; 119cdf0e10cSrcweir bool m_bHasProgress; 120cdf0e10cSrcweir bool m_bProgressChanged; 121cdf0e10cSrcweir bool m_bStartProgress; 122cdf0e10cSrcweir bool m_bStopProgress; 123cdf0e10cSrcweir bool m_bUpdateWarning; 124cdf0e10cSrcweir bool m_bEnableWarning; 125cdf0e10cSrcweir bool m_bDisableWarning; 126cdf0e10cSrcweir bool m_bDeleteWarning; 127cdf0e10cSrcweir long m_nProgress; 128cdf0e10cSrcweir Timer m_aTimeoutTimer; 129cdf0e10cSrcweir TheExtensionManager *m_pManager; 130cdf0e10cSrcweir 131cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::task::XAbortChannel > m_xAbortChannel; 132cdf0e10cSrcweir 133cdf0e10cSrcweir bool removeExtensionWarn( const ::rtl::OUString &rExtensionTitle ) const; 134cdf0e10cSrcweir 135cdf0e10cSrcweir DECL_DLLPRIVATE_LINK( HandleAddBtn, void * ); 136cdf0e10cSrcweir DECL_DLLPRIVATE_LINK( HandleUpdateBtn, void * ); 137cdf0e10cSrcweir DECL_DLLPRIVATE_LINK( HandleCancelBtn, void * ); 138cdf0e10cSrcweir DECL_DLLPRIVATE_LINK( HandleHyperlink, svt::FixedHyperlink * ); 139cdf0e10cSrcweir DECL_DLLPRIVATE_LINK( TimeOutHdl, Timer* ); 140cdf0e10cSrcweir DECL_DLLPRIVATE_LINK( startProgress, void * ); 141cdf0e10cSrcweir 142cdf0e10cSrcweir public: 143cdf0e10cSrcweir ExtMgrDialog( Window * pParent, TheExtensionManager *pManager ); 144cdf0e10cSrcweir virtual ~ExtMgrDialog(); 145cdf0e10cSrcweir 146cdf0e10cSrcweir virtual void Resize(); 147cdf0e10cSrcweir virtual long Notify( NotifyEvent& rNEvt ); 148cdf0e10cSrcweir virtual sal_Bool Close(); 149cdf0e10cSrcweir 150cdf0e10cSrcweir virtual void showProgress( bool bStart ); 151cdf0e10cSrcweir virtual void updateProgress( const ::rtl::OUString &rText, 152cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::task::XAbortChannel > &xAbortChannel); 153cdf0e10cSrcweir virtual void updateProgress( const long nProgress ); 154cdf0e10cSrcweir 155cdf0e10cSrcweir virtual void updatePackageInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); 156cdf0e10cSrcweir 157cdf0e10cSrcweir void setGetExtensionsURL( const ::rtl::OUString &rURL ); 158cdf0e10cSrcweir virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &, 159cdf0e10cSrcweir bool bLicenseMissing = false ); 160cdf0e10cSrcweir bool enablePackage(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, 161cdf0e10cSrcweir bool bEnable ); 162cdf0e10cSrcweir bool removePackage(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); 163cdf0e10cSrcweir bool updatePackage(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); 164cdf0e10cSrcweir bool acceptLicense(const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); 165cdf0e10cSrcweir 166cdf0e10cSrcweir virtual void prepareChecking(); 167cdf0e10cSrcweir virtual void checkEntries(); 168cdf0e10cSrcweir 169cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > raiseAddPicker(); 170cdf0e10cSrcweir }; 171cdf0e10cSrcweir 172cdf0e10cSrcweir //============================================================================== 173cdf0e10cSrcweir class UpdateRequiredDialog : public ModalDialog, 174cdf0e10cSrcweir public DialogHelper 175cdf0e10cSrcweir { 176cdf0e10cSrcweir ExtensionBox_Impl *m_pExtensionBox; 177cdf0e10cSrcweir FixedText m_aUpdateNeeded; 178cdf0e10cSrcweir PushButton m_aUpdateBtn; 179cdf0e10cSrcweir PushButton m_aCloseBtn; 180cdf0e10cSrcweir HelpButton m_aHelpBtn; 181cdf0e10cSrcweir CancelButton m_aCancelBtn; 182cdf0e10cSrcweir FixedLine m_aDivider; 183cdf0e10cSrcweir FixedText m_aProgressText; 184cdf0e10cSrcweir ProgressBar m_aProgressBar; 185cdf0e10cSrcweir const String m_sAddPackages; 186cdf0e10cSrcweir const String m_sCloseText; 187cdf0e10cSrcweir String m_sProgressText; 188cdf0e10cSrcweir ::osl::Mutex m_aMutex; 189cdf0e10cSrcweir bool m_bHasProgress; 190cdf0e10cSrcweir bool m_bProgressChanged; 191cdf0e10cSrcweir bool m_bStartProgress; 192cdf0e10cSrcweir bool m_bStopProgress; 193cdf0e10cSrcweir bool m_bUpdateWarning; 194cdf0e10cSrcweir bool m_bDisableWarning; 195cdf0e10cSrcweir bool m_bHasLockedEntries; 196cdf0e10cSrcweir long m_nProgress; 197cdf0e10cSrcweir Timer m_aTimeoutTimer; 198cdf0e10cSrcweir TheExtensionManager *m_pManager; 199cdf0e10cSrcweir 200cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::task::XAbortChannel > m_xAbortChannel; 201cdf0e10cSrcweir 202cdf0e10cSrcweir DECL_DLLPRIVATE_LINK( HandleUpdateBtn, void * ); 203cdf0e10cSrcweir DECL_DLLPRIVATE_LINK( HandleCloseBtn, void * ); 204cdf0e10cSrcweir DECL_DLLPRIVATE_LINK( HandleCancelBtn, void * ); 205cdf0e10cSrcweir DECL_DLLPRIVATE_LINK( TimeOutHdl, Timer* ); 206cdf0e10cSrcweir DECL_DLLPRIVATE_LINK( startProgress, void * ); 207cdf0e10cSrcweir DECL_DLLPRIVATE_LINK( HandleHyperlink, svt::FixedHyperlink * ); 208cdf0e10cSrcweir 209cdf0e10cSrcweir bool isEnabled( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) const; 210cdf0e10cSrcweir bool checkDependencies( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ) const; 211cdf0e10cSrcweir bool hasActiveEntries(); 212cdf0e10cSrcweir void disableAllEntries(); 213cdf0e10cSrcweir 214cdf0e10cSrcweir public: 215cdf0e10cSrcweir UpdateRequiredDialog( Window * pParent, TheExtensionManager *pManager ); 216cdf0e10cSrcweir virtual ~UpdateRequiredDialog(); 217cdf0e10cSrcweir 218cdf0e10cSrcweir virtual short Execute(); 219cdf0e10cSrcweir virtual void Resize(); 220cdf0e10cSrcweir virtual sal_Bool Close(); 221cdf0e10cSrcweir // virtual long Notify( NotifyEvent& rNEvt ); 222cdf0e10cSrcweir 223cdf0e10cSrcweir virtual void showProgress( bool bStart ); 224cdf0e10cSrcweir virtual void updateProgress( const ::rtl::OUString &rText, 225cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::task::XAbortChannel > &xAbortChannel); 226cdf0e10cSrcweir virtual void updateProgress( const long nProgress ); 227cdf0e10cSrcweir 228cdf0e10cSrcweir virtual void updatePackageInfo( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); 229cdf0e10cSrcweir 230cdf0e10cSrcweir void selectEntry( long nPos ); 231cdf0e10cSrcweir virtual long addPackageToList( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &, 232cdf0e10cSrcweir bool bLicenseMissing = false ); 233cdf0e10cSrcweir bool enablePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage, bool bEnable ); 234cdf0e10cSrcweir bool updatePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); 235cdf0e10cSrcweir 236cdf0e10cSrcweir virtual void prepareChecking(); 237cdf0e10cSrcweir virtual void checkEntries(); 238cdf0e10cSrcweir 239cdf0e10cSrcweir ::com::sun::star::uno::Sequence< ::rtl::OUString > raiseAddPicker(); 240cdf0e10cSrcweir 241cdf0e10cSrcweir bool installForAllUsers( bool &bInstallForAll ) const; 242cdf0e10cSrcweir bool installExtensionWarn( const ::rtl::OUString &rExtensionURL ) const; 243cdf0e10cSrcweir }; 244cdf0e10cSrcweir 245cdf0e10cSrcweir //============================================================================== 246cdf0e10cSrcweir class ShowLicenseDialog : public ModalDialog 247cdf0e10cSrcweir { 248cdf0e10cSrcweir MultiLineEdit m_aLicenseText; 249cdf0e10cSrcweir OKButton m_aCloseBtn; 250cdf0e10cSrcweir 251cdf0e10cSrcweir public: 252cdf0e10cSrcweir ShowLicenseDialog( Window * pParent, 253cdf0e10cSrcweir const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage ); 254cdf0e10cSrcweir virtual ~ShowLicenseDialog(); 255cdf0e10cSrcweir 256cdf0e10cSrcweir virtual void Resize(); 257cdf0e10cSrcweir }; 258cdf0e10cSrcweir 259cdf0e10cSrcweir //============================================================================== 260cdf0e10cSrcweir class UpdateRequiredDialogService : public ::cppu::WeakImplHelper1< ::com::sun::star::ui::dialogs::XExecutableDialog > 261cdf0e10cSrcweir { 262cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const m_xComponentContext; 263cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow > m_xParent; 264cdf0e10cSrcweir ::rtl::OUString m_sInitialTitle; 265cdf0e10cSrcweir 266cdf0e10cSrcweir public: 267cdf0e10cSrcweir UpdateRequiredDialogService( ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Any > const & args, 268cdf0e10cSrcweir ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> const & xComponentContext ); 269cdf0e10cSrcweir 270cdf0e10cSrcweir // XExecutableDialog 271cdf0e10cSrcweir virtual void SAL_CALL setTitle( rtl::OUString const & title ) throw ( ::com::sun::star::uno::RuntimeException ); 272cdf0e10cSrcweir virtual sal_Int16 SAL_CALL execute() throw ( ::com::sun::star::uno::RuntimeException ); 273cdf0e10cSrcweir }; 274cdf0e10cSrcweir 275cdf0e10cSrcweir } // namespace dp_gui 276cdf0e10cSrcweir 277cdf0e10cSrcweir #endif 278