2000-09-18 10:18:56 -05:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
|
|
|
* $RCSfile: confevents.cxx,v $
|
|
|
|
*
|
2002-02-21 07:11:15 -06:00
|
|
|
* $Revision: 1.6 $
|
2000-09-18 10:18:56 -05:00
|
|
|
*
|
2002-02-21 07:11:15 -06:00
|
|
|
* last change: $Author: hr $ $Date: 2002-02-21 14:07:21 $
|
2000-09-18 10:18:56 -05:00
|
|
|
*
|
|
|
|
* The Contents of this file are made available subject to the terms of
|
|
|
|
* either of the following licenses
|
|
|
|
*
|
|
|
|
* - GNU Lesser General Public License Version 2.1
|
|
|
|
* - Sun Industry Standards Source License Version 1.1
|
|
|
|
*
|
|
|
|
* Sun Microsystems Inc., October, 2000
|
|
|
|
*
|
|
|
|
* GNU Lesser General Public License Version 2.1
|
|
|
|
* =============================================
|
|
|
|
* Copyright 2000 by Sun Microsystems, Inc.
|
|
|
|
* 901 San Antonio Road, Palo Alto, CA 94303, USA
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License version 2.1, as published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This library 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 for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston,
|
|
|
|
* MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* Sun Industry Standards Source License Version 1.1
|
|
|
|
* =================================================
|
|
|
|
* The contents of this file are subject to the Sun Industry Standards
|
|
|
|
* Source License Version 1.1 (the "License"); You may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of the
|
|
|
|
* License at http://www.openoffice.org/license.html.
|
|
|
|
*
|
|
|
|
* Software provided under this License is provided on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING,
|
|
|
|
* WITHOUT LIMITATION, WARRANTIES THAT THE SOFTWARE IS FREE OF DEFECTS,
|
|
|
|
* MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE, OR NON-INFRINGING.
|
|
|
|
* See the License for the specific provisions governing your rights and
|
|
|
|
* obligations concerning the Software.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is: Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* Copyright: 2000 by Sun Microsystems, Inc.
|
|
|
|
*
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): _______________________________________
|
|
|
|
*
|
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2002-02-21 07:11:15 -06:00
|
|
|
#include <string.h>
|
2000-09-18 10:18:56 -05:00
|
|
|
#include "confevents.hxx"
|
|
|
|
|
|
|
|
#ifndef CONFIGMGR_API_EVENTHELPERS_HXX_
|
|
|
|
#include "confeventhelpers.hxx"
|
|
|
|
#endif
|
2001-07-05 11:05:51 -05:00
|
|
|
#ifndef CONFIGMGR_TREECHANGELIST_HXX
|
|
|
|
#include "treechangelist.hxx"
|
|
|
|
#endif
|
|
|
|
|
2000-09-18 10:18:56 -05:00
|
|
|
#ifndef _OSL_DIAGNOSE_H_
|
|
|
|
#include <osl/diagnose.h>
|
|
|
|
#endif
|
|
|
|
namespace configmgr
|
|
|
|
{
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
using internal::ConfigChangesBroadcasterImpl;
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2000-12-04 02:25:10 -06:00
|
|
|
class ConfigChangeBroadcastHelper // broadcasts changes for a given set of options
|
2000-09-18 10:18:56 -05:00
|
|
|
{
|
2000-12-04 02:25:10 -06:00
|
|
|
ConfigChangesBroadcasterImpl m_changes;
|
2000-09-18 10:18:56 -05:00
|
|
|
public:
|
2000-12-04 02:25:10 -06:00
|
|
|
ConfigChangeBroadcastHelper();
|
|
|
|
~ConfigChangeBroadcastHelper();
|
2000-09-18 10:18:56 -05:00
|
|
|
|
2002-02-11 06:47:56 -06:00
|
|
|
void broadcast(memory::Accessor const& _aChangedDataAccessor, TreeChangeList const& anUpdate, sal_Bool bError, IConfigBroadcaster* pSource);
|
2000-09-18 10:18:56 -05:00
|
|
|
|
2000-12-04 02:25:10 -06:00
|
|
|
public:
|
|
|
|
// IConfigBroadcaster implementation helper
|
2001-07-05 11:05:51 -05:00
|
|
|
void addListener(AbsolutePath const& aName, INodeListenerRef const& );
|
2000-12-08 04:19:25 -06:00
|
|
|
void removeListener(INodeListenerRef const&);
|
2000-09-18 10:18:56 -05:00
|
|
|
|
2000-12-04 02:25:10 -06:00
|
|
|
void dispose(IConfigBroadcaster* pSource);
|
|
|
|
};
|
2000-09-18 10:18:56 -05:00
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2000-12-04 02:25:10 -06:00
|
|
|
ConfigChangeBroadcaster::ConfigChangeBroadcaster()
|
2000-09-18 10:18:56 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2000-12-04 02:25:10 -06:00
|
|
|
ConfigChangeBroadcaster::~ConfigChangeBroadcaster()
|
2000-09-18 10:18:56 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2000-12-04 02:25:10 -06:00
|
|
|
ConfigChangeBroadcastHelper::ConfigChangeBroadcastHelper()
|
|
|
|
: m_changes()
|
2000-09-18 10:18:56 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2000-12-04 02:25:10 -06:00
|
|
|
ConfigChangeBroadcastHelper::~ConfigChangeBroadcastHelper()
|
2000-09-18 10:18:56 -05:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2000-12-04 02:25:10 -06:00
|
|
|
void ConfigChangeBroadcastHelper::dispose(IConfigBroadcaster* pSource)
|
2000-09-18 10:18:56 -05:00
|
|
|
{
|
2000-12-04 02:25:10 -06:00
|
|
|
m_changes.disposing(pSource);
|
2000-09-18 10:18:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2000-12-04 02:25:10 -06:00
|
|
|
// IConfigBroadcaster implementation
|
2001-07-05 11:05:51 -05:00
|
|
|
void ConfigChangeBroadcaster::addListener(AbsolutePath const& aName, const vos::ORef < OOptions >& _xOptions, INodeListenerRef const& pHandler)
|
2000-09-18 10:18:56 -05:00
|
|
|
{
|
2000-12-04 02:25:10 -06:00
|
|
|
if (ConfigChangeBroadcastHelper* pHelper = getBroadcastHelper(_xOptions,true))
|
2000-09-18 10:18:56 -05:00
|
|
|
{
|
2000-12-04 02:25:10 -06:00
|
|
|
pHelper->addListener(aName, pHandler);
|
2000-09-18 10:18:56 -05:00
|
|
|
}
|
|
|
|
else
|
2000-12-04 02:25:10 -06:00
|
|
|
OSL_ASSERT(false);
|
2000-09-18 10:18:56 -05:00
|
|
|
}
|
|
|
|
|
2000-12-08 04:19:25 -06:00
|
|
|
void ConfigChangeBroadcaster::removeListener(const vos::ORef < OOptions >& _xOptions, INodeListenerRef const& pHandler)
|
2000-09-18 10:18:56 -05:00
|
|
|
{
|
2000-12-04 02:25:10 -06:00
|
|
|
if (ConfigChangeBroadcastHelper* pHelper = getBroadcastHelper(_xOptions,false))
|
2000-09-18 10:18:56 -05:00
|
|
|
{
|
2000-12-04 02:25:10 -06:00
|
|
|
pHelper->removeListener( pHandler);
|
2000-09-18 10:18:56 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-12-08 04:19:25 -06:00
|
|
|
/* void ConfigChangeBroadcaster::removeNode(OUString const& aPath, const vos::ORef < OOptions >& _xOptions, bool bRemovedFromModel)
|
2000-09-18 10:18:56 -05:00
|
|
|
{
|
2000-12-04 02:25:10 -06:00
|
|
|
if (ConfigChangeBroadcastHelper* pHelper = getBroadcastHelper(_xOptions,false))
|
2000-09-18 10:18:56 -05:00
|
|
|
{
|
2000-12-04 02:25:10 -06:00
|
|
|
pHelper->removeNode(aPath, bRemovedFromModel, this);
|
2000-09-18 10:18:56 -05:00
|
|
|
}
|
|
|
|
}
|
2000-12-08 04:19:25 -06:00
|
|
|
*/
|
2000-09-18 10:18:56 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2002-02-11 06:47:56 -06:00
|
|
|
void ConfigChangeBroadcaster::fireChanges(memory::Accessor const& _aChangedDataAccessor, TreeChangeList const& rList_, sal_Bool bError_)
|
2000-09-18 10:18:56 -05:00
|
|
|
{
|
2001-07-05 11:05:51 -05:00
|
|
|
if (ConfigChangeBroadcastHelper* pHelper = getBroadcastHelper(rList_.getOptions(),false))
|
2000-09-18 10:18:56 -05:00
|
|
|
{
|
2002-02-11 06:47:56 -06:00
|
|
|
pHelper->broadcast(_aChangedDataAccessor, rList_, bError_, this);
|
2000-09-18 10:18:56 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2000-12-04 02:25:10 -06:00
|
|
|
ConfigChangeBroadcastHelper* ConfigChangeBroadcaster::newBroadcastHelper()
|
2000-09-18 10:18:56 -05:00
|
|
|
{
|
2000-12-04 02:25:10 -06:00
|
|
|
return new ConfigChangeBroadcastHelper();
|
2000-09-18 10:18:56 -05:00
|
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2000-12-04 02:25:10 -06:00
|
|
|
void ConfigChangeBroadcaster::disposeBroadcastHelper(ConfigChangeBroadcastHelper* pHelper)
|
2000-09-18 10:18:56 -05:00
|
|
|
{
|
2000-12-04 02:25:10 -06:00
|
|
|
if (pHelper)
|
2000-09-18 10:18:56 -05:00
|
|
|
{
|
2000-12-04 02:25:10 -06:00
|
|
|
pHelper->dispose(this);
|
|
|
|
delete pHelper;
|
2000-09-18 10:18:56 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2000-12-04 02:25:10 -06:00
|
|
|
// IConfigBroadcaster implementation help
|
2001-07-05 11:05:51 -05:00
|
|
|
void ConfigChangeBroadcastHelper::addListener(AbsolutePath const& aName, INodeListenerRef const& pHandler)
|
2000-09-18 10:18:56 -05:00
|
|
|
{
|
2000-12-04 02:25:10 -06:00
|
|
|
m_changes.add(aName, pHandler);
|
2000-09-18 10:18:56 -05:00
|
|
|
}
|
|
|
|
|
2000-12-08 04:19:25 -06:00
|
|
|
void ConfigChangeBroadcastHelper::removeListener(INodeListenerRef const& pHandler)
|
2000-09-18 10:18:56 -05:00
|
|
|
{
|
2000-12-04 02:25:10 -06:00
|
|
|
m_changes.remove(pHandler);
|
2000-09-18 10:18:56 -05:00
|
|
|
}
|
|
|
|
|
2000-12-08 04:19:25 -06:00
|
|
|
/* void ConfigChangeBroadcastHelper::removeNode(OUString const& aPath, bool bRemovedFromModel, IConfigBroadcaster* pSource)
|
2000-09-18 10:18:56 -05:00
|
|
|
{
|
2000-12-04 02:25:10 -06:00
|
|
|
m_changes.removed(aPath, bRemovedFromModel,pSource);
|
2000-09-18 10:18:56 -05:00
|
|
|
}
|
2000-12-08 04:19:25 -06:00
|
|
|
*/
|
2000-12-04 02:25:10 -06:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2002-02-11 06:47:56 -06:00
|
|
|
void ConfigChangeBroadcastHelper::broadcast(memory::Accessor const& _aChangedDataAccessor, TreeChangeList const& anUpdate, sal_Bool bError, IConfigBroadcaster* pSource)
|
2000-09-18 10:18:56 -05:00
|
|
|
{
|
2002-02-11 06:47:56 -06:00
|
|
|
m_changes.dispatch(_aChangedDataAccessor, anUpdate, bError, pSource);
|
2000-09-18 10:18:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
|
|
|
|
|