1 /* This file is part of the KDE project
2 Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
3 Copyright (C) 2000 Yves Arrouye <yves@realnames.com>
4 Copyright (C) 2002, 2003 Dawit Alemayehu <adawit@kde.org>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "kuriikwsfilter.h"
25 #include <QtDBus/QtDBus>
33 #include "kuriikwsfiltereng.h"
36 * IMPORTANT: If you change anything here, please run the regression test
37 * ../tests/kurifiltertest
40 K_PLUGIN_FACTORY(KAutoWebSearchFactory
, registerPlugin
<KAutoWebSearch
>();)
41 K_EXPORT_PLUGIN(KAutoWebSearchFactory("kcmkurifilt"))
43 KAutoWebSearch::KAutoWebSearch(QObject
*parent
, const QVariantList
&)
44 :KUriFilterPlugin( "kuriikwsfilter", parent
)
46 KGlobal::locale()->insertCatalog("kurifilter");
47 QDBusConnection::sessionBus().connect(QString(), QString(), "org.kde.KUriFilterPlugin",
48 "configure", this, SLOT(configure()));
51 KAutoWebSearch::~KAutoWebSearch()
55 void KAutoWebSearch::configure()
57 if ( KURISearchFilterEngine::self()->verbose() )
58 kDebug() << "KAutoWebSearch::configure: Config reload requested...";
60 KURISearchFilterEngine::self()->loadConfig();
63 bool KAutoWebSearch::filterUri( KUriFilterData
&data
) const
65 if( data
.uriType() != KUriFilterData::Unknown
)
68 if (KURISearchFilterEngine::self()->verbose())
69 kDebug() << "KAutoWebSearch::filterURI: '" << data
.uri().url() << "'";
72 if ( u
.pass().isEmpty() )
74 QString result
= KURISearchFilterEngine::self()->autoWebSearchQuery( data
.typedString() );
75 if( !result
.isEmpty() )
77 if ( KURISearchFilterEngine::self()->verbose() )
78 kDebug () << "Filtered URL: " << result
;
80 setFilteredUri( data
, KUrl( result
) );
81 setUriType( data
, KUriFilterData::NetProtocol
);
88 #include "kuriikwsfilter.moc"