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

kopete/libkopete

  • sources
  • kde-4.12
  • kdenetwork
  • kopete
  • libkopete
kopeteblacklister.cpp
Go to the documentation of this file.
1 /*
2  kopeteblacklister.cpp - Kopete BlackLister
3 
4  Copyright (c) 2004 by Roie Kerstein <sf_kersteinroie@bezeqint.net>
5 
6  *************************************************************************
7  * *
8  * This library is free software; you can redistribute it and/or *
9  * modify it under the terms of the GNU Lesser General Public *
10  * License as published by the Free Software Foundation; either *
11  * version 2 of the License, or (at your option) any later version. *
12  * *
13  *************************************************************************
14 */
15 
16 #include "kopeteblacklister.h"
17 
18 #include "kopetecontact.h"
19 
20 #include <ksharedconfig.h>
21 #include <kconfiggroup.h>
22 #include <kglobal.h>
23 
24 #include <qstringlist.h>
25 
26 namespace Kopete
27 {
28 
29 class BlackLister::Private
30 {
31 public:
32  QStringList blacklist;
33  QString owner;
34  QString protocol;
35 };
36 
37 
38 BlackLister::BlackLister(const QString &protocolId, const QString &accountId, QObject *parent)
39  : QObject(parent), d( new Private )
40 {
41  KConfigGroup config = KGlobal::config()->group("BlackLister");
42 
43  d->owner = accountId;
44  d->protocol = protocolId;
45  d->blacklist = config.readEntry( d->protocol + QString::fromLatin1("_") + d->owner, QStringList() );
46 }
47 
48 BlackLister::~BlackLister()
49 {
50  delete d;
51 }
52 
53 
54 bool BlackLister::isBlocked(const QString &contactId)
55 {
56  return (d->blacklist.indexOf( contactId ) != -1 );
57 }
58 
59 bool BlackLister::isBlocked(Contact *contact)
60 {
61  return isBlocked(contact->contactId());
62 }
63 
64 void BlackLister::addContact(const QString &contactId)
65 {
66  if( !isBlocked(contactId) )
67  {
68  d->blacklist += contactId;
69  saveToDisk();
70  emit contactAdded( contactId );
71  }
72 }
73 
74 void BlackLister::addContact(Contact *contact)
75 {
76  QString temp = contact->contactId();
77 
78  addContact( temp );
79 }
80 
81 void BlackLister::removeContact(Contact *contact)
82 {
83  QString temp = contact->contactId();
84 
85  removeContact( temp );
86 }
87 
88 void BlackLister::saveToDisk()
89 {
90  KConfigGroup config = KGlobal::config()->group("BlackLister");
91  config.writeEntry( d->protocol + QString::fromLatin1("_") + d->owner, d->blacklist );
92  config.sync();
93 }
94 
95 void BlackLister::removeContact(const QString &contactId)
96 {
97  if( isBlocked(contactId) )
98  {
99  d->blacklist.removeAll( contactId );
100  saveToDisk();
101  emit contactRemoved( contactId );
102  }
103 }
104 
105 }
106 
107 #include "kopeteblacklister.moc"
Kopete::Contact::contactId
QString contactId
Definition: kopetecontact.h:70
QObject
Kopete::BlackLister::removeContact
void removeContact(Contact *contact)
Remove a contact from the blacklist.
Definition: kopeteblacklister.cpp:81
Kopete::BlackLister::isBlocked
bool isBlocked(Contact *contact)
Definition: kopeteblacklister.cpp:59
Kopete::Contact
Definition: kopetecontact.h:58
Kopete::BlackLister::contactAdded
void contactAdded(const QString &contactId)
A new contact has been added to the list.
Kopete::BlackLister::addContact
void addContact(const QString &contactId)
Add a contact to the blacklist.
Definition: kopeteblacklister.cpp:64
Kopete::BlackLister::contactRemoved
void contactRemoved(const QString &contactId)
A contact has been removed from the list.
kopeteblacklister.h
Kopete::BlackLister::BlackLister
BlackLister(const QString &protocolId, const QString &accountId, QObject *parent=0)
Create an instance, and read the blacklist from disk if it exists.
Definition: kopeteblacklister.cpp:38
Kopete::BlackLister::~BlackLister
~BlackLister()
Definition: kopeteblacklister.cpp:48
kopetecontact.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:53:51 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

kopete/libkopete

Skip menu "kopete/libkopete"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Related Pages

kdenetwork API Reference

Skip menu "kdenetwork API Reference"
  • kget
  • kopete
  •   kopete
  •   libkopete
  • krdc
  • krfb

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