• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

messageviewer

  • sources
  • kde-4.12
  • kdepim
  • messageviewer
  • adblock
adblockrule.cpp
Go to the documentation of this file.
1 /* ============================================================
2  *
3  * This file is a part of the rekonq project
4  * Copyright (c) 2013 Montel Laurent <montel@kde.org>
5  * based on code from rekonq
6  * Copyright (c) 2009 by Zsombor Gegesy <gzsombor@gmail.com>
7  * Copyright (c) 2009 by Benjamin C. Meyer <ben@meyerhome.net>
8  * Copyright (C) 2010-2012 by Andrea Diamantini <adjam7 at gmail dot com>
9  *
10  *
11  * This program is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU General Public License as
13  * published by the Free Software Foundation; either version 2 of
14  * the License or (at your option) version 3 or any later version
15  * accepted by the membership of KDE e.V. (or its successor approved
16  * by the membership of KDE e.V.), which shall act as a proxy
17  * defined in Section 14 of version 3 of the license.
18  *
19  * This program is distributed in the hope that it will be useful,
20  * but WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  * GNU General Public License for more details.
23  *
24  * You should have received a copy of the GNU General Public License
25  * along with this program. If not, see <http://www.gnu.org/licenses/>.
26  *
27  * ============================================================ */
28 
29 
30 // Self Includes
31 #include "adblockrule.h"
32 
33 // Local Includes
34 #include "adblockrulefallbackimpl.h"
35 #include "adblockrulenullimpl.h"
36 #include "adblockruletextmatchimpl.h"
37 
38 #include <KDebug>
39 
40 using namespace MessageViewer;
41 AdBlockRule::AdBlockRule(const QString &filter)
42 {
43  switch (AdBlockRule::ruleType(filter))
44  {
45  case TextRule:
46  m_implementation = QSharedPointer<AdBlockRuleImpl>(new AdBlockRuleTextMatchImpl(filter));
47  break;
48 
49  case FallbackRule:
50  m_implementation = QSharedPointer<AdBlockRuleImpl>(new AdBlockRuleFallbackImpl(filter));
51  break;
52 
53  case NullRule:
54  default:
55  m_implementation = QSharedPointer<AdBlockRuleImpl>(new AdBlockRuleNullImpl(filter));
56  break;
57  }
58 }
59 
60 
61 RuleTypes AdBlockRule::ruleType(const QString &filter)
62 {
63  if (AdBlockRuleTextMatchImpl::isTextMatchFilter(filter))
64  return TextRule;
65 
66  if (AdBlockRuleNullImpl::isNullFilter(filter))
67  return NullRule;
68 
69  return FallbackRule;
70 }
71 
72 bool AdBlockRule::match(const QNetworkRequest &request, const QString &encodedUrl, const QString &encodedUrlLowerCase) const
73 {
74  Q_ASSERT(encodedUrl.toLower() == encodedUrlLowerCase);
75  const bool b = m_implementation->match(request, encodedUrl, encodedUrlLowerCase);
76  if (b) {
77  kDebug() << m_implementation->ruleType() << ": rule string = " << m_implementation->ruleString();
78  }
79  return b;
80 }
MessageViewer::AdBlockRule::match
bool match(const QNetworkRequest &request, const QString &encodedUrl, const QString &encodedUrlLowerCase) const
Definition: adblockrule.cpp:72
adblockrule.h
MessageViewer::AdBlockRuleNullImpl
Definition: adblockrulenullimpl.h:39
MessageViewer::AdBlockRuleFallbackImpl
Definition: adblockrulefallbackimpl.h:38
MessageViewer::AdBlockRule::ruleType
static RuleTypes ruleType(const QString &filter)
Definition: adblockrule.cpp:61
MessageViewer::AdBlockRule::AdBlockRule
AdBlockRule(const QString &filter)
Definition: adblockrule.cpp:41
adblockrulenullimpl.h
MessageViewer::TextRule
Definition: adblockrule.h:43
MessageViewer::NullRule
Definition: adblockrule.h:45
MessageViewer::RuleTypes
RuleTypes
Definition: adblockrule.h:41
adblockrulefallbackimpl.h
MessageViewer::AdBlockRuleNullImpl::isNullFilter
static bool isNullFilter(const QString &filter)
Definition: adblockrulenullimpl.cpp:47
MessageViewer::AdBlockRuleTextMatchImpl
Definition: adblockruletextmatchimpl.h:39
adblockruletextmatchimpl.h
MessageViewer::FallbackRule
Definition: adblockrule.h:44
MessageViewer::AdBlockRuleTextMatchImpl::isTextMatchFilter
static bool isTextMatchFilter(const QString &filter)
Definition: adblockruletextmatchimpl.cpp:61
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:55:57 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

messageviewer

Skip menu "messageviewer"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal