unopkg_cmdenv.cxx (2722cedd) | unopkg_cmdenv.cxx (97c864cc) |
---|---|
1/************************************************************** | 1/************************************************************** |
2 * | 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 | 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 * | 10 * |
11 * http://www.apache.org/licenses/LICENSE-2.0 | 11 * http://www.apache.org/licenses/LICENSE-2.0 |
12 * | 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. | 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 * | 19 * |
20 *************************************************************/ 21 22 23 24// MARKER(update_precomp.py): autogen include statement, do not remove 25#include "precompiled_desktop.hxx" 26 27#include "../../deployment/gui/dp_gui.hrc" --- 53 unchanged lines hidden (view full) --- 81 sal_Int32 m_logLevel; 82 bool m_option_force_overwrite; 83 bool m_option_verbose; 84 Reference< XComponentContext > m_xComponentContext; 85 Reference< XProgressHandler > m_xLogFile; 86 87 void update_( Any const & Status ) throw (RuntimeException); 88 void printLicense(const OUString & sName,const OUString& sLicense, | 20 *************************************************************/ 21 22 23 24// MARKER(update_precomp.py): autogen include statement, do not remove 25#include "precompiled_desktop.hxx" 26 27#include "../../deployment/gui/dp_gui.hrc" --- 53 unchanged lines hidden (view full) --- 81 sal_Int32 m_logLevel; 82 bool m_option_force_overwrite; 83 bool m_option_verbose; 84 Reference< XComponentContext > m_xComponentContext; 85 Reference< XProgressHandler > m_xLogFile; 86 87 void update_( Any const & Status ) throw (RuntimeException); 88 void printLicense(const OUString & sName,const OUString& sLicense, |
89 bool & accept, bool & decline); 90 | 89 bool & accept, bool & decline); 90 |
91public: 92 virtual ~CommandEnvironmentImpl(); 93 CommandEnvironmentImpl( 94 Reference<XComponentContext> const & xComponentContext, 95 OUString const & log_file, 96 bool option_force_overwrite, 97 bool option_verbose); | 91public: 92 virtual ~CommandEnvironmentImpl(); 93 CommandEnvironmentImpl( 94 Reference<XComponentContext> const & xComponentContext, 95 OUString const & log_file, 96 bool option_force_overwrite, 97 bool option_verbose); |
98 | 98 |
99 // XCommandEnvironment 100 virtual Reference< task::XInteractionHandler > SAL_CALL 101 getInteractionHandler() throw (RuntimeException); 102 virtual Reference< XProgressHandler > SAL_CALL getProgressHandler() 103 throw (RuntimeException); 104 105 // XInteractionHandler 106 virtual void SAL_CALL handle( 107 Reference< task::XInteractionRequest > const & xRequest ) 108 throw (RuntimeException); | 99 // XCommandEnvironment 100 virtual Reference< task::XInteractionHandler > SAL_CALL 101 getInteractionHandler() throw (RuntimeException); 102 virtual Reference< XProgressHandler > SAL_CALL getProgressHandler() 103 throw (RuntimeException); 104 105 // XInteractionHandler 106 virtual void SAL_CALL handle( 107 Reference< task::XInteractionRequest > const & xRequest ) 108 throw (RuntimeException); |
109 | 109 |
110 // XProgressHandler 111 virtual void SAL_CALL push( Any const & Status ) throw (RuntimeException); 112 virtual void SAL_CALL update( Any const & Status ) throw (RuntimeException); 113 virtual void SAL_CALL pop() throw (RuntimeException); 114}; 115 116 117//______________________________________________________________________________ --- 43 unchanged lines hidden (view full) --- 161 OUString s1(s1tmp); 162 OUString s2 = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_2, *pResMgr)); 163 OUString s3 = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_3, *pResMgr)); 164 OUString s4 = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_4, *pResMgr)); 165 OUString sYES = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_YES, *pResMgr)); 166 OUString sY = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_Y, *pResMgr)); 167 OUString sNO = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_NO, *pResMgr)); 168 OUString sN = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_N, *pResMgr)); | 110 // XProgressHandler 111 virtual void SAL_CALL push( Any const & Status ) throw (RuntimeException); 112 virtual void SAL_CALL update( Any const & Status ) throw (RuntimeException); 113 virtual void SAL_CALL pop() throw (RuntimeException); 114}; 115 116 117//______________________________________________________________________________ --- 43 unchanged lines hidden (view full) --- 161 OUString s1(s1tmp); 162 OUString s2 = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_2, *pResMgr)); 163 OUString s3 = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_3, *pResMgr)); 164 OUString s4 = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_4, *pResMgr)); 165 OUString sYES = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_YES, *pResMgr)); 166 OUString sY = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_Y, *pResMgr)); 167 OUString sNO = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_NO, *pResMgr)); 168 OUString sN = String(ResId(RID_STR_UNOPKG_ACCEPT_LIC_N, *pResMgr)); |
169 | 169 |
170 OUString sNewLine(RTL_CONSTASCII_USTRINGPARAM("\n")); | 170 OUString sNewLine(RTL_CONSTASCII_USTRINGPARAM("\n")); |
171 | 171 |
172 dp_misc::writeConsole(sNewLine + sNewLine + s1 + sNewLine + sNewLine); 173 dp_misc::writeConsole(sLicense + sNewLine + sNewLine); 174 dp_misc::writeConsole(s2 + sNewLine); 175 dp_misc::writeConsole(s3); | 172 dp_misc::writeConsole(sNewLine + sNewLine + s1 + sNewLine + sNewLine); 173 dp_misc::writeConsole(sLicense + sNewLine + sNewLine); 174 dp_misc::writeConsole(s2 + sNewLine); 175 dp_misc::writeConsole(s3); |
176 | 176 |
177 //the user may enter "yes" or "no", we compare in a case insensitive way 178 Reference< css::i18n::XCollator > xCollator( 179 m_xComponentContext->getServiceManager() 180 ->createInstanceWithContext( 181 OUSTR("com.sun.star.i18n.Collator"),m_xComponentContext), 182 UNO_QUERY_THROW ); | 177 //the user may enter "yes" or "no", we compare in a case insensitive way 178 Reference< css::i18n::XCollator > xCollator( 179 m_xComponentContext->getServiceManager() 180 ->createInstanceWithContext( 181 OUSTR("com.sun.star.i18n.Collator"),m_xComponentContext), 182 UNO_QUERY_THROW ); |
183 xCollator->loadDefaultCollator(OfficeLocale::get(), | 183 xCollator->loadDefaultCollator(OfficeLocale::get(), |
184 css::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE); 185 186 do 187 { 188 OUString sAnswer = dp_misc::readConsole(); 189 if (xCollator->compareString(sAnswer, sYES) == 0 190 || xCollator->compareString(sAnswer, sY) == 0) 191 { --- 32 unchanged lines hidden (view full) --- 224// XInteractionHandler 225//______________________________________________________________________________ 226void CommandEnvironmentImpl::handle( 227 Reference<task::XInteractionRequest> const & xRequest ) 228 throw (RuntimeException) 229{ 230 Any request( xRequest->getRequest() ); 231 OSL_ASSERT( request.getValueTypeClass() == TypeClass_EXCEPTION ); | 184 css::i18n::CollatorOptions::CollatorOptions_IGNORE_CASE); 185 186 do 187 { 188 OUString sAnswer = dp_misc::readConsole(); 189 if (xCollator->compareString(sAnswer, sYES) == 0 190 || xCollator->compareString(sAnswer, sY) == 0) 191 { --- 32 unchanged lines hidden (view full) --- 224// XInteractionHandler 225//______________________________________________________________________________ 226void CommandEnvironmentImpl::handle( 227 Reference<task::XInteractionRequest> const & xRequest ) 228 throw (RuntimeException) 229{ 230 Any request( xRequest->getRequest() ); 231 OSL_ASSERT( request.getValueTypeClass() == TypeClass_EXCEPTION ); |
232 dp_misc::TRACE(OUSTR("[unopkg_cmdenv.cxx] incoming request:\n") | 232 dp_misc::TRACE(OUSTR("[unopkg_cmdenv.cxx] incoming request:\n") |
233 + ::comphelper::anyToString(request) + OUSTR("\n\n")); | 233 + ::comphelper::anyToString(request) + OUSTR("\n\n")); |
234 | 234 |
235 // selections: 236 bool approve = false; 237 bool abort = false; | 235 // selections: 236 bool approve = false; 237 bool abort = false; |
238 | 238 |
239 lang::WrappedTargetException wtExc; 240 deployment::LicenseException licExc; 241 deployment::InstallException instExc; 242 deployment::PlatformException platExc; 243 deployment::VersionException verExc; 244 245 246 bool bLicenseException = false; --- 16 unchanged lines hidden (view full) --- 263 } 264 } 265 abort = !approve; 266 if (abort) { 267 // notify cause as error: 268 request = wtExc.TargetException; 269 } 270 else { | 239 lang::WrappedTargetException wtExc; 240 deployment::LicenseException licExc; 241 deployment::InstallException instExc; 242 deployment::PlatformException platExc; 243 deployment::VersionException verExc; 244 245 246 bool bLicenseException = false; --- 16 unchanged lines hidden (view full) --- 263 } 264 } 265 abort = !approve; 266 if (abort) { 267 // notify cause as error: 268 request = wtExc.TargetException; 269 } 270 else { |
271 // handable deployment error signalled, e.g. | 271 // handable deployment error signaled, e.g. |
272 // bundle item registration failed, notify as warning: 273 update_( wtExc.TargetException ); 274 } 275 } 276 else if (request >>= licExc) 277 { 278 printLicense(licExc.ExtensionName, licExc.Text, approve, abort); 279 } | 272 // bundle item registration failed, notify as warning: 273 update_( wtExc.TargetException ); 274 } 275 } 276 else if (request >>= licExc) 277 { 278 printLicense(licExc.ExtensionName, licExc.Text, approve, abort); 279 } |
280 else if (request >>= instExc) | 280 else if (request >>= instExc) |
281 { | 281 { |
282 //Only if the unopgk was started with gui + extension then we user is asked. | 282 //Only if the unopgk was started with gui + extension then the user is asked. |
283 //In console mode there is no asking. 284 approve = true; 285 } 286 else if (request >>= platExc) 287 { 288 String sMsg(ResId(RID_STR_UNSUPPORTED_PLATFORM, *dp_gui::DeploymentGuiResMgr::get())); 289 sMsg.SearchAndReplaceAllAscii("%Name", platExc.package->getDisplayName()); 290 dp_misc::writeConsole(OUSTR("\n") + sMsg + OUSTR("\n\n")); --- 5 unchanged lines hidden (view full) --- 296 approve = m_option_force_overwrite || 297 (::dp_misc::compareVersions(nc_exc.NewVersion, nc_exc.Deployed->getVersion()) 298 == ::dp_misc::GREATER); 299 abort = !approve; 300 } 301 else 302 return; // unknown request => no selection at all 303 } | 283 //In console mode there is no asking. 284 approve = true; 285 } 286 else if (request >>= platExc) 287 { 288 String sMsg(ResId(RID_STR_UNSUPPORTED_PLATFORM, *dp_gui::DeploymentGuiResMgr::get())); 289 sMsg.SearchAndReplaceAllAscii("%Name", platExc.package->getDisplayName()); 290 dp_misc::writeConsole(OUSTR("\n") + sMsg + OUSTR("\n\n")); --- 5 unchanged lines hidden (view full) --- 296 approve = m_option_force_overwrite || 297 (::dp_misc::compareVersions(nc_exc.NewVersion, nc_exc.Deployed->getVersion()) 298 == ::dp_misc::GREATER); 299 abort = !approve; 300 } 301 else 302 return; // unknown request => no selection at all 303 } |
304 | 304 |
305 //In case of a user declining a license abort is true but this is intended, 306 //therefore no logging | 305 //In case of a user declining a license abort is true but this is intended, 306 //therefore no logging |
307 if (abort && m_option_verbose && !bLicenseException) 308 { | 307 if (abort && m_option_verbose && !bLicenseException) 308 { |
309 OUString msg = ::comphelper::anyToString(request); 310 dp_misc::writeConsoleError( 311 OUSTR("\nERROR: ") + msg + OUSTR("\n")); 312 } | 309 OUString msg = ::comphelper::anyToString(request); 310 dp_misc::writeConsoleError( 311 OUSTR("\nERROR: ") + msg + OUSTR("\n")); 312 } |
313 | 313 |
314 // select: 315 Sequence< Reference<task::XInteractionContinuation> > conts( 316 xRequest->getContinuations() ); 317 Reference<task::XInteractionContinuation> const * pConts = 318 conts.getConstArray(); 319 sal_Int32 len = conts.getLength(); 320 for ( sal_Int32 pos = 0; pos < len; ++pos ) 321 { 322 if (approve) { 323 Reference<task::XInteractionApprove> xInteractionApprove( 324 pConts[ pos ], UNO_QUERY ); 325 if (xInteractionApprove.is()) { 326 xInteractionApprove->select(); 327 break; 328 } 329 } 330 else if (abort) { 331 Reference<task::XInteractionAbort> xInteractionAbort( 332 pConts[ pos ], UNO_QUERY ); | 314 // select: 315 Sequence< Reference<task::XInteractionContinuation> > conts( 316 xRequest->getContinuations() ); 317 Reference<task::XInteractionContinuation> const * pConts = 318 conts.getConstArray(); 319 sal_Int32 len = conts.getLength(); 320 for ( sal_Int32 pos = 0; pos < len; ++pos ) 321 { 322 if (approve) { 323 Reference<task::XInteractionApprove> xInteractionApprove( 324 pConts[ pos ], UNO_QUERY ); 325 if (xInteractionApprove.is()) { 326 xInteractionApprove->select(); 327 break; 328 } 329 } 330 else if (abort) { 331 Reference<task::XInteractionAbort> xInteractionAbort( 332 pConts[ pos ], UNO_QUERY ); |
333 if (xInteractionAbort.is()) { | 333 if (xInteractionAbort.is()) { |
334 xInteractionAbort->select(); 335 break; 336 } 337 } 338 } 339} 340 341// XProgressHandler --- 88 unchanged lines hidden --- | 334 xInteractionAbort->select(); 335 break; 336 } 337 } 338 } 339} 340 341// XProgressHandler --- 88 unchanged lines hidden --- |