incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m..@apache.org
Subject svn commit: r1172103 - in /incubator/ooo/trunk/main/desktop/source/deployment: gui/ manager/ registry/
Date Sat, 17 Sep 2011 22:37:06 GMT
Author: mst
Date: Sat Sep 17 22:37:06 2011
New Revision: 1172103

URL: http://svn.apache.org/viewvc?rev=1172103&view=rev
Log:
imported patch package_eventlistener.patch

# HG changeset patch
# User Juergen Schmidt <jsc@openoffice.org>
# Date 1302787515 -7200
# Node ID 7386a13a033052b446b61a3ac3e2e0dc63c0f04f
# Parent  373e7cdd07e7b5fd5c1fb5eb0951a6f29981f906

Modified:
    incubator/ooo/trunk/main/desktop/source/deployment/gui/dp_gui_dialog2.cxx
    incubator/ooo/trunk/main/desktop/source/deployment/gui/dp_gui_extlistbox.cxx   (contents,
props changed)
    incubator/ooo/trunk/main/desktop/source/deployment/gui/dp_gui_extlistbox.hxx   (contents,
props changed)
    incubator/ooo/trunk/main/desktop/source/deployment/manager/dp_extensionmanager.cxx
    incubator/ooo/trunk/main/desktop/source/deployment/manager/dp_manager.cxx
    incubator/ooo/trunk/main/desktop/source/deployment/manager/dp_managerfac.cxx
    incubator/ooo/trunk/main/desktop/source/deployment/registry/dp_backend.cxx

