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