2010-10-27 13:11:31 +01:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2002-05-02 10:34:58 +00:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 05:51:28 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2002-05-02 10:34:58 +00:00
|
|
|
*
|
2010-02-12 15:01:35 +01:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2002-05-02 10:34:58 +00:00
|
|
|
*
|
2008-04-11 05:51:28 +00:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2002-05-02 10:34:58 +00:00
|
|
|
*
|
2008-04-11 05:51:28 +00:00
|
|
|
* This file is part of OpenOffice.org.
|
2002-05-02 10:34:58 +00:00
|
|
|
*
|
2008-04-11 05:51:28 +00:00
|
|
|
* 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.
|
2002-05-02 10:34:58 +00:00
|
|
|
*
|
2008-04-11 05:51:28 +00:00
|
|
|
* 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).
|
2002-05-02 10:34:58 +00:00
|
|
|
*
|
2008-04-11 05:51:28 +00:00
|
|
|
* 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.
|
2002-05-02 10:34:58 +00:00
|
|
|
*
|
|
|
|
************************************************************************/
|
|
|
|
|
|
|
|
#ifndef __FRAMEWORK_CLASSES_PROTOCOLHANDLERCACHE_HXX_
|
|
|
|
#define __FRAMEWORK_CLASSES_PROTOCOLHANDLERCACHE_HXX_
|
|
|
|
|
|
|
|
#include <general.h>
|
|
|
|
#include <stdtypes.h>
|
|
|
|
#include <macros/debug.hxx>
|
|
|
|
|
|
|
|
#include <com/sun/star/util/URL.hpp>
|
|
|
|
|
|
|
|
#include <unotools/configitem.hxx>
|
|
|
|
#include <rtl/ustring.hxx>
|
2010-04-16 23:01:28 +02:00
|
|
|
#include <fwidllapi.h>
|
2002-05-02 10:34:58 +00:00
|
|
|
|
|
|
|
namespace framework{
|
|
|
|
|
|
|
|
#define PACKAGENAME_PROTOCOLHANDLER DECLARE_ASCII("Office.ProtocolHandler" ) /// name of our configuration package
|
|
|
|
|
2012-02-01 14:42:58 +01:00
|
|
|
#define CFG_PATH_SEPERATOR DECLARE_ASCII("/" ) /// separator for configuration paths
|
2002-05-02 10:34:58 +00:00
|
|
|
|
|
|
|
#define SETNAME_HANDLER DECLARE_ASCII("HandlerSet" ) /// name of configuration set inside package
|
|
|
|
#define PROPERTY_PROTOCOLS DECLARE_ASCII("Protocols" ) /// properties of a protocol handler
|
|
|
|
|
|
|
|
//_________________________________________________________________________________________________________________
|
|
|
|
|
|
|
|
/**
|
|
|
|
Programmer can register his own services to handle different protocols.
|
|
|
|
Don't forget: It doesn't mean "handling of documents" ... these services could handle protocols ...
|
2006-06-19 09:49:37 +00:00
|
|
|
e.g. "mailto:", "file://", ".java:"
|
2002-05-02 10:34:58 +00:00
|
|
|
This struct holds the information about one such registered protocol handler.
|
|
|
|
A list of handler objects is defined as ProtocolHandlerHash. see below
|
|
|
|
*/
|
2010-04-16 23:01:28 +02:00
|
|
|
struct FWI_DLLPUBLIC ProtocolHandler
|
2002-05-02 10:34:58 +00:00
|
|
|
{
|
|
|
|
/* member */
|
|
|
|
public:
|
|
|
|
|
|
|
|
/// the uno implementation name of this handler
|
|
|
|
::rtl::OUString m_sUNOName;
|
|
|
|
/// list of URL pattern which defines the protocols which this handler is registered for
|
|
|
|
OUStringList m_lProtocols;
|
|
|
|
};
|
|
|
|
|
|
|
|
//_________________________________________________________________________________________________________________
|
|
|
|
|
|
|
|
/**
|
|
|
|
This hash use registered pattern of all protocol handlers as keys and provide her
|
|
|
|
uno implementation names as value. Overloading of the index operator makes it possible
|
|
|
|
to search for a key by using a full qualified URL on list of all possible pattern keys.
|
|
|
|
*/
|
2010-04-16 23:01:28 +02:00
|
|
|
class FWI_DLLPUBLIC PatternHash : public BaseHash< ::rtl::OUString >
|
2002-05-02 10:34:58 +00:00
|
|
|
{
|
|
|
|
/* interface */
|
|
|
|
public:
|
|
|
|
|
|
|
|
PatternHash::iterator findPatternKey( const ::rtl::OUString& sURL );
|
|
|
|
};
|
|
|
|
|
|
|
|
//_________________________________________________________________________________________________________________
|
|
|
|
|
|
|
|
/**
|
|
|
|
This hash holds protocol handler structs by her names.
|
|
|
|
*/
|
|
|
|
typedef BaseHash< ProtocolHandler > HandlerHash;
|
|
|
|
|
|
|
|
//_________________________________________________________________________________________________________________
|
|
|
|
|
|
|
|
/**
|
|
|
|
@short this hash makes it easy to find a protocol handler by using his uno implementation name.
|
|
|
|
@descr It holds two lists of informations:
|
|
|
|
- first holds all handler by her uno implementation names and
|
|
|
|
can be used to get her other properties
|
|
|
|
- another one maps her registered pattern to her uno names to
|
|
|
|
perform search on such data
|
|
|
|
But this lists a static for all instances of this class. So it's possible to
|
|
|
|
create new objects without opening configuration twice and free memory automaticly
|
|
|
|
if last object will gone.
|
|
|
|
|
|
|
|
@attention We implement a singleton concept - so we doesn't need any mutex member here.
|
|
|
|
Because to safe access on static member we must use a static global lock
|
|
|
|
here too.
|
|
|
|
|
|
|
|
@devstatus ready to use
|
|
|
|
@threadsafe yes
|
|
|
|
*/
|
2005-03-23 13:11:29 +00:00
|
|
|
|
|
|
|
class HandlerCFGAccess;
|
2010-04-16 23:01:28 +02:00
|
|
|
class FWI_DLLPUBLIC HandlerCache
|
2002-05-02 10:34:58 +00:00
|
|
|
{
|
|
|
|
/* member */
|
|
|
|
private:
|
|
|
|
|
|
|
|
/// list of all registered handler registered by her uno implementation names
|
|
|
|
static HandlerHash* m_pHandler;
|
|
|
|
/// maps URL pattern to handler names
|
|
|
|
static PatternHash* m_pPattern;
|
2005-03-23 13:11:29 +00:00
|
|
|
/// informs about config updates
|
|
|
|
static HandlerCFGAccess* m_pConfig;
|
2002-05-02 10:34:58 +00:00
|
|
|
/// ref count to construct/destruct internal member lists on demand by using singleton mechanism
|
|
|
|
static sal_Int32 m_nRefCount;
|
|
|
|
|
|
|
|
/* interface */
|
|
|
|
public:
|
|
|
|
|
|
|
|
HandlerCache();
|
|
|
|
virtual ~HandlerCache();
|
|
|
|
|
|
|
|
sal_Bool search( const ::rtl::OUString& sURL, ProtocolHandler* pReturn ) const;
|
|
|
|
sal_Bool search( const css::util::URL& aURL, ProtocolHandler* pReturn ) const;
|
2005-03-23 13:11:29 +00:00
|
|
|
|
|
|
|
void takeOver(HandlerHash* pHandler, PatternHash* pPattern);
|
2002-05-02 10:34:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
//_________________________________________________________________________________________________________________
|
|
|
|
|
|
|
|
/**
|
|
|
|
@short implements configuration access for handler configuration
|
|
|
|
@descr We use the ConfigItem mechanism to read/write values from/to configuration.
|
|
|
|
We set a data container pointer for filling or reading ... this class use it temp.
|
|
|
|
After successfuly calling of read(), we can use filled container directly or merge it with an existing one.
|
|
|
|
After successfuly calling of write() all values of given data container are flushed to our configuration -
|
|
|
|
but current implementation doesn't support writeing realy.
|
|
|
|
|
|
|
|
@base ::utl::ConfigItem
|
|
|
|
base mechanism for configuration access
|
|
|
|
|
|
|
|
@devstatus ready to use
|
|
|
|
@threadsafe no
|
|
|
|
*/
|
2010-04-16 23:01:28 +02:00
|
|
|
class FWI_DLLPUBLIC HandlerCFGAccess : public ::utl::ConfigItem
|
2002-05-02 10:34:58 +00:00
|
|
|
{
|
2005-03-23 13:11:29 +00:00
|
|
|
private:
|
|
|
|
HandlerCache* m_pCache;
|
|
|
|
|
2002-05-02 10:34:58 +00:00
|
|
|
/* interface */
|
|
|
|
public:
|
|
|
|
HandlerCFGAccess( const ::rtl::OUString& sPackage );
|
|
|
|
void read ( HandlerHash** ppHandler ,
|
|
|
|
PatternHash** ppPattern );
|
2005-03-23 13:11:29 +00:00
|
|
|
|
|
|
|
void setCache(HandlerCache* pCache) {m_pCache = pCache;};
|
|
|
|
virtual void Notify(const css::uno::Sequence< rtl::OUString >& lPropertyNames);
|
2009-10-16 00:05:16 +02:00
|
|
|
virtual void Commit();
|
2002-05-02 10:34:58 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace framework
|
|
|
|
|
|
|
|
#endif // #ifndef __FRAMEWORK_CLASSES_PROTOCOLHANDLERCACHE_HXX_
|
2010-10-27 13:11:31 +01:00
|
|
|
|
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|