KVIrc  4.9.2
DeveloperAPIs
Public Types | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
KviIrcMask Class Reference

Irc user mask handling. More...

#include <KviIrcMask.h>

+ Inheritance diagram for KviIrcMask:

Public Types

enum  MaskType {
  NickUserHost = 0, NickUserNet = 1, NickUser = 2, NickHost = 3,
  NickNet = 4, Nick = 5, UserHost = 6, UserNet = 7,
  User = 8, Host = 9, Net = 10, NickCleanUserHost = 11,
  NickCleanUserNet = 12, NickCleanUser = 13, CleanUserHost = 14, CleanUserNet = 15,
  CleanUser = 16, NickUserLargeNet = 17, NickLargeNet = 18, UserLargeNet = 19,
  NickCleanUserLargeNet = 20, CleanUserLargeNet = 21, NickUserSmartNet = 22, NickSmartNet = 23,
  UserSmartNet = 24, NickCleanUserSmartNet = 25, CleanUserSmartNet = 26
}
 Defines the type of the masks. More...
 

Public Member Functions

bool hasHost () const
 Returns true if the hostname is set in the mask. More...
 
bool hasNumericHost () const
 Returns true if the hostname is a numeric IP. More...
 
bool hasUser () const
 Returns true if the username is set in the mask. More...
 
bool hasWildNick ()
 Returns true if the nickname contains wildcards (* and ?) More...
 
const QString & host () const
 Returns the hostname of this user. More...
 
 KviIrcMask ()
 Constructs an empty mask (*!*@*) More...
 
 KviIrcMask (const QString &szMask)
 Constructs this KviIrcMask object from a string mask. More...
 
 KviIrcMask (const KviIrcMask &ircUser)
 Carbon copy. More...
 
 KviIrcMask (const QString &nick, const QString &user, const QString &host)
 Carbon copy. More...
 
void mask (QString &szMask, MaskType eMaskType=NickCleanUserHost) const
 Returns in szMask the specified (if possible) mask of this user. More...
 
bool matchedBy (const KviIrcMask &mask) const
 Fixed internal matches (this is fixed, external is wild) More...
 
bool matches (const KviIrcMask &mask) const
 Wild external matches (this and external are wild) More...
 
bool matchesFixed (const QString &szNick, const QString &szUser, const QString &szHost) const
 Fixed external matches (this is wild, external is fixed) More...
 
bool matchesFixed (const KviIrcMask &mask) const
 Fixed external matches (this is wild, external is fixed) More...
 
bool matchWildString (const QString &szExp, const QString &szStr) const
 Matches 2 strings. More...
 
const QString & nick () const
 Returns the nickname of this user. More...
 
int nonWildChars ()
 Returns the number of non-wildcards characters in the mask. More...
 
bool operator== (const KviIrcMask &user)
 Comparison. More...
 
void setHost (const QString &szHost)
 Sets the host for this user. More...
 
void setNick (const QString &szNick)
 Sets the nick for this user. More...
 
void setUser (const QString &szUser)
 Sets the username for this user. More...
 
void setUsername (const QString &szUser)
 Sets the username for this user. More...
 
const QString & user () const
 Returns the username of this user. More...
 

Private Member Functions

QString getHostDomainMask () const
 Returns the ip in the form xxx.xxx.xxx.*. More...
 
int getIpDomainMaskLen () const
 Returns the number of characters which are parts of the IP. More...
 
QString getLargeHostDomainMask () const
 Returns the ip in the form xxx.xxx.*. More...
 
int getLargeIpDomainMaskLen () const
 Returns the number of characters which are parts of the IP. More...
 
bool hasMaskedIp () const
 Returns true if the user has the ip in the mask. More...
 

Private Attributes

QString m_szHost
 
QString m_szNick
 
QString m_szUser
 

Static Private Attributes

static QString m_szWild
 

Friends

class KviIrcUserChanList
 
class KviIrcUserList
 

Detailed Description