Modified: incubator/ooo/trunk/main/desktop/source/deployment/gui/dp_gui_dialog2.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/desktop/source/deployment/gui/dp_gui_dialog2.cxx?rev=1172103&r1=1172102&r2=1172103&view=diff
==============================================================================
--- incubator/ooo/trunk/main/desktop/source/deployment/gui/dp_gui_dialog2.cxx (original)
+++ incubator/ooo/trunk/main/desktop/source/deployment/gui/dp_gui_dialog2.cxx Sat Sep 17 22:37:06
2011
@@ -1633,6 +1633,13 @@ void UpdateRequiredDialog::Resize()
 // VCL::Dialog
 short UpdateRequiredDialog::Execute()
 {
+    //ToDo
+    //I believe m_bHasLockedEntries was used to prevent showing extensions which cannot
+    //be disabled because they are in a read only repository. However, disabling extensions
+    //is now always possible because the registration data of all repositories 
+    //are in the user installation.
+    //Therfore all extensions could be displayed and all the handling around m_bHasLockedEntries
+    //could be removed.
     if ( m_bHasLockedEntries )
     {
         // Set other text, disable update btn, remove not shared entries from list;
@@ -1696,21 +1703,15 @@ bool UpdateRequiredDialog::isEnabled( co
 }
 
 //------------------------------------------------------------------------------
+//Checks the dependencies no matter if the extension is enabled or disabled!
 bool UpdateRequiredDialog::checkDependencies( const uno::Reference< deployment::XPackage
> &xPackage ) const
 {
-    if ( isEnabled( xPackage ) )
-    {
-        bool bDependenciesValid = false;
-        try {
-            bDependenciesValid = xPackage->checkDependencies( uno::Reference< ucb::XCommandEnvironment
>() );
-        }
-        catch ( deployment::DeploymentException & ) {}
-        if ( ! bDependenciesValid )
-        {
-            return false;
-        }
+    bool bDependenciesValid = false;
+    try {
+        bDependenciesValid = xPackage->checkDependencies( uno::Reference< ucb::XCommandEnvironment
>() );
     }
-    return true;
+    catch ( deployment::DeploymentException & ) {}
+    return bDependenciesValid;
 }
 
 //------------------------------------------------------------------------------
@@ -1724,7 +1725,7 @@ bool UpdateRequiredDialog::hasActiveEntr
     {
         TEntry_Impl pEntry = m_pExtensionBox->GetEntryData( nIndex );
         
-        if ( !checkDependencies( pEntry->m_xPackage ) )
+        if ( isEnabled(pEntry->m_xPackage) && !checkDependencies( pEntry->m_xPackage
) )
         {
             bRet = true;
             break;

Modified: incubator/ooo/trunk/main/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/desktop/source/deployment/gui/dp_gui_extlistbox.cxx?rev=1172103&r1=1172102&r2=1172103&view=diff
==============================================================================
--- incubator/ooo/trunk/main/desktop/source/deployment/gui/dp_gui_extlistbox.cxx (original)
+++ incubator/ooo/trunk/main/desktop/source/deployment/gui/dp_gui_extlistbox.cxx Sat Sep 17
22:37:06 2011
@@ -40,7 +40,7 @@
 #include "com/sun/star/i18n/CollatorOptions.hpp"
 #include "com/sun/star/deployment/DependencyException.hpp"
 #include "com/sun/star/deployment/DeploymentException.hpp"
-
+#include "cppuhelper/weakref.hxx"
 
 #define OUSTR(x) ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM(x) )
 
@@ -52,6 +52,25 @@ using namespace ::com::sun::star;
 
 namespace dp_gui {
 
+namespace {
+
+struct FindWeakRef
+{
+    const uno::Reference<deployment::XPackage> m_extension;
+    
+    FindWeakRef( uno::Reference<deployment::XPackage> const & ext): m_extension(ext)
{}
+    bool operator () (uno::WeakReference< deployment::XPackage >  const & ref);
+};
+
+bool FindWeakRef::operator () (uno::WeakReference< deployment::XPackage >  const &
ref)
+{
+    const uno::Reference<deployment::XPackage> ext(ref);
+    if (ext == m_extension)
+        return true;
+    return false;
+}
+
+} // end namespace
 //------------------------------------------------------------------------------
 //                          struct Entry_Impl
 //------------------------------------------------------------------------------
@@ -960,6 +979,35 @@ bool ExtensionBox_Impl::FindEntryPos( co
     }
 }
 
+void ExtensionBox_Impl::cleanVecListenerAdded()
+{
+    typedef ::std::vector<uno::WeakReference<deployment::XPackage> >::iterator
IT;
+    IT i = m_vListenerAdded.begin();
+    while( i != m_vListenerAdded.end())
+    {
+        const uno::Reference<deployment::XPackage> hardRef(*i);
+        if (!hardRef.is())
+            i = m_vListenerAdded.erase(i);
+        else
+            ++i;
+    }
+}
+
+void ExtensionBox_Impl::addEventListenerOnce(
+    uno::Reference<deployment::XPackage > const & extension)
+{
+    //make sure to only add the listener once
+    cleanVecListenerAdded();
+    if ( ::std::find_if(m_vListenerAdded.begin(), m_vListenerAdded.end(),
+                        FindWeakRef(extension))
+         == m_vListenerAdded.end())
+    {
+        extension->addEventListener( uno::Reference< lang::XEventListener > (
+                                         m_xRemoveListener, uno::UNO_QUERY ) );
+        m_vListenerAdded.push_back(extension);
+    }
+}
+
 //------------------------------------------------------------------------------
 long ExtensionBox_Impl::addEntry( const uno::Reference< deployment::XPackage > &xPackage,
                                   bool bLicenseMissing )
@@ -974,17 +1022,17 @@ long ExtensionBox_Impl::addEntry( const 
     if ( ! pEntry->m_sTitle.Len() )
         return 0;
 
-    xPackage->addEventListener( uno::Reference< lang::XEventListener > ( m_xRemoveListener,
uno::UNO_QUERY ) );
-
     ::osl::ClearableMutexGuard guard(m_entriesMutex);
     if ( m_vEntries.empty() )
     {
+        addEventListenerOnce(xPackage);
         m_vEntries.push_back( pEntry );
     }
     else
     {
         if ( !FindEntryPos( pEntry, 0, m_vEntries.size()-1, nPos ) )
         {
+            addEventListenerOnce(xPackage);
             m_vEntries.insert( m_vEntries.begin()+nPos, pEntry );
         }
         else if ( !m_bInCheckMode )
@@ -1047,9 +1095,14 @@ void ExtensionBox_Impl::updateEntry( con
 }
 
 //------------------------------------------------------------------------------
+//This function is also called as a result of removing an extension.
+//see PackageManagerImpl::removePackage
+//The gui is a registered as listener on the package. Removing it will cause the 
+//listeners to be notified an then this function is called. At this moment xPackage
+//is in the disposing state and all calls on it may result in a DisposedException.
 void ExtensionBox_Impl::removeEntry( const uno::Reference< deployment::XPackage > &xPackage
)
 {
-    if ( ! m_bInDelete )
+   if ( ! m_bInDelete )
     {
         ::osl::ClearableMutexGuard aGuard( m_entriesMutex );
 
@@ -1066,8 +1119,10 @@ void ExtensionBox_Impl::removeEntry( con
                 // the entry will be moved into the m_vRemovedEntries list which will be
                 // cleared on the next paint event
                 m_vRemovedEntries.push_back( *iIndex );
+                (*iIndex)->m_xPackage->removeEventListener(
+                    uno::Reference<lang::XEventListener>(m_xRemoveListener, uno::UNO_QUERY));
                 m_vEntries.erase( iIndex );
-
+                
                 m_bNeedsRecalc = true;
 
                 if ( IsReallyVisible() )

Propchange: incubator/ooo/trunk/main/desktop/source/deployment/gui/dp_gui_extlistbox.cxx
------------------------------------------------------------------------------
    svn:executable = *

Modified: incubator/ooo/trunk/main/desktop/source/deployment/gui/dp_gui_extlistbox.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/desktop/source/deployment/gui/dp_gui_extlistbox.hxx?rev=1172103&r1=1172102&r2=1172103&view=diff
==============================================================================
--- incubator/ooo/trunk/main/desktop/source/deployment/gui/dp_gui_extlistbox.hxx (original)
+++ incubator/ooo/trunk/main/desktop/source/deployment/gui/dp_gui_extlistbox.hxx Sat Sep 17
22:37:06 2011
@@ -165,6 +165,14 @@ class ExtensionBox_Impl : public ::svt::
 	::com::sun::star::lang::Locale    *m_pLocale;
 	CollatorWrapper *m_pCollator;
 
+    //Holds weak references to extensions to which is we have added an XEventListener
+    std::vector< ::com::sun::star::uno::WeakReference<
+        ::com::sun::star::deployment::XPackage> > m_vListenerAdded;
+    //Removes the dead weak references from m_vListenerAdded
+    void cleanVecListenerAdded();
+    void addEventListenerOnce( ::com::sun::star::uno::Reference<
+                               ::com::sun::star::deployment::XPackage> const & extension);
+    
     void            CalcActiveHeight( const long nPos );
     long            GetTotalHeight() const;
     void            SetupScrollBar();

Propchange: incubator/ooo/trunk/main/desktop/source/deployment/gui/dp_gui_extlistbox.hxx
------------------------------------------------------------------------------
    svn:executable = *

Modified: incubator/ooo/trunk/main/desktop/source/deployment/manager/dp_extensionmanager.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/desktop/source/deployment/manager/dp_extensionmanager.cxx?rev=1172103&r1=1172102&r2=1172103&view=diff
==============================================================================
--- incubator/ooo/trunk/main/desktop/source/deployment/manager/dp_extensionmanager.cxx (original)
+++ incubator/ooo/trunk/main/desktop/source/deployment/manager/dp_extensionmanager.cxx Sat
Sep 17 22:37:06 2011
@@ -239,6 +239,10 @@ ExtensionManager::getPackageManager(::rt
         xPackageManager = getSharedRepository();
     else if (repository.equals(OUSTR("bundled")))
         xPackageManager = getBundledRepository();
+    else if (repository.equals(OUSTR("tmp")))
+        xPackageManager = getTmpRepository();
+    else if (repository.equals(OUSTR("bak")))
+        xPackageManager = getBakRepository();
     else
         throw lang::IllegalArgumentException(
             OUSTR("No valid repository name provided."), 

Modified: incubator/ooo/trunk/main/desktop/source/deployment/manager/dp_manager.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/desktop/source/deployment/manager/dp_manager.cxx?rev=1172103&r1=1172102&r2=1172103&view=diff
==============================================================================
--- incubator/ooo/trunk/main/desktop/source/deployment/manager/dp_manager.cxx (original)
+++ incubator/ooo/trunk/main/desktop/source/deployment/manager/dp_manager.cxx Sat Sep 17 22:37:06
2011
@@ -536,7 +536,8 @@ void PackageManagerImpl::disposing()
 //______________________________________________________________________________
 void PackageManagerImpl::dispose() throw (RuntimeException)
 {
-    check();
+    //Do not call check here. We must not throw an exception here if the object 
+    //is being disposed or is already disposed. See com.sun.star.lang.XComponent
     WeakComponentImplHelperBase::dispose();
 }
 
@@ -544,7 +545,8 @@ void PackageManagerImpl::dispose() throw
 void PackageManagerImpl::addEventListener(
     Reference<lang::XEventListener> const & xListener ) throw (RuntimeException)
 {
-    check();
+    //Do not call check here. We must not throw an exception here if the object 
+    //is being disposed or is already disposed. See com.sun.star.lang.XComponent
     WeakComponentImplHelperBase::addEventListener( xListener );
 }
 
@@ -552,7 +554,8 @@ void PackageManagerImpl::addEventListene
 void PackageManagerImpl::removeEventListener(
     Reference<lang::XEventListener> const & xListener ) throw (RuntimeException)
 {
-    check();
+    //Do not call check here. We must not throw an exception here if the object 
+    //is being disposed or is already disposed. See com.sun.star.lang.XComponent
     WeakComponentImplHelperBase::removeEventListener( xListener );
 }
 

Modified: incubator/ooo/trunk/main/desktop/source/deployment/manager/dp_managerfac.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/desktop/source/deployment/manager/dp_managerfac.cxx?rev=1172103&r1=1172102&r2=1172103&view=diff
==============================================================================
--- incubator/ooo/trunk/main/desktop/source/deployment/manager/dp_managerfac.cxx (original)
+++ incubator/ooo/trunk/main/desktop/source/deployment/manager/dp_managerfac.cxx Sat Sep 17
22:37:06 2011
@@ -54,6 +54,8 @@ class PackageManagerFactoryImpl : privat
     Reference<deployment::XPackageManager> m_xUserMgr;
     Reference<deployment::XPackageManager> m_xSharedMgr;
     Reference<deployment::XPackageManager> m_xBundledMgr;
+    Reference<deployment::XPackageManager> m_xTmpMgr;
+    Reference<deployment::XPackageManager> m_xBakMgr;
     typedef ::std::hash_map<
         OUString, WeakReference<deployment::XPackageManager>,
         ::rtl::OUStringHash > t_string2weakref;
@@ -143,6 +145,8 @@ void PackageManagerFactoryImpl::disposin
     m_xUserMgr.clear();
     m_xSharedMgr.clear();
     m_xBundledMgr.clear();
+    m_xTmpMgr.clear();
+    m_xBakMgr.clear();
 }
 
 // XPackageManagerFactory
@@ -176,6 +180,10 @@ PackageManagerFactoryImpl::getPackageMan
             m_xSharedMgr = xRet;
         else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bundled") ))
             m_xBundledMgr = xRet;
+        else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("tmp") ))
+            m_xTmpMgr = xRet;
+        else if (context.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM("bak") ))
+            m_xBakMgr = xRet;
     }
     else
     {

Modified: incubator/ooo/trunk/main/desktop/source/deployment/registry/dp_backend.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/desktop/source/deployment/registry/dp_backend.cxx?rev=1172103&r1=1172102&r2=1172103&view=diff
==============================================================================
--- incubator/ooo/trunk/main/desktop/source/deployment/registry/dp_backend.cxx (original)
+++ incubator/ooo/trunk/main/desktop/source/deployment/registry/dp_backend.cxx Sat Sep 17
22:37:06 2011
@@ -373,7 +373,8 @@ void Package::check() const
 //______________________________________________________________________________
 void Package::dispose() throw (RuntimeException)
 {
-    check();
+    //Do not call check here. We must not throw an exception here if the object 
+    //is being disposed or is already disposed. See com.sun.star.lang.XComponent
     WeakComponentImplHelperBase::dispose();
 }
 
@@ -381,7 +382,8 @@ void Package::dispose() throw (RuntimeEx
 void Package::addEventListener(
     Reference<lang::XEventListener> const & xListener ) throw (RuntimeException)
 {
-    check();
+    //Do not call check here. We must not throw an exception here if the object 
+    //is being disposed or is already disposed. See com.sun.star.lang.XComponent
     WeakComponentImplHelperBase::addEventListener( xListener );
 }
 
@@ -389,7 +391,8 @@ void Package::addEventListener(
 void Package::removeEventListener(
     Reference<lang::XEventListener> const & xListener ) throw (RuntimeException)
 {
-    check();
+    //Do not call check here. We must not throw an exception here if the object 
+    //is being disposed or is already disposed. See com.sun.star.lang.XComponent
     WeakComponentImplHelperBase::removeEventListener( xListener );
 }
 



Mime
View raw message