summaryrefslogtreecommitdiffstats
path: root/kcontrol/ebrowsing/plugins/shorturi/kshorturifilter.h
blob: 33ba20cadfc9c7d9afce610a32d99aba5e5c1dbc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
/*
    kshorturifilter.h

    This file is part of the KDE project
    Copyright (C) 2000 Dawit Alemayehu <adawit@kde.org>
    Copyright (C) 2000 Malte Starostik <starosti@zedat.fu-berlin.de>

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program 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 General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/

#ifndef _KSHORTURIFILTER_H_
#define _KSHORTURIFILTER_H_

#include <dcopobject.h>
#include <kgenericfactory.h>
#include <kurifilter.h>

class TDEInstance;

/**
* This is short URL filter class.
*
* @short A filter that converts short URLs into fully qualified ones.
*
* @author Dawit Alemayehu <adawit@kde.org>
* @author Malte Starostik <starosti@zedat.fu-berlin.de>
*/
class KShortURIFilter : public KURIFilterPlugin , public DCOPObject
{
    K_DCOP
    Q_OBJECT
public:

    /**
     * Creates a Short URI filter object
     *
     * @param parent the parent of this class.
     * @param name the internal name for this object.
     */
    KShortURIFilter( TQObject *parent = 0, const char *name = 0,
	             const TQStringList &args = TQStringList() );

    /**
     * Destructor
     */
    virtual ~KShortURIFilter() {};

    /**
     * Converts short URIs into fully qualified valid URIs
     * whenever possible.
     *
     * Parses any given invalid URI to determine whether it
     * is a known short URI and converts it to its fully
     * qualified version.
     *
     * @param data the data to be filtered
     * @return true if the url has been filtered
     */
    virtual bool filterURI( KURIFilterData &data ) const;

    /**
     * Returns the name of the config module for
     * this plugin.
     *
     * @return the name of the config module.
     */
    virtual TQString configName() const;

    /**
     * Returns an instance of the module used to configure
     * this object.
         *
         * @return the config module
         */
    virtual TDECModule* configModule( TQWidget*, const char* ) const;

public:
k_dcop:
    virtual void configure();

private:

    struct URLHint
    {
        URLHint() {}
        URLHint( TQString r, TQString p, 
                 KURIFilterData::URITypes t = KURIFilterData::NET_PROTOCOL )
               : regexp(r), prepend(p), type(t) {}
        TQString regexp; // if this matches, then...
        TQString prepend; // ...prepend this to the url
        KURIFilterData::URITypes type;
    };

    TQValueList<URLHint> m_urlHints;
    TQString m_strDefaultProtocol;
    bool m_bVerbose;
};

#endif