Irc user mask handling.

Member Enumeration Documentation

Defines the type of the masks.

Enumerator
NickUserHost 

0 : nick!~user@machine.host.top (default)

NickUserNet 

1 : nick!~user@*.abc.host.top

NickUser 

2 : nick!~user@*

NickHost 

3 : nick!*@machine.host.top

NickNet 

4 : nick!*@*.abc.host.top

Nick 

5 : nick!*@*

UserHost 

6 : *!~user@machine.host.top

UserNet 

7 : *!~user@*.abc.host.top

User 

8 : *!~user@*

Host 

9 : *!*@machine.host.top

Net 

10 : *!*@*.abc.host.top

NickCleanUserHost 

11 : nick!*user@machine.host.top

NickCleanUserNet 

12 : nick!*user@*.abc.host.top

NickCleanUser 

13 : nick!*user@*

CleanUserHost 

14 : *!*user@machine.host.top

CleanUserNet 

15 : *!*user@*.abc.host.top

CleanUser 

16 : *!*user@*

NickUserLargeNet 

17 : nick!~user@*.host.top

NickLargeNet 

18 : nick!*@*.host.top

UserLargeNet 

19 : *!~user@*.host.top

NickCleanUserLargeNet 

20 : nick!*user@*.host.top

CleanUserLargeNet 

21 : *!*user@*.host.top

NickUserSmartNet 

22 : nick!~user@*.host.top

NickSmartNet 

23 : nick!*@*.host.top

UserSmartNet 

24 : *!~user@*.host.top

NickCleanUserSmartNet 

25 : nick!*user@*.host.top

CleanUserSmartNet 

26 : *!*user@*.host.top

Constructor & Destructor Documentation

KviIrcMask::KviIrcMask ( )

Constructs an empty mask (*!*@*)

Returns
KviIrcMask

References m_szHost, m_szNick, m_szUser, and m_szWild.

KviIrcMask::KviIrcMask ( const QString &  szMask)

Constructs this KviIrcMask object from a string mask.

Parameters
szMaskThe mask of the user
Returns
KviIrcMask

References m_szHost, m_szNick, and m_szUser.

KviIrcMask::KviIrcMask ( const KviIrcMask ircUser)
inline

Carbon copy.

Parameters
ircUserThe mask of the user
Returns
KviIrcMask
KviIrcMask::KviIrcMask ( const QString &  nick,
const QString &  user,
const QString &  host 
)
inline

Carbon copy.

Parameters
nickThe nickname of the user
userThe username of the user
hostThe hostname of the user
Returns
KviIrcMask

Member Function Documentation

QString KviIrcMask::getHostDomainMask ( ) const
private

Returns the ip in the form xxx.xxx.xxx.*.

Returns
QString

References m_szHost.

Referenced by mask().

int KviIrcMask::getIpDomainMaskLen ( ) const
private

Returns the number of characters which are parts of the IP.

The IP is in the form xxx.xxx.xxx.*

Returns
int

References m_szHost.

Referenced by mask().

QString KviIrcMask::getLargeHostDomainMask ( ) const
private

Returns the ip in the form xxx.xxx.*.

Returns
QString

References m_szHost.

Referenced by mask().

int KviIrcMask::getLargeIpDomainMaskLen ( ) const
private

Returns the number of characters which are parts of the IP.

The IP is in the form xxx.xxx.*

Returns
int

References m_szHost.

Referenced by mask().

bool KviIrcMask::hasHost ( ) const
inline

Returns true if the hostname is set in the mask.

Returns
bool

Referenced by KviIrcServerParser::parseNumericTopicWhoTime(), and KviUserListView::userAction().

bool KviIrcMask::hasMaskedIp ( ) const
private

Returns true if the user has the ip in the mask.

Returns
bool
Warning
This is just a GUESS and must be called AFTER making sure that it is NOT a plain numeric IP

References m_szHost.

Referenced by mask().

bool KviIrcMask::hasNumericHost ( ) const

