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