~ubuntu-branches/ubuntu/trusty/kvirc/trusty

« back to all changes in this revision

Viewing changes to src/kvilib/ext/KviRegisteredUser.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Kai Wasserbäch, Kai Wasserbäch, Raúl Sánchez Siles
  • Date: 2011-02-12 10:40:21 UTC
  • mfrom: (14.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20110212104021-5mh4f75jlku20mnt
The combined "Twisted Experiment" and "Nocturnal Raid" release.

[ Kai Wasserbäch ]
* Synced to upstream's SVN revision 5467.
* debian/rules:
  - Added .PHONY line.
  - Resurrect -DMANUAL_REVISION, got lost somewhere and we build SVN
    revisions again.
  - Replace "-DWITH_NO_EMBEDDED_CODE=YES" with "-DWANT_CRYPTOPP=YES".
  - Change the remaining -DWITH/-DWITHOUT to the new -DWANT syntax.
* debian/control:
  - Removed DMUA, I'm a DD now.
  - Changed my e-mail address.
  - Removed unneeded relationships (no upgrades over two releases are
    supported).
  - Fix Suggests for kvirc-dbg.
  - kvirc-data: Make the "Suggests: kvirc" a Recommends, doesn't make much
    sense to install the -data package without the program.
* debian/source/local-options: Added with "unapply-patches".
* debian/kvirc.lintian-overrides: Updated to work for 4.1.1.
* debian/patches/21_make_shared-mime-info_B-D_superfluous.patch: Updated.
* debian/kvirc-data.install: Added .notifyrc.

[ Raúl Sánchez Siles ]
* Stating the right version where kvirc-data break and replace should happen.
* Fixing link to license file.
* Added French and Portuguese man pages.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _KVIREGUSER_H_
 
2
#define _KVIREGUSER_H_
 
3
 
 
4
//=============================================================================
 
5
//
 
6
//   File : KviRegisteredUser.cpp
 
7
//   Creation date : Wed Dec 29 2010 02:44:05 CEST by Elvio Basello
 
8
//
 
9
//   This file is part of the KVIrc irc client distribution
 
10
//   Copyright (C) 2010 Elvio Basello (hellvis69 at gmail dot com)
 
11
//
 
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.
 
16
//
 
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.
 
21
//
 
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.
 
25
//
 
26
//=============================================================================
 
27
 
 
28
#include "KviRegisteredUser.h"
 
29
 
 
30
KviRegisteredUser::KviRegisteredUser(const QString & name)
 
31
{
 
32
        m_iIgnoreFlags  =0;
 
33
        m_bIgnoreEnabled=false;
 
34
        m_szName        = name;
 
35
        m_pPropertyDict = 0;
 
36
        m_pMaskList     = new KviPointerList<KviIrcMask>;
 
37
        m_pMaskList->setAutoDelete(true);
 
38
}
 
39
 
 
40
KviRegisteredUser::~KviRegisteredUser()
 
41
{
 
42
        if(m_pPropertyDict)
 
43
                delete m_pPropertyDict;
 
44
        delete m_pMaskList;
 
45
}
 
46
 
 
47
bool KviRegisteredUser::isIgnoreEnabledFor(IgnoreFlags flag)
 
48
{
 
49
        if(!m_bIgnoreEnabled) return false;
 
50
        return m_iIgnoreFlags & flag;
 
51
}
 
52
 
 
53
KviIrcMask * KviRegisteredUser::findMask(const KviIrcMask &mask)
 
54
{
 
55
        for(KviIrcMask * m = m_pMaskList->first();m;m = m_pMaskList->next())
 
56
        {
 
57
                if(*m == mask)return m;
 
58
        }
 
59
        return 0;
 
60
}
 
61
 
 
62
bool KviRegisteredUser::addMask(KviIrcMask * mask)
 
63
{
 
64
        if(findMask(*mask))
 
65
        {
 
66
                delete mask;
 
67
        mask = 0;
 
68
                return false;
 
69
        }
 
70
        m_pMaskList->append(mask);
 
71
        return true;
 
72
}
 
73
 
 
74
bool KviRegisteredUser::removeMask(KviIrcMask * mask)
 
75
{
 
76
        if(!mask)return false;
 
77
        return m_pMaskList->removeRef(mask);
 
78
}
 
79
 
 
80
bool KviRegisteredUser::matches(const KviIrcMask &mask)
 
81
{
 
82
        for(KviIrcMask * m = m_pMaskList->first();m;m = m_pMaskList->next())
 
83
        {
 
84
                if(m->matches(mask))return true;
 
85
        }
 
86
        return false;
 
87
}
 
88
 
 
89
bool KviRegisteredUser::matchesFixed(const KviIrcMask &mask)
 
90
{
 
91
        for(KviIrcMask * m = m_pMaskList->first();m;m = m_pMaskList->next())
 
92
        {
 
93
                if(m->matchesFixed(mask))return true;
 
94
        }
 
95
        return false;
 
96
}
 
97
 
 
98
bool KviRegisteredUser::matchesFixed(const QString & nick,const QString & user,const QString & host)
 
99
{
 
100
        for(KviIrcMask * m = m_pMaskList->first();m;m = m_pMaskList->next())
 
101
        {
 
102
                if(m->matchesFixed(nick,user,host))return true;
 
103
        }
 
104
        return false;
 
105
}
 
106
 
 
107
void KviRegisteredUser::setProperty(const QString &name,bool value)
 
108
{
 
109
        setProperty(name,value ? QString("true") : QString("false"));
 
110
}
 
111
 
 
112
void KviRegisteredUser::setProperty(const QString & name,const QString & value)
 
113
{
 
114
        if(!value.isEmpty())
 
115
        {
 
116
                if(!m_pPropertyDict)
 
117
                {
 
118
                        m_pPropertyDict = new KviPointerHashTable<QString,QString>(7,false);
 
119
                        m_pPropertyDict->setAutoDelete(true);
 
120
                }
 
121
 
 
122
                QString * val = new QString(value.trimmed());
 
123
                if(!val->isEmpty())
 
124
                {
 
125
                        m_pPropertyDict->replace(name,val);
 
126
                } else {
 
127
                        delete val;
 
128
                        val = 0;
 
129
                }
 
130
        } else {
 
131
                if(m_pPropertyDict)m_pPropertyDict->remove(name);
 
132
        }
 
133
}
 
134
 
 
135
bool KviRegisteredUser::getProperty(const QString & name,QString &value)
 
136
{
 
137
        if(!m_pPropertyDict)return false;
 
138
        if(name.isEmpty()) return false;
 
139
        QString * pValue = m_pPropertyDict->find(name);
 
140
        if(pValue)value = *pValue;
 
141
        else return false;
 
142
        return true;
 
143
}
 
144
 
 
145
const QString & KviRegisteredUser::getProperty(const QString & name)
 
146
{
 
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;
 
152
}
 
153
 
 
154
bool KviRegisteredUser::getBoolProperty(const QString & name,bool def)
 
155
{
 
156
        if(!m_pPropertyDict)return def;
 
157
        if(name.isEmpty()) return def;
 
158
        QString * pValue = m_pPropertyDict->find(name);
 
159
        if(pValue)
 
160
        {
 
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;
 
168
        }
 
169
        return def;
 
170
}
 
171
 
 
172
#endif // _KVIREGUSER_H_