4
//=============================================================================
6
// File : KviRegisteredUser.cpp
7
// Creation date : Wed Dec 29 2010 02:44:05 CEST by Elvio Basello
9
// This file is part of the KVIrc irc client distribution
10
// Copyright (C) 2010 Elvio Basello (hellvis69 at gmail dot com)
12
// This program is FREE software. You can redistribute it and/or
13
// modify it under the terms of the GNU General Public License
14
// as published by the Free Software Foundation; either version 2
15
// of the License, or (at your opinion) any later version.
17
// This program is distributed in the HOPE that it will be USEFUL,
18
// but WITHOUT ANY WARRANTY; without even the implied warranty of
19
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20
// See the GNU General Public License for more details.
22
// You should have received a copy of the GNU General Public License
23
// along with this program. If not, write to the Free Software Foundation,
24
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
26
//=============================================================================
28
#include "KviRegisteredUser.h"
30
KviRegisteredUser::KviRegisteredUser(const QString & name)
33
m_bIgnoreEnabled=false;
36
m_pMaskList = new KviPointerList<KviIrcMask>;
37
m_pMaskList->setAutoDelete(true);
40
KviRegisteredUser::~KviRegisteredUser()
43
delete m_pPropertyDict;
47
bool KviRegisteredUser::isIgnoreEnabledFor(IgnoreFlags flag)
49
if(!m_bIgnoreEnabled) return false;
50
return m_iIgnoreFlags & flag;
53
KviIrcMask * KviRegisteredUser::findMask(const KviIrcMask &mask)
55
for(KviIrcMask * m = m_pMaskList->first();m;m = m_pMaskList->next())
57
if(*m == mask)return m;
62
bool KviRegisteredUser::addMask(KviIrcMask * mask)
70
m_pMaskList->append(mask);
74
bool KviRegisteredUser::removeMask(KviIrcMask * mask)
76
if(!mask)return false;
77
return m_pMaskList->removeRef(mask);
80
bool KviRegisteredUser::matches(const KviIrcMask &mask)
82
for(KviIrcMask * m = m_pMaskList->first();m;m = m_pMaskList->next())
84
if(m->matches(mask))return true;
89
bool KviRegisteredUser::matchesFixed(const KviIrcMask &mask)
91
for(KviIrcMask * m = m_pMaskList->first();m;m = m_pMaskList->next())
93
if(m->matchesFixed(mask))return true;
98
bool KviRegisteredUser::matchesFixed(const QString & nick,const QString & user,const QString & host)
100
for(KviIrcMask * m = m_pMaskList->first();m;m = m_pMaskList->next())
102
if(m->matchesFixed(nick,user,host))return true;
107
void KviRegisteredUser::setProperty(const QString &name,bool value)
109
setProperty(name,value ? QString("true") : QString("false"));
112
void KviRegisteredUser::setProperty(const QString & name,const QString & value)
118
m_pPropertyDict = new KviPointerHashTable<QString,QString>(7,false);
119
m_pPropertyDict->setAutoDelete(true);
122
QString * val = new QString(value.trimmed());
125
m_pPropertyDict->replace(name,val);
131
if(m_pPropertyDict)m_pPropertyDict->remove(name);
135
bool KviRegisteredUser::getProperty(const QString & name,QString &value)
137
if(!m_pPropertyDict)return false;
138
if(name.isEmpty()) return false;
139
QString * pValue = m_pPropertyDict->find(name);
140
if(pValue)value = *pValue;
145
const QString & KviRegisteredUser::getProperty(const QString & name)
147
if(!m_pPropertyDict)return KviQString::Empty;
148
if(name.isEmpty())return KviQString::Empty;
149
QString * pValue = m_pPropertyDict->find(name);
150
if(pValue)return *pValue;
151
return KviQString::Empty;
154
bool KviRegisteredUser::getBoolProperty(const QString & name,bool def)
156
if(!m_pPropertyDict)return def;
157
if(name.isEmpty()) return def;
158
QString * pValue = m_pPropertyDict->find(name);
161
// be flexible, allow more "true" values (pragma)
162
if(KviQString::equalCS(*pValue,"1"))return true;
163
if(KviQString::equalCI(*pValue,"true"))return true;
164
if(KviQString::equalCI(*pValue,"yes"))return true;
165
//if(KviQString::equalCI(*pValue,"yeah"))return true;
166
//if(KviQString::equalCI(*pValue,"sure"))return true;
167
//if(KviQString::equalCI(*pValue,"sureashell"))return true;
172
#endif // _KVIREGUSER_H_