Returns true if the hostname is a numeric IP.

Returns
bool

References m_szHost.

Referenced by mask(), and mask_kvs_fnc_hasnumerichost().

bool KviIrcMask::hasUser ( ) const
inline

Returns true if the username is set in the mask.

Returns
bool

Referenced by KviIrcServerParser::parseNumericTopicWhoTime(), and KviUserListView::userAction().

bool KviIrcMask::hasWildNick ( )

Returns true if the nickname contains wildcards (* and ?)

Returns
bool

References m_szNick.

Referenced by KviRegisteredUserDataBase::addMask(), and KviRegisteredUserDataBase::removeMaskByPointer().

const QString& KviIrcMask::host ( ) const
inline
void KviIrcMask::mask ( QString &  szMask,
MaskType  eMaskType = NickCleanUserHost 
) const

Returns in szMask the specified (if possible) mask of this user.

If the host or username are not known, the mask may contain less information than requested.

Mask types: 0: nick!user\machine.host.top (nick!user\XXX.XXX.XXX.XXX) (default) 1: nick!user@*.host.top (nick!user\XXX.XXX.XXX.*) 2: nick!user@* 3: nick!*\machine.host.top (nick!user\XXX.XXX.XXX.XXX) 4: nick!*@*.host.top (nick!user\XXX.XXX.XXX.*) 5: nick!*@* 6: *!user\machine.host.top (*!user\XXX.XXX.XXX.XX) 7: *!user@*.host.top (*!user\XXX.XXX.XXX.*) 8: *!user@* 9: *!*\machine.host.top (*!*\XXX.XXX.XXX.XXX) 10: *!*@*.host.top (*!*\XXX.XXX.XXX.*) 11: nick!*user\machine.host.top (nick!*user\machine.host.top) 12: nick!*user@*.host.top (nick!*user@*.host.top) 13: nick!*user@* 14: *!*user\machine.host.top (*!*user\machine.host.top) 15: *!*user@*.host.top (*!*user@*.host.top) 16: *!*user@* 17: nick!~user@*.host.top (nick!~user\XXX.XXX.*) 18: nick!*@*.host.top (nick!*\XXX.XXX.*) 19: *!~user@*.host.top (*!~user\XXX.XXX.*) 20: nick!*user@*.host.top (nick!*user\XXX.XXX.*) 21: *!*user@*.host.top (*!user@*XXX.XXX.*)

Smart versions of the masks 17-21 that try take care of masked ip addresses in the form xxx.xxx.INVALID-TOP-MASK 22: nick!~user@*.host.top (nick!~user\XXX.XXX.*) 23: nick!*@*.host.top (nick!*\XXX.XXX.*) 24: *!~user@*.host.top (*!~user\XXX.XXX.*) 25: nick!*user@*.host.top (nick!*user\XXX.XXX.*) 26: *!*user@*.host.top (*!user@*XXX.XXX.*)

If some data is missing, these types may change: For example, if hostname is missing, the mask type 3 or 4 may be reduced to type 5

ident is fun.. ahem prefixes used: none I line with ident ^ I line with OTHER type ident ~ I line, no ident

  • i line with ident = i line with OTHER type ident
  • i line, no ident
    Parameters
    szMaskThe mask of the user
    eMaskTypeThe mask type
    Returns
    void

References getHostDomainMask(), getIpDomainMaskLen(), getLargeHostDomainMask(), getLargeIpDomainMaskLen(), hasMaskedIp(), hasNumericHost(), m_szHost, m_szNick, m_szUser, m_szWild, NickUserHost, szHost, and ucMaskTable.

Referenced by dccModuleParseDccGet(), KviConsoleWindow::getUserTipText(), KviKvsCoreFunctions::KVSCF(), KviAvatarCache::lookup(), OptionsWidget_channelAdvanced::OptionsWidget_channelAdvanced(), KviIrcServerParser::parseCtcpRequestAvatar(), KviAvatarCache::remove(), KviAvatarCache::replace(), and sharedfile_kvs_cmd_add().

