KVIrc  4.9.2
DeveloperAPIs
KviRegisteredUserDataBase.h
Go to the documentation of this file.
1 #ifndef _KVI_REGUSERSDB_H_
2 #define _KVI_REGUSERSDB_H_
3 //=================================================================================================
4 //
5 // File : KviRegisteredUserDataBase.h
6 // Creation date : Sat Sep 09 2000 15:30:56 by Szymon Stefanek
7 //
8 // This file is part of the KVIrc IRC client distribution
9 // Copyright (C) 2000-2010 Szymon Stefanek (pragma at kvirc dot net)
10 //
11 // This program is FREE software. You can redistribute it and/or
12 // modify it under the terms of the GNU General Public License
13 // as published by the Free Software Foundation; either version 2
14 // of the License, or (at your option) any later version.
15 //
16 // This program is distributed in the HOPE that it will be USEFUL,
17 // but WITHOUT ANY WARRANTY; without even the implied warranty of
18 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 // See the GNU General Public License for more details.
20 //
21 // You should have received a copy of the GNU General Public License
22 // along with this program. If not, write to the Free Software Foundation,
23 // Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24 //
25 //=================================================================================================
26 
27 //
28 // REGISTERED USERS
29 //
30 // Here we manage users resigered by mask and their (generic!) properties
31 //
32 
33 #include "kvi_settings.h"
34 #include "kvi_debug.h"
35 
36 #include "KviHeapObject.h"
37 #include "KviPointerHashTable.h"
38 #include "KviRegisteredUserGroup.h"
39 #include "KviRegisteredUserMask.h"
40 
41 #include <QObject>
42 
43 //=================================================================================================
44 //
45 // KviRegisteredUserDataBase
46 //
47 // Manages a set of KviRegisteredUser instances stored in the m_pUserDict dictionary
48 // The users are identified by masks stored in m_pMaskDict and m_pWildMaskList
49 // m_pMaskDict contains lists of non wild-nick KviRegisteredUserMask that point to users
50 // m_pWildMaskList is a list of wild-nick KviRegisteredUserMask that point to users
51 //
52 
53 class KVILIB_API KviRegisteredUserDataBase : public QObject
54 {
55  Q_OBJECT
56 public:
59 
60 private:
61  KviPointerHashTable<QString, KviRegisteredUser> * m_pUserDict; // unique namespace, owns the objects, does not copy keys
65 
66 public:
67  void copyFrom(KviRegisteredUserDataBase * db);
68  KviRegisteredUser * addUser(const QString & name); // returns 0 if already there
69  KviRegisteredUser * getUser(const QString & name); // returns existing or adds
70  bool removeUser(const QString & name);
71  bool removeGroup(const QString & name);
72  KviRegisteredUser * findUserByName(const QString & name) { return m_pUserDict->find(name); };
73  // mask must be allocated on the heap and the ownership is transferred!
74  // returns non zero if there is already a user with this mask (returns the pointer to it!)
75  KviRegisteredUser * addMask(KviRegisteredUser * u, KviIrcMask * mask);
76  bool removeMaskByPointer(KviIrcMask * mask);
77  bool removeMask(const KviIrcMask & mask);
78  KviRegisteredUser * findMatchingUser(const QString & nick, const QString & user, const QString & host);
79  KviRegisteredUser * findUserWithMask(const KviIrcMask & mask);
80  KviRegisteredUserMask * findExactMask(const KviIrcMask & mask);
81  KviRegisteredUserMask * findMatchingMask(const QString & nick, const QString & user, const QString & host);
82  //Only used in few places (actually one) of the code, but lot of times;perfect for inlining...
83  //bool isIgnoredUser(const char * nick,const char * user,const char * host);
84  void load(const QString & filename);
85  void save(const QString & filename);
86 
89 
90  KviRegisteredUserGroup * addGroup(const QString & name);
91 signals:
92  void userRemoved(const QString &);
93  void userChanged(const QString &);
94  void userAdded(const QString &);
95  void databaseCleared();
96 };
97 
98 #ifndef _KVI_REGUSERDB_CPP_
100 #endif // _KVI_REGUSERDB_CPP_
101 
102 #endif //_KVI_REGUSERSDB_H_
Definition: KviRegisteredUserGroup.h:35
KviRegisteredUserMaskList * m_pWildMaskList
Definition: KviRegisteredUserDataBase.h:63
This file contains the definition of the debug macros;.
KviPointerHashTable< QString, KviRegisteredUser > * userDict()
Definition: KviRegisteredUserDataBase.h:87
Definition: KviRegisteredUser.h:35
Irc user mask handling.
Definition: KviIrcMask.h:45
KviPointerHashTable< QString, KviRegisteredUserMaskList > * m_pMaskDict
Definition: KviRegisteredUserDataBase.h:62
KviPointerHashTable< QString, KviRegisteredUser > * m_pUserDict
Definition: KviRegisteredUserDataBase.h:61
Pointer Hash Table.
KVILIB_API KviRegisteredUserDataBase * g_pRegisteredUserDataBase
Definition: KviRegisteredUserDataBase.cpp:119
Definition: KviRegisteredUserMask.h:34
bool save(KviThemeInfo &options, bool bSaveIcons)
Definition: KviOptions.cpp:986
KviRegisteredUser * findUserByName(const QString &name)
Definition: KviRegisteredUserDataBase.h:72
Definition: KviRegisteredUserDataBase.h:53
KviPointerHashTable< QString, KviRegisteredUserGroup > * groupDict()
Definition: KviRegisteredUserDataBase.h:88
A template double linked list of pointers.
Definition: KviPointerList.h:55
Heap Object.
QString name()
Definition: KviRuntimeInfo.cpp:655
#define u
Definition: detector.cpp:85
This file contains compile time settings.
KviPointerHashTable< QString, KviRegisteredUserGroup > * m_pGroupDict
Definition: KviRegisteredUserDataBase.h:64
#define KVILIB_API
Definition: kvi_settings.h:125