• 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
adblockhostmatcher.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) 2010-2011 by Benjamin Poulain <ikipou at gmail dot com>
7 * Copyright (C) 2012 by Andrea Diamantini <adjam7 at gmail dot com>
8 *
9 *
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License or (at your option) version 3 or any later version
14 * accepted by the membership of KDE e.V. (or its successor approved
15 * by the membership of KDE e.V.), which shall act as a proxy
16 * defined in Section 14 of version 3 of the license.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 *
26 * ============================================================ */
27 
28 // Self Includes
29 #include "adblockhostmatcher.h"
30 
31 
32 using namespace MessageViewer;
33 bool AdBlockHostMatcher::tryAddFilter(const QString &filter)
34 {
35  if (filter.startsWith(QLatin1String("||")))
36  {
37  QString domain = filter.mid(2);
38 
39  if (!domain.endsWith(QLatin1Char('^')))
40  return false;
41 
42  if (domain.contains(QLatin1Char('$')))
43  return false;
44 
45  domain = domain.left(domain.size() - 1);
46 
47  if (domain.contains(QLatin1Char('/')) || domain.contains(QLatin1Char('*')) || domain.contains(QLatin1Char('^')))
48  return false;
49 
50  domain = domain.toLower();
51  m_hostList.insert(domain);
52  return true;
53  }
54 
55  if (filter.startsWith(QLatin1String("@@")))
56  {
57  QString domain = filter.mid(2);
58 
59  if (domain.contains(QLatin1Char('^')))
60  return false;
61 
62  if (domain.contains(QLatin1Char('$')))
63  return false;
64 
65  if (domain.contains(QLatin1Char('*')))
66  return false;
67 
68  if (domain.contains(QLatin1Char('|')))
69  return false;
70 
71  if (domain.contains(QLatin1Char('/')))
72  {
73  if (!domain.endsWith(QLatin1Char('/')))
74  return false;
75  }
76  domain = domain.toLower();
77  m_hostList.insert(domain);
78  return true;
79  }
80 
81  return false;
82 }
83 
84 bool AdBlockHostMatcher::match(const QString &host) const
85 {
86  return m_hostList.contains(host.toLower());
87 }
88 
89 void AdBlockHostMatcher::clear()
90 {
91  m_hostList.clear();
92 }
adblockhostmatcher.h
MessageViewer::AdBlockHostMatcher::tryAddFilter
bool tryAddFilter(const QString &filter)
Definition: adblockhostmatcher.cpp:33
MessageViewer::AdBlockHostMatcher::clear
void clear()
Definition: adblockhostmatcher.cpp:89
MessageViewer::AdBlockHostMatcher::match
bool match(const QString &host) const
Definition: adblockhostmatcher.cpp:84
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