bool KviIrcMask::matchedBy ( const KviIrcMask mask) const
inline

Fixed internal matches (this is fixed, external is wild)

Parameters
maskThe mask of the user
Returns
bool

References matchesFixed().

Referenced by KviSharedFilesManager::lookupSharedFile(), and KviNickServRuleSet::matchRule().

bool KviIrcMask::matches ( const KviIrcMask mask) const

Wild external matches (this and external are wild)

Parameters
maskThe mask of the user
Returns
bool

References m_szHost, m_szNick, m_szUser, and KviQString::matchWildExpressions().

bool KviIrcMask::matchesFixed ( const QString &  szNick,
const QString &  szUser,
const QString &  szHost 
) const

Fixed external matches (this is wild, external is fixed)

Parameters
szNickThe nickname of the user
szUserThe username of the user
szHostThe hostname of the user
Returns
bool

References m_szHost, m_szNick, m_szUser, and matchWildString().

Referenced by chan_kvs_fnc_users(), mask_kvs_fnc_match(), matchedBy(), and KviIrcServerParser::parseChannelMode().

bool KviIrcMask::matchesFixed ( const KviIrcMask mask) const

Fixed external matches (this is wild, external is fixed)

Parameters
maskThe make of the user
Returns
bool

References m_szHost, m_szNick, m_szUser, and matchWildString().

bool KviIrcMask::matchWildString ( const QString &  szExp,
const QString &  szStr 
) const

Matches 2 strings.

Parameters
szExpFirst string; can contains wildcards; special escape applies
szStrSecond string, fixed
Returns
bool

Referenced by matchesFixed().

const QString& KviIrcMask::nick ( ) const
inline
int KviIrcMask::nonWildChars ( )

Returns the number of non-wildcards characters in the mask.

Returns
int

References m_szHost, m_szNick, and m_szUser.

Referenced by KviRegisteredUserMask::KviRegisteredUserMask().

bool KviIrcMask::operator== ( const KviIrcMask user)

Comparison.

Parameters
userThe username of the user
Returns
bool

References KviQString::equalCI(), m_szHost, m_szNick, and m_szUser.

void KviIrcMask::setHost ( const QString &  szHost)
inline

Sets the host for this user.

If szHost is NULL or it points to an empty string the host is set to "*".

Parameters
szHostThe hostname of the user
Returns
void

References szHost.

Referenced by KviKvsCoreFunctions::KVSCF(), and RegisteredUserMaskDialog::okClicked().

void KviIrcMask::setNick ( const QString &  szNick)
inline

Sets the nick for this user.

If szNick is NULL or it points to an empty string the nick is set to "*".

Parameters
szNickThe nickname of the user
Returns
void

Referenced by KviKvsCoreFunctions::KVSCF(), and RegisteredUserMaskDialog::okClicked().

void KviIrcMask::setUser ( const QString &  szUser)
inline

Sets the username for this user.

If szUsername is NULL or it points to an empty string the username is set to "*". This is an alias of setUsername()

Parameters
szUserThe username of the user
Returns
void
void KviIrcMask::setUsername ( const QString &  szUser)
inline

Sets the username for this user.

If szUsername is NULL or it points to an empty string the username is set to "*".

Parameters
szUserThe username of the user
Returns
void

Referenced by KviKvsCoreFunctions::KVSCF(), and RegisteredUserMaskDialog::okClicked().

const QString& KviIrcMask::user ( ) const
inline

Friends And Related Function Documentation

friend class KviIrcUserChanList
friend
friend class KviIrcUserList
friend

Member Data Documentation

QString KviIrcMask::m_szHost
private
QString KviIrcMask::m_szNick
private
QString KviIrcMask::m_szUser
private
QString KviIrcMask::m_szWild
staticprivate

Referenced by KviIrcMask(), and mask().


The documentation for this class was generated from the following files: