summaryrefslogtreecommitdiff
path: root/desktop/source/deployment/gui
diff options
context:
space:
mode:
authorRĂ¼diger Timm <rt@openoffice.org>2008-11-18 07:24:15 +0000
committerRĂ¼diger Timm <rt@openoffice.org>2008-11-18 07:24:15 +0000
commit8fc3fe99c8f98853bee4795db7db28b697b69d69 (patch)
tree906f1163e99689d81d8869de6ec8cd66aec9c341 /desktop/source/deployment/gui
parent0746817c7bb5687dd6513ba31637df9cdff832d0 (diff)
CWS-TOOLING: integrate CWS extmgrui06
2008-10-30 15:46:52 +0100 hr r262831 : CWS-TOOLING: rebase CWS extmgrui06 to trunk@262620 (milestone: DEV300:m34) 2008-10-22 11:19:35 +0200 dv r262586 : #i80640# mirgate CWS extmgrui06 to SVN 2008-10-22 11:19:03 +0200 dv r262585 : #i80640# mirgate CWS extmgrui06 to SVN
Diffstat (limited to 'desktop/source/deployment/gui')
-rw-r--r--desktop/source/deployment/gui/dp_gui.h342
-rw-r--r--desktop/source/deployment/gui/dp_gui_addextensionqueue.cxx375
-rw-r--r--desktop/source/deployment/gui/dp_gui_addextensionqueue.hxx104
-rw-r--r--desktop/source/deployment/gui/dp_gui_cmdenv.cxx579
-rw-r--r--desktop/source/deployment/gui/dp_gui_cmdenv.h190
-rw-r--r--desktop/source/deployment/gui/dp_gui_dialog.cxx1535
-rw-r--r--desktop/source/deployment/gui/dp_gui_dialog2.cxx99
-rw-r--r--desktop/source/deployment/gui/dp_gui_dialog2.hxx9
-rw-r--r--desktop/source/deployment/gui/dp_gui_dialog2.src4
-rw-r--r--desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx50
-rw-r--r--desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx6
-rw-r--r--desktop/source/deployment/gui/dp_gui_service.cxx15
-rw-r--r--desktop/source/deployment/gui/dp_gui_theextmgr.cxx7
-rw-r--r--desktop/source/deployment/gui/dp_gui_treelb.cxx1215
-rw-r--r--desktop/source/deployment/gui/dp_gui_updatedialog.cxx4
-rw-r--r--desktop/source/deployment/gui/dp_gui_updatedialog.hxx8
-rw-r--r--desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx77
-rw-r--r--desktop/source/deployment/gui/makefile.mk6
18 files changed, 164 insertions, 4461 deletions
diff --git a/desktop/source/deployment/gui/dp_gui.h b/desktop/source/deployment/gui/dp_gui.h
index 7514bbc37113..65fc7635a6ec 100644
--- a/desktop/source/deployment/gui/dp_gui.h
+++ b/desktop/source/deployment/gui/dp_gui.h
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: dp_gui.h,v $
- * $Revision: 1.24 $
+ * $Revision: 1.24.86.2 $
*
* This file is part of OpenOffice.org.
*
@@ -31,11 +31,9 @@
#if ! defined INCLUDED_DP_GUI_H
#define INCLUDED_DP_GUI_H
-#include "dp_gui_cmdenv.h"
#include "dp_gui_updatedata.hxx"
#include "dp_misc.h"
#include "dp_gui_updatability.hxx"
-#include "dp_gui_addextensionqueue.hxx"
#include "dp_gui.hrc"
#include "rtl/ref.hxx"
#include "rtl/instance.hxx"
@@ -78,347 +76,9 @@ namespace svt {
namespace dp_gui {
-class UpdateDialog;
enum PackageState { REGISTERED, NOT_REGISTERED, AMBIGUOUS, NOT_AVAILABLE };
-PackageState getPackageState(
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> const & xPackage,
- ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment> const & xCmdEnv =
- ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment>() );
-
-
-// Use this mutex whenever a button is clicked, such as Add, Update, Options, in order to prevent that
-// an extension is installed which was startet asynchronously. For example, an office is running with the
-// Extension Manager open and the user installs an extension by double-clicking one in a file browser.
-struct ActionMutex : public rtl::Static< ::osl::Mutex, ActionMutex>{};
-
//==============================================================================
-struct DialogImpl :
- public ModelessDialog,
- public ::cppu::WeakImplHelper2< ::com::sun::star::frame::XTerminateListener,
- ::com::sun::star::ucb::XContentEventListener >
-{
- static ResId getResId( USHORT id );
- static String getResourceString( USHORT id );
-
- struct SelectionBoxControl : public Control
- {
- public:
-
- SelectionBoxControl( DialogImpl * dialog );
-
- long Notify( NotifyEvent & rEvt );
-
- /* Signals that the dialog (DialogImpl) is about to be destroyed.
- In this case we must prevent to access members of the dialog,
- which is the case in Notify. Notify may be called when the dialog
- is being destructed.
- */
- bool m_bShutDown;
- private:
- DialogImpl * m_dialog;
- };
-
- struct TreeListBoxImpl : public SvHeaderTabListBox
- {
- typedef ::std::list<
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> > t_nodeList;
- t_nodeList m_nodes;
- SvLBoxEntry * addNode(
- SvLBoxEntry * parentNode,
- String const & displayName,
- ::rtl::OUString const & factoryURL,
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager>
- const & xPackageManager,
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> const & xPackage,
- ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment> const & xCmdEnv,
- bool sortIn = true );
- SvLBoxEntry * addPackageNode(
- SvLBoxEntry * parentNode,
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> const & xPackage,
- ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment> const & xCmdEnv);
-
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_context;
- DialogImpl * m_dialog;
- SvLBoxEntry * m_currentSelectedEntry;
- bool m_hiContrastMode;
- Timer m_timer;
-
- String m_strEnabled;
- String m_strDisabled;
- String m_strUnknown;
- String m_strCtxAdd;
- String m_strCtxRemove;
- String m_strCtxEnable;
- String m_strCtxDisable;
- String m_strCtxExport;
- String m_strCtxCheckUpdate;
- String m_strCtxOptions;
-
- Image m_defaultPackage;
- Image m_defaultPackage_hc;
- Image m_defaultPackageBundle;
- Image m_defaultPackageBundle_hc;
-
- DECL_LINK( TimerHandler, Timer * );
- virtual void SelectHdl();
- virtual void DeselectHdl();
- virtual void MouseMove( MouseEvent const & evt );
- virtual void KeyInput( KeyEvent const & evt );
- virtual void RequestingChilds( SvLBoxEntry * pEntry );
- using SvListView::Expand;
- virtual BOOL Expand( SvLBoxEntry * pParent );
- virtual void DataChanged( DataChangedEvent const & evt );
- virtual PopupMenu * CreateContextMenu(void);
- virtual void ExcecuteContextMenuAction( USHORT nSelectedPopupEntry );
-
- virtual ~TreeListBoxImpl();
- TreeListBoxImpl(
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> const & context,
- Window * pParent, DialogImpl * dialog );
-
- SvLBoxEntry * getCurrentSingleSelectedEntry() const;
- bool isFirstLevelChild( SvLBoxEntry * entry ) const;
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> getPackage(
- SvLBoxEntry * entry ) const;
- void select(::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> const & xPackage);
-
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> getPackageManager(
- SvLBoxEntry * entry ) const;
-
- /** returns a vector of pairs of packages and the respective package managers.
-
- Only returns valid packages. That is the top-level nodes StarOffice Extensions and
- my Extensions have no associated XPackage.
- */
- ::std::vector<
- ::std::pair<
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage>,
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> > >
- getSelectedPackages(bool onlyFirstLevel) const;
- typedef ::std::vector<
- ::std::pair<
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage>,
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> > >::const_iterator
- CI_PAIR_PACKAGE;
- };
-
- class SyncPushButton : public PushButton
- {
- public:
- typedef void (DialogImpl::* t_clickCallback)( USHORT id );
- inline SyncPushButton(
- DialogImpl * dialog, t_clickCallback cb, USHORT id )
- : PushButton( dialog, getResId(id) ),
- m_dialog(dialog), m_clickCallback(cb), m_id(id) {}
- // PushButton
- virtual void Click();
- private:
- DialogImpl * m_dialog;
- t_clickCallback m_clickCallback;
- USHORT m_id;
- };
-
- class ThreadedPushButton : public SyncPushButton
- {
- oslThread m_thread;
- public:
- virtual ~ThreadedPushButton();
- inline ThreadedPushButton(
- DialogImpl * dialog, t_clickCallback cb, USHORT id )
- : SyncPushButton( dialog, cb, id ), m_thread(0) {}
- // PushButton
- virtual void Click();
- };
-
- virtual BOOL Close();
- virtual void Resize();
- DECL_LINK( headbar_dragEnd, HeaderBar * );
- DECL_LINK( hyperlink_clicked, svt::FixedHyperlink * );
-
- // solar thread functions, because of gtk file/folder picker:
- ::com::sun::star::uno::Sequence<rtl::OUString> solarthread_raiseAddPicker(
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager>
- const & xPackageManager );
- bool solarthread_raiseExportPickers(
- ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> >
- const & selection,
- rtl::OUString & rDestFolder, rtl::OUString & rNewTitle,
- sal_Int32 & rNameClashAction );
-
- void clickClose( USHORT id );
- void clickAdd( USHORT id );
- void clickRemove( USHORT id );
- void clickEnableDisable( USHORT id );
- void clickExport( USHORT id );
- void clickCheckUpdates( USHORT id );
- void clickOptions( USHORT id );
-// void installExtensions();
-
- void updateButtonStates(
- ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XCommandEnvironment> const & xCmdEnv =
- com::sun::star::uno::Reference<
- com::sun::star::ucb::XCommandEnvironment>() );
-
-
- void checkUpdates( bool selected, bool showUpdateOnly = false, bool parentVisible = true );
- void errbox( ::rtl::OUString const & msg, Window const * pParent = NULL ) const;
- bool supportsOptions( ::rtl::OUString const & sExtensionId);
- void openWebBrowser(::rtl::OUString const & sURL) const;
-
- /** return a vector which only contains information for directly downloadable updates.
- */
- static ::std::vector<dp_gui::UpdateData> excludeWebsiteDownloads(
- ::std::vector<dp_gui::UpdateData> const & data);
-
-
- enum ACTION { ADD_ACTION, REMOVE_ACTION, ENABLE_ACTION, DISABLE_ACTION, UPDATE_ACTION };
- /** checks if an some action is done with a shared extension.
-
- If so, the user will be warned by message box, reading that all other office instances
- need to be closed. If the user selects the cancel button then this function returns false.
- Otherwise it returns true.
- When the action is UPDATE_ACTION then, and only then, pUpdateDialog must be provided.
- */
- bool continueActionForSharedExtension(
- ::com::sun::star::uno::Reference<
- ::com::sun::star::deployment::XPackageManager> const & xPMgr, ACTION a,
- Window * pUpdateDialog = NULL);
-
- /** called from update dialog.
- */
- bool continueUpdateForSharedExtension(
- Window * pUpdateDialog,
- ::com::sun::star::uno::Reference<
- ::com::sun::star::deployment::XPackageManager> const & xPMgr);
-
-
- /** The extensions which are passed when the Extension Manager dialog is created.
- This is the case when the Extension Manager is started as a result of a
- "system integration operation", such as double clicking on a oxt file.
- This extension is always installed as user extension.
- */
- ::rtl::OUString m_extensionURL;
-
- /** This flag is used to show that there are extensions being installed and the buttons should
- therefore be disabled. For example, when the Extension Manager was started as a result of
- double-click on an extension in a file browser, then that extension is being immediately
- installed. During that time the buttons and context menus should be disabled.
- */
- bool m_bAddingExtensions;
-
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> m_xComponentContext;
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManagerFactory> m_xPkgMgrFac;
- ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> >
- m_packageManagers;
- ::com::sun::star::uno::Reference< ::com::sun::star::frame::XDesktop> m_xDesktop;
- ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XContent> m_xTdocRoot;
- ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xNameAccessNodes;
- ::com::sun::star::uno::Reference< ::com::sun::star::container::XNameAccess> m_xNameAccessRepositories;
-
- const String m_strAddPackages;
- const String m_strAddingPackages;
- const String m_strRemovingPackages;
- const String m_strEnablingPackages;
- const String m_strDisablingPackages;
- const String m_strExportPackage;
- const String m_strExportPackages;
- const String m_strExportingPackages;
-
- Size m_buttonSize;
- Size m_textSize;
- Size m_relatedSpace;
- Size m_unrelatedSpace;
- Size m_borderLeftTopSpace;
- Size m_borderRightBottomSpace;
- long m_ftFontHeight;
- long m_descriptionYSpace;
-
-
- // controls:
- ::std::auto_ptr<FixedText> m_ftPackages;
- ::std::auto_ptr<SelectionBoxControl> m_selectionBox;
- ::std::auto_ptr<HeaderBar> m_headerBar;
- ::std::auto_ptr<TreeListBoxImpl> m_treelb;
-
- ::std::auto_ptr<ThreadedPushButton> m_addButton;
- ::std::auto_ptr<ThreadedPushButton> m_removeButton;
- ::std::auto_ptr<ThreadedPushButton> m_enableButton;
- ::std::auto_ptr<ThreadedPushButton> m_disableButton;
- ::std::auto_ptr<ThreadedPushButton> m_exportButton;
- ::std::auto_ptr<SyncPushButton> m_checkUpdatesButton;
- ::std::auto_ptr<ThreadedPushButton> m_optionsButton;
- ::std::auto_ptr<svt::FixedHyperlink> m_getExtensionsButton;
- ::std::auto_ptr<FixedLine> m_bottomLine;
-
- ::std::auto_ptr<OKButton> m_closeButton;
- ::std::auto_ptr<HelpButton> m_helpButton;
-
- ::std::auto_ptr<Updatability> m_updatability;
- ::std::auto_ptr<AddExtensionQueue> m_addExtensionQueue;
-
- DECL_LINK( destroyDialog, DialogImpl *);
- DECL_LINK( startInstallExtensions, DialogImpl *);
- static ::rtl::Reference<DialogImpl> s_dialog;
- /** This mutex is used to protect s_dialog.
- */
- static ::osl::Mutex s_dialogMutex;
-
- /** When the user closes the Extension Manager dialog, then the current instance of
- the dialog will be transferred from s_dialog to s_closingDialog. The dialog will
- remain open until all remaining installation request (see m_addExtensionsQueue)
- are processed. See DialogImpl::Close and DialogImpl::destroyDialog in dp_gui_treelb.cxx.
- */
- static ::rtl::Reference<DialogImpl> s_closingDialog;
- /* This mutex is used to protect s_closingDialog
- */
- static ::osl::Mutex s_closingMutex;
-
- virtual ~DialogImpl();
- DialogImpl(
- Window * pParent,
- ::rtl::OUString const & extensionURL,
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & xContext );
- static ::rtl::Reference<DialogImpl> get(
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext> const & xContext,
- ::com::sun::star::uno::Reference< ::com::sun::star::awt::XWindow> const & xParent = 0,
- ::rtl::OUString const & extensionURL = ::rtl::OUString(),
- ::rtl::OUString const & view = ::rtl::OUString() );
- // XEventListener
- virtual void SAL_CALL disposing( ::com::sun::star::lang::EventObject const & evt )
- throw (::com::sun::star::uno::RuntimeException);
- // XContentEventListener
- virtual void SAL_CALL contentEvent( ::com::sun::star::ucb::ContentEvent const & evt )
- throw (::com::sun::star::uno::RuntimeException);
- // XTerminateListener
- virtual void SAL_CALL queryTermination( ::com::sun::star::lang::EventObject const & evt )
- throw (::com::sun::star::frame::TerminationVetoException,
- ::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL notifyTermination(
- ::com::sun::star::lang::EventObject const & evt ) throw (::com::sun::star::uno::RuntimeException);
-};
-
-#if 0
-class SelectedPackageIterator: public salhelper::SimpleReferenceObject {
-public:
- SelectedPackageIterator(DialogImpl::TreeListBoxImpl & list);
-
- virtual ~SelectedPackageIterator();
-
- void next(
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage> * package,
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager> * packageManager);
- // must only be called with Application::GetSolarMutex() locked and
- // while the DialogImpl::TreeListBoxImpl is still alive
-
-private:
- SelectedPackageIterator(SelectedPackageIterator &); // not defined
- void operator =(SelectedPackageIterator &); // not defined
-
- DialogImpl::TreeListBoxImpl & m_list;
- SvLBoxEntry * m_entry;
-};
-#endif
class SelectedPackage: public salhelper::SimpleReferenceObject {
public:
diff --git a/desktop/source/deployment/gui/dp_gui_addextensionqueue.cxx b/desktop/source/deployment/gui/dp_gui_addextensionqueue.cxx
deleted file mode 100644
index 9b536a426480..000000000000
--- a/desktop/source/deployment/gui/dp_gui_addextensionqueue.cxx
+++ /dev/null
@@ -1,375 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: dp_gui_addextensionqueue.cxx,v $
- * $Revision: 1.3 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_desktop.hxx"
-
-#include "sal/config.h"
-
-#include <cstddef>
-
-#include "com/sun/star/deployment/DeploymentException.hpp"
-#include "com/sun/star/deployment/UpdateInformationProvider.hpp"
-#include "com/sun/star/deployment/XPackage.hpp"
-#include "com/sun/star/deployment/XPackageManager.hpp"
-#include "com/sun/star/task/XAbortChannel.hpp"
-#include "com/sun/star/ucb/CommandAbortedException.hpp"
-#include "com/sun/star/ucb/CommandFailedException.hpp"
-#include "com/sun/star/ucb/XCommandEnvironment.hpp"
-#include "com/sun/star/uno/Reference.hxx"
-#include "com/sun/star/uno/RuntimeException.hpp"
-#include "com/sun/star/uno/Sequence.hxx"
-#include "com/sun/star/uno/XInterface.hpp"
-#include "com/sun/star/uno/TypeClass.hpp"
-#include "osl/conditn.hxx"
-#include "osl/diagnose.h"
-#include "osl/mutex.hxx"
-#include "rtl/ref.hxx"
-#include "rtl/ustring.h"
-#include "rtl/ustring.hxx"
-#include "sal/types.h"
-#include "ucbhelper/content.hxx"
-#include "cppuhelper/exc_hlp.hxx"
-#include "comphelper/anytostring.hxx"
-#include "vcl/msgbox.hxx"
-
-
-#include "dp_gui.h"
-#include "dp_gui_thread.hxx"
-#include "dp_gui_addextensionqueue.hxx"
-
-#include <queue>
-
-
-namespace com { namespace sun { namespace star { namespace uno {
- class XComponentContext;
-} } } }
-
-using dp_gui::AddExtensionQueue;
-using ::rtl::OUString;
-
-namespace {
-
-namespace css = com::sun::star;
-
-}
-
-class AddExtensionQueue::Thread: public dp_gui::Thread {
-public:
- Thread(dp_gui::DialogImpl * pDialog ,
- css::uno::Reference< css::uno::XComponentContext > const & componentContext,
- css::uno::Reference< css::deployment::XPackageManager > const & packageManager
- );
-
- void addExtension(const ::rtl::OUString & extensionURL);
-
- void stop();
-
- bool hasTerminated();
-
-private:
- Thread(Thread &); // not defined
- void operator =(Thread &); // not defined
-
- virtual ~Thread();
-
- virtual void execute();
- virtual void SAL_CALL onTerminated();
-
-
- enum Input { NONE, START, STOP };
-
- dp_gui::DialogImpl * m_pDialog;
- const css::uno::Reference<css::uno::XComponentContext > m_componentContext;
- const css::uno::Reference<css::deployment::XPackageManager > m_packageManager;
- OUString m_strAddingPackages;
-
- osl::Condition m_wakeup;
- osl::Mutex m_mutex;
- Input m_input;
- css::uno::Reference< css::task::XAbortChannel > m_abort;
- std::queue< ::rtl::OUString > m_queue;
- bool m_bTerminated;
- bool m_bStopped;
-};
-
-AddExtensionQueue::Thread::Thread(dp_gui::DialogImpl * pDialog ,
- css::uno::Reference< css::uno::XComponentContext > const & componentContext,
- css::uno::Reference< css::deployment::XPackageManager > const & packageManager
-):
- m_pDialog(pDialog),
- m_componentContext(componentContext),
- m_packageManager(packageManager),
- m_strAddingPackages( dp_gui::DialogImpl::getResourceString(RID_STR_ADDING_PACKAGES) ),
- m_input(NONE),
- m_bTerminated(false),
- m_bStopped(false)
-{
- OSL_ASSERT(pDialog);
-}
-
-void AddExtensionQueue::Thread::addExtension(const ::rtl::OUString & extensionURL)
-{
- ::osl::MutexGuard g(m_mutex);
- //If someone called stop then we do not add the extensions- > game over!
- if (m_bStopped)
- return;
- if (extensionURL.getLength())
- {
- m_queue.push(extensionURL);
- m_input = START;
- m_wakeup.set();
- }
-}
-
-//Stopping this thread will not abort the installation of extensions.
-void AddExtensionQueue::Thread::stop()
-{
- osl::MutexGuard g1(m_mutex);
- m_bStopped = true;
- m_input = STOP;
- m_wakeup.set();
-}
-bool AddExtensionQueue::Thread::hasTerminated()
-{
- ::osl::MutexGuard g(m_mutex);
- return m_bTerminated;
-}
-
-AddExtensionQueue::Thread::~Thread() {}
-
-void AddExtensionQueue::Thread::execute()
-{
- for (;;)
- {
- if (m_wakeup.wait() != osl::Condition::result_ok) {
- OSL_TRACE(
- "dp_gui::AddExtensionQueue::Thread::run: ignored "
- "osl::Condition::wait failure");
- }
- m_wakeup.reset();
- Input input;
- {
- osl::MutexGuard g(m_mutex);
- input = m_input;
- m_input = NONE;
- }
- // If this thread has been woken up by anything else except start, stop
- // then input is NONE and we wait again.
- if (input == NONE) {
- continue;
- }
-
- if (input == STOP) {
- break;
- }
-
- //If the user is running some task in the Extension Manager, that is he clicked
- //the add, update, options, etc. button, then we will not interfere. We proceed
- //only when that action is concluded.
- ::osl::MutexGuard actionGuard(ActionMutex::get());
- //disable all buttons
-// m_pDialog->m_bAddingExtensions = true;
-// m_pDialog->updateButtonStates();
-
- ::rtl::Reference<ProgressCommandEnv> currentCmdEnv(
- new ProgressCommandEnv(m_componentContext, m_pDialog, m_strAddingPackages, true) );
-
- css::uno::Reference<css::task::XAbortChannel> xAbortChannel(
- m_packageManager->createAbortChannel() );
- {
- osl::MutexGuard g(m_mutex);
- input = m_input;
- m_input = NONE;
- if (input == NONE || input == START) {
- //In case input would be STOP then we would later break out of the loop
- //before further calls to the XPackageManger are done. That is, the abort
- //channel would not be used anyway.
- m_abort = xAbortChannel;
- }
- else if (input == STOP) {
- break;
- }
- else
- OSL_ASSERT(0);
- }
-
- //We only install the extension which are currently in the queue.
- //The progressbar will be set to show the progress of the current number
- //of extensions. If we allowed to add extensions now then the progressbar may
- //have reached the end while we still install newly added extensions.
- int size = 0;
- {
- ::osl::MutexGuard queueGuard(m_mutex);
- size = m_queue.size();
- }
- if (size == 0)
- continue;
-
- //Do not lock the following part with addExtension. addExtension may be called in the main thread.
- //If the message box "Do you want to install the extension (or similar)" is shown and then
- //addExtension is called, which then blocks the main thread, then we deadlock.
- currentCmdEnv->showProgress(size);
- while (!currentCmdEnv->isAborted() && --size >= 0)
- {
- try
- {
- OUString file;
- {
- ::osl::MutexGuard queueGuard2(m_mutex);
- file = m_queue.front();
- m_queue.pop();
- }
-
- css::uno::Any anyTitle =
- ::ucbhelper::Content( file, currentCmdEnv.get() ).getPropertyValue(OUSTR("Title") );
- //check if we have a string in anyTitle. For example "unopkg gui \" caused anyTitle to be void
- //and anyTitle.get<OUString> throws as RuntimeException.
- OUString sTitle;
- if ( ! (anyTitle >>= sTitle))
- {
- OSL_ENSURE(0, "Could not get file name for extension.");
- continue;
- }
- currentCmdEnv->progressSection(sTitle, xAbortChannel );
- css::uno::Reference<css::deployment::XPackage> xPackage(
- m_packageManager->addPackage(
- file, OUString() /* detect media-type */,
- xAbortChannel, currentCmdEnv.get() ) );
- OSL_ASSERT( xPackage.is() );
- m_pDialog->m_treelb->select(xPackage);
- }
- //catch (css::deployment::DeploymentException &)
- //{
- //}
- //catch (css::lang::IllegalArgumentException &)
- //{
- //}
- catch (css::ucb::CommandAbortedException &)
- {
- //This exception is thrown when the user clicks cancel on the progressbar.
- //Then we cancel the installation of all extensions and remove them from
- //the queue.
- {
- ::osl::MutexGuard queueGuard2(m_mutex);
- while (--size >= 0)
- m_queue.pop();
- }
- break;
- }
- catch (css::ucb::CommandFailedException &)
- {
- //This exception is thrown when a user clicked cancel in the messagebox which was
- //startet by the interaction handler. For example the user will be asked if he/she
- //really wants to install the extension.
- //These interaction are run for exectly one extension at a time. Therefore we continue
- //with installing the remaining extensions.
- continue;
- }
- catch (css::uno::Exception &)
- {
- //Todo display the user an error
- //see also DialogImpl::SyncPushButton::Click()
- css::uno::Any exc( ::cppu::getCaughtException() );
- OUString msg;
- css::deployment::DeploymentException dpExc;
- if ((exc >>= dpExc) &&
- dpExc.Cause.getValueTypeClass() == css::uno::TypeClass_EXCEPTION)
- {
- // notify error cause only:
- msg = reinterpret_cast<css::uno::Exception const *>(
- dpExc.Cause.getValue() )->Message;
- }
- if (msg.getLength() == 0) // fallback for debugging purposes
- msg = ::comphelper::anyToString(exc);
-
- const ::vos::OGuard guard( Application::GetSolarMutex() );
- ::std::auto_ptr<ErrorBox> box(
- new ErrorBox( currentCmdEnv->activeDialog(), WB_OK, msg ) );
- box->SetText( m_pDialog->GetText() );
- box->Execute();
- //Continue with installation of the remaining extensions
- }
-
- }
- //end while
- //enable all buttons
-// m_pDialog->m_bAddingExtensions = false;
-// m_pDialog->updateButtonStates();
-
- }
- //end for
- //enable all buttons
- //ToDo: Investigate why calling updateButtonStates causes a deadlock when pressing
- //the close button. updateButtonSTates uses the solar mutex.
-// m_pDialog->m_bAddingExtensions = false;
-// m_pDialog->updateButtonStates();
-}
-
-
-void AddExtensionQueue::Thread::onTerminated()
-{
- ::osl::MutexGuard g(m_mutex);
- m_bTerminated = true;
-}
-
-
-AddExtensionQueue::AddExtensionQueue(dp_gui::DialogImpl * pDialogImpl,
- css::uno::Reference<css::uno::XComponentContext > const & componentContext,
- css::uno::Reference< css::deployment::XPackageManager > const & packageManager):
- m_thread(new Thread(pDialogImpl,componentContext, packageManager))
-{
- m_thread->launch();
-}
-
-AddExtensionQueue::~AddExtensionQueue() {
- stop();
-}
-
-void AddExtensionQueue::addExtension(const ::rtl::OUString & extensionURL)
-{
- m_thread->addExtension(extensionURL);
-}
-
-void AddExtensionQueue::stop()
-{
- m_thread->stop();
-}
-
-void AddExtensionQueue::stopAndWait()
-{
- m_thread->stop();
- m_thread->join();
-}
-
-bool AddExtensionQueue::hasTerminated()
-{
- return m_thread->hasTerminated();
-}
diff --git a/desktop/source/deployment/gui/dp_gui_addextensionqueue.hxx b/desktop/source/deployment/gui/dp_gui_addextensionqueue.hxx
deleted file mode 100644
index 62bb0687103f..000000000000
--- a/desktop/source/deployment/gui/dp_gui_addextensionqueue.hxx
+++ /dev/null
@@ -1,104 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: dp_gui_addextensionqueue.hxx,v $
- * $Revision: 1.3 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#ifndef INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_GUI_DP_GUI_ADDEXTENSIONQUEUE_HXX
-#define INCLUDED_DESKTOP_SOURCE_DEPLOYMENT_GUI_DP_GUI_ADDEXTENSIONQUEUE_HXX
-
-#include "sal/config.h"
-#include "com/sun/star/uno/Reference.hxx"
-#include "com/sun/star/uno/Sequence.hxx"
-#include "rtl/ref.hxx"
-
-/// @HTML
-
-class Window;
-namespace com { namespace sun { namespace star {
- namespace deployment { class XPackageManager; }
- namespace uno { class XComponentContext; }
-} } }
-
-namespace dp_gui {
-
-/**
- Manages installing of extensions in the GUI mode. Requests for installing
- Extensions can be asynchronous. For example, the Extension Manager is running
- in an office process and someone uses the system integration to install an Extension.
- That is, the user double clicks an extension symbol in a file browser, which then
- causes an invocation of "unopkg gui ext". When at that time the Extension Manager
- already performs a task, triggered by the user (for example, add, update, disable,
- enable) then adding of the extension will be postponed until the user has finished
- the task.
-
- This class also ensures that the extensions are not installed in the main thread.
- Doing so would cause a deadlock because of the progress bar which needs to be constantly
- updated.
-*/
-class AddExtensionQueue {
-public:
- /**
- Create an instance.
- */
- AddExtensionQueue( DialogImpl * pDialog,
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > const & componentContext,
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > const &
- packageManager);
-
- ~AddExtensionQueue();
-
- /**
- */
- void addExtension( ::rtl::OUString const & extensionURL);
-
- /**
- This call does not block. It signals the internal thread
- that it should install the remaining extensions and then terminate.
- */
- void stop();
-
- /** Determines if thread of this class has terminated.
- */
- bool hasTerminated();
-
- /** Blocks until the thread has terminated. All URLs in the queue will be processed.
- */
- void stopAndWait();
-
-private:
- AddExtensionQueue(AddExtensionQueue &); // not defined
- void operator =(AddExtensionQueue &); // not defined
-
- class Thread;
-
- rtl::Reference< Thread > m_thread;
-};
-
-}
-
-#endif
diff --git a/desktop/source/deployment/gui/dp_gui_cmdenv.cxx b/desktop/source/deployment/gui/dp_gui_cmdenv.cxx
deleted file mode 100644
index 70e4b326005e..000000000000
--- a/desktop/source/deployment/gui/dp_gui_cmdenv.cxx
+++ /dev/null
@@ -1,579 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: dp_gui_cmdenv.cxx,v $
- * $Revision: 1.19 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_desktop.hxx"
-
-#include "dp_gui.hrc"
-#include "dp_gui.h"
-#include "dp_gui_cmdenv.h"
-#include "dp_gui_shared.hxx"
-#include "dp_gui_dependencydialog.hxx"
-#include "dp_dependencies.hxx"
-#include "dp_identifier.hxx"
-#include "dp_version.hxx"
-#include "comphelper/anytostring.hxx"
-#include "com/sun/star/lang/WrappedTargetException.hpp"
-#include "com/sun/star/beans/PropertyValue.hpp"
-#include "com/sun/star/task/XInteractionAbort.hpp"
-#include "com/sun/star/task/XInteractionApprove.hpp"
-#include "com/sun/star/deployment/DependencyException.hpp"
-#include "com/sun/star/deployment/LicenseException.hpp"
-#include "com/sun/star/deployment/LicenseIndividualAgreementException.hpp"
-#include "com/sun/star/deployment/VersionException.hpp"
-#include "com/sun/star/deployment/InstallException.hpp"
-#include "com/sun/star/deployment/PlatformException.hpp"
-#include "com/sun/star/deployment/ui/LicenseDialog.hpp"
-#include "com/sun/star/ui/dialogs/ExecutableDialogResults.hpp"
-#include "tools/resid.hxx"
-#include "tools/rcid.h"
-#include "vcl/msgbox.hxx"
-#include "vcl/threadex.hxx"
-#include "toolkit/helper/vclunohelper.hxx"
-#include "boost/bind.hpp"
-
-
-namespace css = ::com::sun::star;
-using namespace ::com::sun::star;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::ucb;
-using ::rtl::OUString;
-
-namespace {
-
-rtl::OUString getVersion(
- css::uno::Reference< css::deployment::XPackage > const & package)
-{
- rtl::OUString s(package->getVersion());
- return s.getLength() == 0
- ? rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("0")) : s;
-}
-
-}
-
-namespace dp_gui
-{
- ProgressCommandEnv::UpdateParams::UpdateParams(
- Reference<XInterface> const & _xProgressCommandEnv, OUString const & _text):
- xProgressCommandEnv(_xProgressCommandEnv),
- text(_text)
-{
-}
-//______________________________________________________________________________
-void ProgressCommandEnv::ProgressDialog::CancelButtonImpl::Click()
-{
- m_dialog->m_cmdEnv->m_aborted = true;
- if (m_dialog->m_cmdEnv->m_xAbortChannel.is())
- {
- try {
- m_dialog->m_cmdEnv->m_xAbortChannel->sendAbort();
- }
- catch (RuntimeException &) {
- OSL_ENSURE( 0, "### unexpected RuntimeException!" );
- }
- }
-}
-
-void ProgressCommandEnv::solarthread_dtor()
-{
- if (m_progressDialog.get() != 0) {
- const ::vos::OGuard guard( Application::GetSolarMutex() );
- m_progressDialog->SetModalInputMode( FALSE );
- m_progressDialog.reset();
- }
-}
-
-Dialog * ProgressCommandEnv::activeDialog() {
- Dialog * p = m_progressDialog.get();
- return p == NULL ? m_dialog : p;
-}
-
-//______________________________________________________________________________
-ProgressCommandEnv::~ProgressCommandEnv()
-{
- vcl::solarthread::syncExecute(
- boost::bind( &ProgressCommandEnv::solarthread_dtor, this ) );
-}
-
-//______________________________________________________________________________
-ProgressCommandEnv::ProgressDialog::ProgressDialog(
- ProgressCommandEnv * cmdEnv )
- : Dialog( cmdEnv->m_dialog, WB_STDMODAL ),
- m_cmdEnv( cmdEnv )
-{
- SetModalInputMode( TRUE );
-}
-
-//______________________________________________________________________________
-IMPL_LINK( ProgressCommandEnv, executeDialog, ::osl::Condition *, pCond )
-{
- {
- DialogImpl *mainDialog = dynamic_cast<dp_gui::DialogImpl*>(m_dialog);
- if (mainDialog == NULL)
- {
- OSL_ASSERT(0);
- return 0;
- }
- ::std::auto_ptr<ProgressDialog> that( new ProgressDialog( this ) );
- that->SetHelpId( HID_PACKAGE_MANAGER_PROGRESS );
-
- that->SetStyle( that->GetStyle() & ~WB_CLOSEABLE ); // non-closeable
- that->SetText( m_title );
-
- long totalWidth = that->LogicToPixel(
- Size( 250, 0 ), MapMode( MAP_APPFONT ) ).getWidth();
- long barWidth = totalWidth -
- (2 * mainDialog->m_borderLeftTopSpace.getWidth());
- long posY = mainDialog->m_borderLeftTopSpace.getHeight();
-
- that->m_ftCurrentAction.reset( new FixedText( that.get() ) );
- that->m_ftCurrentAction->SetPosSizePixel(
- mainDialog->m_borderLeftTopSpace.getWidth(), posY,
- barWidth, mainDialog->m_ftFontHeight );
- posY += (mainDialog->m_ftFontHeight +
- mainDialog->m_descriptionYSpace);
-
- that->m_statusBar.reset(
- new StatusBar( that.get(), WB_LEFT | WB_3DLOOK ) );
- that->m_statusBar->SetPosSizePixel(
- mainDialog->m_borderLeftTopSpace.getWidth(), posY,
- barWidth, mainDialog->m_ftFontHeight + 4 );
- posY += (mainDialog->m_ftFontHeight + 4 +
- mainDialog->m_unrelatedSpace.getHeight());
-
- that->m_cancelButton.reset(
- new ProgressDialog::CancelButtonImpl( that.get() ) );
- that->m_cancelButton->SetHelpId( HID_PACKAGE_MANAGER_PROGRESS_CANCEL );
- that->m_cancelButton->SetPosSizePixel(
- (totalWidth - mainDialog->m_buttonSize.getWidth()) / 2,
- posY,
- mainDialog->m_buttonSize.getWidth(),
- mainDialog->m_buttonSize.getHeight() );
- posY += mainDialog->m_buttonSize.getHeight();
-
- that->SetSizePixel(
- Size( totalWidth,
- posY + mainDialog->m_borderRightBottomSpace.getHeight() ) );
-
- that->m_ftCurrentAction->Show();
- that->m_statusBar->Show();
- that->m_cancelButton->Show();
- that->Show();
- m_progressDialog = that;
- }
-
- pCond->set();
- return 0;
-}
-
-//______________________________________________________________________________
-void ProgressCommandEnv::showProgress( sal_Int32 progressSections )
-{
- m_progressSections = progressSections;
- m_currentProgressSection = 0;
- m_currentInnerProgress = 0;
- if (m_progressDialog.get() == 0) {
- ::osl::Condition cond;
- Application::PostUserEvent(
- LINK( this, ProgressCommandEnv, executeDialog ), &cond );
- cond.wait();
- }
-}
-
-//______________________________________________________________________________
-void ProgressCommandEnv::progressSection(
- String const & text, Reference<task::XAbortChannel> const & xAbortChannel )
-{
- m_xAbortChannel = xAbortChannel;
- if (! m_aborted)
- {
- ++m_currentProgressSection;
- m_currentInnerProgress = 0;
- if (m_progressDialog.get() != 0) {
- const ::vos::OGuard guard( Application::GetSolarMutex() );
- if (m_progressDialog->m_statusBar->IsProgressMode())
- m_progressDialog->m_statusBar->EndProgressMode();
- m_progressDialog->m_statusBar->StartProgressMode( text );
- m_progressDialog->m_ftCurrentAction->SetText( String() );
- updateProgress();
- }
- }
-}
-
-//______________________________________________________________________________
-void ProgressCommandEnv::updateProgress( OUString const & text )
-{
- //We pass a reference to this to keep the ProgrssCommandEnv alive until
- //asyncUpdateProgress was called.
- Application::PostUserEvent(
- LINK(this, ProgressCommandEnv, asyncUpdateProgress),
- new UpdateParams(
- Reference<XInterface>(static_cast<OWeakObject*>(this), UNO_QUERY_THROW), text));
- }
-
-// This function may not call in any package manager functions. These use a mutex and
-//then we have both the Solar and the package manager mutex locked here, which may
-//cause deadlocks.
-IMPL_LINK(ProgressCommandEnv, asyncUpdateProgress, UpdateParams*, pUpdateParams)
-{
- try
- {
- if (m_progressDialog.get() != 0)
- {
- // const ::vos::OGuard guard( Application::GetSolarMutex() );
- if (pUpdateParams->text.getLength() > 0)
- m_progressDialog->m_ftCurrentAction->SetText(pUpdateParams->text);
- // xxx todo: how to do better?
- m_progressDialog->m_statusBar->SetProgressValue(
- static_cast<USHORT>(
- (((m_currentProgressSection - 1) +
- (m_currentInnerProgress >= 20
- ? 0.99 : (double)m_currentInnerProgress / 20.0)) * 100)
- / m_progressSections ) % 101 );
- // static_cast<USHORT>(
- // ((m_currentProgressSection +
- // (1.0 - (m_currentInnerProgress == 0
- // ? 1.0 : 1.0 / m_currentInnerProgress))) * 100)
- // / m_progressSections ) % 101 );
- }
- }
- catch (...)
- {
- delete pUpdateParams;
- }
-
- //Make sure we release the reference to NodeImpl
- delete pUpdateParams;
-
- return 0;
-}
-
-// XCommandEnvironment
-//______________________________________________________________________________
-Reference<task::XInteractionHandler> ProgressCommandEnv::getInteractionHandler()
- throw (RuntimeException)
-{
- return this;
-}
-
-//______________________________________________________________________________
-Reference<XProgressHandler> ProgressCommandEnv::getProgressHandler()
- throw (RuntimeException)
-{
- return this;
-}
-
-// XInteractionHandler
-//______________________________________________________________________________
-void ProgressCommandEnv::handle(
- Reference<task::XInteractionRequest> const & xRequest )
- throw (RuntimeException)
-{
- Any request( xRequest->getRequest() );
- OSL_ASSERT( request.getValueTypeClass() == TypeClass_EXCEPTION );
-#if OSL_DEBUG_LEVEL > 1
- OSL_TRACE( "[dp_gui_cmdenv.cxx] incoming request:\n%s\n",
- ::rtl::OUStringToOString( ::comphelper::anyToString(request),
- RTL_TEXTENCODING_UTF8 ).getStr() );
-#endif
-
- lang::WrappedTargetException wtExc;
- deployment::DependencyException depExc;
- deployment::LicenseException licExc;
- deployment::LicenseIndividualAgreementException licAgreementExc;
- deployment::VersionException verExc;
- deployment::InstallException instExc;
- deployment::PlatformException platExc;
-
- // selections:
- bool approve = false;
- bool abort = false;
-
- if (request >>= wtExc) {
- // handable deployment error signalled, e.g.
- // bundle item registration failed, notify cause only:
- Any cause;
- deployment::DeploymentException dpExc;
- if (wtExc.TargetException >>= dpExc)
- cause = dpExc.Cause;
- else {
- CommandFailedException cfExc;
- if (wtExc.TargetException >>= cfExc)
- cause = cfExc.Reason;
- else
- cause = wtExc.TargetException;
- }
- update_( cause );
-
- // ignore intermediate errors of legacy packages, i.e.
- // former pkgchk behaviour:
- const Reference<deployment::XPackage> xPackage(
- wtExc.Context, UNO_QUERY );
- OSL_ASSERT( xPackage.is() );
- if (xPackage.is()) {
- const Reference<deployment::XPackageTypeInfo> xPackageType(
- xPackage->getPackageType() );
- OSL_ASSERT( xPackageType.is() );
- if (xPackageType.is()) {
- approve = (xPackage->isBundle() &&
- xPackageType->getMediaType().matchAsciiL(
- RTL_CONSTASCII_STRINGPARAM(
- "application/"
- "vnd.sun.star.legacy-package-bundle") ));
- }
- }
- abort = !approve;
- }
- else if (request >>= depExc)
- {
- std::vector< rtl::OUString > deps;
- for (sal_Int32 i = 0; i < depExc.UnsatisfiedDependencies.getLength();
- ++i)
- {
- deps.push_back(
- dp_misc::Dependencies::name(depExc.UnsatisfiedDependencies[i]));
- }
- {
- vos::OGuard guard(Application::GetSolarMutex());
- short n = DependencyDialog(activeDialog(), deps).Execute();
- // Distinguish between closing the dialog and programatically
- // canceling the dialog (headless VCL):
- approve = n == RET_OK
- || n == RET_CANCEL && !Application::IsDialogCancelEnabled();
- }
- }
- else if (request >>= licAgreementExc)
- {
- vos::OGuard aSolarGuard( Application::GetSolarMutex() );
- ResId warnId(WARNINGBOX_NOSHAREDALLOWED, *DeploymentGuiResMgr::get());
- WarningBox warn(activeDialog(), warnId);
- String msgText = warn.GetMessText();
- msgText.SearchAndReplaceAllAscii( "%PRODUCTNAME", BrandName::get() );
- msgText.SearchAndReplaceAllAscii("%NAME", licAgreementExc.ExtensionName);
- warn.SetMessText(msgText);
- warn.Execute();
- abort = true;
- }
- else if (request >>= licExc)
- {
- Reference<ui::dialogs::XExecutableDialog> xDialog(
- css::deployment::ui::LicenseDialog::create(
- m_xContext, VCLUnoHelper::GetInterface(activeDialog()), licExc.Text ) );
- sal_Int16 res = xDialog->execute();
- if (res == css::ui::dialogs::ExecutableDialogResults::CANCEL)
- abort = true;
- else if (res == css::ui::dialogs::ExecutableDialogResults::OK)
- approve = true;
- else
- {
- OSL_ASSERT(0);
- }
- }
- else if (request >>= verExc)
- {
- sal_uInt32 id;
- switch (dp_misc::comparePackageVersions(
- verExc.New, verExc.Deployed))
- {
- case dp_misc::LESS:
- id = RID_WARNINGBOX_VERSION_LESS;
- break;
- case dp_misc::EQUAL:
- id = RID_WARNINGBOX_VERSION_EQUAL;
- break;
- default: // dp_misc::GREATER
- id = RID_WARNINGBOX_VERSION_GREATER;
- break;
- }
- OSL_ASSERT(verExc.New.is() && verExc.Deployed.is());
- bool bEqualNames = verExc.New->getDisplayName().equals(
- verExc.Deployed->getDisplayName());
-
- {
- vos::OGuard guard(Application::GetSolarMutex());
- WarningBox box(activeDialog(), ResId(id, *DeploymentGuiResMgr::get()));
- String s;
- if (bEqualNames)
- {
- s = box.GetMessText();
- }
- else if (id == RID_WARNINGBOX_VERSION_EQUAL)
- {
- //hypothetical: requires two instances of an extension with the same
- //version to have different display names. Probably the developer forgot
- //to change the version.
- s = String(ResId(RID_STR_WARNINGBOX_VERSION_EQUAL_DIFFERENT_NAMES,
- *DeploymentGuiResMgr::get()));
- }
- else if (id == RID_WARNINGBOX_VERSION_LESS)
- {
- s = String(ResId(RID_STR_WARNINGBOX_VERSION_LESS_DIFFERENT_NAMES,
- *DeploymentGuiResMgr::get()));
- }
- else if (id == RID_WARNINGBOX_VERSION_GREATER)
- {
- s = String(ResId(RID_STR_WARNINGBOX_VERSION_GREATER_DIFFERENT_NAMES,
- *DeploymentGuiResMgr::get()));
- }
- //s.SearchAndReplaceAllAscii(
- // "$NAME", dp_misc::getIdentifier(verExc.New));
- s.SearchAndReplaceAllAscii(
- "$NAME", verExc.New->getDisplayName());
- s.SearchAndReplaceAllAscii(
- "$OLDNAME", verExc.Deployed->getDisplayName());
-
- s.SearchAndReplaceAllAscii("$NEW", getVersion(verExc.New));
- s.SearchAndReplaceAllAscii(
- "$DEPLOYED", getVersion(verExc.Deployed));
- box.SetMessText(s);
- approve = box.Execute() == RET_OK;
- abort = !approve;
- }
- }
- else if (request >>= instExc)
- {
- //Only if the unopgk was started with gui + extension then we ask the user
- if (!m_bAskWhenInstalling)
- {
- approve = true;
- }
- else
- {
- vos::OGuard guard(Application::GetSolarMutex());
- WarningBox box(activeDialog(), ResId(RID_WARNINGBOX_INSTALL_EXTENSION, *DeploymentGuiResMgr::get()));
- String s(box.GetMessText());
- s.SearchAndReplaceAllAscii("%NAME", instExc.New->getDisplayName());
- box.SetMessText(s);
- approve = box.Execute() == RET_OK;
- abort = !approve;
- }
- }
- else if (request >>= platExc)
- {
- vos::OGuard guard(Application::GetSolarMutex());
- String sMsg(ResId(RID_STR_UNSUPPORTED_PLATFORM, *DeploymentGuiResMgr::get()));
- sMsg.SearchAndReplaceAllAscii("%Name", platExc.package->getDisplayName());
- ErrorBox box(activeDialog(), WB_OK, sMsg);
- box.Execute();
- approve = true;
- }
-
-
- if (approve == false && abort == false)
- {
- // forward to UUI handler:
- if (! m_xHandler.is()) {
- // late init:
- Sequence<Any> handlerArgs( 1 );
- handlerArgs[ 0 ] <<= beans::PropertyValue(
-
- OUSTR("Context"), -1, Any(m_title),
- beans::PropertyState_DIRECT_VALUE );
- m_xHandler.set( m_xContext->getServiceManager()
- ->createInstanceWithArgumentsAndContext(
- OUSTR("com.sun.star.uui.InteractionHandler"),
- handlerArgs, m_xContext ), UNO_QUERY_THROW );
- }
- m_xHandler->handle( xRequest );
- }
- else
- {
- // select:
- Sequence< Reference<task::XInteractionContinuation> > conts(
- xRequest->getContinuations() );
- Reference<task::XInteractionContinuation> const * pConts =
- conts.getConstArray();
- sal_Int32 len = conts.getLength();
- for ( sal_Int32 pos = 0; pos < len; ++pos )
- {
- if (approve) {
- Reference<task::XInteractionApprove> xInteractionApprove(
- pConts[ pos ], UNO_QUERY );
- if (xInteractionApprove.is()) {
- xInteractionApprove->select();
- // don't query again for ongoing continuations:
- approve = false;
- }
- }
- else if (abort) {
- Reference<task::XInteractionAbort> xInteractionAbort(
- pConts[ pos ], UNO_QUERY );
- if (xInteractionAbort.is()) {
- xInteractionAbort->select();
- // don't query again for ongoing continuations:
- abort = false;
- }
- }
- }
- }
-}
-
-// XProgressHandler
-//______________________________________________________________________________
-void ProgressCommandEnv::push( Any const & Status )
- throw (RuntimeException)
-{
- update_( Status );
-}
-
-//______________________________________________________________________________
-void ProgressCommandEnv::update_( Any const & Status )
- throw (RuntimeException)
-{
- DialogImpl *mainDialog = dynamic_cast<dp_gui::DialogImpl*>(m_dialog);
- if (mainDialog == NULL)
- return;
- OUString text;
- if (Status.hasValue() && !(Status >>= text)) {
- if (Status.getValueTypeClass() == TypeClass_EXCEPTION)
- text = static_cast<Exception const *>(Status.getValue())->Message;
- if (text.getLength() == 0)
- text = ::comphelper::anyToString(Status); // fallback
- mainDialog->errbox( text, activeDialog() );
- }
- updateProgress( text );
- ++m_currentInnerProgress;
-}
-
-//______________________________________________________________________________
-void ProgressCommandEnv::update( Any const & Status )
- throw (RuntimeException)
-{
- update_( Status );
-}
-
-//______________________________________________________________________________
-void ProgressCommandEnv::pop() throw (RuntimeException)
-{
- update_( Any() ); // no message
-}
-
-}
-
diff --git a/desktop/source/deployment/gui/dp_gui_cmdenv.h b/desktop/source/deployment/gui/dp_gui_cmdenv.h
deleted file mode 100644
index f66b34f7a84e..000000000000
--- a/desktop/source/deployment/gui/dp_gui_cmdenv.h
+++ /dev/null
@@ -1,190 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: dp_gui_cmdenv.h,v $
- * $Revision: 1.14 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-#if ! defined INCLUDED_DP_GUI_CMDENV_H
-#define INCLUDED_DP_GUI_CMDENV_H
-
-#include "tools/resmgr.hxx"
-#include "osl/conditn.hxx"
-#include "cppuhelper/implbase3.hxx"
-#include "vcl/dialog.hxx"
-#include "vcl/button.hxx"
-#include "vcl/fixed.hxx"
-#include "vcl/status.hxx"
-#include "com/sun/star/ucb/XCommandEnvironment.hpp"
-#include <memory>
-
-#include "com/sun/star/uno/XInterface.hpp"
-
-namespace com { namespace sun { namespace star {
- namespace ucb {
- class XProgressHandler;
- }
- namespace task {
- class XInteractionHandler;
- class XAbortChannel;
- }
- namespace uno {
-// class XInterface;
- class XComponentContext;
- }
-} } }
-
-namespace dp_gui
-{
-
-struct DialogImpl;
-
-//==============================================================================
-//Only if the class is consructed with the DialogImpl then the ProgressDialog can be
-//displayed. Otherwise this class can still be used to forward an interaction. This
-//is done by the interaction handler of the "Download and Installation" dialog.
-
-class ProgressCommandEnv
- : public ::cppu::WeakImplHelper3< ::com::sun::star::ucb::XCommandEnvironment,
- ::com::sun::star::task::XInteractionHandler,
- ::com::sun::star::ucb::XProgressHandler >
-{
- ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler> m_xHandler;
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xContext;
- Dialog * m_dialog;
- ::rtl::OUString m_title;
- bool m_bAskWhenInstalling;
- sal_Int32 m_currentInnerProgress;
- sal_Int32 m_currentProgressSection;
- sal_Int32 m_progressSections;
- void updateProgress( ::rtl::OUString const & text = ::rtl::OUString() );
- void syncProgress(::rtl::OUString const & text);
- ::com::sun::star::uno::Reference< ::com::sun::star::task::XAbortChannel> m_xAbortChannel;
- bool m_aborted;
-
- struct ProgressDialog : public Dialog
- {
- struct CancelButtonImpl : public CancelButton
- {
- ProgressDialog * m_dialog;
- inline CancelButtonImpl( ProgressDialog * dialog )
- : CancelButton( dialog ),
- m_dialog( dialog )
- {}
- virtual void Click();
- };
- friend struct CancelButtonImpl;
-
- ProgressCommandEnv * m_cmdEnv;
- ::std::auto_ptr<FixedText> m_ftCurrentAction;
- ::std::auto_ptr<StatusBar> m_statusBar;
- ::std::auto_ptr<CancelButtonImpl> m_cancelButton;
-
- ProgressDialog( ProgressCommandEnv * cmdEnv );
- };
-
- //Keeps the parameters of the ProgressCommandEnv::updateProgress call so they can be
- //used later in the event handler asyncUpdateProgress. It also keeps the ProgressCommandEnv
- //instance alive so that the posted events (to ourself) can always be processed
- struct UpdateParams
- {
- UpdateParams(::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface>
- const & xProgressCommandEnv, ::rtl::OUString const & _text);
- //This reference keeps the ProgressCommandEnv alive until the event has been processed
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XInterface> xProgressCommandEnv;
- //The argument supplied to ProgressCommandEnv::updateProgress
- ::rtl::OUString text;
- };
- //Perfom asynchronous updateProgress call in main thread
- DECL_LINK(asyncUpdateProgress, UpdateParams*);
-
- friend struct ProgressDialog;
- friend struct ProgressDialog::CancelButtonImpl;
-
- ::std::auto_ptr<ProgressDialog> m_progressDialog;
- DECL_LINK( executeDialog, ::osl::Condition * );
-
- void update_( ::com::sun::star::uno::Any const & Status )
- throw (::com::sun::star::uno::RuntimeException);
-
- void solarthread_dtor();
-
-public:
- virtual ~ProgressCommandEnv();
-
- /** When param bAskWhenInstalling = true, then the user is asked if he
- agrees to install this extension. In case this extension is already installed
- then the user is also notified and asked if he wants to replace that existing
- extension. In first case an interaction request with an InstallException
- will be handled and in the second case a VersionException will be handled.
-
-
- */
- inline ProgressCommandEnv(
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > ctx,
- Dialog * dialog,
- ::rtl::OUString const & title,
- bool bAskWhenInstalling = false):
- m_xContext(ctx),
- m_dialog( dialog ),
- m_title( title ),
- m_bAskWhenInstalling(bAskWhenInstalling),
- m_aborted( false )
- {}
-
- Dialog * activeDialog(); // either m_progressDialog or m_dialog
-
-
- void showProgress( sal_Int32 progressSections );
- void progressSection(
- String const & text,
- ::com::sun::star::uno::Reference< ::com::sun::star::task::XAbortChannel > const & xAbortChannel = 0 );
- inline bool isAborted() const { return m_aborted; }
-
-
-
- // XCommandEnvironment
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionHandler > SAL_CALL
- getInteractionHandler() throw (::com::sun::star::uno::RuntimeException);
- virtual ::com::sun::star::uno::Reference< ::com::sun::star::ucb::XProgressHandler >
- SAL_CALL getProgressHandler() throw (::com::sun::star::uno::RuntimeException);
-
- // XInteractionHandler
- virtual void SAL_CALL handle(
- ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest > const & xRequest )
- throw (::com::sun::star::uno::RuntimeException);
-
- // XProgressHandler
- virtual void SAL_CALL push( ::com::sun::star::uno::Any const & Status )
- throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL update( ::com::sun::star::uno::Any const & Status )
- throw (::com::sun::star::uno::RuntimeException);
- virtual void SAL_CALL pop() throw (::com::sun::star::uno::RuntimeException);
-};
-
-}
-
-#endif
diff --git a/desktop/source/deployment/gui/dp_gui_dialog.cxx b/desktop/source/deployment/gui/dp_gui_dialog.cxx
deleted file mode 100644
index b7cfef124bf6..000000000000
--- a/desktop/source/deployment/gui/dp_gui_dialog.cxx
+++ /dev/null
@@ -1,1535 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: dp_gui_dialog.cxx,v $
- * $Revision: 1.36 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_desktop.hxx"
-
-#include "svtools/controldims.hrc"
-#include "dp_gui.h"
-#include "dp_gui_shared.hxx"
-#include "dp_gui_updatedialog.hxx"
-#include "dp_gui_updateinstalldialog.hxx"
-#include "dp_gui_updatedata.hxx"
-#include "dp_identifier.hxx"
-#include "rtl/uri.hxx"
-#include "osl/thread.hxx"
-#include "osl/mutex.hxx"
-#include "cppuhelper/exc_hlp.hxx"
-#include "cppuhelper/implbase1.hxx"
-#include "ucbhelper/content.hxx"
-#include "comphelper/anytostring.hxx"
-#include "comphelper/sequence.hxx"
-#include "tools/resmgr.hxx"
-#include "toolkit/helper/vclunohelper.hxx"
-#include "vcl/wintypes.hxx"
-#include "vcl/msgbox.hxx"
-#include "vcl/threadex.hxx"
-#include "svtools/svtools.hrc"
-#include "com/sun/star/lang/XMultiComponentFactory.hpp"
-#include "svtools/fixedhyper.hxx"
-#include "com/sun/star/lang/WrappedTargetException.hpp"
-#include "com/sun/star/container/XChild.hpp"
-#include "com/sun/star/container/NoSuchElementException.hpp"
-#include "com/sun/star/ui/dialogs/XFilePicker.hpp"
-#include "com/sun/star/ui/dialogs/XFilePickerControlAccess.hpp"
-#include "com/sun/star/ui/dialogs/XFilterManager.hpp"
-#include "com/sun/star/ui/dialogs/XFolderPicker.hpp"
-#include "com/sun/star/ui/dialogs/TemplateDescription.hpp"
-#include "com/sun/star/ui/dialogs/ExecutableDialogResults.hpp"
-#include "com/sun/star/ui/dialogs/ExtendedFilePickerElementIds.hpp"
-#include "com/sun/star/system/SystemShellExecuteFlags.hpp"
-#include "com/sun/star/system/XSystemShellExecute.hpp"
-#include "com/sun/star/ucb/XContent.hpp"
-#include "com/sun/star/ucb/XContentAccess.hpp"
-#include "com/sun/star/ucb/NameClash.hpp"
-#include "com/sun/star/ucb/ContentAction.hpp"
-#include "com/sun/star/sdbc/XResultSet.hpp"
-#include "com/sun/star/sdbc/XRow.hpp"
-#include "com/sun/star/beans/XPropertySet.hpp"
-#include "com/sun/star/beans/Optional.hpp"
-#include "com/sun/star/beans/PropertyValue.hpp"
-#include "com/sun/star/frame/XDesktop.hpp"
-#include "com/sun/star/deployment/thePackageManagerFactory.hpp"
-#include "boost/function.hpp"
-#include "boost/bind.hpp"
-#include <sfx2/sfxdlg.hxx>
-#include <map>
-#include <vector>
-#include <algorithm>
-
-#define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
-using namespace ::dp_misc;
-using namespace ::com::sun::star;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::ucb;
-
-namespace css = ::com::sun::star;
-using ::rtl::OUString;
-
-
-
-
-namespace dp_gui {
-
-const long ITEM_ID_PACKAGE = 1;
-const long ITEM_ID_VERSION = 2;
-const long ITEM_ID_STATUS = 3;
-
-
-//______________________________________________________________________________
-DialogImpl::DialogImpl(
- Window * pParent, OUString const & extensionURL,
- Reference<XComponentContext> const & xContext )
- : ModelessDialog( pParent, getResId(RID_DLG_PACKAGE_MANAGER) ),
- m_extensionURL(extensionURL),
-// m_bAddingExtensions(false),
- m_xComponentContext( xContext ),
- m_xPkgMgrFac( deployment::thePackageManagerFactory::get(xContext) ),
- m_strAddPackages( getResourceString(RID_STR_ADD_PACKAGES) ),
- m_strAddingPackages( getResourceString(RID_STR_ADDING_PACKAGES) ),
- m_strRemovingPackages( getResourceString(RID_STR_REMOVING_PACKAGES) ),
- m_strEnablingPackages( getResourceString(RID_STR_ENABLING_PACKAGES) ),
- m_strDisablingPackages( getResourceString(RID_STR_DISABLING_PACKAGES) ),
- m_strExportPackage( getResourceString(RID_STR_EXPORT_PACKAGE) ),
- m_strExportPackages( getResourceString(RID_STR_EXPORT_PACKAGES) ),
- m_strExportingPackages( getResourceString(RID_STR_EXPORTING_PACKAGES) )
-{
-
- m_addExtensionQueue.reset(new AddExtensionQueue(this, m_xComponentContext,
- m_xPkgMgrFac->getPackageManager(OUSTR("user"))));
- // If the extensionURL contains a URL then we were
- //started as a result of an install request triggered by user, for example by
- //double clicking an extension in a file browser. This extension will be installed
- //immediatly and for that time we disable the buttons
-// if (extensionURL.getLength())
-// m_bAddingExtensions = true;
-
- Reference<css::lang::XMultiServiceFactory> xConfig(
- xContext->getServiceManager()->createInstanceWithContext(
- OUSTR("com.sun.star.configuration.ConfigurationProvider"), m_xComponentContext),
- UNO_QUERY_THROW);
- Any args[1];
- css::beans::PropertyValue val1(
- OUSTR("nodepath"), 0, Any(OUSTR("/org.openoffice.Office.OptionsDialog/Nodes")),
- ::css::beans::PropertyState_DIRECT_VALUE);
- args[0] <<= val1;
- m_xNameAccessNodes = Reference<css::container::XNameAccess>(
- xConfig->createInstanceWithArguments(OUSTR("com.sun.star.configuration.ConfigurationAccess"),
- Sequence<Any>(args, 1)), UNO_QUERY_THROW);
-
- css::beans::PropertyValue val2(
- OUSTR("nodepath"), 0, Any(OUSTR("/org.openoffice.Office.ExtensionManager/ExtensionRepositories")),
- ::css::beans::PropertyState_DIRECT_VALUE);
- args[0] <<= val2;
- m_xNameAccessRepositories = Reference<css::container::XNameAccess>(
- xConfig->createInstanceWithArguments(OUSTR("com.sun.star.configuration.ConfigurationAccess"),
- Sequence<Any>(args, 1)), UNO_QUERY_THROW);
-}
-
-//______________________________________________________________________________
-DialogImpl::~DialogImpl()
-{
-}
-
-//------------------------------------------------------------------------------
-::rtl::Reference<DialogImpl> DialogImpl::s_dialog;
-::osl::Mutex DialogImpl::s_dialogMutex;
-::rtl::Reference<DialogImpl> DialogImpl::s_closingDialog;
-::osl::Mutex DialogImpl::s_closingMutex;
-
-//______________________________________________________________________________
-::rtl::Reference<DialogImpl> DialogImpl::get(
- Reference<XComponentContext> const & xContext,
- Reference<awt::XWindow> const & xParent,
- OUString const & extensionURL,
- OUString const & defaultView )
-{
- {
- ::osl::MutexGuard g(s_dialogMutex);
- if (s_dialog.is())
- {
- //Add extensions. In this case the Extension Manager is already open
- //and someone installs an extension by using the system integration. That is, by
- //double clicking and extension.
- //In case the application message loop does not work yet, which is the case when
- //this service is created in the unpkg process, then the queue thread may be blocked
- //during installation until messages are dispatched.
- s_dialog->m_addExtensionQueue->addExtension(extensionURL);
- return s_dialog;
- }
- }
-
- Window * pParent = DIALOG_NO_PARENT;
- if (xParent.is())
- pParent = VCLUnoHelper::GetWindow(xParent);
- ::rtl::Reference<DialogImpl> that( new DialogImpl( pParent,
- extensionURL,xContext ) );
-
- // !!! tab-order relates to creation order:
- that->m_ftPackages.reset(
- new FixedText( that.get(), getResId(RID_FT_PACKAGES) ) );
-
- // selection box: header bar + treelistbox:
- that->m_selectionBox.reset( new SelectionBoxControl( that.get() ) );
- that->m_treelb.reset(
- new TreeListBoxImpl(
- xContext, that->m_selectionBox.get(), that.get() ) );
- that->m_headerBar.reset(
- new HeaderBar( that->m_selectionBox.get() ) );
- that->m_headerBar->SetEndDragHdl(
- LINK( that.get(), DialogImpl, headbar_dragEnd ) );
-
- that->m_addButton.reset(
- new ThreadedPushButton( that.get(),
- &DialogImpl::clickAdd, RID_BTN_ADD ) );
- that->m_removeButton.reset(
- new ThreadedPushButton( that.get(),
- &DialogImpl::clickRemove, RID_BTN_REMOVE ) );
- that->m_enableButton.reset(
- new ThreadedPushButton( that.get(),
- &DialogImpl::clickEnableDisable,
- RID_BTN_ENABLE ) );
- that->m_disableButton.reset(
- new ThreadedPushButton( that.get(),
- &DialogImpl::clickEnableDisable,
- RID_BTN_DISABLE ) );
- that->m_exportButton.reset(
- new ThreadedPushButton( that.get(),
- &DialogImpl::clickExport, RID_BTN_EXPORT ) );
- that->m_checkUpdatesButton.reset(
- new SyncPushButton( that.get(), &DialogImpl::clickCheckUpdates,
- RID_BTN_CHECK_UPDATES ) );
-
- that->m_optionsButton.reset(
- new ThreadedPushButton( that.get(), &DialogImpl::clickOptions,
- RID_BTN_OPTIONS ) );
-
- that->m_optionsButton->Enable(true);
-
- that->m_getExtensionsButton.reset(
- new svt::FixedHyperlink( that.get(), getResId( RID_BTN_GET_EXTENSIONS ) ) );
-
- that->m_getExtensionsButton->SetClickHdl( LINK( that.get(), DialogImpl, hyperlink_clicked ) );
- css::uno::Any aValue = that->m_xNameAccessRepositories->getByName(OUSTR("WebsiteLink"));
- String sURL( aValue.get< OUString >() );
- that->m_getExtensionsButton->SetQuickHelpText( sURL );
-
- that->m_bottomLine.reset( new FixedLine( that.get() ) );
- that->m_closeButton.reset(
- new OKButton( that.get(), getResId(RID_BTN_CLOSE) ) );
- that->m_helpButton.reset(
- new HelpButton( that.get(), getResId(RID_BTN_HELP) ) );
- if (! office_is_running())
- that->m_helpButton->Disable();
-
- // free local resources (RID < 256):
- that->FreeResource();
-
- css::uno::Reference<css::deployment::XPackageManager> xUserContext(
- that->m_xPkgMgrFac->getPackageManager( OUSTR("user") ) );
- css::uno::Reference<css::deployment::XPackageManager> xSharedContext(
- that->m_xPkgMgrFac->getPackageManager( OUSTR("shared") ) );
- that->m_packageManagers.realloc(2);
- that->m_packageManagers[0] = xUserContext;
- that->m_packageManagers[1] = xSharedContext;
-
- that->m_updatability.reset(
- new Updatability(
- that->m_packageManagers, *that->m_checkUpdatesButton ) );
-
- // sizes, spacing, position:
- that->m_buttonSize = that->LogicToPixel(
- Size( RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_PUSHBUTTON_HEIGHT ),
- MapMode( MAP_APPFONT ) );
- that->m_textSize = that->LogicToPixel(
- Size( 0, RSC_CD_CHECKBOX_HEIGHT ),
- MapMode( MAP_APPFONT ) );
- that->m_relatedSpace = that->LogicToPixel(
- Size( RSC_SP_CTRL_GROUP_X, RSC_SP_CTRL_GROUP_Y ),
- MapMode( MAP_APPFONT ) );
- that->m_unrelatedSpace = that->LogicToPixel(
- Size( RSC_SP_CTRL_X, RSC_SP_CTRL_Y ),
- MapMode( MAP_APPFONT ) );
- that->m_borderLeftTopSpace = that->LogicToPixel(
- Size( RSC_SP_DLG_INNERBORDER_LEFT, RSC_SP_DLG_INNERBORDER_TOP ),
- MapMode( MAP_APPFONT ) );
- that->m_borderRightBottomSpace = that->LogicToPixel(
- Size( RSC_SP_DLG_INNERBORDER_RIGHT, RSC_SP_DLG_INNERBORDER_BOTTOM ),
- MapMode( MAP_APPFONT ) );
- that->m_ftFontHeight = that->m_textSize.Height() /*!!!that->m_ftPackages->GetTextHeight()*/;
- that->m_descriptionYSpace = that->LogicToPixel(
- Size( 0, RSC_SP_CTRL_DESC_Y ), MapMode( MAP_APPFONT ) ).getHeight();
-
- // minimum size:
- that->SetMinOutputSizePixel(
- Size( // width:
- that->m_borderLeftTopSpace.getWidth() +
- (3 * that->m_buttonSize.getWidth()) +
- (2 * that->m_unrelatedSpace.getWidth()) +
- that->m_borderRightBottomSpace.getWidth(),
- // height:
- that->m_borderLeftTopSpace.getHeight() +
- that->m_ftFontHeight +
- that->m_descriptionYSpace +
- (5 * that->m_buttonSize.getHeight()) +
- (1 * that->m_textSize.Height()) +
- (4 * that->m_relatedSpace.getHeight()) +
- (2 * that->m_unrelatedSpace.getHeight()) +
- that->m_borderRightBottomSpace.getHeight() ) );
-
- that->Resize();
-
- // calculate tabs:
- long selWidth = that->m_treelb->GetSizePixel().getWidth();
- long vscrollWidth =
- Application::GetSettings().GetStyleSettings().GetScrollBarSize();
-
- long statusWidth = that->m_treelb->GetTextWidth(
- that->m_treelb->m_strEnabled );
- statusWidth = ::std::max(
- statusWidth, that->m_treelb->GetTextWidth(
- that->m_treelb->m_strDisabled ) );
- statusWidth = ::std::max(
- statusWidth, that->m_treelb->GetTextWidth(
- that->m_treelb->m_strUnknown ) );
- String strStatus( getResourceString(RID_STR_PACKAGE_STATUS) );
- statusWidth = ::std::max(
- statusWidth, that->m_treelb->GetTextWidth( strStatus ) );
- statusWidth += 1;
-
- that->m_headerBar->InsertItem(
- ITEM_ID_PACKAGE, getResourceString(RID_STR_PACKAGE),
- selWidth - statusWidth - statusWidth - vscrollWidth );
- that->m_headerBar->InsertItem( ITEM_ID_VERSION, getResourceString(RID_STR_EXTENSION_VERSION), statusWidth);
- that->m_headerBar->InsertItem( ITEM_ID_STATUS, strStatus, statusWidth );
-
- long tabs[ 4 ];
- tabs[ 0 ] = 3; // two tabs
- tabs[ 1 ] = 0;
- tabs[ 2 ] = selWidth - statusWidth -statusWidth - vscrollWidth;
- tabs[ 3 ] = selWidth - statusWidth - vscrollWidth;
- that->m_treelb->SetTabs( tabs, MAP_PIXEL );
- that->m_treelb->InitHeaderBar( that->m_headerBar.get() );
-
- //### add top-level nodes: #########################
-
- that->m_treelb->SetUpdateMode(FALSE);
-
- that->m_treelb->addNode(
- 0 /* no parent */,
- getResourceString(RID_STR_USER_INSTALLATION),
- OUString() /* no factory URL */,
- xUserContext,
- Reference<deployment::XPackage>(),
- Reference<XCommandEnvironment>(),
- false /* no sort in */ );
- that->m_treelb->addNode(
- 0 /* no parent */,
- getResourceString(RID_STR_SHARED_INSTALLATION),
- OUString() /* no factory URL */,
- xSharedContext,
- Reference<deployment::XPackage>(),
- Reference<XCommandEnvironment>(),
- false /* no sort in */ );
-
- if (office_is_running())
- {
- that->m_xDesktop.set(
- that->m_xComponentContext->getServiceManager()
- ->createInstanceWithContext(
- OUSTR("com.sun.star.frame.Desktop"),
- that->m_xComponentContext ),
- UNO_QUERY_THROW );
- that->m_xDesktop->addTerminateListener( that.get() );
- ::ucbhelper::Content ucb_tdocRoot( OUSTR("vnd.sun.star.tdoc:/"), 0 );
- that->m_xTdocRoot.set( ucb_tdocRoot.get() );
-
-// // scan for open documents:
-// Reference<sdbc::XResultSet> xResultSet(
-// ucb_tdocRoot.createCursor( Sequence<OUString>(),
-// ::ucbhelper::INCLUDE_FOLDERS_ONLY ) );
-// while (xResultSet->next()) {
-// that->contentEvent(
-// ContentEvent( that->m_xTdocRoot,
-// ContentAction::INSERTED,
-// Reference<XContentAccess>(
-// xResultSet, UNO_QUERY_THROW )->queryContent(),
-// that->m_xTdocRoot->getIdentifier() ) );
-// }
-// that->m_xTdocRoot->addContentEventListener( that.get() );
- }
-
- that->m_treelb->SetUpdateMode(TRUE);
-
- //##################################################
- that->updateButtonStates();
- that->m_selectionBox->Show();
- that->m_headerBar->Show();
- that->m_treelb->Show();
- that->m_bottomLine->Show();
-
- // default selection:
- that->m_treelb->GrabFocus();
- SvLBoxEntry * defEntry = that->m_treelb->GetEntry(
- defaultView.equalsIgnoreAsciiCaseAsciiL(
- RTL_CONSTASCII_STRINGPARAM("shared") ) ? 1 : 0 );
- if (defEntry != 0)
- that->m_treelb->Select( defEntry );
-
- //Assuming two threads enter this function shortly after each other and
- //both run to this point, then only one dialog will be kept alive by setting
- //it to s_dialog. The other dialog will be destructed after leaving this function.
- //That also means that an installation request (double-click on oxt file), must not
- //be past into the constructor of DialogImpl, because the dialog may be destructed
- //rigth away and will never show.
- //See also DialogImpl::Close, DialogImpl::destroyDialog, DialogImpl::disposing
- {
- ::osl::MutexGuard g(s_dialogMutex);
- if (! s_dialog.is()) {
- OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
- s_dialog = that;
- }
- }
- s_dialog->m_addExtensionQueue->addExtension(extensionURL);
- return s_dialog;
-}
-
-//______________________________________________________________________________
-void DialogImpl::Resize()
-{
- Size totalSize( GetSizePixel() );
- Size selSize( totalSize.getWidth() -
- m_borderRightBottomSpace.getWidth() -
- m_buttonSize.getWidth() -
- m_unrelatedSpace.getWidth() -
- m_borderLeftTopSpace.getWidth(),
-
- totalSize.getHeight() -
- m_borderLeftTopSpace.getHeight() -
- m_ftFontHeight -
- m_descriptionYSpace -
- (2 * m_unrelatedSpace.getHeight()) -
- m_buttonSize.getHeight() -
- m_textSize.getHeight() -
- m_relatedSpace.getHeight() -
- m_borderRightBottomSpace.getHeight() );
-
- long buttonX =
- m_borderLeftTopSpace.getWidth() + selSize.getWidth() +
- m_unrelatedSpace.getWidth();
- long buttonY = m_borderLeftTopSpace.getHeight() +
- m_ftFontHeight + m_descriptionYSpace;
-
- m_ftPackages->SetPosSizePixel(
- m_borderLeftTopSpace.getWidth(), m_borderLeftTopSpace.getHeight(),
- selSize.getWidth(), m_ftFontHeight );
-
- m_selectionBox->SetPosSizePixel(
- m_borderLeftTopSpace.getWidth(), buttonY,
- selSize.getWidth(), selSize.getHeight() );
- long selBarHeight = m_headerBar->GetSizePixel().getHeight();
- Size selOutputSize( m_selectionBox->GetOutputSizePixel() );
- m_headerBar->SetPosSizePixel(
- 0, 0, selOutputSize.getWidth(), selBarHeight );
- m_treelb->SetPosSizePixel(
- 0, selBarHeight, selOutputSize.getWidth(),
- selOutputSize.getHeight() - selBarHeight );
-
- m_addButton->SetPosSizePixel(
- buttonX,
- buttonY + (0 * (m_buttonSize.getHeight() + m_relatedSpace.getHeight())),
- m_buttonSize.getWidth(), m_buttonSize.getHeight() );
- m_removeButton->SetPosSizePixel(
- buttonX,
- buttonY + (1 * (m_buttonSize.getHeight() + m_relatedSpace.getHeight())),
- m_buttonSize.getWidth(), m_buttonSize.getHeight() );
- m_enableButton->SetPosSizePixel(
- buttonX,
- buttonY + (2 * (m_buttonSize.getHeight() + m_relatedSpace.getHeight())),
- m_buttonSize.getWidth(), m_buttonSize.getHeight() );
- m_disableButton->SetPosSizePixel(
- buttonX,
- buttonY + (3 * (m_buttonSize.getHeight() + m_relatedSpace.getHeight())),
- m_buttonSize.getWidth(), m_buttonSize.getHeight() );
- m_exportButton->SetPosSizePixel(
- buttonX,
- buttonY + (4 * (m_buttonSize.getHeight() + m_relatedSpace.getHeight())),
- m_buttonSize.getWidth(), m_buttonSize.getHeight() );
- m_checkUpdatesButton->SetPosSizePixel(
- buttonX,
- buttonY + (5 * (m_buttonSize.getHeight() + m_relatedSpace.getHeight())),
- m_buttonSize.getWidth(), m_buttonSize.getHeight() );
- m_optionsButton->SetPosSizePixel(
- buttonX,
- buttonY + (6 * (m_buttonSize.getHeight() + m_relatedSpace.getHeight())),
- m_buttonSize.getWidth(), m_buttonSize.getHeight() );
- m_getExtensionsButton->SetPosSizePixel(
- m_borderLeftTopSpace.getWidth(),
- buttonY + selSize.getHeight() + m_relatedSpace.getHeight(),
- selSize.getWidth(), m_textSize.Height() );
- long bottomY =
- totalSize.getHeight() -
- m_borderRightBottomSpace.getHeight() - m_buttonSize.getHeight();
- m_closeButton->SetPosSizePixel(
- buttonX - m_unrelatedSpace.getWidth() - m_buttonSize.getWidth(),
- bottomY,
- m_buttonSize.getWidth(), m_buttonSize.getHeight() );
- m_helpButton->SetPosSizePixel(
- buttonX, bottomY,
- m_buttonSize.getWidth(), m_buttonSize.getHeight() );
- m_bottomLine->SetPosSizePixel(
- 0, bottomY - m_unrelatedSpace.getHeight() - 4,
- totalSize.getWidth(), 8 );
-}
-
-//______________________________________________________________________________
-IMPL_LINK( DialogImpl, headbar_dragEnd, HeaderBar *, pBar )
-{
- if (pBar != 0 && pBar->GetCurItemId() == 0)
- return 0;
- OSL_ASSERT( m_headerBar.get() == pBar );
-
- if (! m_headerBar->IsItemMode())
- {
- const sal_Int32 TAB_WIDTH_MIN = 10;
- sal_Int32 maxWidth =
- m_headerBar->GetSizePixel().getWidth() - TAB_WIDTH_MIN;
-
- sal_Int32 packageWith = m_headerBar->GetItemSize( ITEM_ID_PACKAGE );
- if (packageWith < TAB_WIDTH_MIN)
- m_headerBar->SetItemSize( ITEM_ID_PACKAGE, TAB_WIDTH_MIN );
- else if (packageWith > maxWidth)
- m_headerBar->SetItemSize( ITEM_ID_PACKAGE, maxWidth );
- if (m_headerBar->GetItemSize( ITEM_ID_STATUS ) < TAB_WIDTH_MIN)
- m_headerBar->SetItemSize( ITEM_ID_STATUS, TAB_WIDTH_MIN );
-
- sal_Int32 nPos = 0;
- USHORT nTabs = m_headerBar->GetItemCount();
- OSL_ASSERT( m_treelb->TabCount() == nTabs );
- for ( USHORT i = 1; i < nTabs; ++i ) {
- nPos += m_headerBar->GetItemSize( i );
- m_treelb->SetTab( i, nPos, MAP_PIXEL );
- }
- }
- return 1;
-}
-
-//______________________________________________________________________________
-IMPL_LINK( DialogImpl, hyperlink_clicked, svt::FixedHyperlink*, EMPTYARG )
-{
- OUString sURL;
- try
- { //throws css::container::NoSuchElementException, css::lang::WrappedTargetException
- Any value = m_xNameAccessRepositories->getByName(OUSTR("WebsiteLink"));
- sURL = value.get<OUString> ();
- openWebBrowser(sURL);
- }
- catch (css::uno::Exception& )
- {
- Any exc( ::cppu::getCaughtException() );
- OUString msg(::comphelper::anyToString(exc));
- errbox( msg );
- }
- return 1;
-}
-
-
-//This event is posted after DialogImpl::Show was called.
-//It is used to install the extension when running unopkg gui extension
-//We use this event to make sure that the extension manager dialog is showing.
-IMPL_LINK( DialogImpl, startInstallExtensions, DialogImpl * , EMPTYARG )
-{
- //See also updateButtonState which uses m_arExtensions
- m_addExtensionQueue->addExtension(m_extensionURL);
- m_extensionURL = OUString();
- return 0;
-}
-
-void DialogImpl::openWebBrowser(OUString const & sURL) const
-{
- try
- {
- Reference< css::system::XSystemShellExecute > xSystemShellExecute(
- m_xComponentContext->getServiceManager()->createInstanceWithContext(
- OUString::createFromAscii( "com.sun.star.system.SystemShellExecute" ),
- m_xComponentContext), UNO_QUERY_THROW);
- //throws css::lang::IllegalArgumentException, css::system::SystemShellExecuteException
- xSystemShellExecute->execute(
- sURL, OUString(), css::system::SystemShellExecuteFlags::DEFAULTS);
- }
- catch (css::uno::Exception& )
- {
- Any exc( ::cppu::getCaughtException() );
- OUString msg(::comphelper::anyToString(exc));
- errbox( msg );
- }
-}
-
-::std::vector<dp_gui::UpdateData> DialogImpl::excludeWebsiteDownloads(
- ::std::vector<dp_gui::UpdateData> const & data)
-{
- ::std::vector<dp_gui::UpdateData> ret;
- typedef std::vector< dp_gui::UpdateData >::const_iterator cit;
- for (cit i = data.begin(); i < data.end(); i++)
- {
- if (i->sWebsiteURL.getLength() == 0)
- ret.push_back(*i);
- }
- return ret;
-}
-//______________________________________________________________________________
-void DialogImpl::updateButtonStates(
- Reference<XCommandEnvironment> const & xCmdEnv )
-{
- m_updatability->start();
-
- bool allowModification = true;
- bool bEnable = true;
- bool bDisable = true;
- bool bRemove = true;
- bool bExport = true;
- bool bOptions = true;
-
- sal_Int32 nSelectedPackages = 0;
- Reference<css::deployment::XPackage> xPackage;
- Reference<css::deployment::XPackageManager> xPackageManager;
- for ( SvLBoxEntry * entry = m_treelb->FirstSelected();
- entry != 0; entry = m_treelb->NextSelected(entry) )
- {
- allowModification = allowModification &&
- ! m_treelb->getPackageManager(entry)->isReadOnly();
-
- xPackage = m_treelb->getPackage(entry);
-
- if (xPackage.is())
- {
- ++nSelectedPackages;
- if (m_treelb->isFirstLevelChild( entry ))
- {
- //get the package manager for this package which we need to determine if
- //options button is to be shown.
- xPackageManager = m_treelb->getPackageManager(entry);
- switch (getPackageState( xPackage, xCmdEnv ))
- {
- case REGISTERED:
- bEnable = false;
- break;
- case NOT_REGISTERED:
- bDisable = false;
- break;
- case AMBIGUOUS:
- break;
- case NOT_AVAILABLE:
- bEnable = false;
- bDisable = false;
- break;
- }
- }
- else {
- // export still possible:
- bEnable = bDisable = bRemove = bOptions = false;
- }
- }
- else { // selected non-package entry:
- bExport = bEnable = bDisable = bRemove = bOptions = false;
- }
- }
-// bEnable &= (allowModification && nSelectedPackages > 0) && !m_bAddingExtensions;
-// bDisable &= (allowModification && nSelectedPackages > 0) && !m_bAddingExtensions;
-// bRemove &= (allowModification && nSelectedPackages > 0) && !m_bAddingExtensions;
- bEnable &= allowModification && nSelectedPackages > 0;
- bDisable &= allowModification && nSelectedPackages > 0;
- bRemove &= allowModification && nSelectedPackages > 0;
-
- bExport &= (nSelectedPackages > 0);
-
- if (bOptions)
- {
- //We do not support multiple selection for the Options button
- if (nSelectedPackages == 1 && xPackage->isBundle())
- {
- //check if this package is shared. Then if the same package exist as
- //user then we will not enable the button
- css::beans::Optional<OUString> aId = xPackage->getIdentifier();
- //a bundle must always have an id
- OSL_ASSERT(aId.IsPresent);
- if (xPackageManager->getContext().equals(OUSTR("shared")))
- {
- //get the "user" xpackage manager;
- Reference<css::deployment::XPackageManager> xUserPM;
- for (sal_Int32 i = 0; i < m_packageManagers.getLength(); i++)
- {
- Reference<css::deployment::XPackageManager> const & xPM = m_packageManagers[i];
- if (xPM->getContext().equals(OUSTR("user")))
- {
- xUserPM = xPM;
- break;
- }
- }
- try {
- //getDeployedPackage throws an IllegalArgumentException if the package
- //does not exist
- xUserPM->getDeployedPackage(
- aId.Value, OUSTR(""),
- Reference<css::ucb::XCommandEnvironment>()).is();
- bOptions = false;
- } catch (css::uno::Exception & ) {
- }
- }
- if (bOptions && ! supportsOptions(aId.Value))
- bOptions = false;
- }
- else
- {
- bOptions = false;
- }
- }
-
- {
- const ::vos::OGuard guard( Application::GetSolarMutex() );
- m_disableButton->Enable( bDisable );
- m_enableButton->Enable( bEnable );
- m_exportButton->Enable( bExport );
- m_optionsButton->Enable( bOptions);
- SvLBoxEntry * currEntry = m_treelb->getCurrentSingleSelectedEntry();
-
- m_addButton->Enable(
-// !m_bAddingExtensions &&
- allowModification &&
- (currEntry != 0 &&
- m_treelb->GetParent( currEntry ) == 0 /* top-level */) &&
- (nSelectedPackages == 0) );
- m_removeButton->Enable( bRemove );
- }
-}
-
-// The function investigates if the extension supports options.
-bool DialogImpl::supportsOptions( ::rtl::OUString const & sExtensionId)
-{
- bool bOptions = false;
- //iterate over all available nodes
- Sequence<OUString> seqNames = m_xNameAccessNodes->getElementNames();
-
- for (int i = 0; i < seqNames.getLength(); i++)
- {
- Any anyNode = m_xNameAccessNodes->getByName(seqNames[i]);
- //If we have a node then then it must contain the set of leaves. This is part of OptionsDialog.xcs
- Reference<XInterface> xIntNode = anyNode.get<Reference<XInterface> >();
- Reference<css::container::XNameAccess> xNode(xIntNode, UNO_QUERY_THROW);
-
- Any anyLeaves = xNode->getByName(OUSTR("Leaves"));
- Reference<XInterface> xIntLeaves = anyLeaves.get<Reference<XInterface> >();
- Reference<css::container::XNameAccess> xLeaves(xIntLeaves, UNO_QUERY_THROW);
-
- //iterate over all available leaves
- Sequence<OUString> seqLeafNames = xLeaves->getElementNames();
- for (int j = 0; j < seqLeafNames.getLength(); j++)
- {
- Any anyLeaf = xLeaves->getByName(seqLeafNames[j]);
- Reference<XInterface> xIntLeaf = anyLeaf.get<Reference<XInterface> >();
- Reference<css::beans::XPropertySet> xLeaf(xIntLeaf, UNO_QUERY_THROW);
- //investigate the Id property if it matches the extension identifier which
- //has been passed in.
- Any anyValue = xLeaf->getPropertyValue(OUSTR("Id"));
-
- OUString sId = anyValue.get<OUString>();
- if (sId == sExtensionId)
- {
- bOptions = true;
- break;
- }
- }
- if (bOptions)
- break;
- }
- return bOptions;
-}
-
-//______________________________________________________________________________
-
-::std::vector<
- ::std::pair<
- Reference< deployment::XPackage>,
- Reference< deployment::XPackageManager> > >
- DialogImpl::TreeListBoxImpl::getSelectedPackages(bool onlyFirstLevel) const
-{
- ::std::vector< ::std::pair< Reference<deployment::XPackage>,
- Reference<deployment::XPackageManager> > > ret;
-
- for ( SvLBoxEntry * entry = FirstSelected();
- entry != 0; entry = NextSelected(entry) )
- {
- if (onlyFirstLevel && ! isFirstLevelChild( entry ))
- continue;
- Reference<deployment::XPackage> xPackage( getPackage(entry) );
- Reference<deployment::XPackageManager> xPackageManager(getPackageManager(entry));
- OSL_ASSERT(xPackageManager.is());
- if (xPackage.is())
- ret.push_back( ::std::make_pair(xPackage, xPackageManager));
- }
- return ret;
-}
-
-namespace {
-struct StrAllFiles : public rtl::StaticWithInit<const OUString, StrAllFiles> {
- const OUString operator () () {
- const ::vos::OGuard guard( Application::GetSolarMutex() );
- ::std::auto_ptr<ResMgr> const resmgr(
- ResMgr::CreateResMgr( "fps_office" ) );
- OSL_ASSERT( resmgr.get() != 0 );
- String ret( ResId( STR_FILTERNAME_ALL, *resmgr.get() ) );
- return ret;
- }
-};
-} // anon namespace
-
-//______________________________________________________________________________
-Sequence<OUString> DialogImpl::solarthread_raiseAddPicker(
- Reference<deployment::XPackageManager> const & xPackageManager )
-{
- const Any mode( static_cast<sal_Int16>(
- ui::dialogs::TemplateDescription::FILEOPEN_SIMPLE ) );
- const Reference<ui::dialogs::XFilePicker> xFilePicker(
- m_xComponentContext->getServiceManager()
- ->createInstanceWithArgumentsAndContext(
- OUSTR("com.sun.star.ui.dialogs.FilePicker"),
- Sequence<Any>(&mode, 1), m_xComponentContext ), UNO_QUERY_THROW );
- xFilePicker->setTitle( m_strAddPackages );
- xFilePicker->setMultiSelectionMode(true);
-
- // collect and set filter list:
- typedef /* sorted */ ::std::map<OUString, OUString> t_string2string;
- t_string2string title2filter;
- const Sequence< Reference<deployment::XPackageTypeInfo> > packageTypes(
- xPackageManager->getSupportedPackageTypes() );
- for ( sal_Int32 pos = 0; pos < packageTypes.getLength(); ++pos ) {
- Reference<deployment::XPackageTypeInfo> const & xPackageType =
- packageTypes[ pos ];
- const OUString filter( xPackageType->getFileFilter() );
- if (filter.getLength() > 0)
- {
- const OUString title( xPackageType->getShortDescription() );
- const ::std::pair<t_string2string::iterator, bool> insertion(
- title2filter.insert( t_string2string::value_type(
- title, filter ) ) );
- if (! insertion.second) { // already existing, append extensions:
- ::rtl::OUStringBuffer buf;
- buf.append( insertion.first->second );
- buf.append( static_cast<sal_Unicode>(';') );
- buf.append( filter );
- insertion.first->second = buf.makeStringAndClear();
- }
- }
- }
-
- const Reference<ui::dialogs::XFilterManager> xFilterManager(
- xFilePicker, UNO_QUERY_THROW );
- // All files at top:
- xFilterManager->appendFilter( StrAllFiles::get(), OUSTR("*.*") );
- // then supported ones:
- t_string2string::const_iterator iPos( title2filter.begin() );
- const t_string2string::const_iterator iEnd( title2filter.end() );
- for ( ; iPos != iEnd; ++iPos ) {
- try {
- xFilterManager->appendFilter( iPos->first, iPos->second );
- }
- catch (lang::IllegalArgumentException & exc) {
- OSL_ENSURE( 0, ::rtl::OUStringToOString(
- exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
- (void) exc;
- }
- }
- xFilterManager->setCurrentFilter( StrAllFiles::get() );
-
- if (xFilePicker->execute() != ui::dialogs::ExecutableDialogResults::OK)
- return Sequence<OUString>(); // cancelled
-
- Sequence<OUString> files( xFilePicker->getFiles() );
- OSL_ASSERT( files.getLength() > 0 );
- return files;
-}
-
-//______________________________________________________________________________
-void DialogImpl::clickAdd( USHORT )
-{
- //Prevent adding of new extension (m_addExtensionQueue) which are caused by
- //calls to "unopkg gui ext", for example, double-clicking and extension.
- ::osl::MutexGuard actionGuard(ActionMutex::get());
-
- //The top level nodes of the tree contain the respective XPackageManager
- OSL_ASSERT( m_treelb->getSelectedPackages(false).size() == 0 );
- const Reference<deployment::XPackageManager> xPackageManager(
- m_treelb->getPackageManager(m_treelb->getCurrentSingleSelectedEntry() ) );
- OSL_ASSERT(xPackageManager.is() );
-
- if (! continueActionForSharedExtension(xPackageManager, ADD_ACTION))
- return;
-
- const Sequence<OUString> files(
- vcl::solarthread::syncExecute(
- boost::bind( &DialogImpl::solarthread_raiseAddPicker, this,
- xPackageManager ) ) );
- if (files.getLength() == 0)
- return;
-
- ::rtl::Reference<ProgressCommandEnv> currentCmdEnv(
- new ProgressCommandEnv( m_xComponentContext, this, m_strAddingPackages ) );
- currentCmdEnv->showProgress( files.getLength() );
- Reference<task::XAbortChannel> xAbortChannel(
- xPackageManager->createAbortChannel() );
-
- for ( sal_Int32 pos = files.getLength() > 1 ? 1 : 0;
- !currentCmdEnv->isAborted() && pos < files.getLength(); ++pos )
- {
- OUString file;
- if (files.getLength() > 1)
- file = makeURL( files[ 0 ], files[ pos ] );
- else
- file = files[ pos ];
- currentCmdEnv->progressSection(
- ::ucbhelper::Content( file, currentCmdEnv.get() ).getPropertyValue(
- OUSTR("Title") ).get<OUString>(), xAbortChannel );
- try {
- Reference<deployment::XPackage> xPackage(
- xPackageManager->addPackage(
- file, OUString() /* detect media-type */,
- xAbortChannel, currentCmdEnv.get() ) );
- OSL_ASSERT( xPackage.is() );
- }
- catch (css::ucb::CommandFailedException & )
- {
- //For exampl, we want to add many extensions, and one of them
- //is already installed. Then we'll get a dialog asking if we want to overwrite. If we then press
- //cancel the exception is thrown. This should not prevent us from installing all other
- //extensions.
- }
- catch (CommandAbortedException &) {
- //User clicked the cancel button
- break;
- }
- }
-}
-
-//______________________________________________________________________________
-void DialogImpl::clickRemove( USHORT )
-{
- //Prevent adding of new extension (m_addExtensionQueue) which are caused by
- //calls to "unopkg gui ext", for example, double-clicking and extension.
- ::osl::MutexGuard actionGuard(ActionMutex::get());
-
- const ::std::vector< ::std::pair< Reference<deployment::XPackage>,
- Reference<deployment::XPackageManager> > > selection(
- m_treelb->getSelectedPackages(true) );
- OSL_ASSERT( selection.size() > 0 );
-
- //Check if we want to remove a shared extension and notify user if necessary
- for (TreeListBoxImpl::CI_PAIR_PACKAGE i = selection.begin();
- i != selection.end(); i++)
- {
- if (! continueActionForSharedExtension(i->second, REMOVE_ACTION))
- {
- return;
- }
- else
- {
- //We only show the the messagebox once
- if (i->second->getContext().equals(OUSTR("shared")))
- break;
- }
- }
- ::rtl::Reference<ProgressCommandEnv> currentCmdEnv(
- new ProgressCommandEnv( m_xComponentContext, this, m_strRemovingPackages) );
- currentCmdEnv->showProgress( selection.size() );
- for ( TreeListBoxImpl::CI_PAIR_PACKAGE pos = selection.begin();
- !currentCmdEnv->isAborted() && pos != selection.end(); ++pos )
- {
- Reference<task::XAbortChannel> xAbortChannel(
- pos->second->createAbortChannel() );
- OUString id( dp_misc::getIdentifier( pos->first ) );
- currentCmdEnv->progressSection( id, xAbortChannel );
- try {
- pos->second->removePackage(
- id, pos->first->getName(), xAbortChannel,
- currentCmdEnv.get() );
- }
- catch (CommandAbortedException &) {
- break;
- }
- }
-
- // Check, if there are still updates to be notified via menu bar icon
- css::uno::Sequence< css::uno::Sequence< rtl::OUString > > aItemList;
- UpdateDialog::createNotifyJob( false, aItemList );
-}
-
-//______________________________________________________________________________
-void DialogImpl::clickEnableDisable( USHORT id )
-{
- //Prevent adding of new extension (m_addExtensionQueue) which are caused by
- //calls to "unopkg gui ext", for example, double-clicking and extension.
- ::osl::MutexGuard actionGuard(ActionMutex::get());
-
- const ::std::vector< ::std::pair< Reference<deployment::XPackage>,
- Reference<deployment::XPackageManager> > > selection(
- m_treelb->getSelectedPackages(true) );
- OSL_ASSERT( selection.size() > 0 );
-
- //Check if we want to remove a shared extension and notify user if necessary
- for (TreeListBoxImpl::CI_PAIR_PACKAGE i = selection.begin();
- i != selection.end(); i++)
- {
- if (! continueActionForSharedExtension(i->second,
- id == RID_BTN_ENABLE ? ENABLE_ACTION : DISABLE_ACTION))
- {
- return;
- }
- else
- {
- //We only show the the messagebox once
- if (i->second->getContext().equals(OUSTR("shared")))
- break;
- }
- }
-
- ::rtl::Reference<ProgressCommandEnv> currentCmdEnv(
- new ProgressCommandEnv( m_xComponentContext, this, id == RID_BTN_ENABLE
- ? m_strEnablingPackages
- : m_strDisablingPackages ) );
- currentCmdEnv->showProgress( selection.size() );
- for ( TreeListBoxImpl::CI_PAIR_PACKAGE pos = selection.begin();
- !currentCmdEnv->isAborted() && pos != selection.end(); ++pos )
- {
- Reference<deployment::XPackage> const & xPackage = pos->first;
- Reference<task::XAbortChannel> xAbortChannel(
- xPackage->createAbortChannel() );
- currentCmdEnv->progressSection( xPackage->getDisplayName(),
- xAbortChannel );
- try {
- if (id == RID_BTN_ENABLE)
- xPackage->registerPackage( xAbortChannel,
- currentCmdEnv.get() );
- else
- xPackage->revokePackage( xAbortChannel,
- currentCmdEnv.get() );
- }
- catch (CommandAbortedException &) {
- break;
- }
- }
-}
-
-bool DialogImpl::solarthread_raiseExportPickers(
- Sequence< Reference<deployment::XPackage> > const & selection,
- OUString & rDestFolder, OUString & rNewTitle, sal_Int32 & rNameClashAction )
-{
- rNameClashAction = NameClash::ASK;
-
- if (selection.getLength() > 1)
- {
- // raise folder picker:
- Reference<ui::dialogs::XFolderPicker> xFolderPicker(
- m_xComponentContext->getServiceManager()
- ->createInstanceWithContext(
- OUSTR("com.sun.star.ui.dialogs.FolderPicker"),
- m_xComponentContext ), UNO_QUERY_THROW );
- xFolderPicker->setTitle( m_strExportPackages );
- if (xFolderPicker->execute() !=ui::dialogs::ExecutableDialogResults::OK)
- return false; // cancelled
- rDestFolder = xFolderPicker->getDirectory();
- }
- else // single item selected
- {
- const Any mode( static_cast<sal_Int16>(
- ui::dialogs::TemplateDescription::FILESAVE_AUTOEXTENSION ) );
- const Reference<ui::dialogs::XFilePicker> xFilePicker(
- m_xComponentContext->getServiceManager()
- ->createInstanceWithArgumentsAndContext(
- OUSTR("com.sun.star.ui.dialogs.FilePicker"),
- Sequence<Any>(&mode, 1), m_xComponentContext ),
- UNO_QUERY_THROW );
- xFilePicker->setTitle( m_strExportPackage );
- xFilePicker->setMultiSelectionMode(false);
-
- const Reference<ui::dialogs::XFilePickerControlAccess> xFPControlAccess(
- xFilePicker, UNO_QUERY_THROW );
- xFPControlAccess->setValue(
- ui::dialogs::ExtendedFilePickerElementIds::CHECKBOX_AUTOEXTENSION,
- 0, Any(true));
-
- ::rtl::Reference<ProgressCommandEnv> currentCmdEnv(
- new ProgressCommandEnv( m_xComponentContext, this, m_strExportPackage) );
- OSL_ASSERT( selection.getLength() == 1 );
- Reference<deployment::XPackage> const & xPackage = selection[ 0 ];
-
- // set filter:
- const Reference<deployment::XPackageTypeInfo> xPackageType(
- xPackage->getPackageType() );
- bool isLegacyBundle = false;
- bool isBundle = false;
- OUString bundleext(RTL_CONSTASCII_USTRINGPARAM(".oxt"));
- OUString bundlefilterext(RTL_CONSTASCII_USTRINGPARAM("*.oxt"));
- if (xPackageType.is()) {
- const Reference<ui::dialogs::XFilterManager> xFilterManager(
- xFilePicker, UNO_QUERY_THROW );
- try {
- // All files at top:
- xFilterManager->appendFilter(
- StrAllFiles::get(), OUSTR("*.*") );
-
- // then package filter:
- if (xPackageType->getMediaType().equals(
- OUSTR("application/vnd.sun.star.legacy-package-bundle"))) {
- isLegacyBundle = true;
- xFilterManager->appendFilter(
- xPackageType->getShortDescription(),
- bundlefilterext);
- } else {
- if (xPackageType->getMediaType().equals(
- OUSTR("application/vnd.sun.star.package-bundle")))
- isBundle = true;
-
- xFilterManager->appendFilter(
- xPackageType->getShortDescription(),
- xPackageType->getFileFilter() );
- }
-
- xFilterManager->setCurrentFilter(
- xPackageType->getShortDescription() );
- }
- catch (lang::IllegalArgumentException & exc) {
- OSL_ENSURE( 0, ::rtl::OUStringToOString(
- exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
- (void) exc;
- }
- }
-
- // set default selection:
- ::ucbhelper::Content sourceContent(
- xPackage->getURL(), currentCmdEnv.get() );
- OUString defaultname(sourceContent.getPropertyValue(
- OUSTR("Title") ).get<OUString>());
- OUString legacyext(RTL_CONSTASCII_USTRINGPARAM(".zip"));
- OUString legacyextlong(RTL_CONSTASCII_USTRINGPARAM(".uno.zip"));
- OUString bundleextold(RTL_CONSTASCII_USTRINGPARAM(".uno.pkg"));
- if (isLegacyBundle && defaultname.lastIndexOf(legacyext)>0) {
- if (defaultname.lastIndexOf(legacyextlong)>0) {
- defaultname = defaultname.replaceAt(
- defaultname.lastIndexOf(legacyextlong), 8, bundleext);
- } else {
- defaultname = defaultname.replaceAt(
- defaultname.lastIndexOf(legacyext), 4, bundleext);
- }
- } else if (isBundle && defaultname.lastIndexOf(bundleextold)>0) {
- defaultname = defaultname.replaceAt(
- defaultname.lastIndexOf(bundleextold), 8, bundleext);
- }
- xFilePicker->setDefaultName(defaultname);
-
- if (xFilePicker->execute() != ui::dialogs::ExecutableDialogResults::OK)
- return false; // cancelled
-
- Sequence<OUString> files( xFilePicker->getFiles() );
- OSL_ASSERT( files.getLength() == 1 );
- OUString const & url = files[ 0 ];
- ::ucbhelper::Content childContent( url, currentCmdEnv.get() );
- Reference<container::XChild> xChild( childContent.get(),
- UNO_QUERY_THROW );
- ::ucbhelper::Content destFolderContent(
- Reference<XContent>( xChild->getParent(), UNO_QUERY_THROW ),
- currentCmdEnv.get() );
- rDestFolder = destFolderContent.getURL();
- rNewTitle = rtl::Uri::decode( url.copy( url.lastIndexOf( '/' ) + 1 ),
- rtl_UriDecodeWithCharset,
- RTL_TEXTENCODING_UTF8 );
- // overwrite, because FilePicker has already asked:
- rNameClashAction = NameClash::OVERWRITE;
- }
- return true;
-}
-
-//______________________________________________________________________________
-void DialogImpl::clickExport( USHORT )
-{
- //Prevent adding of new extension (m_addExtensionQueue) which are caused by
- //calls to "unopkg gui ext", for example, double-clicking and extension.
- ::osl::MutexGuard actionGuard(ActionMutex::get());
-
- const ::std::vector< ::std::pair< Reference<deployment::XPackage>,
- Reference<deployment::XPackageManager> > > selection(
- m_treelb->getSelectedPackages(false) );
-
- OSL_ASSERT( selection.size() > 0 );
-
- //create the Sequence<Reference<XPackage> > out of selection for use in
- //syncExecute
- Sequence<Reference<deployment::XPackage> > seqPackages(
- selection.size());
- sal_Int32 j = 0;
- for (TreeListBoxImpl::CI_PAIR_PACKAGE i = selection.begin();
- i != selection.end(); i++, j++)
- {
- seqPackages[j] = i->first;
- }
-
- OUString destFolder;
- OUString newTitle;
- sal_Int32 nameClashAction = NameClash::ASK;
- using namespace vcl::solarthread;
- if (! syncExecute( boost::bind(
- &DialogImpl::solarthread_raiseExportPickers, this,
- seqPackages,
- inout_by_ref(destFolder),
- inout_by_ref(newTitle),
- inout_by_ref(nameClashAction) ) ))
- return;
-
- ::rtl::Reference<ProgressCommandEnv> currentCmdEnv(
- new ProgressCommandEnv( m_xComponentContext, this, m_strExportingPackages ) );
- currentCmdEnv->showProgress( selection.size() );
- for ( TreeListBoxImpl::CI_PAIR_PACKAGE pos = selection.begin();
- !currentCmdEnv->isAborted() && pos != selection.end(); ++pos )
- {
- Reference<deployment::XPackage> const & xPackage = pos->first;
- currentCmdEnv->progressSection( xPackage->getDisplayName() );
- OSL_ASSERT( destFolder.getLength() > 0 );
- xPackage->exportTo( destFolder, newTitle, nameClashAction,
- currentCmdEnv.get() );
- }
-}
-
-//______________________________________________________________________________
-void DialogImpl::clickCheckUpdates( USHORT )
-{
- // see checkUpdates.
- checkUpdates(false);
-}
-
-//______________________________________________________________________________
-void DialogImpl::clickOptions( USHORT )
-{
- //Prevent adding of new extension (m_addExtensionQueue) which are caused by
- //calls to "unopkg gui ext", for example, double-clicking and extension.
- ::osl::MutexGuard actionGuard(ActionMutex::get());
-
- SfxAbstractDialogFactory* pFact = SfxAbstractDialogFactory::Create();
- if ( pFact )
- {
- rtl::OUString sExtensionId;
- Reference<deployment::XPackage> xPackage(
- m_treelb->getPackage( m_treelb->FirstSelected() ) );
- if ( xPackage.is() )
- sExtensionId = xPackage->getIdentifier().Value;
-
- const ::vos::OGuard guard( Application::GetSolarMutex() );
- VclAbstractDialog* pDlg = pFact->CreateOptionsDialog( this, sExtensionId, rtl::OUString() );
- pDlg->Execute();
- delete pDlg;
- }
-}
-
-//______________________________________________________________________________
-void DialogImpl::errbox( OUString const & msg, Window const * parent) const
-{
- const ::vos::OGuard guard( Application::GetSolarMutex() );
- Window const * thisParent = parent ? parent : this;
- const ::std::auto_ptr<ErrorBox> box( new ErrorBox( const_cast<Window*>(thisParent), WB_OK, msg ) );
- box->SetText( GetText() );
- box->Execute();
-}
-
-//______________________________________________________________________________
-void DialogImpl::checkUpdates( bool selected, bool showUpdateOnly, bool parentVisible )
-{
- //Prevent adding of new extension (m_addExtensionQueue) which are caused by
- //calls to "unopkg gui ext", for example, double-clicking and extension.
- ::osl::MutexGuard actionGuard(ActionMutex::get());
- ::vos::OClearableGuard aGuard( Application::GetSolarMutex() );
-
- UpdateDialog* pUpdateDialog;
- std::vector<UpdateData> data;
- Window * pParent = this;
-
- if ( showUpdateOnly && !parentVisible )
- pParent = GetParent();
-
- pUpdateDialog = new UpdateDialog( m_xComponentContext, pParent,
- ( /*selected ? new SelectedPackageIterator(*m_treelb.get())
- : rtl::Reference<SelectedPackageIterator>()),*/
- rtl::Reference<SelectedPackage>()),
- ( selected ? Sequence<Reference<deployment::XPackageManager> >()
- : m_packageManagers ),
- &data );
- if ( ( pUpdateDialog->Execute() == RET_OK ) && !data.empty() )
- {
- pUpdateDialog->notifyMenubar( true, false ); // prepare the checking, if there updates to be notified via menu bar icon
- //If there is at least one directly downloadable dialog then we
- //open the install dialog.
- int countWebsiteDownload = 0;
- typedef std::vector< dp_gui::UpdateData >::const_iterator cit;
- for (cit i = data.begin(); i < data.end(); i++)
- {
- if (i->sWebsiteURL.getLength() > 0)
- countWebsiteDownload ++;
- }
-
- short nDialogResult = RET_OK;
- if (data.size() - countWebsiteDownload > 0)
- {
- ::std::vector<dp_gui::UpdateData> dataDownload(excludeWebsiteDownloads(data));
- nDialogResult = UpdateInstallDialog( pParent, dataDownload, m_xComponentContext ).Execute();
- pUpdateDialog->notifyMenubar( false, true ); // Check, if there are still pending updates to be notified via menu bar icon
- }
- else
- pUpdateDialog->notifyMenubar( false, false ); // Check, if there are pending updates to be notified via menu bar icon
- //Now start the webbrowser and navigate to the websites where we get the updates
- if (RET_OK == nDialogResult)
- {
- for (cit i = data.begin(); i < data.end(); i++)
- {
- if (i->sWebsiteURL.getLength() > 0)
- {
- openWebBrowser(i->sWebsiteURL);
- }
- }
- }
- }
- delete pUpdateDialog;
-}
-
-bool DialogImpl::continueUpdateForSharedExtension(
- Window * pUpdateDialog,
- Reference<css::deployment::XPackageManager> const & xPMgr)
-{
- return continueActionForSharedExtension(xPMgr, UPDATE_ACTION, pUpdateDialog);
-}
-
-
-bool DialogImpl::continueActionForSharedExtension(
- Reference<css::deployment::XPackageManager> const & xPMgr, ACTION action,
- Window * pUpdateDialog)
-{
- /** The following flags are used to indicate that a warning has already been displayed
- for a particular action.
- We show a warning if a user is going to modify a shared extension. This warning
- shall only appear once during a session.
- Because this function is called from the various button handlers only there is
- no risk of concurrent access.
- ToDo!!! We should move these flags to DialogImpl and make it a real one instance
- service. Currently it is destroyed when the window is being closed.
- */
-
- static bool bWarningAddSharedDisplayed = false;
- static bool bWarningRemoveSharedDisplayed = false;
- static bool bWarningEnableSharedDisplayed = false;
- static bool bWarningDisableSharedDisplayed = false;
- static bool bWarningUpdateSharedDisplayed = false;
-
- //If the package manager is readonly then the user cannot modify anything anyway.
- //Then the messagebox need not be displayed. Also the add, remove, disable buttons
- //should not be enabled.
- sal_uInt32 id = 0;
- //The flag is used to determine if the warning for this action was already displayed.
- //We only display the warning once for each action.
- bool bWasAlreadyDisplayed = false;
- switch (action)
- {
- case ADD_ACTION:
- OSL_ASSERT(!pUpdateDialog);
- id = RID_WARNINGBOX_ADD_SHARED_EXTENSION;
- bWasAlreadyDisplayed = bWarningAddSharedDisplayed;
- bWarningAddSharedDisplayed = true;
- break;
- case REMOVE_ACTION:
- OSL_ASSERT(!pUpdateDialog);
- id = RID_WARNINGBOX_REMOVE_SHARED_EXTENSION;
- bWasAlreadyDisplayed = bWarningRemoveSharedDisplayed;
- bWarningRemoveSharedDisplayed = true;
- break;
- case ENABLE_ACTION:
- OSL_ASSERT(!pUpdateDialog);
- id = RID_WARNINGBOX_ENABLE_SHARED_EXTENSION;
- bWasAlreadyDisplayed = bWarningEnableSharedDisplayed;
- bWarningEnableSharedDisplayed = true;
- break;
- case DISABLE_ACTION:
- OSL_ASSERT(!pUpdateDialog);
- id = RID_WARNINGBOX_DISABLE_SHARED_EXTENSION;
- bWasAlreadyDisplayed = bWarningDisableSharedDisplayed;
- bWarningDisableSharedDisplayed = true;
- break;
- case UPDATE_ACTION:
- OSL_ASSERT(pUpdateDialog);
- id = RID_WARNINGBOX_UPDATE_SHARED_EXTENSION;
- bWasAlreadyDisplayed = bWarningUpdateSharedDisplayed;
- bWarningUpdateSharedDisplayed = true;
- break;
-
- default:
- OSL_ASSERT(0);
- }
- if (! bWasAlreadyDisplayed
- &&xPMgr->getContext().equals(OUSTR("shared"))
- && ! xPMgr->isReadOnly())
- {
- vos::OGuard guard(Application::GetSolarMutex());
- WarningBox box(pUpdateDialog ? pUpdateDialog : this,
- ResId(id, *DeploymentGuiResMgr::get()));
- String msgText = box.GetMessText();
- msgText.SearchAndReplaceAllAscii( "%PRODUCTNAME", BrandName::get() );
- if (RET_OK == box.Execute())
- return true;
- else
- return false;
- }
- return true;
-}
-
-//______________________________________________________________________________
-void DialogImpl::SyncPushButton::Click()
-{
- try {
- (m_dialog->*m_clickCallback)( m_id );
- }
- catch (CommandFailedException &) {
- // already handled by interaction handler
- }
- catch (Exception &) {
- Any exc( ::cppu::getCaughtException() );
- OUString msg;
- deployment::DeploymentException dpExc;
- if ((exc >>= dpExc) &&
- dpExc.Cause.getValueTypeClass() == TypeClass_EXCEPTION) {
- // notify error cause only:
- msg = reinterpret_cast<Exception const *>(
- dpExc.Cause.getValue() )->Message;
- }
- if (msg.getLength() == 0) // fallback for debugging purposes
- msg = ::comphelper::anyToString(exc);
- m_dialog->errbox( msg );
- }
-}
-
-
-//------------------------------------------------------------------------------
-namespace {
-extern "C" {
-void SAL_CALL ThreadedPushButton_callback( void * p )
-{
- DialogImpl::ThreadedPushButton * that =
- static_cast<DialogImpl::ThreadedPushButton *>(p);
- that->DialogImpl::SyncPushButton::Click();
-}
-}
-}
-
-
-//______________________________________________________________________________
-void DialogImpl::ThreadedPushButton::Click()
-{
- if (m_thread != 0) {
- const ULONG nLockCount = Application::ReleaseSolarMutex();
- //todo deadlock. When the add button is clicked then the file picker is started which
- //runs in the main thread. When I click again on Add, then this function is called again
- //and also from the main thread. That is I join the main thread on itself here. However
- //I could only achieve this on Windows when I debugged the app. Since the file picker is a modal dialog
- //one cannot click again on Add as long as the file picker is open.
- osl_joinWithThread( m_thread );
- if (nLockCount > 0)
- Application::AcquireSolarMutex( nLockCount );
- osl_destroyThread( m_thread );
- }
- m_thread = osl_createSuspendedThread( ThreadedPushButton_callback, this );
- OSL_ASSERT( m_thread != 0 );
- osl_resumeThread( m_thread );
-}
-
-//______________________________________________________________________________
-DialogImpl::ThreadedPushButton::~ThreadedPushButton()
-{
- if (m_thread != 0) {
- const ULONG nLockCount = Application::ReleaseSolarMutex();
- osl_joinWithThread( m_thread );
- if (nLockCount > 0)
- Application::AcquireSolarMutex( nLockCount );
- osl_destroyThread( m_thread );
- }
-}
-
-//==============================================================================
-ResId DialogImpl::getResId( USHORT id )
-{
- const ::vos::OGuard guard( Application::GetSolarMutex() );
- return ResId( id, *DeploymentGuiResMgr::get() );
-}
-
-//==============================================================================
-String DialogImpl::getResourceString( USHORT id )
-{
- // init with non-acquired solar mutex:
- BrandName::get();
- const ::vos::OGuard guard( Application::GetSolarMutex() );
- String ret( ResId( id, *DeploymentGuiResMgr::get() ) );
- if (ret.SearchAscii( "%PRODUCTNAME" ) != STRING_NOTFOUND) {
- ret.SearchAndReplaceAllAscii( "%PRODUCTNAME", BrandName::get() );
- }
- return ret;
-}
-
-#if 0
-SelectedPackageIterator::SelectedPackageIterator(
- DialogImpl::TreeListBoxImpl & list):
- m_list(list),
- m_entry(NULL)
-{}
-
-SelectedPackageIterator::~SelectedPackageIterator() {}
-
-void SelectedPackageIterator::next(
- Reference<deployment::XPackage> * package,
- Reference<deployment::XPackageManager> * packageManager)
-{
- OSL_ASSERT(package != NULL && packageManager != NULL);
- for (;;) {
- m_entry = m_entry == NULL
- ? m_list.FirstSelected() : m_list.NextSelected(m_entry);
- if (m_entry == NULL) {
- package->clear();
- packageManager->clear();
- break;
- }
- if (m_list.isFirstLevelChild(m_entry)) {
- *package = m_list.getPackage(m_entry);
- *packageManager = m_list.getPackageManager(m_entry);
- break;
- }
- }
-}
-#endif
-}
diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx
index a3aef0156edb..13e3f66a8347 100644
--- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx
+++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx
@@ -8,7 +8,7 @@
*
* $RCSfile: dp_gui_dialog2.cxx,v $
*
- * $Revision: 1.9 $
+ * $Revision: 1.8.4.8 $
*
* This file is part of OpenOffice.org.
*
@@ -184,7 +184,7 @@ Entry_Impl::Entry_Impl( const uno::Reference< deployment::XPackage > &xPackage,
m_bLocked = m_xPackageManager->isReadOnly();
- if ( ( eState != REGISTERED ) && ( eState != NOT_REGISTERED ) )
+ if ( eState == AMBIGUOUS )
m_sErrorText = ExtMgrDialog::getResourceString( RID_STR_ERROR_UNKNOWN_STATUS );
}
@@ -704,11 +704,14 @@ void ExtensionBox_Impl::selectEntry( long nPos )
}
SetButtonStatus( m_vEntries[ nPos ] ); //dv
}
+ else
+ {
+ m_pOptionsBtn->Hide();
+ m_pEnableBtn->Hide();
+ m_pRemoveBtn->Hide();
+ }
guard.clear();
- m_pOptionsBtn->Show( m_bHasActive );
- m_pEnableBtn->Show( m_bHasActive );
- m_pRemoveBtn->Show( m_bHasActive );
}
// -----------------------------------------------------------------------
@@ -728,7 +731,7 @@ void ExtensionBox_Impl::SetButtonPos( const Rectangle& rRect )
// -----------------------------------------------------------------------
void ExtensionBox_Impl::SetButtonStatus( const TEntry_Impl pEntry )
{
- if ( pEntry->m_eState == REGISTERED )
+ if ( ( pEntry->m_eState == REGISTERED ) || ( pEntry->m_eState == NOT_AVAILABLE ) )
{
m_pEnableBtn->SetText( ExtMgrDialog::getResourceString( RID_CTX_ITEM_DISABLE ) );
m_pEnableBtn->SetHelpId( HID_EXTENSION_MANAGER_LISTBOX_DISABLE );
@@ -739,8 +742,23 @@ void ExtensionBox_Impl::SetButtonStatus( const TEntry_Impl pEntry )
m_pEnableBtn->SetHelpId( HID_EXTENSION_MANAGER_LISTBOX_ENABLE );
}
- m_pOptionsBtn->Enable( pEntry->m_bHasOptions );
- m_pEnableBtn->Enable( !pEntry->m_bLocked );
+ if ( pEntry->m_eState == NOT_AVAILABLE )
+ m_pEnableBtn->Hide();
+ else
+ {
+ m_pEnableBtn->Enable( !pEntry->m_bLocked );
+ m_pEnableBtn->Show();
+ }
+
+ if ( pEntry->m_bHasOptions )
+ {
+ m_pOptionsBtn->Enable( pEntry->m_bHasOptions );
+ m_pOptionsBtn->Show();
+ }
+ else
+ m_pOptionsBtn->Hide();
+
+ m_pRemoveBtn->Show();
m_pRemoveBtn->Enable( !pEntry->m_bLocked );
}
@@ -749,10 +767,10 @@ void ExtensionBox_Impl::DrawRow( const Rectangle& rRect, const TEntry_Impl pEntr
{
const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
- if ( pEntry->m_eState != REGISTERED )
- SetTextColor( rStyleSettings.GetDisableColor() );
- else if ( pEntry->m_bActive )
+ if ( pEntry->m_bActive )
SetTextColor( rStyleSettings.GetHighlightTextColor() );
+ else if ( ( pEntry->m_eState != REGISTERED ) && ( pEntry->m_eState != NOT_AVAILABLE ) )
+ SetTextColor( rStyleSettings.GetDisableColor() );
else if ( IsControlForeground() )
SetTextColor( GetControlForeground() );
else
@@ -762,7 +780,6 @@ void ExtensionBox_Impl::DrawRow( const Rectangle& rRect, const TEntry_Impl pEntr
{
SetLineColor();
SetFillColor( rStyleSettings.GetHighlightColor() );
- // SetTextFillColor( rStyleSettings.GetHighlightColor() );
DrawRect( rRect );
}
else
@@ -883,7 +900,7 @@ void ExtensionBox_Impl::DrawRow( const Rectangle& rRect, const TEntry_Impl pEntr
aPos = rRect.TopRight() + Point( -(RIGHT_ICON_OFFSET + SMALL_ICON_SIZE), TOP_OFFSET );
DrawImage( aPos, Size( SMALL_ICON_SIZE, SMALL_ICON_SIZE ), isHCMode() ? m_aLockedImageHC : m_aLockedImage );
}
- if ( ( pEntry->m_eState != REGISTERED ) && ( pEntry->m_eState != NOT_REGISTERED ) )
+ if ( pEntry->m_eState == AMBIGUOUS )
{
aPos = rRect.TopRight() + Point( -(RIGHT_ICON_OFFSET + SPACE_BETWEEN + 2*SMALL_ICON_SIZE), TOP_OFFSET );
DrawImage( aPos, Size( SMALL_ICON_SIZE, SMALL_ICON_SIZE ), isHCMode() ? m_aWarningImageHC : m_aWarningImage );
@@ -1011,7 +1028,7 @@ MENU_COMMAND ExtensionBox_Impl::ShowPopupMenu( const Point & rPos, const long nP
{
if ( m_vEntries[ nPos ]->m_eState == REGISTERED )
aPopup.InsertItem( CMD_DISABLE, ExtMgrDialog::getResourceString( RID_CTX_ITEM_DISABLE ) );
- else
+ else if ( m_vEntries[ nPos ]->m_eState != NOT_AVAILABLE )
aPopup.InsertItem( CMD_ENABLE, ExtMgrDialog::getResourceString( RID_CTX_ITEM_ENABLE ) );
aPopup.InsertItem( CMD_REMOVE, ExtMgrDialog::getResourceString( RID_CTX_ITEM_REMOVE ) );
@@ -1327,7 +1344,7 @@ void ExtensionBox_Impl::updateEntry( const uno::Reference< deployment::XPackage
(*iIndex)->m_sVersion = xPackage->getVersion();
(*iIndex)->m_sDescription = xPackage->getDescription();
- if ( ( eState != REGISTERED ) && ( eState != NOT_REGISTERED ) )
+ if ( eState == AMBIGUOUS )
(*iIndex)->m_sErrorText = ExtMgrDialog::getResourceString( RID_STR_ERROR_UNKNOWN_STATUS );
else
(*iIndex)->m_sErrorText = String();
@@ -1382,7 +1399,7 @@ void ExtensionBox_Impl::checkEntries()
else
{
//We reach this point when we updated an extension.
- m_vEntries.erase( iIndex );
+ iIndex = m_vEntries.erase( iIndex );
bNext = false;
if ( m_bHasActive )
@@ -1573,7 +1590,7 @@ ExtMgrDialog::ExtMgrDialog( Window *pParent, TheExtensionManager *pManager ) :
m_bEnableWarning( false ),
m_bDisableWarning( false ),
m_bDeleteWarning( false ),
- m_bHasSharedExtensions( false ),
+ m_bIsBusy( false ),
m_nProgress( 0 ),
m_pManager( pManager )
{
@@ -1838,9 +1855,14 @@ uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker( const uno::Reference< de
uno::Sequence< uno::Any >( &mode, 1 ), xContext ), uno::UNO_QUERY_THROW );
xFilePicker->setTitle( m_sAddPackages );
+ if ( m_sLastFolderURL.Len() )
+ xFilePicker->setDisplayDirectory( m_sLastFolderURL );
+
// collect and set filter list:
typedef ::std::map< OUString, OUString > t_string2string;
t_string2string title2filter;
+ OUString sDefaultFilter( StrAllFiles::get() );
+
const uno::Sequence< uno::Reference< deployment::XPackageTypeInfo > > packageTypes( xPackageManager->getSupportedPackageTypes() );
for ( sal_Int32 pos = 0; pos < packageTypes.getLength(); ++pos )
@@ -1860,6 +1882,8 @@ uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker( const uno::Reference< de
buf.append( filter );
insertion.first->second = buf.makeStringAndClear();
}
+ if ( xPackageType->getMediaType() == OUSTR( "application/vnd.sun.star.package-bundle" ) )
+ sDefaultFilter = title;
}
}
@@ -1879,11 +1903,12 @@ uno::Sequence< OUString > ExtMgrDialog::raiseAddPicker( const uno::Reference< de
(void) exc;
}
}
- xFilterManager->setCurrentFilter( StrAllFiles::get() );
+ xFilterManager->setCurrentFilter( sDefaultFilter );
if ( xFilePicker->execute() != ui::dialogs::ExecutableDialogResults::OK )
return uno::Sequence<OUString>(); // cancelled
+ m_sLastFolderURL = xFilePicker->getDisplayDirectory();
uno::Sequence< OUString > files( xFilePicker->getFiles() );
OSL_ASSERT( files.getLength() > 0 );
return files;
@@ -1908,9 +1933,10 @@ IMPL_LINK( ExtMgrDialog, HandleCancelBtn, void*, EMPTYARG )
}
// ------------------------------------------------------------------------------
-IMPL_LINK( ExtMgrDialog, startProgress, ::osl::Condition *, pCond )
+IMPL_LINK( ExtMgrDialog, startProgress, void*, _bLockInterface )
{
- bool bLockInterface = true;
+ ::osl::MutexGuard aGuard( m_aMutex );
+ bool bLockInterface = (bool) _bLockInterface;
if ( m_bStartProgress && !m_bHasProgress )
m_aTimeoutTimer.Start();
@@ -1920,7 +1946,12 @@ IMPL_LINK( ExtMgrDialog, startProgress, ::osl::Condition *, pCond )
if ( m_aProgressBar.IsVisible() )
m_aProgressBar.SetValue( 100 );
m_xAbortChannel.clear();
- bLockInterface = false;
+// bLockInterface = false;
+ OSL_TRACE( " startProgress handler: stop\n" );
+ }
+ else
+ {
+ OSL_TRACE( " startProgress handler: start\n" );
}
m_aCancelBtn.Enable( bLockInterface );
@@ -1928,27 +1959,34 @@ IMPL_LINK( ExtMgrDialog, startProgress, ::osl::Condition *, pCond )
m_aUpdateBtn.Enable( !bLockInterface && m_pExtensionBox->getItemCount() );
m_pExtensionBox->enableButtons( !bLockInterface );
- pCond->set();
+// pCond->set();
return 0;
}
// ------------------------------------------------------------------------------
-void ExtMgrDialog::showProgress( bool bStart )
+void ExtMgrDialog::showProgress( bool _bStart )
{
+ ::osl::MutexGuard aGuard( m_aMutex );
+
+ bool bStart = _bStart;
+
if ( bStart )
{
m_nProgress = 0;
m_bStartProgress = true;
+ OSL_TRACE( "showProgress start\n" );
}
else
{
m_nProgress = 100;
m_bStopProgress = true;
+ OSL_TRACE( "showProgress stop!\n" );
}
- ::osl::Condition cond;
- Application::PostUserEvent( LINK( this, ExtMgrDialog, startProgress ), &cond );
- cond.wait();
+ Application::PostUserEvent( LINK( this, ExtMgrDialog, startProgress ), (void*) bStart );
+// ::osl::Condition cond;
+// Application::PostUserEvent( LINK( this, ExtMgrDialog, startProgress ), &cond );
+// cond.wait();
}
// -----------------------------------------------------------------------
@@ -1986,14 +2024,17 @@ void ExtMgrDialog::removeEntry( const uno::Reference< deployment::XPackage > &xP
// -----------------------------------------------------------------------
IMPL_LINK( ExtMgrDialog, HandleAddBtn, void*, EMPTYARG )
{
- uno::Reference< deployment::XPackageManager > xUserPkgMgr = m_pManager->getUserPkgMgr();
+ m_bIsBusy = true;
+ uno::Reference< deployment::XPackageManager > xUserPkgMgr = m_pManager->getUserPkgMgr();
uno::Sequence< OUString > aFileList = raiseAddPicker( xUserPkgMgr );
if ( aFileList.getLength() )
{
m_pManager->installPackage( aFileList[0] );
}
+
+ m_bIsBusy = false;
return 1;
}
@@ -2073,8 +2114,8 @@ void ExtMgrDialog::Resize()
aPos.X() -= ( RSC_SP_CTRL_GROUP_Y + aBtnSize.Width() );
m_aAddBtn.SetPosPixel( aPos );
- Size aDivSize( aTotalSize.Width() - RSC_SP_DLG_INNERBORDER_LEFT - RSC_SP_DLG_INNERBORDER_RIGHT, LINE_SIZE );
- aPos = Point( RSC_SP_DLG_INNERBORDER_LEFT, aPos.Y() - LINE_SIZE - RSC_SP_DLG_INNERBORDER_BOTTOM );
+ Size aDivSize( aTotalSize.Width(), LINE_SIZE );
+ aPos = Point( 0, aPos.Y() - LINE_SIZE - RSC_SP_DLG_INNERBORDER_BOTTOM );
m_aDivider.SetPosSizePixel( aPos, aDivSize );
Size aFTSize( m_aGetExtensions.CalcMinimumSize() );
diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.hxx b/desktop/source/deployment/gui/dp_gui_dialog2.hxx
index c43916301329..2deaad268ec3 100644
--- a/desktop/source/deployment/gui/dp_gui_dialog2.hxx
+++ b/desktop/source/deployment/gui/dp_gui_dialog2.hxx
@@ -8,7 +8,7 @@
*
* $RCSfile: dp_gui_dialog2.hxx,v $
*
- * $Revision: 1.4 $
+ * $Revision: 1.4.74.3 $
*
* This file is part of OpenOffice.org.
*
@@ -71,6 +71,7 @@ class ExtMgrDialog : public ModelessDialog
CancelButton m_aCancelBtn;
const String m_sAddPackages;
String m_sProgressText;
+ String m_sLastFolderURL;
::osl::Mutex m_aMutex;
bool m_bHasProgress;
bool m_bProgressChanged;
@@ -80,7 +81,7 @@ class ExtMgrDialog : public ModelessDialog
bool m_bEnableWarning;
bool m_bDisableWarning;
bool m_bDeleteWarning;
- bool m_bHasSharedExtensions;
+ bool m_bIsBusy;
long m_nProgress;
Timer m_aTimeoutTimer;
TheExtensionManager *m_pManager;
@@ -96,7 +97,7 @@ class ExtMgrDialog : public ModelessDialog
DECL_DLLPRIVATE_LINK( HandleCancelBtn, void * );
DECL_DLLPRIVATE_LINK( HandleHyperlink, svt::FixedHyperlink * );
DECL_DLLPRIVATE_LINK( TimeOutHdl, Timer* );
- DECL_DLLPRIVATE_LINK( startProgress, ::osl::Condition * );
+ DECL_DLLPRIVATE_LINK( startProgress, void * );
public:
ExtMgrDialog( Window * pParent, TheExtensionManager *pManager );
@@ -118,6 +119,8 @@ public:
bool updatePackage( const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackageManager > &xPackageManager,
const ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XPackage > &xPackage );
+ bool isBusy() { return m_bIsBusy; }
+
void showProgress( bool bStart );
void updateProgress( const ::rtl::OUString &rText,
const ::com::sun::star::uno::Reference< ::com::sun::star::task::XAbortChannel > &xAbortChannel);
diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.src b/desktop/source/deployment/gui/dp_gui_dialog2.src
index 172e872b1334..e82e8c762a9e 100644
--- a/desktop/source/deployment/gui/dp_gui_dialog2.src
+++ b/desktop/source/deployment/gui/dp_gui_dialog2.src
@@ -8,7 +8,7 @@
*
* $RCSfile: dp_gui_dialog2.src,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.2.86.1 $
*
* This file is part of OpenOffice.org.
*
@@ -63,7 +63,7 @@ ModelessDialog RID_DLG_EXTENSION_MANAGER
{
NoLabel = TRUE;
TabStop = TRUE;
- Text [ en-US ] = "Get more extensions here...";
+ Text [ en-US ] = "Get more extensions online...";
Size = MAP_APPFONT(RSC_CD_PUSHBUTTON_WIDTH, RSC_CD_FIXEDTEXT_HEIGHT );
};
diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx
index 67719dc75805..6e8e214a6d12 100644
--- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx
+++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.cxx
@@ -8,7 +8,7 @@
*
* $RCSfile: dp_gui_extensioncmdqueue.cxx,v $
*
- * $Revision: 1.7 $
+ * $Revision: 1.7.4.3 $
*
* This file is part of OpenOffice.org.
*
@@ -98,20 +98,6 @@
#include <queue>
#include <boost/shared_ptr.hpp>
-#if 0
-#include "dp_gui.hrc"
-#include "dp_gui.h"
-#include "dp_gui_cmdenv.h"
-#include "comphelper/anytostring.hxx"
-#include "com/sun/star/lang/WrappedTargetException.hpp"
-#include "tools/resid.hxx"
-#include "tools/rcid.h"
-#include "vcl/msgbox.hxx"
-#include "vcl/threadex.hxx"
-#include "boost/bind.hpp"
-
-#endif
-
#if (defined(_MSC_VER) && (_MSC_VER < 1400))
#define _WIN32_WINNT 0x0400
#endif
@@ -140,9 +126,6 @@ OUString getVersion( const uno::Reference< deployment::XPackage > &rPackage )
namespace dp_gui {
//==============================================================================
-//Only if the class is consructed with the DialogImpl then the ProgressDialog can be
-//displayed. Otherwise this class can still be used to forward an interaction. This
-//is done by the interaction handler of the "Download and Installation" dialog.
class ProgressCmdEnv
: public ::cppu::WeakImplHelper3< ucb::XCommandEnvironment,
@@ -185,6 +168,7 @@ public:
Dialog * activeDialog() { return m_pDialog; }
+ void setTitle( const OUString& rNewTitle ) { m_sTitle = rNewTitle; }
void startProgress();
void stopProgress();
void progressSection( const OUString &rText,
@@ -312,6 +296,7 @@ private:
const OUString m_sDisablingPackages;
const OUString m_sAddingPackages;
const OUString m_sRemovingPackages;
+ const OUString m_sDefaultCmd;
osl::Condition m_wakeup;
osl::Mutex m_mutex;
Input m_eInput;
@@ -659,6 +644,7 @@ ExtensionCmdQueue::Thread::Thread( ExtMgrDialog *pDialog,
m_sDisablingPackages( ExtMgrDialog::getResourceString( RID_STR_DISABLING_PACKAGES ) ),
m_sAddingPackages( ExtMgrDialog::getResourceString( RID_STR_ADDING_PACKAGES ) ),
m_sRemovingPackages( ExtMgrDialog::getResourceString( RID_STR_REMOVING_PACKAGES ) ),
+ m_sDefaultCmd( ExtMgrDialog::getResourceString( RID_STR_ADD_PACKAGES ) ),
m_eInput( NONE ),
m_bTerminated( false ),
m_bStopped( false ),
@@ -830,7 +816,7 @@ void ExtensionCmdQueue::Thread::execute()
if ( eInput == STOP )
break;
- ::rtl::Reference< ProgressCmdEnv > currentCmdEnv( new ProgressCmdEnv( m_xContext, m_pDialog, m_sAddingPackages ) );
+ ::rtl::Reference< ProgressCmdEnv > currentCmdEnv( new ProgressCmdEnv( m_xContext, m_pDialog, m_sDefaultCmd ) );
// Do not lock the following part with addExtension. addExtension may be called in the main thread.
// If the message box "Do you want to install the extension (or similar)" is shown and then
@@ -935,6 +921,12 @@ void ExtensionCmdQueue::Thread::execute()
}
}
+ {
+ // when leaving the while loop with break, we should set working to false, too
+ osl::MutexGuard aGuard( m_mutex );
+ m_bWorking = false;
+ }
+
if ( !bStartProgress )
currentCmdEnv->stopProgress();
}
@@ -955,7 +947,16 @@ void ExtensionCmdQueue::Thread::_addExtension( ::rtl::Reference< ProgressCmdEnv
{
//check if we have a string in anyTitle. For example "unopkg gui \" caused anyTitle to be void
//and anyTitle.get<OUString> throws as RuntimeException.
- uno::Any anyTitle = ::ucbhelper::Content( rPackageURL, rCmdEnv.get() ).getPropertyValue( OUSTR("Title") );
+ uno::Any anyTitle;
+ try
+ {
+ anyTitle = ::ucbhelper::Content( rPackageURL, rCmdEnv.get() ).getPropertyValue( OUSTR("Title") );
+ }
+ catch ( uno::Exception & )
+ {
+ return;
+ }
+
OUString sName;
if ( ! (anyTitle >>= sName) )
{
@@ -974,8 +975,6 @@ void ExtensionCmdQueue::Thread::_addExtension( ::rtl::Reference< ProgressCmdEnv
rPackageURL, OUString() /* detect media-type */,
xAbortChannel, rCmdEnv.get() ) );
OSL_ASSERT( xPackage.is() );
-// long nPos = m_pDialog->addPackageToList( xPackage, xPackageManager );
-// m_pDialog->selectEntry( nPos );
}
catch ( ucb::CommandFailedException & )
{
@@ -1206,5 +1205,12 @@ bool ExtensionCmdQueue::isBusy()
return m_thread->isBusy();
}
+void handleInteractionRequest( const uno::Reference< uno::XComponentContext > & xContext,
+ const uno::Reference< task::XInteractionRequest > & xRequest )
+{
+ ::rtl::Reference< ProgressCmdEnv > xCmdEnv( new ProgressCmdEnv( xContext, NULL, OUSTR("Extension Manager") ) );
+ xCmdEnv->handle( xRequest );
+}
+
} //namespace dp_gui
diff --git a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx
index f1ad41097c1c..06ecefd7749b 100644
--- a/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx
+++ b/desktop/source/deployment/gui/dp_gui_extensioncmdqueue.hxx
@@ -8,7 +8,7 @@
*
* $RCSfile: dp_gui_extensioncmdqueue.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.3.14.1 $
*
* This file is part of OpenOffice.org.
*
@@ -50,6 +50,7 @@
namespace com { namespace sun { namespace star {
namespace deployment { class XPackageManager; }
+ namespace task { class XInteractionRequest; }
namespace uno { class XComponentContext; }
} } }
@@ -120,6 +121,9 @@ private:
rtl::Reference< Thread > m_thread;
};
+void handleInteractionRequest( const ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > & xContext,
+ const ::com::sun::star::uno::Reference< ::com::sun::star::task::XInteractionRequest > & xRequest );
+
}
#endif
diff --git a/desktop/source/deployment/gui/dp_gui_service.cxx b/desktop/source/deployment/gui/dp_gui_service.cxx
index f90a8e2d9fb4..6e61e95f07cb 100644
--- a/desktop/source/deployment/gui/dp_gui_service.cxx
+++ b/desktop/source/deployment/gui/dp_gui_service.cxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: dp_gui_service.cxx,v $
- * $Revision: 1.23 $
+ * $Revision: 1.23.86.1 $
*
* This file is part of OpenOffice.org.
*
@@ -197,13 +197,14 @@ ServiceImpl::ServiceImpl( Sequence<Any> const& args,
void ServiceImpl::setDialogTitle( OUString const & title )
throw (RuntimeException)
{
- if (::dp_gui::DialogImpl::s_dialog.is()) {
+ if ( dp_gui::TheExtensionManager::s_ExtMgr.is() )
+ {
const ::vos::OGuard guard( Application::GetSolarMutex() );
- ::dp_gui::DialogImpl::get(
- m_xComponentContext,
- m_parent ? *m_parent : Reference<awt::XWindow>(),
- m_extensionURL ? *m_extensionURL : OUString(),
- m_view ? *m_view : OUString() )->SetText( title );
+ ::rtl::Reference< ::dp_gui::TheExtensionManager > dialog(
+ ::dp_gui::TheExtensionManager::get( m_xComponentContext,
+ m_parent ? *m_parent : Reference<awt::XWindow>(),
+ m_extensionURL ? *m_extensionURL : OUString() ) );
+ dialog->SetText( title );
}
else
m_initialTitle = title;
diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx
index df29c63a3c57..721d67c8f35b 100644
--- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx
+++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx
@@ -8,7 +8,7 @@
*
* $RCSfile: dp_gui_theextmgr.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.3.14.2 $
*
* This file is part of OpenOffice.org.
*
@@ -281,7 +281,6 @@ void TheExtensionManager::createPackageList()
if ( ! createPackageList( m_sPackageManagers[i] ) )
break;
}
- m_pDialog->selectEntry( 0 );
}
//------------------------------------------------------------------------------
@@ -394,13 +393,15 @@ void TheExtensionManager::disposing( lang::EventObject const & rEvt )
void TheExtensionManager::queryTermination( ::lang::EventObject const & )
throw ( frame::TerminationVetoException, uno::RuntimeException )
{
- if ( m_pExecuteCmdQueue->isBusy() )
+ if ( m_pExecuteCmdQueue->isBusy() || ( m_pDialog && m_pDialog->isBusy() ) )
{
ToTop( TOTOP_RESTOREWHENMIN );
throw frame::TerminationVetoException(
OUSTR("The office cannot be closed while the Extension Manager is running"),
uno::Reference<XInterface>(static_cast<frame::XTerminateListener*>(this), uno::UNO_QUERY));
}
+ else if ( m_pDialog )
+ m_pDialog->Close();
}
//------------------------------------------------------------------------------
diff --git a/desktop/source/deployment/gui/dp_gui_treelb.cxx b/desktop/source/deployment/gui/dp_gui_treelb.cxx
deleted file mode 100644
index d52913596fb0..000000000000
--- a/desktop/source/deployment/gui/dp_gui_treelb.cxx
+++ /dev/null
@@ -1,1215 +0,0 @@
-/*************************************************************************
- *
- * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
- *
- * Copyright 2008 by Sun Microsystems, Inc.
- *
- * OpenOffice.org - a multi-platform office productivity suite
- *
- * $RCSfile: dp_gui_treelb.cxx,v $
- * $Revision: 1.29 $
- *
- * This file is part of OpenOffice.org.
- *
- * OpenOffice.org is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License version 3
- * only, as published by the Free Software Foundation.
- *
- * OpenOffice.org is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Lesser General Public License version 3 for more details
- * (a copy is included in the LICENSE file that accompanied this code).
- *
- * You should have received a copy of the GNU Lesser General Public License
- * version 3 along with OpenOffice.org. If not, see
- * <http://www.openoffice.org/license.html>
- * for a copy of the LGPLv3 License.
- *
- ************************************************************************/
-
-// MARKER(update_precomp.py): autogen include statement, do not remove
-#include "precompiled_desktop.hxx"
-
-#include "dp_misc.h"
-#include "dp_gui.h"
-#include "dp_gui_shared.hxx"
-#include "dp_ucb.h"
-#include "cppuhelper/exc_hlp.hxx"
-#include "comphelper/anytostring.hxx"
-#include "ucbhelper/content.hxx"
-#include "vos/mutex.hxx"
-#include "vcl/help.hxx"
-#include "vcl/waitobj.hxx"
-#include "tools/urlobj.hxx"
-#include "svtools/imagemgr.hxx"
-#include "com/sun/star/lang/WrappedTargetRuntimeException.hpp"
-#include "com/sun/star/beans/PropertyValue.hpp"
-#include "com/sun/star/container/XNameAccess.hpp"
-#include "com/sun/star/deployment/UpdateInformationProvider.hpp"
-#include "com/sun/star/deployment/XPackageManagerFactory.hpp"
-#include "com/sun/star/uno/XComponentContext.hpp"
-#include "com/sun/star/ucb/ContentAction.hpp"
-#include "com/sun/star/frame/XModuleManager.hpp"
-#include "com/sun/star/frame/XDesktop.hpp"
-#include <hash_set>
-
-
-using namespace ::dp_misc;
-using namespace ::com::sun::star;
-using namespace ::com::sun::star::uno;
-using namespace ::com::sun::star::ucb;
-using ::rtl::OUString;
-
-
-namespace dp_gui
-{
-
-//------------------------------------------------------------------------------
-PackageState getPackageState(
- Reference<deployment::XPackage> const & xPackage,
- Reference<XCommandEnvironment> const & xCmdEnv )
-{
- try {
- beans::Optional< beans::Ambiguous<sal_Bool> > option(
- xPackage->isRegistered( Reference<task::XAbortChannel>(),
- xCmdEnv ) );
- if (option.IsPresent)
- {
- beans::Ambiguous<sal_Bool> const & reg = option.Value;
- if (reg.IsAmbiguous)
- return AMBIGUOUS;
- else
- return reg.Value ? REGISTERED : NOT_REGISTERED;
- }
- else
- return NOT_AVAILABLE;
- }
- catch (RuntimeException &) {
- throw;
- }
- catch (Exception & exc) {
- (void) exc;
- OSL_ENSURE( 0, ::rtl::OUStringToOString(
- exc.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
- return NOT_AVAILABLE;
- }
-}
-
-
-//==============================================================================
-struct NodeImpl : public ::cppu::WeakImplHelper1<util::XModifyListener>
-{
- //Keeps the parameters of the XModifyListener::modified call so they can be
- //used later in the event handler asyncModified. It also keeps the NodeImpl
- //instance alive so that the posted events (to ourself) can always be processed
- struct ModifiedParams
- {
- ModifiedParams(Reference<XInterface> const & _xNodeImpl,
- Reference<XCommandEnvironment> const & _xCmdEnv, PackageState _state,
- Sequence< Reference<deployment::XPackage> > const & _packages);
- //This reference keeps the NodeImpl alive until the event has been processed
- Reference<XInterface> xNodeImpl;
- //The argument supplied to XModifyListener::modified
- Reference<XCommandEnvironment> xCmdEnv;
- //The status: registered, unregistered etc.
- PackageState state;
- //deployed packages
- const Sequence< Reference<deployment::XPackage> > deployedPackages;
- };
-
- DialogImpl::TreeListBoxImpl * m_treelb;
- SvLBoxEntry * m_lbEntry;
- DialogImpl::TreeListBoxImpl::t_nodeList::iterator m_it;
-
- const OUString m_factoryURL;
- Reference<deployment::XPackageManager> m_xPackageManager;
- Reference<deployment::XPackage> m_xPackage;
- Reference<css::uno::XComponentContext> m_xComponentContext;
- bool m_bDisposing;
-
- virtual ~NodeImpl();
-
- inline NodeImpl( Reference<css::uno::XComponentContext> xComponentContext,
- DialogImpl::TreeListBoxImpl * treelb,
- OUString const & factoryURL,
- Reference<deployment::XPackageManager> const &
- xPackageManager,
- Reference<deployment::XPackage> const & xPackage )
- : m_treelb( treelb ),
- m_lbEntry( 0 ),
- m_it( treelb->m_nodes.end() ),
- m_factoryURL( factoryURL ),
- m_xPackageManager( xPackageManager ),
- m_xPackage( xPackage ),
- m_xComponentContext(xComponentContext),
- m_bDisposing(false)
- {}
-
- //Perfom asynchronous Modified call in main thread
- DECL_LINK(asyncModified, ModifiedParams*);
-
- Image getIcon() const;
-
- static inline NodeImpl * get( SvLBoxEntry * entry );
-
- void modified( Reference<XCommandEnvironment> const & xCmdEnv );
-
- // XEventListener
- virtual void SAL_CALL disposing( lang::EventObject const & evt )
- throw (RuntimeException);
- // XModifyListener
- virtual void SAL_CALL modified( lang::EventObject const & )
- throw (RuntimeException);
-
-};
-
-NodeImpl::ModifiedParams::ModifiedParams(
- Reference<XInterface> const & _xNodeImpl,
- Reference<XCommandEnvironment> const & _xCmdEnv, PackageState _state,
- Sequence< Reference<deployment::XPackage> > const & _deployedPackages):
- xNodeImpl(_xNodeImpl),
- xCmdEnv(_xCmdEnv),
- state(_state),
- deployedPackages(_deployedPackages)
-{
-}
-//______________________________________________________________________________
-inline NodeImpl * NodeImpl::get( SvLBoxEntry * entry )
-{
- OSL_ASSERT( entry != 0 );
- if (entry != 0) {
- NodeImpl * node = static_cast<NodeImpl *>(entry->GetUserData());
- OSL_ASSERT( node != 0 );
- return node;
- }
- return 0;
-}
-
-//______________________________________________________________________________
-NodeImpl::~NodeImpl()
-{
-}
-
-//______________________________________________________________________________
-Image NodeImpl::getIcon() const
-{
- Image ret;
- if (m_xPackage.is())
- {
- const Reference<deployment::XPackageTypeInfo> xPackageType(
- m_xPackage->getPackageType() );
- sal_uInt16 id = 0;
- if (xPackageType.is() &&
- (xPackageType->getIcon(
- // works here, because getCppuType(unsigned short) is defined
- // for IDL UNSIGNED SHORT (not IDL CHAR),
- // try to avoid UNSIGNED SHORT if possible:
- m_treelb->m_hiContrastMode, true /* small */ ) >>= id))
- {
- // opt most common package bundle icon:
- if (id == RID_IMG_DEF_PACKAGE_BUNDLE)
- ret = m_treelb->m_defaultPackageBundle;
- else if (id == RID_IMG_DEF_PACKAGE_BUNDLE_HC)
- ret = m_treelb->m_defaultPackageBundle_hc;
- else
- ret = DialogImpl::getResId(id);
- }
- else
- {
- if (m_xPackage->isBundle())
- ret = m_treelb->m_hiContrastMode
- ? m_treelb->m_defaultPackageBundle_hc
- : m_treelb->m_defaultPackageBundle;
- else
- ret = m_treelb->m_hiContrastMode
- ? m_treelb->m_defaultPackage_hc
- : m_treelb->m_defaultPackage;
- }
- }
- else if (m_factoryURL.getLength() > 0)
- {
- ret = SvFileInformationManager::GetFileImage(
- INetURLObject(m_factoryURL), false /* big */,
- m_treelb->m_hiContrastMode );
- }
- else
- {
- OUString context( m_xPackageManager->getContext() );
- if (context.matchIgnoreAsciiCaseAsciiL(
- RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.tdoc:") ))
- {
- // unknown document:
- if (m_treelb->m_hiContrastMode)
- ret = DialogImpl::getResId(RID_IMG_DEF_DOCUMENT);
- else
- ret = DialogImpl::getResId(RID_IMG_DEF_DOCUMENT_HC);
- }
- else
- {
- OSL_ASSERT(
- context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("user") ) ||
- context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("shared") ) );
-
- if (m_treelb->m_hiContrastMode)
- ret = DialogImpl::getResId(RID_IMG_DEF_INSTALLATION_HC);
- else
- ret = DialogImpl::getResId(RID_IMG_DEF_INSTALLATION);
- }
- }
-
- return ret;
-}
-
-void NodeImpl::disposing( lang::EventObject const & evt )
- throw (RuntimeException)
-{
- const ::vos::OGuard guard( Application::GetSolarMutex() );
- m_bDisposing = true;
-
- OSL_ASSERT( m_lbEntry != 0 );
- if (m_lbEntry != 0)
- {
- // remove all children:
- SvLBoxEntry * entry = m_treelb->FirstChild(m_lbEntry);
- while (entry != 0) {
- ::rtl::Reference<NodeImpl> node( NodeImpl::get(entry) );
- entry = m_treelb->NextSibling(entry);
- node->disposing( evt );
- }
-
- m_treelb->GetModel()->Remove( m_lbEntry );
- m_lbEntry = 0;
- }
-
- OSL_ASSERT( m_it != m_treelb->m_nodes.end() );
- if (m_it != m_treelb->m_nodes.end()) {
- m_treelb->m_nodes.erase( m_it );
- m_it = m_treelb->m_nodes.end();
- }
-
- if (m_xPackage.is())
- m_xPackage->removeModifyListener( this );
- else
- m_xPackageManager->removeModifyListener( this );
- m_xPackageManager.clear();
- m_xPackage.clear();
-
- if (m_treelb->m_dialog != 0)
- m_treelb->m_dialog->updateButtonStates();
-}
-
-
-struct iface_hash {
- ::std::size_t operator () (Reference<deployment::XPackage> const &x) const {
- return reinterpret_cast< ::std::size_t >(
- Reference<XInterface>(x, UNO_QUERY_THROW).get() );
- }
-};
-
-//______________________________________________________________________________
-//Can be called from a separate thread, for example the thread which installes the
-//extension updates, or when clicking the add button. Then the solar mutex is not
-//yet locked. We try to avoid locking it here to prevent a deadlock.
-//We make sure to modifiy the gui only in the main thread.
-//We keep the NodeImpl alive by incresing the ref count (ModifiedParams).
-void NodeImpl::modified( Reference<XCommandEnvironment> const & xCmdEnv )
-{
- PackageState state = NOT_AVAILABLE;
- if (m_xPackage.is())
- state = getPackageState(m_xPackage, xCmdEnv);
-
- const Sequence< Reference<deployment::XPackage> > packages(
- m_xPackageManager->getDeployedPackages(
- Reference<task::XAbortChannel>(), xCmdEnv ) );
-
-
-
- Application::PostUserEvent(
- LINK( this, NodeImpl, asyncModified ),
- new ModifiedParams(
- Reference<XInterface>(static_cast<OWeakObject*>(this), UNO_QUERY_THROW),
- xCmdEnv, state, packages));
-}
-
-//ToDo: We should try to avoid locking the package manager mutex here to prevent
-//deadlocks. However calling updateButtonStates will call into the package manager.
-IMPL_LINK(NodeImpl, asyncModified, ModifiedParams*, pModifiedParams)
-{
- //m_bDisposing is guarded by the solar mutex
- if (! m_bDisposing)
- {
- const Reference<XCommandEnvironment> & xCmdEnv = pModifiedParams->xCmdEnv;
- try {
- if (m_xPackage.is())
- {
- switch (pModifiedParams->state)
- {
- case REGISTERED:
- m_treelb->SetEntryText( m_treelb->m_strEnabled, m_lbEntry, 2 );
- break;
- case NOT_REGISTERED:
- m_treelb->SetEntryText( m_treelb->m_strDisabled, m_lbEntry, 2 );
- break;
- case AMBIGUOUS:
- m_treelb->SetEntryText( m_treelb->m_strUnknown, m_lbEntry, 2 );
- break;
- case NOT_AVAILABLE:
- m_treelb->SetEntryText( String(), m_lbEntry, 2 );
- break;
- }
-
- if (m_treelb->m_dialog != 0)
- m_treelb->m_dialog->updateButtonStates( xCmdEnv );
- }
- else
- {
- typedef ::std::hash_set<
- Reference<deployment::XPackage>, iface_hash > t_set;
- t_set tlboxPackages;
- sal_Int32 count = m_treelb->GetLevelChildCount(m_lbEntry);
- sal_Int32 pos = 0;
- for ( ; pos < count; ++pos ) {
- tlboxPackages.insert(
- NodeImpl::get(
- m_treelb->GetEntry(m_lbEntry, pos) )->m_xPackage );
- }
-
- const Sequence< Reference<deployment::XPackage> > & packages =
- pModifiedParams->deployedPackages;
- t_set::const_iterator const iEnd( tlboxPackages.end() );
- for ( pos = packages.getLength(); pos--; )
- {
- t_set::iterator iFind( tlboxPackages.find( packages[ pos ] ) );
- if (iFind == iEnd) {
- try
- {
- m_treelb->addPackageNode(
- m_lbEntry, packages[ pos ], xCmdEnv );
- }
- catch (lang::DisposedException &)
- {
- //In case an extension was uninstalled or updated then
- //the package may already be disposed
- }
- }
- }
- }
- }
- catch (...)
- {
- //Make sure we release the reference to NodeImpl
- delete pModifiedParams;
- throw;
- }
- } // if (!m_bDisposing)
-
- //Make sure we release the reference to NodeImpl
- delete pModifiedParams;
-
- return 0;
-}
-
-// XModifyListener
-//______________________________________________________________________________
-void NodeImpl::modified( lang::EventObject const & )
- throw (RuntimeException)
-{
- try {
- const Reference<XCommandEnvironment> xCmdEnv(
- new ProgressCommandEnv( m_xComponentContext, m_treelb->m_dialog, String() ) );
- modified( xCmdEnv );
- }
- catch (RuntimeException &) {
- throw;
- }
- catch (CommandFailedException &) {
- // already handled by UUI handler
- }
- catch (Exception &) {
- Any exc( ::cppu::getCaughtException() );
- m_treelb->m_dialog->errbox( ::comphelper::anyToString(exc) );
- }
-}
-
-//______________________________________________________________________________
-DialogImpl::TreeListBoxImpl::~TreeListBoxImpl()
-{
- const ::vos::OGuard guard( Application::GetSolarMutex() );
- m_dialog = 0; // in deinit
-
- const lang::EventObject evt;
- SvLBoxEntry * entry = First();
- while (entry != 0) {
- // remove all contexts:
- ::rtl::Reference<NodeImpl> node( NodeImpl::get(entry) );
- OSL_ASSERT( ! node->m_xPackage.is() );
- entry = NextSibling(entry);
- node->disposing( evt );
- }
- OSL_ASSERT( m_nodes.empty() );
-}
-
-//______________________________________________________________________________
-DialogImpl::SelectionBoxControl::SelectionBoxControl( DialogImpl * dialog )
- : Control( dialog, WB_BORDER | WB_TABSTOP ),
- m_bShutDown(false),
- m_dialog(dialog)
-{
-}
-
-long DialogImpl::SelectionBoxControl::Notify( NotifyEvent & rEvt )
-{
- const long nRet = Control::Notify( rEvt );
- if (IsReallyVisible() &&
- rEvt.GetType() == EVENT_GETFOCUS &&
- rEvt.GetWindow() != static_cast<Window *>(m_dialog->m_treelb.get())
- && ! m_bShutDown)
- {
- m_dialog->m_treelb->GrabFocus();
- }
- return nRet;
-}
-
-//______________________________________________________________________________
-DialogImpl::TreeListBoxImpl::TreeListBoxImpl(
- Reference<XComponentContext> const & context, Window * pParent,
- DialogImpl * dialog )
- : SvHeaderTabListBox( pParent,
- WB_CLIPCHILDREN | WB_TABSTOP |
- WB_HASBUTTONS | WB_HASLINES |
- /* WB_BORDER | */ WB_HASLINESATROOT |
- WB_HASBUTTONSATROOT | WB_HIDESELECTION |
- WB_HSCROLL ),
- m_context( context ),
- m_dialog( dialog ),
- m_currentSelectedEntry( 0 ),
- m_hiContrastMode( GetDisplayBackground().GetColor().IsDark() ),
- m_strEnabled( getResourceString(RID_STR_ENABLED) ),
- m_strDisabled( getResourceString(RID_STR_DISABLED) ),
- m_strUnknown( getResourceString(RID_STR_UNKNOWN) ),
- m_strCtxAdd( getResourceString(RID_CTX_ITEM_ADD) ),
- m_strCtxRemove( getResourceString(RID_CTX_ITEM_REMOVE) ),
- m_strCtxEnable( getResourceString(RID_CTX_ITEM_ENABLE) ),
- m_strCtxDisable( getResourceString(RID_CTX_ITEM_DISABLE) ),
- m_strCtxExport( getResourceString(RID_CTX_ITEM_EXPORT) ),
- m_strCtxCheckUpdate( getResourceString(RID_CTX_ITEM_CHECK_UPDATE) ),
- m_strCtxOptions( getResourceString(RID_CTX_ITEM_OPTIONS) ),
- m_defaultPackage( getResId(RID_IMG_DEF_PACKAGE) ),
- m_defaultPackage_hc( getResId(RID_IMG_DEF_PACKAGE_HC) ),
- m_defaultPackageBundle( getResId(RID_IMG_DEF_PACKAGE_BUNDLE) ),
- m_defaultPackageBundle_hc( getResId(RID_IMG_DEF_PACKAGE_BUNDLE_HC) )
-{
- SetHelpId( HID_PACKAGE_MANAGER_TREELISTBOX );
- SetNodeBitmaps( Image( getResId(RID_IMG_PLUS) ),
- Image( getResId(RID_IMG_MINUS) ),
- BMP_COLOR_NORMAL );
- SetNodeBitmaps( Image( getResId(RID_IMG_PLUS_HC) ),
- Image( getResId(RID_IMG_MINUS_HC) ),
- BMP_COLOR_HIGHCONTRAST );
- SetSelectionMode( MULTIPLE_SELECTION );
- SetSpaceBetweenEntries( 4 );
- EnableContextMenuHandling();
-
- // timer for balloon help:
- m_timer.SetTimeout( 200 );
- m_timer.SetTimeoutHdl(
- LINK( this, DialogImpl::TreeListBoxImpl, TimerHandler ) );
-}
-
-//______________________________________________________________________________
-SvLBoxEntry * DialogImpl::TreeListBoxImpl::addNode(
- SvLBoxEntry * parentNode,
- String const & displayName,
- OUString const & factoryURL,
- Reference<deployment::XPackageManager> const & xPackageManager,
- Reference<deployment::XPackage> const & xPackage,
- Reference<XCommandEnvironment> const & xCmdEnv,
- bool sortIn )
-{
- OSL_ASSERT(xPackageManager.is());
- NodeImpl * node = new NodeImpl(
- m_context, this, factoryURL, xPackageManager, xPackage );
- Reference<util::XModifyListener> xListener( node );
- m_nodes.push_front( xListener );
- node->m_it = m_nodes.begin();
-
- ULONG pos = LIST_APPEND;
- if (sortIn)
- {
- // sort in after top-level nodes after user, shared:
- pos = parentNode == 0 ? 2 : 0;
- ULONG count = GetLevelChildCount(parentNode);
- for ( ; pos < count; ++pos )
- {
- SvLBoxEntry * entry = GetEntry( parentNode, pos );
- OSL_ASSERT( entry != 0 );
- if (GetEntryText(entry).CompareIgnoreCaseToAscii(
- displayName ) == COMPARE_GREATER)
- break;
- }
- if (pos >= count)
- pos = LIST_APPEND;
- }
-
- Image imgIcon( node->getIcon() );
- if (parentNode == 0)
- {
- // top-level node:
- node->m_lbEntry = InsertEntryToColumn(
- displayName, imgIcon, imgIcon, NULL, pos, 0xffff, node );
- node->m_xPackageManager->addModifyListener( xListener );
- }
- else
- {
- String name( displayName );
- name.AppendAscii( RTL_CONSTASCII_STRINGPARAM("\t\t") );
- node->m_lbEntry = InsertEntryToColumn(
- name, imgIcon, imgIcon, parentNode, pos, 0xffff, node );
- SetEntryText( xPackage->getVersion(), node->m_lbEntry, 1 );
- // update status:
- node->modified( xCmdEnv );
- node->m_xPackage->addModifyListener( xListener );
- }
-
- bool hasChildren = !xPackage.is() || xPackage->isBundle();
- if (hasChildren && node->m_lbEntry != 0)
- {
- // HACK: xxx todo: missing method in svtools
- // set the flag which allows if the entry can be expanded
- // test ondemand
- node->m_lbEntry->SetFlags(
- (node->m_lbEntry->GetFlags() &
- ~(SV_ENTRYFLAG_NO_NODEBMP | SV_ENTRYFLAG_HAD_CHILDREN))
- | SV_ENTRYFLAG_CHILDS_ON_DEMAND );
- }
-
- return node->m_lbEntry;
-}
-
-//______________________________________________________________________________
-SvLBoxEntry * DialogImpl::TreeListBoxImpl::addPackageNode(
- SvLBoxEntry * parentNode,
- Reference<deployment::XPackage> const & xPackage,
- Reference<XCommandEnvironment> const & xCmdEnv )
-{
- return addNode( parentNode, xPackage->getDisplayName(),
- OUString() /* no factory URL */,
- NodeImpl::get(parentNode)->m_xPackageManager,
- xPackage, xCmdEnv );
-}
-
-//______________________________________________________________________________
-SvLBoxEntry * DialogImpl::TreeListBoxImpl::getCurrentSingleSelectedEntry() const
-{
- SvLBoxEntry * entry = FirstSelected();
- if (entry != 0 && NextSelected(entry) == 0)
- return entry;
- else
- return 0;
-}
-
-//______________________________________________________________________________
-bool DialogImpl::TreeListBoxImpl::isFirstLevelChild( SvLBoxEntry * entry ) const
-{
- if (entry == 0)
- return false;
- entry = GetParent( entry );
- if (entry != 0)
- return GetParent( entry ) == 0;
- else
- return false;
-}
-
-//______________________________________________________________________________
-Reference<deployment::XPackage>
-DialogImpl::TreeListBoxImpl::getPackage( SvLBoxEntry * entry ) const
-{
- if (entry == 0)
- return Reference<deployment::XPackage>();
- else
- return NodeImpl::get(entry)->m_xPackage;
-}
-
-//______________________________________________________________________________
-Reference<deployment::XPackageManager>
-DialogImpl::TreeListBoxImpl::getPackageManager( SvLBoxEntry * entry ) const
-{
- if (entry == 0)
- return Reference<deployment::XPackageManager>();
- else
- return NodeImpl::get(entry)->m_xPackageManager;
-}
-
-//______________________________________________________________________________
-PopupMenu * DialogImpl::TreeListBoxImpl::CreateContextMenu(void)
-{
- if (m_dialog == 0)
- return 0;
-
- ::std::auto_ptr<PopupMenu> menu( new PopupMenu );
-
- if (m_dialog->m_addButton->IsEnabled())
- menu->InsertItem( RID_BTN_ADD, m_strCtxAdd );
- if (m_dialog->m_removeButton->IsEnabled())
- menu->InsertItem( RID_BTN_REMOVE, m_strCtxRemove );
-
- if ((m_dialog->m_enableButton->IsEnabled()
- || m_dialog->m_disableButton->IsEnabled())
- && menu->GetItemCount() != 0)
- menu->InsertSeparator();
- if (m_dialog->m_enableButton->IsEnabled())
- menu->InsertItem( RID_BTN_ENABLE, m_strCtxEnable );
- if (m_dialog->m_disableButton->IsEnabled())
- menu->InsertItem( RID_BTN_DISABLE, m_strCtxDisable );
-
- if (m_dialog->m_exportButton->IsEnabled())
- {
- if (menu->GetItemCount() != 0)
- menu->InsertSeparator();
- menu->InsertItem( RID_BTN_EXPORT, m_strCtxExport );
- }
-
- bool updateUrl = false;
- OUString sExtUpdateUrl;
- if (dp_misc::getExtensionDefaultUpdateURL().getLength() > 0)
- updateUrl = true;
-
- for (SvLBoxEntry * e = FirstSelected(); e != NULL; e = NextSelected(e))
- {
- if (isFirstLevelChild(e))
- {
- updateUrl = updateUrl ||
- getPackage(e)->getUpdateInformationURLs().getLength() != 0;
- }
- else
- {
- updateUrl = false;
- break;
- }
- }
- if (updateUrl)
- {
- if (menu->GetItemCount() != 0)
- menu->InsertSeparator();
- menu->InsertItem( RID_BTN_CHECK_UPDATES, m_strCtxCheckUpdate );
- }
-
- if (m_dialog->m_optionsButton->IsEnabled())
- {
- menu->InsertSeparator();
- menu->InsertItem( RID_BTN_OPTIONS, m_strCtxOptions );
- }
-
- return menu.release();
-}
-
-//______________________________________________________________________________
-void DialogImpl::TreeListBoxImpl::ExcecuteContextMenuAction(
- USHORT nSelectedPopupEntry )
-{
- if (m_dialog == 0)
- return;
-
- switch (nSelectedPopupEntry) {
- case 0:
- break;
- case RID_BTN_ADD:
- m_dialog->m_addButton->Click();
- break;
- case RID_BTN_REMOVE:
- m_dialog->m_removeButton->Click();
- break;
- case RID_BTN_ENABLE:
- m_dialog->m_enableButton->Click();
- break;
- case RID_BTN_DISABLE:
- m_dialog->m_disableButton->Click();
- break;
- case RID_BTN_EXPORT:
- m_dialog->m_exportButton->Click();
- break;
- case RID_BTN_CHECK_UPDATES:
- m_dialog->checkUpdates(true);
- break;
- case RID_BTN_OPTIONS:
- m_dialog->m_optionsButton->Click();
- break;
- default:
- OSL_ENSURE( 0, "### forgot button entry?!" );
- break;
- }
-}
-
-//______________________________________________________________________________
-void DialogImpl::TreeListBoxImpl::MouseMove( MouseEvent const & evt )
-{
- Point pos = evt.GetPosPixel();
- m_currentSelectedEntry = getCurrentSingleSelectedEntry();
-
- if (m_currentSelectedEntry != 0 &&
- GetEntry( pos ) == m_currentSelectedEntry)
- {
- m_timer.Start();
- }
- else
- {
- Help::ShowBalloon( this, pos, String() );
- m_timer.Stop();
- }
-}
-
-//______________________________________________________________________________
-IMPL_LINK( DialogImpl::TreeListBoxImpl, TimerHandler, Timer *, EMPTYARG )
-{
- m_timer.Stop();
- Point pos = GetPointerPosPixel();
- SvLBoxEntry * currentEntry = getCurrentSingleSelectedEntry();
- if (currentEntry != 0 &&
- GetEntry( pos ) == currentEntry &&
- m_currentSelectedEntry == currentEntry ) // still the same?
- {
- NodeImpl * node = NodeImpl::get(currentEntry);
- String balloon;
- if (node->m_xPackage.is()) {
- ::rtl::OUStringBuffer buf;
- buf.append( node->m_xPackage->getDescription() );
- const Reference<deployment::XPackageTypeInfo> xPackageType(
- node->m_xPackage->getPackageType() );
- if (xPackageType.is()) {
- if (buf.getLength() > 0)
- buf.append( static_cast<sal_Unicode>('\n') );
- buf.append( static_cast<sal_Unicode>('(') );
- buf.append( xPackageType->getMediaType() );
-#if OSL_DEBUG_LEVEL > 1
- buf.appendAscii( RTL_CONSTASCII_STRINGPARAM(",\n") );
- buf.append( node->m_xPackage->getURL() );
-#endif
- buf.append( static_cast<sal_Unicode>(')') );
- balloon = buf.makeStringAndClear();
- }
- }
- else if (node->m_factoryURL.getLength() > 0) {
- balloon = SvFileInformationManager::GetDescription(
- INetURLObject(node->m_factoryURL) );
- }
-
- if (balloon.Len() > 0)
- Help::ShowBalloon( this, OutputToScreenPixel( pos ), balloon );
- }
- return 0;
-}
-
-//______________________________________________________________________________
-void DialogImpl::TreeListBoxImpl::SelectHdl()
-{
- if (m_dialog != 0)
- m_dialog->updateButtonStates();
-}
-
-//______________________________________________________________________________
-void DialogImpl::TreeListBoxImpl::DeselectHdl()
-{
- if (m_dialog != 0)
- m_dialog->updateButtonStates();
-}
-
-//______________________________________________________________________________
-void DialogImpl::TreeListBoxImpl::KeyInput( KeyEvent const & evt )
-{
- const KeyCode key = evt.GetKeyCode();
- if (key == KEY_DELETE &&
- m_dialog != 0 && m_dialog->m_removeButton->IsEnabled())
- {
- // remove selected:
- m_dialog->m_removeButton->Click();
- return;
- }
- SvTreeListBox::KeyInput( evt );
-}
-
-//______________________________________________________________________________
-void DialogImpl::TreeListBoxImpl::RequestingChilds( SvLBoxEntry * pParent )
-{
- try {
- if (GetChildCount( pParent ) > 0)
- return;
-
- WaitObject wo(this); // clock...
-
- Sequence< Reference<deployment::XPackage> > packages;
- NodeImpl * parentNode = NodeImpl::get(pParent);
-
- const Reference<XCommandEnvironment> xCmdEnv(
- new ProgressCommandEnv(m_context, m_dialog, String()) );
- if (parentNode->m_xPackage.is()) {
- packages = parentNode->m_xPackage->getBundle(
- Reference<task::XAbortChannel>(), xCmdEnv );
- }
- else { // is context
- packages = parentNode->m_xPackageManager->getDeployedPackages(
- Reference<task::XAbortChannel>(), xCmdEnv );
- }
- if (packages.getLength() > 0) {
- Reference<deployment::XPackage> const * ppackages =
- packages.getConstArray();
- SetUpdateMode(FALSE);
- for ( sal_Int32 pos = packages.getLength(); pos--; ) {
- //disregard executable (application/vnd.sun.star.executable)
- //it will not be displayed an shall not be disabled/enabled
- OUString sType = ppackages[ pos ]->getPackageType()->getMediaType();
- if (sType.equals(OUSTR("application/vnd.sun.star.executable")))
- continue;
-
- addPackageNode(
- parentNode->m_lbEntry, ppackages[ pos ], xCmdEnv );
- }
- SetUpdateMode(TRUE);
- }
- }
- catch (CommandFailedException &) {
- // already handled by UUI handler
- }
- catch (Exception &) {
- Any exc( ::cppu::getCaughtException() );
- m_dialog->errbox( ::comphelper::anyToString(exc) );
- }
-}
-
-//______________________________________________________________________________
-BOOL DialogImpl::TreeListBoxImpl::Expand( SvLBoxEntry * pParent )
-{
- BOOL ret = SvTreeListBox::Expand( pParent );
- if (ret)
- {
- ULONG nVisibleEntries =
- GetOutputSizePixel().Height() / GetEntryHeight();
- ULONG nVisibleChildren = GetVisibleChildCount( pParent );
-
- if ((nVisibleChildren + 1) > nVisibleEntries) {
- MakeVisible( pParent, TRUE );
- }
- else {
- SvLBoxEntry * pEntry = GetFirstEntryInView();
- ULONG nParentPos = 0;
- while (pEntry != 0 && pEntry != pParent) {
- ++nParentPos;
- pEntry = GetNextEntryInView( pEntry );
- }
-
- if ((nParentPos + nVisibleChildren + 1) > nVisibleEntries)
- ScrollOutputArea( static_cast<short>(
- nVisibleEntries -
- (nParentPos + nVisibleChildren + 1) ) );
- }
- }
- return ret;
-}
-
-//______________________________________________________________________________
-void DialogImpl::TreeListBoxImpl::DataChanged( DataChangedEvent const & evt )
-{
- SvTreeListBox::DataChanged( evt );
- if (evt.GetType() == DATACHANGED_SETTINGS &&
- (evt.GetFlags() & SETTINGS_STYLE) != 0 &&
- m_hiContrastMode != (bool)GetDisplayBackground().GetColor().IsDark())
- {
- m_hiContrastMode = ! m_hiContrastMode;
-
- // Update all images as we changed from/to high contrast mode:
- for ( SvLBoxEntry * entry = First(); entry != 0; entry = Next(entry) )
- {
- NodeImpl * node = NodeImpl::get(entry);
- Image img( node->getIcon() );
- SetExpandedEntryBmp( entry, img );
- SetCollapsedEntryBmp( entry, img );
- }
-
- // force redraw:
- Invalidate();
- }
-}
-
-//Currently only works for extensions installed in user context
-void DialogImpl::TreeListBoxImpl::select(css::uno::Reference<css::deployment::XPackage> const & xPackage)
-{
- const ::vos::OGuard guard( Application::GetSolarMutex() );
- //GetEntryCount includes all child nodes
- if (GetEntryCount() == 0)
- {
- OSL_ASSERT(0);
- return;
- }
-
- SvLBoxEntry* rootEntry = FirstChild(NULL);
- if (rootEntry)
- {
- sal_Int32 count = GetLevelChildCount(rootEntry);
- for (sal_Int32 pos = 0; pos < count; pos++)
- {
- SvLBoxEntry* entry = GetEntry(rootEntry, pos);
- Reference<css::deployment::XPackage> const & pack = NodeImpl::get(entry)->m_xPackage;
- if (pack == xPackage)
- {
- SelectAll(false); //delete previous selection
- MakeVisible(entry);
- SetCursor(entry);
- break;
- }
- }
- }
-}
-
-//##############################################################################
-
-//______________________________________________________________________________
-IMPL_LINK( DialogImpl, destroyDialog, DialogImpl *, EMPTYARG )
-{
- //When the install queue has not terminated then we repost the event
- //until the installation thread has finished. We must not block the
- //main thread because installing the extensions requires GUI. Therefore
- //blocking here could cause a deadlock.
- if (m_addExtensionQueue->hasTerminated())
- {
- //make sure the updatability thread (controls the update button) terminates
- //this call blocks until the thread is dead.
- m_updatability->stop();
-
- if (s_closingDialog.is())
- {
- //keep the dialog alive in this scope. disposing will already delete
- //the static reference
- ::rtl::Reference<DialogImpl> dialog( s_closingDialog );
- s_closingDialog.clear();
- try {
- dialog->disposing( lang::EventObject( dialog->m_xDesktop ) );
- }
- catch (RuntimeException &) {
- OSL_ASSERT( 0 );
- }
- dialog->ModelessDialog::Close();
- }
- if (! office_is_running())
- Application::Quit();
- }
- else
- { //Repost event instead of blocking the main thread.
- Application::PostUserEvent(
- LINK( this, DialogImpl, destroyDialog ), 0 );
- return 0;
- }
- return 0;
-}
-
-//______________________________________________________________________________
-//Called when clicking the close button
-//The actual closing of the dialog is done in
-//IMPL_STATIC_LINK( DialogImpl, destroyDialog, void *, EMPTYARG )
-BOOL DialogImpl::Close()
-{
- {
- //Let the user click Close again in the following rare case.
- if (sal_False == s_closingMutex.tryToAcquire()
- || s_closingDialog.get() != NULL)
- return FALSE;
-
- //For all new installation request, for example by double-clicking an oxt file,
- // a new DialogImpl is used. So temporarily there could be two dialogs visible.
- //The old one will process all remaining installation request in the AddExtensionQueue
- //and then die.
- //This is necessary for the case when the user clicks close and in the same moment
- //a new installation request arrives.
- //The last reference to this DialogImpl will be removed in destroyDialog where
- //s_closingDialog.clear is called.
- {
- ::osl::MutexGuard g(s_dialogMutex);
- s_closingDialog = s_dialog;
- s_dialog.clear();
- }
- s_closingMutex.release();
- }
-
- //This call does not block but signals that the installation thread shall terminate.
- m_addExtensionQueue->stop();
-
-
- //Do not call m_addExtensionQueue->stop() here. See event handler destroyDialog.
- Application::PostUserEvent(
- LINK( this, DialogImpl, destroyDialog ), 0 );
- return FALSE;
-}
-
-// XEventListener
-//______________________________________________________________________________
-void DialogImpl::disposing( lang::EventObject const & evt )
-throw (RuntimeException)
-{
- const lang::EventObject evt_( static_cast<OWeakObject *>(this) );
-
- // see destroyDialog
- bool shutDown = (evt.Source == m_xDesktop);
- {
- const ::vos::OGuard guard( Application::GetSolarMutex() );
- // remove contexts:
- SvLBoxEntry * entry = m_treelb->First();
- while (entry != 0)
- {
- ::rtl::Reference<NodeImpl> node( NodeImpl::get(entry) );
- entry = m_treelb->NextSibling(entry);
- if (shutDown ||
- node->m_xPackageManager
- ->getContext().matchIgnoreAsciiCaseAsciiL(
- RTL_CONSTASCII_STRINGPARAM("vnd.sun.star.tdoc:") ))
- node->disposing( evt_ );
- }
-
- if (shutDown)
- {
- m_selectionBox->m_bShutDown = true;
- }
- } // release Solar mutex which will be used by the extension queue.
-
- if (shutDown)
- {
- //Make sure we destroy all threads before destroying the dialog.
- //s_dialog may not contain this anymore but a new dialog
- m_updatability->stop();
- m_addExtensionQueue->stopAndWait();
- {
- ::osl::MutexGuard g(s_dialogMutex);
- if (static_cast<DialogImpl*>(s_dialog.get()) == static_cast<DialogImpl*>(this))
- s_dialog.clear();
- }
- {
- ::osl::MutexGuard g(s_closingMutex);
- if (static_cast<DialogImpl*>(s_closingDialog.get()) == static_cast<DialogImpl*>(this))
- s_closingDialog.clear();
- }
- }
-
- if (m_xTdocRoot.is()) {
- m_xTdocRoot->removeContentEventListener( this );
- m_xTdocRoot.clear();
- }
- if (shutDown && m_xDesktop.is()) {
- m_xDesktop->removeTerminateListener( this );
- m_xDesktop.clear();
- }
-}
-
-
-// XTerminateListener
-//______________________________________________________________________________
-void DialogImpl::queryTermination( lang::EventObject const & )
- throw (frame::TerminationVetoException, RuntimeException)
-{
- // If we did not threw an exception anyway, we would have to do it
- //as long as there are queued installation requests for extensions.
- //See m_addExtensionsQueue.
- throw frame::TerminationVetoException(
- OUSTR("The office cannot be closed while the Extension Manager is running"),
- Reference<XInterface>(static_cast<frame::XTerminateListener*>(this), UNO_QUERY));
-}
-
-//______________________________________________________________________________
-void DialogImpl::notifyTermination( lang::EventObject const & evt )
- throw (RuntimeException)
-{
- if (m_updatability.get() != NULL)
- m_updatability->stop();
- if (m_addExtensionQueue.get() != NULL)
- m_addExtensionQueue->stopAndWait();
-
- disposing( evt );
-}
-
-// XContentEventListener
-//______________________________________________________________________________
-void DialogImpl::contentEvent( ContentEvent const & evt )
- throw (RuntimeException)
-{
- const ::vos::OGuard guard( Application::GetSolarMutex() );
-
- OSL_ASSERT( evt.Id == m_xTdocRoot->getIdentifier() );
- try {
- switch (evt.Action) {
- case ContentAction::INSERTED:
- {
- ::ucbhelper::Content ucbContent( evt.Content, 0 );
- OUString factoryURL;
- Reference<XInterface> xDocumentModel;
- if (ucbContent.getPropertyValue(
- OUSTR("DocumentModel") ) >>= xDocumentModel)
- {
- Reference< ::com::sun::star::frame::XModuleManager >
- xModuleManager(
- m_xComponentContext->getServiceManager()
- ->createInstanceWithContext(
- OUSTR("com.sun.star.frame.ModuleManager"),
- m_xComponentContext ),
- UNO_QUERY_THROW );
- Reference<container::XNameAccess> xModuleConfig(
- xModuleManager, UNO_QUERY_THROW );
- // get the long name of the document:
- const OUString appModule( xModuleManager->identify(
- xDocumentModel ) );
- const Any any_appModule( xModuleConfig->getByName(appModule) );
- const Sequence<beans::PropertyValue> moduleDescr(
- any_appModule.get< Sequence<beans::PropertyValue> >() );
- for ( sal_Int32 pos = moduleDescr.getLength(); pos--; )
- {
- if (moduleDescr[ pos ].Name.equalsAsciiL(
- RTL_CONSTASCII_STRINGPARAM(
- "ooSetupFactoryEmptyDocumentURL") )) {
- moduleDescr[ pos ].Value >>= factoryURL;
- break;
- }
- }
- }
-
- m_treelb->addNode(
- 0 /* no parent */,
- ucbContent.getPropertyValue( OUSTR("Title") ).get<OUString>(),
- factoryURL,
- m_xPkgMgrFac->getPackageManager(
- makeURL( ucbContent.getURL(), OUSTR("uno_packages") ) ),
- Reference<deployment::XPackage>(),
- Reference<XCommandEnvironment>() );
- break;
- }
- case ContentAction::REMOVED: {
- ::ucbhelper::Content ucbContent( evt.Content, 0 );
- OUString context(
- makeURL( ucbContent.getURL(), OUSTR("uno_packages") ) );
-
- // find tdoc context and remove:
- SvLBoxEntry * entry = m_treelb->First();
- while (entry != 0)
- {
- ::rtl::Reference<NodeImpl> node( NodeImpl::get(entry) );
- entry = m_treelb->NextSibling(entry);
- if (node->m_xPackageManager->getContext().equals( context )) {
- node->disposing( lang::EventObject(
- static_cast<OWeakObject *>(this) ) );
- break;
- }
- }
- break;
- }
- default:
- break;
- }
- }
- catch (RuntimeException &) {
- throw;
- }
- catch (Exception &) {
- Any exc( ::cppu::getCaughtException() );
- throw lang::WrappedTargetRuntimeException(
- OUSTR("unexpected exception occured!"),
- static_cast<OWeakObject *>(this), exc );
- }
-}
-
-}
-
diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx
index 595c0d1afbcb..8d93b9bba3b4 100644
--- a/desktop/source/deployment/gui/dp_gui_updatedialog.cxx
+++ b/desktop/source/deployment/gui/dp_gui_updatedialog.cxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: dp_gui_updatedialog.cxx,v $
- * $Revision: 1.18 $
+ * $Revision: 1.18.10.1 $
*
* This file is part of OpenOffice.org.
*
@@ -599,8 +599,6 @@ bool UpdateDialog::Thread::update(
UpdateDialog::UpdateDialog(
css::uno::Reference< css::uno::XComponentContext > const & context,
Window * parent,
-// TODO: check!
-// rtl::Reference<dp_gui::DialogImpl> const & extensionManagerDialog ,
rtl::Reference< dp_gui::SelectedPackage > const & selectedPackage,
css::uno::Sequence< css::uno::Reference<
css::deployment::XPackageManager > > const & packageManagers,
diff --git a/desktop/source/deployment/gui/dp_gui_updatedialog.hxx b/desktop/source/deployment/gui/dp_gui_updatedialog.hxx
index 9edb7f5342b3..bfdb5392e740 100644
--- a/desktop/source/deployment/gui/dp_gui_updatedialog.hxx
+++ b/desktop/source/deployment/gui/dp_gui_updatedialog.hxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: dp_gui_updatedialog.hxx,v $
- * $Revision: 1.9 $
+ * $Revision: 1.9.86.1 $
*
* This file is part of OpenOffice.org.
*
@@ -71,8 +71,6 @@ namespace dp_gui {
namespace dp_gui {
- struct DialogImpl;
-
/**
The modal &ldquo;Check for Updates&rdquo; dialog.
*/
@@ -230,10 +228,6 @@ private:
Size m_aFirstLineSize;
long m_nFirstLineDelta;
long m_nOneLineMissing;
- // TODO: check
- // The dialog only knows if we already showed the warning about
- // updating a shared extension during this session.
- // const ::rtl::Reference<DialogImpl> m_extensionManagerDialog;
};
}
diff --git a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx
index 9c20d787c6a0..97431a13e49b 100644
--- a/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx
+++ b/desktop/source/deployment/gui/dp_gui_updateinstalldialog.cxx
@@ -7,7 +7,7 @@
* OpenOffice.org - a multi-platform office productivity suite
*
* $RCSfile: dp_gui_updateinstalldialog.cxx,v $
- * $Revision: 1.9 $
+ * $Revision: 1.9.76.1 $
*
* This file is part of OpenOffice.org.
*
@@ -69,7 +69,6 @@
#include "com/sun/star/task/XInteractionApprove.hpp"
#include "dp_descriptioninfoset.hxx"
-#include "dp_gui_cmdenv.h"
#include "dp_gui.hrc"
#include "dp_gui_updateinstalldialog.hxx"
#include "dp_gui_shared.hxx"
@@ -78,6 +77,7 @@
#include "dp_misc.h"
#include "dp_version.hxx"
#include "dp_gui_thread.hxx"
+#include "dp_gui_extensioncmdqueue.hxx"
#include "ucbhelper/content.hxx"
#include "osl/mutex.hxx"
#include "vos/mutex.hxx"
@@ -85,7 +85,6 @@
#include "com/sun/star/uno/Sequence.h"
#include "comphelper/anytostring.hxx"
#include "toolkit/helper/vclunohelper.hxx"
-//#include "com/sun/star/uno/Type.hxx"
#include <vector>
@@ -94,7 +93,6 @@ class Window;
namespace cssu = ::com::sun::star::uno;
namespace css = ::com::sun::star;
-using ::com::sun::star::uno::Reference;
using ::rtl::OUString;
@@ -103,7 +101,7 @@ namespace dp_gui {
class UpdateInstallDialog::Thread: public dp_gui::Thread {
friend class UpdateCommandEnv;
public:
- Thread(::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > ctx,
+ Thread(cssu::Reference< cssu::XComponentContext > ctx,
UpdateInstallDialog & dialog, std::vector< dp_gui::UpdateData > & aVecUpdateData);
void stop();
@@ -123,12 +121,12 @@ private:
void removeTempDownloads();
UpdateInstallDialog & m_dialog;
- ::com::sun::star::uno::Reference< ::com::sun::star::deployment::XUpdateInformationProvider >
+ cssu::Reference< css::deployment::XUpdateInformationProvider >
m_updateInformation;
// guarded by Application::GetSolarMutex():
- ::com::sun::star::uno::Reference< ::com::sun::star::task::XAbortChannel > m_abort;
- ::com::sun::star::uno::Reference< ::com::sun::star::uno::XComponentContext > m_xComponentContext;
+ cssu::Reference< css::task::XAbortChannel > m_abort;
+ cssu::Reference< cssu::XComponentContext > m_xComponentContext;
std::vector< dp_gui::UpdateData > & m_aVecUpdateData;
::rtl::Reference<UpdateCommandEnv> m_updateCmdEnv;
@@ -148,36 +146,36 @@ class UpdateCommandEnv
UpdateInstallDialog & m_updateDialog;
::rtl::Reference<UpdateInstallDialog::Thread> m_installThread;
- Reference<css::task::XInteractionHandler> m_xMainDialogHandler;
+ cssu::Reference< cssu::XComponentContext > m_xContext;
public:
virtual ~UpdateCommandEnv();
- UpdateCommandEnv( Reference< cssu::XComponentContext > const & xCtx,
+ UpdateCommandEnv( cssu::Reference< cssu::XComponentContext > const & xCtx,
UpdateInstallDialog & updateDialog,
::rtl::Reference<UpdateInstallDialog::Thread>const & thread);
// XCommandEnvironment
- virtual css::uno::Reference<css::task::XInteractionHandler > SAL_CALL
- getInteractionHandler() throw (css::uno::RuntimeException);
- virtual css::uno::Reference<css::ucb::XProgressHandler >
- SAL_CALL getProgressHandler() throw (css::uno::RuntimeException);
+ virtual cssu::Reference<css::task::XInteractionHandler > SAL_CALL
+ getInteractionHandler() throw (cssu::RuntimeException);
+ virtual cssu::Reference<css::ucb::XProgressHandler >
+ SAL_CALL getProgressHandler() throw (cssu::RuntimeException);
// XInteractionHandler
virtual void SAL_CALL handle(
- css::uno::Reference<css::task::XInteractionRequest > const & xRequest )
- throw (css::uno::RuntimeException);
+ cssu::Reference<css::task::XInteractionRequest > const & xRequest )
+ throw (cssu::RuntimeException);
// XProgressHandler
- virtual void SAL_CALL push( css::uno::Any const & Status )
- throw (css::uno::RuntimeException);
- virtual void SAL_CALL update( css::uno::Any const & Status )
- throw (css::uno::RuntimeException);
- virtual void SAL_CALL pop() throw (css::uno::RuntimeException);
+ virtual void SAL_CALL push( cssu::Any const & Status )
+ throw (cssu::RuntimeException);
+ virtual void SAL_CALL update( cssu::Any const & Status )
+ throw (cssu::RuntimeException);
+ virtual void SAL_CALL pop() throw (cssu::RuntimeException);
};
UpdateInstallDialog::Thread::Thread(
- Reference< cssu::XComponentContext> xCtx,
+ cssu::Reference< cssu::XComponentContext> xCtx,
UpdateInstallDialog & dialog,
std::vector< dp_gui::UpdateData > & aVecUpdateData):
m_dialog(dialog),
@@ -188,7 +186,7 @@ UpdateInstallDialog::Thread::Thread(
{}
void UpdateInstallDialog::Thread::stop() {
- css::uno::Reference< css::task::XAbortChannel > abort;
+ cssu::Reference< css::task::XAbortChannel > abort;
{
vos::OGuard g(Application::GetSolarMutex());
abort = m_abort;
@@ -231,7 +229,7 @@ void UpdateInstallDialog::Thread::execute()
UpdateInstallDialog::UpdateInstallDialog(
Window * parent,
std::vector<dp_gui::UpdateData> & aVecUpdateData,
- Reference< cssu::XComponentContext > const & xCtx):
+ cssu::Reference< cssu::XComponentContext > const & xCtx):
ModalDialog(
parent,
DpGuiResId(RID_DLG_UPDATEINSTALL)),
@@ -492,14 +490,14 @@ void UpdateInstallDialog::Thread::installExtensions()
// osl::Thread::wait(v);
bool bError = false;
bool bLicenseDeclined = false;
- Reference<css::deployment::XPackage> xPackage;
+ cssu::Reference<css::deployment::XPackage> xPackage;
UpdateData & curData = *i;
cssu::Exception exc;
try
{
if (curData.sLocalURL.getLength() == 0)
continue;
- Reference< css::task::XAbortChannel > xAbortChannel(
+ cssu::Reference< css::task::XAbortChannel > xAbortChannel(
curData.aPackageManager->createAbortChannel() );
{
vos::OGuard g(Application::GetSolarMutex());
@@ -564,10 +562,10 @@ void UpdateInstallDialog::Thread::removeTempDownloads()
if (m_sDownloadFolder.getLength())
{
dp_misc::erase_path(m_sDownloadFolder,
- Reference<css::ucb::XCommandEnvironment>(),false /* no throw: ignore errors */ );
+ cssu::Reference<css::ucb::XCommandEnvironment>(),false /* no throw: ignore errors */ );
//remove also the temp file which we have used to create the unique name
OUString tempFile = m_sDownloadFolder.copy(0, m_sDownloadFolder.getLength() - 1);
- dp_misc::erase_path(tempFile, Reference<css::ucb::XCommandEnvironment>(),false);
+ dp_misc::erase_path(tempFile, cssu::Reference<css::ucb::XCommandEnvironment>(),false);
m_sDownloadFolder = OUString();
}
}
@@ -624,14 +622,13 @@ void UpdateInstallDialog::Thread::download(OUString const & sDownloadURL, Update
// -------------------------------------------------------------------------------------------------------
-UpdateCommandEnv::UpdateCommandEnv( Reference< cssu::XComponentContext > const & xCtx,
+UpdateCommandEnv::UpdateCommandEnv( cssu::Reference< cssu::XComponentContext > const & xCtx,
UpdateInstallDialog & updateDialog,
::rtl::Reference<UpdateInstallDialog::Thread>const & thread)
: m_updateDialog( updateDialog ),
- m_installThread(thread)
+ m_installThread(thread),
+ m_xContext(xCtx)
{
- m_xMainDialogHandler = new ProgressCommandEnv(xCtx, &updateDialog,
- OUSTR("Extension Manager"));
}
UpdateCommandEnv::~UpdateCommandEnv()
@@ -641,14 +638,14 @@ UpdateCommandEnv::~UpdateCommandEnv()
// XCommandEnvironment
//______________________________________________________________________________
-Reference<css::task::XInteractionHandler> UpdateCommandEnv::getInteractionHandler()
+cssu::Reference<css::task::XInteractionHandler> UpdateCommandEnv::getInteractionHandler()
throw (cssu::RuntimeException)
{
return this;
}
//______________________________________________________________________________
-Reference<css::ucb::XProgressHandler> UpdateCommandEnv::getProgressHandler()
+cssu::Reference<css::ucb::XProgressHandler> UpdateCommandEnv::getProgressHandler()
throw (cssu::RuntimeException)
{
return this;
@@ -656,7 +653,7 @@ throw (cssu::RuntimeException)
// XInteractionHandler
void UpdateCommandEnv::handle(
- Reference< css::task::XInteractionRequest> const & xRequest )
+ cssu::Reference< css::task::XInteractionRequest> const & xRequest )
throw (cssu::RuntimeException)
{
cssu::Any request( xRequest->getRequest() );
@@ -683,20 +680,20 @@ void UpdateCommandEnv::handle(
if (approve == false && abort == false)
{
//forward to interaction handler for main dialog.
- m_xMainDialogHandler->handle( xRequest );
+ handleInteractionRequest( m_xContext, xRequest );
}
else
{
// select:
- cssu::Sequence< Reference< css::task::XInteractionContinuation > > conts(
+ cssu::Sequence< cssu::Reference< css::task::XInteractionContinuation > > conts(
xRequest->getContinuations() );
- Reference< css::task::XInteractionContinuation > const * pConts =
+ cssu::Reference< css::task::XInteractionContinuation > const * pConts =
conts.getConstArray();
sal_Int32 len = conts.getLength();
for ( sal_Int32 pos = 0; pos < len; ++pos )
{
if (approve) {
- Reference< css::task::XInteractionApprove > xInteractionApprove(
+ cssu::Reference< css::task::XInteractionApprove > xInteractionApprove(
pConts[ pos ], cssu::UNO_QUERY );
if (xInteractionApprove.is()) {
xInteractionApprove->select();
@@ -705,7 +702,7 @@ void UpdateCommandEnv::handle(
}
}
else if (abort) {
- Reference< css::task::XInteractionAbort > xInteractionAbort(
+ cssu::Reference< css::task::XInteractionAbort > xInteractionAbort(
pConts[ pos ], cssu::UNO_QUERY );
if (xInteractionAbort.is()) {
xInteractionAbort->select();
diff --git a/desktop/source/deployment/gui/makefile.mk b/desktop/source/deployment/gui/makefile.mk
index e9bbe65666be..e3211ab7f73f 100644
--- a/desktop/source/deployment/gui/makefile.mk
+++ b/desktop/source/deployment/gui/makefile.mk
@@ -8,7 +8,7 @@
#
# $RCSfile: makefile.mk,v $
#
-# $Revision: 1.20 $
+# $Revision: 1.20.30.1 $
#
# This file is part of OpenOffice.org.
#
@@ -50,11 +50,8 @@ DLLPRE =
SLOFILES = \
$(SLO)$/dp_gui_service.obj \
- $(SLO)$/dp_gui_dialog.obj \
$(SLO)$/dp_gui_dialog2.obj \
$(SLO)$/dp_gui_theextmgr.obj \
- $(SLO)$/dp_gui_treelb.obj \
- $(SLO)$/dp_gui_cmdenv.obj \
$(SLO)$/license_dialog.obj \
$(SLO)$/dp_gui_dependencydialog.obj \
$(SLO)$/dp_gui_thread.obj \
@@ -63,7 +60,6 @@ SLOFILES = \
$(SLO)$/dp_gui_updateinstalldialog.obj \
$(SLO)$/dp_gui_autoscrolledit.obj \
$(SLO)$/dp_gui_system.obj \
- $(SLO)$/dp_gui_addextensionqueue.obj \
$(SLO)$/dp_gui_extensioncmdqueue.obj \
$(SLO)$/descedit.obj