aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/kvilib/CMakeLists.txt1
-rw-r--r--src/kvilib/irc/KviIdentityProfile.cpp202
-rw-r--r--src/kvilib/irc/KviIdentityProfile.h154
-rw-r--r--src/kvilib/irc/KviIdentityProfileSet.cpp227
-rw-r--r--src/kvilib/irc/KviIdentityProfileSet.h188
-rw-r--r--src/kvilib/irc/KviIrcMask.cpp621
-rw-r--r--src/kvilib/irc/KviIrcMask.h71
-rw-r--r--src/kvilib/irc/KviIrcNetwork.h65
-rw-r--r--src/kvilib/irc/KviNickServRule.h6
-rw-r--r--src/kvilib/irc/KviNickServRuleSet.h6
-rw-r--r--src/kvirc/kernel/KviApplication.cpp2
-rw-r--r--src/kvirc/kernel/KviIrcConnection.cpp2
-rw-r--r--src/kvirc/sparser/KviIrcServerParser_numericHandlers.cpp2
-rw-r--r--src/modules/options/optw_identity.cpp6
14 files changed, 696 insertions, 857 deletions
diff --git a/src/kvilib/CMakeLists.txt b/src/kvilib/CMakeLists.txt
index ece9c9b62..5b8f57baf 100644
--- a/src/kvilib/CMakeLists.txt
+++ b/src/kvilib/CMakeLists.txt
@@ -96,6 +96,7 @@ SET(kvilib_SRCS
irc/KviAvatar.cpp
irc/KviAvatarCache.cpp
irc/KviIdentityProfile.cpp
+ irc/KviIdentityProfileSet.cpp
irc/KviIrcMask.cpp
irc/KviIrcServer.cpp
irc/KviIrcServerDataBase.cpp
diff --git a/src/kvilib/irc/KviIdentityProfile.cpp b/src/kvilib/irc/KviIdentityProfile.cpp
index 0f49d6047..a8c358852 100644
--- a/src/kvilib/irc/KviIdentityProfile.cpp
+++ b/src/kvilib/irc/KviIdentityProfile.cpp
@@ -25,9 +25,6 @@
#include "KviIdentityProfile.h"
#include "KviConfigurationFile.h"
-KviIdentityProfileSet * KviIdentityProfileSet::m_pSelf = NULL;
-unsigned int KviIdentityProfileSet::m_uCount = 0;
-
KviIdentityProfile::KviIdentityProfile()
: KviHeapObject()
{
@@ -95,202 +92,3 @@ bool KviIdentityProfile::load(KviConfigurationFile * pCfg, const QString & szPre
return true;
}
-
-
-KviIdentityProfileSet::KviIdentityProfileSet()
-: KviHeapObject()
-{
- m_bEnabled = false;
- m_pProfiles = 0;
-}
-
-KviIdentityProfileSet::KviIdentityProfileSet(const KviIdentityProfileSet & set)
-{
- m_pProfiles = 0;
- copyFrom(set);
-}
-
-KviIdentityProfileSet::~KviIdentityProfileSet()
-{
- if(m_pProfiles) delete m_pProfiles;
-}
-
-void KviIdentityProfileSet::init()
-{
- if((!m_pSelf) && (m_pSelf->count() == 0))
- {
- m_pSelf = new KviIdentityProfileSet();
- m_uCount++;
- }
-}
-
-void KviIdentityProfileSet::done()
-{
- m_uCount--;
- if(m_pSelf->count() == 0)
- delete m_pSelf;
-}
-
-void KviIdentityProfileSet::clear()
-{
- if(m_pProfiles)
- {
- delete m_pProfiles;
- m_pProfiles = 0;
- }
- m_bEnabled = false;
-}
-
-KviIdentityProfile * KviIdentityProfileSet::findName(const QString & szName)
-{
- if(!m_pProfiles) return 0;
-
- KviIdentityProfile * pProfile;
- for(pProfile = m_pProfiles->first(); pProfile; pProfile = m_pProfiles->next())
- {
- if(KviQString::matchString(pProfile->name(),szName,false,true))
- return pProfile;
- }
-
- return 0;
-}
-
-KviIdentityProfile * KviIdentityProfileSet::findNetwork(const QString & szNetwork)
-{
- if(!m_pProfiles) return 0;
-
- KviIdentityProfile * pProfile;
- for(pProfile = m_pProfiles->first(); pProfile; pProfile = m_pProfiles->next())
- {
- if(KviQString::matchString(pProfile->network(),szNetwork,false,true))
- return pProfile;
- }
-
- return 0;
-}
-
-void KviIdentityProfileSet::copyFrom(const KviIdentityProfileSet & src)
-{
- if(src.m_pProfiles)
- {
- if(m_pProfiles) m_pProfiles->clear();
- else {
- m_pProfiles = new KviPointerList<KviIdentityProfile>;
- m_pProfiles->setAutoDelete(true);
- }
-
- for(KviIdentityProfile * pSrcProfile = src.m_pProfiles->first(); pSrcProfile; pSrcProfile = src.m_pProfiles->next())
- {
- KviIdentityProfile * pProfile = new KviIdentityProfile();
- pProfile->copyFrom(*pSrcProfile);
- m_pProfiles->append(pProfile);
- }
-
- if(m_pProfiles->isEmpty())
- {
- m_bEnabled = false;
- delete m_pProfiles;
- m_pProfiles = 0;
- } else {
- m_bEnabled = src.m_bEnabled;
- }
- } else {
- m_bEnabled = false;
- if(m_pProfiles)
- {
- delete m_pProfiles;
- m_pProfiles = 0;
- }
- }
-}
-
-void KviIdentityProfileSet::addProfile(KviIdentityProfile * pProfile)
-{
- if(!m_pProfiles)
- {
- m_pProfiles = new KviPointerList<KviIdentityProfile>;
- m_pProfiles->setAutoDelete(true);
- }
-
- m_pProfiles->append(pProfile);
-}
-
-void KviIdentityProfileSet::load(const QString & szConfigFile)
-{
- clear();
- KviConfigurationFile cfg(szConfigFile,KviConfigurationFile::Read);
-
- QString szTmp;
- KviQString::sprintf(szTmp,"ProfilesNumber");
-
- unsigned int uCount = cfg.readUIntEntry(szTmp,0);
- if(uCount == 0) return;
- loadPrivate(&cfg,QString(""),uCount);
-}
-
-void KviIdentityProfileSet::save(const QString & szConfigFile)
-{
- KviConfigurationFile cfg(szConfigFile,KviConfigurationFile::Write);
- cfg.clear();
- save(&cfg,QString(""));
-}
-
-void KviIdentityProfileSet::save(KviConfigurationFile * pCfg, const QString & szPrefix)
-{
- if(!m_pProfiles)
- return;
- if(m_pProfiles->isEmpty())
- return;
-
- QString szTmp;
- if(m_bEnabled)
- {
- KviQString::sprintf(szTmp,"%QProfilesEnabled",&szPrefix);
- pCfg->writeEntry(szTmp,m_bEnabled);
- }
-
- KviQString::sprintf(szTmp,"%QProfilesNumber",&szPrefix);
- pCfg->writeEntry(szTmp,m_pProfiles->count());
-
- int iIdx = 0;
- for(KviIdentityProfile * pProfile = m_pProfiles->first(); pProfile; pProfile = m_pProfiles->next())
- {
- KviQString::sprintf(szTmp,"%QProfile%d_",&szPrefix,iIdx);
- pProfile->save(pCfg,szTmp);
- iIdx++;
- }
-}
-
-bool KviIdentityProfileSet::loadPrivate(KviConfigurationFile * pCfg, const QString & szPrefix, unsigned int uEntries)
-{
- if(m_pProfiles) m_pProfiles->clear();
- else {
- m_pProfiles = new KviPointerList<KviIdentityProfile>;
- m_pProfiles->setAutoDelete(true);
- }
-
- if(uEntries != 0)
- {
- QString szTmp;
- KviQString::sprintf(szTmp,"%QProfilesEnabled",&szPrefix);
- m_bEnabled = pCfg->readBoolEntry(szTmp,false);
-
- for(unsigned int u = 0; u < uEntries; u++)
- {
- KviQString::sprintf(szTmp,"%QProfile%u_",&szPrefix,u);
- KviIdentityProfile * pProfile = new KviIdentityProfile();
- if(!pProfile->load(pCfg,szTmp))
- delete pProfile;
- else m_pProfiles->append(pProfile);
- }
- }
-
- if(m_pProfiles->isEmpty())
- {
- m_bEnabled = false;
- delete m_pProfiles;
- m_pProfiles = 0;
- return false;
- }
- return true;
-}
diff --git a/src/kvilib/irc/KviIdentityProfile.h b/src/kvilib/irc/KviIdentityProfile.h
index 1c9353295..aa51bf12b 100644
--- a/src/kvilib/irc/KviIdentityProfile.h
+++ b/src/kvilib/irc/KviIdentityProfile.h
@@ -1,5 +1,5 @@
-#ifndef _KVI_IDENTITYPROFILES_H_
-#define _KVI_IDENTITYPROFILES_H_
+#ifndef _KVI_IDENTITY_PROFILE_H_
+#define _KVI_IDENTITY_PROFILE_H_
//=============================================================================
//
// File : KviIdentityProfile.h
@@ -167,152 +167,4 @@ public:
bool load(KviConfigurationFile * pCfg, const QString & szPrefix);
};
-/**
-* \class KviIdentityProfileSet
-* \brief Class which manages the list of identity profiles
-*/
-class KVILIB_API KviIdentityProfileSet : public KviHeapObject
-{
-public:
- /**
- * \brief Constructs the identity profile set object
- * \return KviIdentityProfileSet
- */
- KviIdentityProfileSet();
-
- /**
- * \brief Constructs the identity profile set object
- *
- * This is a carbon copy.
- * \param set A profile set to copy from
- * \return KviIdentityProfileSet
- */
- KviIdentityProfileSet(const KviIdentityProfileSet & set);
-
- /**
- * \brief Destroys the identity profile set object
- */
- ~KviIdentityProfileSet();
-private:
- static KviIdentityProfileSet * m_pSelf;
- static unsigned int m_uCount;
-protected:
- KviPointerList<KviIdentityProfile> * m_pProfiles;
- bool m_bEnabled;
-public:
- /**
- * \brief Initializes the class instance
- * \return void
- */
- static void init();
-
- /**
- * \brief Destroys the class instance
- * \return void
- */
- static void done();
-
- /**
- * \brief Returns the instance of the class
- * \return KviIdentityProfileSet *
- */
- static inline KviIdentityProfileSet * instance(){ return m_pSelf; };
-
- /**
- * \brief Returns the number of instances of the class
- * \return unsigned int
- */
- unsigned int count(){ return m_uCount; };
-
- /**
- * \brief Returns the profiles set
- * \return KviPointerList<KviIdentityProfile> *
- */
- KviPointerList<KviIdentityProfile> * profiles(){ return m_pProfiles; };
-
- /**
- * \brief Searches for a profile name. Returns true if the profile exists
- * \param szName The name of the profile
- * \return KviIdentityProfile *
- */
- KviIdentityProfile * findName(const QString & szName);
-
- /**
- * \brief Searches for a profile network. Returns true if the profile exists
- * \param szNetwork The network name of the profile
- * \return KviIdentityProfile *
- */
- KviIdentityProfile * findNetwork(const QString & szNetwork);
-
- /**
- * \brief Clears the list
- * \return void
- */
- void clear();
-
- /**
- * \brief Returns true if the profile set is empty
- * \return bool
- */
- bool isEmpty(){ return m_pProfiles ? m_pProfiles->isEmpty() : true; };
-
- /**
- * \brief Returns true if the profile set is enabled
- * \return bool
- */
- bool isEnabled(){ return m_bEnabled; };
-
- /**
- * \brief Enables the profile set
- * \param bEnabled Whether to enable the profile set
- * \return void
- */
- void setEnabled(bool bEnabled){ m_bEnabled = bEnabled; };
-
- /**
- * \brief Carbon copy
- * \param src The source profile set
- * \return void
- */
- void copyFrom(const KviIdentityProfileSet & src);
-
- /**
- * \brief Adds a profile to the set
- * \param pProfile The source profile to add
- * \return void
- */
- void addProfile(KviIdentityProfile * pProfile);
-
- /**
- * \brief Loads the configuration of the profiles from file
- * \param szConfigFile The file where to load
- * \return void
- */
- void load(const QString & szConfigFile);
-
- /**
- * \brief Saves the configuration of the profiles to file
- * \param szConfigFile The file to save
- * \return void
- */
- void save(const QString & szConfigFile);
-
- /**
- * \brief Saves the configuration of the profiles
- * \param pCfg The configuration file
- * \param szPrefix The prefix of the rules
- * \return void
- */
- void save(KviConfigurationFile * pCfg, const QString & szPrefix);
-protected:
- /**
- * \brief Loads the configuration of the profiles from file
- * \param pCfg The configuration file
- * \param szPrefix The prefix of the rules
- * \param uEntries The number of entries
- * \return bool
- */
- bool loadPrivate(KviConfigurationFile * pCfg, const QString & szPrefix, unsigned int uEntries);
-};
-
-#endif // _KVI_IDENTITYPROFILES_H_
+#endif // _KVI_IDENTITY_PROFILE_H_
diff --git a/src/kvilib/irc/KviIdentityProfileSet.cpp b/src/kvilib/irc/KviIdentityProfileSet.cpp
new file mode 100644
index 000000000..1d76e74e7
--- /dev/null
+++ b/src/kvilib/irc/KviIdentityProfileSet.cpp
@@ -0,0 +1,227 @@
+//=============================================================================
+//
+// File : KviIdentityProfileSet.cpp
+// Creation date : Thu Dec 30 2010 15:54:48 by Elvio Basello
+//
+// This file is part of the KVIrc irc client distribution
+// Copyright (C) 2010 Elvio Basello (hellvis69 at netsons dot org)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=============================================================================
+
+#include "KviIdentityProfileSet.h"
+#include "KviConfigurationFile.h"
+
+KviIdentityProfileSet * KviIdentityProfileSet::m_pSelf = NULL;
+unsigned int KviIdentityProfileSet::m_uCount = 0;
+
+KviIdentityProfileSet::KviIdentityProfileSet()
+: KviHeapObject()
+{
+ m_bEnabled = false;
+ m_pProfiles = 0;
+}
+
+KviIdentityProfileSet::KviIdentityProfileSet(const KviIdentityProfileSet & set)
+{
+ m_pProfiles = 0;
+ copyFrom(set);
+}
+
+KviIdentityProfileSet::~KviIdentityProfileSet()
+{
+ if(m_pProfiles) delete m_pProfiles;
+}
+
+void KviIdentityProfileSet::init()
+{
+ if((!m_pSelf) && (m_pSelf->count() == 0))
+ {
+ m_pSelf = new KviIdentityProfileSet();
+ m_uCount++;
+ }
+}
+
+void KviIdentityProfileSet::done()
+{
+ m_uCount--;
+ if(m_pSelf->count() == 0)
+ delete m_pSelf;
+}
+
+void KviIdentityProfileSet::clear()
+{
+ if(m_pProfiles)
+ {
+ delete m_pProfiles;
+ m_pProfiles = 0;
+ }
+ m_bEnabled = false;
+}
+
+KviIdentityProfile * KviIdentityProfileSet::findName(const QString & szName)
+{
+ if(!m_pProfiles) return 0;
+
+ KviIdentityProfile * pProfile;
+ for(pProfile = m_pProfiles->first(); pProfile; pProfile = m_pProfiles->next())
+ {
+ if(KviQString::matchString(pProfile->name(),szName,false,true))
+ return pProfile;
+ }
+
+ return 0;
+}
+
+KviIdentityProfile * KviIdentityProfileSet::findNetwork(const QString & szNetwork)
+{
+ if(!m_pProfiles) return 0;
+
+ KviIdentityProfile * pProfile;
+ for(pProfile = m_pProfiles->first(); pProfile; pProfile = m_pProfiles->next())
+ {
+ if(KviQString::matchString(pProfile->network(),szNetwork,false,true))
+ return pProfile;
+ }
+
+ return 0;
+}
+
+void KviIdentityProfileSet::copyFrom(const KviIdentityProfileSet & src)
+{
+ if(src.m_pProfiles)
+ {
+ if(m_pProfiles) m_pProfiles->clear();
+ else {
+ m_pProfiles = new KviPointerList<KviIdentityProfile>;
+ m_pProfiles->setAutoDelete(true);
+ }
+
+ for(KviIdentityProfile * pSrcProfile = src.m_pProfiles->first(); pSrcProfile; pSrcProfile = src.m_pProfiles->next())
+ {
+ KviIdentityProfile * pProfile = new KviIdentityProfile();
+ pProfile->copyFrom(*pSrcProfile);
+ m_pProfiles->append(pProfile);
+ }
+
+ if(m_pProfiles->isEmpty())
+ {
+ m_bEnabled = false;
+ delete m_pProfiles;
+ m_pProfiles = 0;
+ } else {
+ m_bEnabled = src.m_bEnabled;
+ }
+ } else {
+ m_bEnabled = false;
+ if(m_pProfiles)
+ {
+ delete m_pProfiles;
+ m_pProfiles = 0;
+ }
+ }
+}
+
+void KviIdentityProfileSet::addProfile(KviIdentityProfile * pProfile)
+{
+ if(!m_pProfiles)
+ {
+ m_pProfiles = new KviPointerList<KviIdentityProfile>;
+ m_pProfiles->setAutoDelete(true);
+ }
+
+ m_pProfiles->append(pProfile);
+}
+
+void KviIdentityProfileSet::load(const QString & szConfigFile)
+{
+ clear();
+ KviConfigurationFile cfg(szConfigFile,KviConfigurationFile::Read);
+
+ QString szTmp;
+ KviQString::sprintf(szTmp,"ProfilesNumber");
+
+ unsigned int uCount = cfg.readUIntEntry(szTmp,0);
+ if(uCount == 0) return;
+ loadPrivate(&cfg,QString(""),uCount);
+}
+
+void KviIdentityProfileSet::save(const QString & szConfigFile)
+{
+ KviConfigurationFile cfg(szConfigFile,KviConfigurationFile::Write);
+ cfg.clear();
+ save(&cfg,QString(""));
+}
+
+void KviIdentityProfileSet::save(KviConfigurationFile * pCfg, const QString & szPrefix)
+{
+ if(!m_pProfiles)
+ return;
+ if(m_pProfiles->isEmpty())
+ return;
+
+ QString szTmp;
+ if(m_bEnabled)
+ {
+ KviQString::sprintf(szTmp,"%QProfilesEnabled",&szPrefix);
+ pCfg->writeEntry(szTmp,m_bEnabled);
+ }
+
+ KviQString::sprintf(szTmp,"%QProfilesNumber",&szPrefix);
+ pCfg->writeEntry(szTmp,m_pProfiles->count());
+
+ int iIdx = 0;
+ for(KviIdentityProfile * pProfile = m_pProfiles->first(); pProfile; pProfile = m_pProfiles->next())
+ {
+ KviQString::sprintf(szTmp,"%QProfile%d_",&szPrefix,iIdx);
+ pProfile->save(pCfg,szTmp);
+ iIdx++;
+ }
+}
+
+bool KviIdentityProfileSet::loadPrivate(KviConfigurationFile * pCfg, const QString & szPrefix, unsigned int uEntries)
+{
+ if(m_pProfiles) m_pProfiles->clear();
+ else {
+ m_pProfiles = new KviPointerList<KviIdentityProfile>;
+ m_pProfiles->setAutoDelete(true);
+ }
+
+ if(uEntries != 0)
+ {
+ QString szTmp;
+ KviQString::sprintf(szTmp,"%QProfilesEnabled",&szPrefix);
+ m_bEnabled = pCfg->readBoolEntry(szTmp,false);
+
+ for(unsigned int u = 0; u < uEntries; u++)
+ {
+ KviQString::sprintf(szTmp,"%QProfile%u_",&szPrefix,u);
+ KviIdentityProfile * pProfile = new KviIdentityProfile();
+ if(!pProfile->load(pCfg,szTmp))
+ delete pProfile;
+ else m_pProfiles->append(pProfile);
+ }
+ }
+
+ if(m_pProfiles->isEmpty())
+ {
+ m_bEnabled = false;
+ delete m_pProfiles;
+ m_pProfiles = 0;
+ return false;
+ }
+ return true;
+}
diff --git a/src/kvilib/irc/KviIdentityProfileSet.h b/src/kvilib/irc/KviIdentityProfileSet.h
new file mode 100644
index 000000000..095cbabf4
--- /dev/null
+++ b/src/kvilib/irc/KviIdentityProfileSet.h
@@ -0,0 +1,188 @@
+#ifndef _KVI_IDENTITY_PROFILE_SET_H_
+#define _KVI_IDENTITY_PROFILE_SET_H_
+//=============================================================================
+//
+// File : KviIdentityProfileSet.h
+// Creation date : Thu Dec 30 2010 15:54:48 by Elvio Basello
+//
+// This file is part of the KVIrc irc client distribution
+// Copyright (C) 2010 Elvio Basello (hellvis69 at netsons dot org)
+//
+// This program is FREE software. You can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; either version 2
+// of the License, or (at your opinion) any later version.
+//
+// This program is distributed in the HOPE that it will be USEFUL,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+// See the GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, write to the Free Software Foundation,
+// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=============================================================================
+
+/**
+* \file KviIdentityProfileSet.h
+* \author Elvio Basello
+* \brief Identity profiles handling
+*/
+
+#include "kvi_settings.h"
+#include "KviHeapObject.h"
+#include "KviPointerList.h"
+#include "KviIdentityProfile.h"
+
+class KviConfigurationFile;
+
+/**
+* \class KviIdentityProfileSet
+* \brief Class which manages the list of identity profiles
+*/
+class KVILIB_API KviIdentityProfileSet : public KviHeapObject
+{
+public:
+ /**
+ * \brief Constructs the identity profile set object
+ * \return KviIdentityProfileSet
+ */
+ KviIdentityProfileSet();
+
+ /**
+ * \brief Constructs the identity profile set object
+ *
+ * This is a carbon copy.
+ * \param set A profile set to copy from
+ * \return KviIdentityProfileSet
+ */
+ KviIdentityProfileSet(const KviIdentityProfileSet & set);
+
+ /**
+ * \brief Destroys the identity profile set object
+ */
+ ~KviIdentityProfileSet();
+private:
+ static KviIdentityProfileSet * m_pSelf;
+ static unsigned int m_uCount;
+protected:
+ KviPointerList<KviIdentityProfile> * m_pProfiles;
+ bool m_bEnabled;
+public:
+ /**
+ * \brief Initializes the class instance
+ * \return void
+ */
+ static void init();
+
+ /**
+ * \brief Destroys the class instance
+ * \return void
+ */
+ static void done();
+
+ /**
+ * \brief Returns the instance of the class
+ * \return KviIdentityProfileSet *
+ */
+ static inline KviIdentityProfileSet * instance(){ return m_pSelf; };
+
+ /**
+ * \brief Returns the number of instances of the class
+ * \return unsigned int
+ */
+ unsigned int count(){ return m_uCount; };
+
+ /**
+ * \brief Returns the profiles set
+ * \return KviPointerList<KviIdentityProfile> *
+ */
+ KviPointerList<KviIdentityProfile> * profiles(){ return m_pProfiles; };
+
+ /**
+ * \brief Searches for a profile name. Returns true if the profile exists
+ * \param szName The name of the profile
+ * \return KviIdentityProfile *
+ */
+ KviIdentityProfile * findName(const QString & szName);
+
+ /**
+ * \brief Searches for a profile network. Returns true if the profile exists
+ * \param szNetwork The network name of the profile
+ * \return KviIdentityProfile *
+ */
+ KviIdentityProfile * findNetwork(const QString & szNetwork);
+
+ /**
+ * \brief Clears the list
+ * \return void
+ */
+ void clear();
+
+ /**
+ * \brief Returns true if the profile set is empty
+ * \return bool
+ */
+ bool isEmpty(){ return m_pProfiles ? m_pProfiles->isEmpty() : true; };
+
+ /**
+ * \brief Returns true if the profile set is enabled
+ * \return bool
+ */
+ bool isEnabled(){ return m_bEnabled; };
+
+ /**
+ * \brief Enables the profile set
+ * \param bEnabled Whether to enable the profile set
+ * \return void
+ */
+ void setEnabled(bool bEnabled){ m_bEnabled = bEnabled; };
+
+ /**
+ * \brief Carbon copy
+ * \param src The source profile set
+ * \return void
+ */
+ void copyFrom(const KviIdentityProfileSet & src);
+
+ /**
+ * \brief Adds a profile to the set
+ * \param pProfile The source profile to add
+ * \return void
+ */
+ void addProfile(KviIdentityProfile * pProfile);
+
+ /**
+ * \brief Loads the configuration of the profiles from file
+ * \param szConfigFile The file where to load
+ * \return void
+ */
+ void load(const QString & szConfigFile);
+
+ /**
+ * \brief Saves the configuration of the profiles to file
+ * \param szConfigFile The file to save
+ * \return void
+ */
+ void save(const QString & szConfigFile);
+
+ /**
+ * \brief Saves the configuration of the profiles
+ * \param pCfg The configuration file
+ * \param szPrefix The prefix of the rules
+ * \return void
+ */
+ void save(KviConfigurationFile * pCfg, const QString & szPrefix);
+protected:
+ /**
+ * \brief Loads the configuration of the profiles from file
+ * \param pCfg The configuration file
+ * \param szPrefix The prefix of the rules
+ * \param uEntries The number of entries
+ * \return bool
+ */
+ bool loadPrivate(KviConfigurationFile * pCfg, const QString & szPrefix, unsigned int uEntries);
+};
+
+#endif // _KVI_IDENTITY_PROFILE_SET_H_
diff --git a/src/kvilib/irc/KviIrcMask.cpp b/src/kvilib/irc/KviIrcMask.cpp
index 665386b23..5d248b397 100644
--- a/src/kvilib/irc/KviIrcMask.cpp
+++ b/src/kvilib/irc/KviIrcMask.cpp
@@ -22,8 +22,6 @@
//
//=============================================================================
-
-
#include "kvi_debug.h"
#include "KviIrcMask.h"
@@ -91,131 +89,35 @@
Pragma!*@*: matches any user with nickname "Pragma".[br]
*/
-/*
-const char * KviIrcMask::setMask(const char *szMask,char c)
-{
- KVI_ASSERT(szMask);
- //nick!username@host.top
- //0123456789
- register const char *p=szMask;
- //Run over nick....
- while(*p && (*p != '!'))p++;
- int len = p - szMask;
- if(len > 0){
- m_nick_ptr = (char *)KviMemory::reallocate(m_nick_ptr,len+1);
- KviMemory::move((void *)m_nick_ptr,(void *)szMask,len);
- } else { //Empty nick...set it to "*"
- len = 1;
- m_nick_ptr = (char *)KviMemory::reallocate(m_nick_ptr,len+1);
- KviMemory::move((void *)m_nick_ptr,(void *)"*",len);
- }
- *(m_nick_ptr+len) = '\0'; //With zero length nick it will be just an empty-string
- if(!(*p)){
- setHost("*");
- setUsername("*");
- return p;
- }
- szMask = ++p;
- //The username
- while(*p && (*p != '@'))p++;
- len = p - szMask;
- if(len > 0){
- m_user_ptr = (char *)KviMemory::reallocate(m_user_ptr,len+1);
- KviMemory::move((void *)m_user_ptr,(void *)szMask,len);
- } else {
- len = 1;
- m_user_ptr = (char *)KviMemory::reallocate(m_user_ptr,len+1);
- KviMemory::move((void *)m_user_ptr,(void *)"*",len);
- }
- *(m_user_ptr+len) = '\0';
- if(!(*p)){
- setHost("*");
- return p;
- }
- szMask = ++p;
- //And finally the host
- while(*p && (*p != c))p++;
- len = p - szMask;
- if(len > 0){
- m_host_ptr = (char *)KviMemory::reallocate(m_host_ptr,len+1);
- KviMemory::move((void *)m_host_ptr,(void *)szMask,len);
- } else {
- len = 1;
- m_host_ptr = (char *)KviMemory::reallocate(m_host_ptr,len+1);
- KviMemory::move((void *)m_host_ptr,(void *)"*",len);
- }
- *(m_host_ptr+len) = '\0';
- return p;
-}
-
-const char * KviIrcMask::setUserhostMask(const char *szMask)
-{
- KVI_ASSERT(szMask);
- //nick[*]=<+!->username@host.top
- //0123456789
- register const char *p=szMask;
- // Run over nick....
- while(*p && (*p != '*') && (*p != '=') && (!isspace(*p)))p++;
- // extract it
- int len = p - szMask;
- if(len > 0){
- m_nick_ptr = (char *)KviMemory::reallocate(m_nick_ptr,len+1);
- KviMemory::move((void *)m_nick_ptr,(void *)szMask,len);
- } else { //Empty nick...set it to "*"
- len = 1;
- m_nick_ptr = (char *)KviMemory::reallocate(m_nick_ptr,len+1);
- KviMemory::move((void *)m_nick_ptr,(void *)"*",len);
- }
- *(m_nick_ptr+len) = '\0'; //With zero length nick it will be just an empty-string
- // now skip all the flags
- while(*p && ((*p=='*')||(*p=='=')||(*p=='+')||(*p=='-')) && (!isspace(*p)))p++;
- // check...
- if((!(*p)) || isspace(*p)){
- // ooops, finished or isspace
- setHost("*");
- setUsername("*");
- while(*p && isspace(*p))p++;
- return p;
- }
-
- szMask = p;
- //The username
- while(*p && (*p != '@') && (!isspace(*p)))p++;
- len = p - szMask;
- if(len > 0){
- m_user_ptr = (char *)KviMemory::reallocate(m_user_ptr,len+1);
- KviMemory::move((void *)m_user_ptr,(void *)szMask,len);
- } else {
- len = 1;
- m_user_ptr = (char *)KviMemory::reallocate(m_user_ptr,len+1);
- KviMemory::move((void *)m_user_ptr,(void *)"*",len);
- }
- *(m_user_ptr+len) = '\0';
-
- if((!(*p))||isspace(*p)){
- // oops finished or isspace
- setHost("*");
- while(*p && isspace(*p))p++;
- return p;
- }
- szMask = ++p;
- //And finally the host
- while(*p && (!isspace(*p)))p++;
- len = p - szMask;
- if(len > 0){
- m_host_ptr = (char *)KviMemory::reallocate(m_host_ptr,len+1);
- KviMemory::move((void *)m_host_ptr,(void *)szMask,len);
- } else {
- len = 1;
- m_host_ptr = (char *)KviMemory::reallocate(m_host_ptr,len+1);
- KviMemory::move((void *)m_host_ptr,(void *)"*",len);
- }
- *(m_host_ptr+len) = '\0';
- while(*p && isspace(*p))p++;
- return p;
-}
-
-*/
+static unsigned char ucMaskTable[27][3] = {
+ { 0 , 0 , 0 }, //0 means normal block
+ { 0 , 0 , 2 }, //2 in the third field means type *.abc.host.top (or XXX.XXX.XXX.*) host mask
+ { 0 , 0 , 1 }, //2 in the second field means *user (strip prefixes)
+ { 0 , 1 , 0 }, //1 means *
+ { 0 , 1 , 2 }, //3 in the third field means type *.host.top (or XXX.XXX.*) host mask
+ { 0 , 1 , 1 }, //4 in the third field is like 3 but tries to detect masked ip addresses too
+ { 1 , 0 , 0 },
+ { 1 , 0 , 2 },
+ { 1 , 0 , 1 },
+ { 1 , 1 , 0 },
+ { 1 , 1 , 2 },
+ { 0 , 2 , 0 },
+ { 0 , 2 , 2 },
+ { 0 , 2 , 1 },
+ { 1 , 2 , 0 },
+ { 1 , 2 , 2 },
+ { 1 , 2 , 1 },
+ { 0 , 0 , 3 },
+ { 0 , 1 , 3 },
+ { 1 , 0 , 3 },
+ { 0 , 2 , 3 },
+ { 1 , 2 , 3 },
+ { 0 , 0 , 4 },
+ { 0 , 1 , 4 },
+ { 1 , 0 , 4 },
+ { 0 , 2 , 4 },
+ { 1 , 2 , 4 }
+};
KviIrcMask::KviIrcMask()
{
@@ -224,55 +126,56 @@ KviIrcMask::KviIrcMask()
m_szNick = m_szWild;
}
-KviIrcMask::KviIrcMask(const QString &szMask)
+KviIrcMask::KviIrcMask(const QString & szMask)
{
static QString szWild("*");
- const QChar * b = KviQString::nullTerminatedArray(szMask);
- if(b)
+ const QChar * pChar = KviQString::nullTerminatedArray(szMask);
+ if(pChar)
{
- const QChar * p = b;
- while(p->unicode() && (p->unicode() != '!'))p++;
- if(p->unicode())
+ const QChar * pChar2 = pChar;
+ while(pChar2->unicode() && (pChar2->unicode() != '!'))
+ pChar2++;
+ if(pChar2->unicode())
{
- if(p != b)
- {
- m_szNick.setUnicode(b,p-b);
- } else {
+ if(pChar2 != pChar)
+ m_szNick.setUnicode(pChar,pChar2-pChar);
+ else
m_szNick = szWild; // ???
- }
} else {
- if(p != b)m_szNick.setUnicode(b,p-b);
- else m_szNick = szWild; // ???
+ if(pChar2 != pChar)
+ m_szNick.setUnicode(pChar,pChar2-pChar);
+ else
+ m_szNick = szWild; // ???
m_szUser = szWild;
m_szHost = szWild;
return;
}
- p++;
- b = p;
- while(p->unicode() && (p->unicode() != '@'))p++;
- if(p->unicode())
+ pChar2++;
+ pChar = pChar2;
+ while(pChar2->unicode() && (pChar2->unicode() != '@'))
+ pChar2++;
+ if(pChar2->unicode())
{
- if(p != b)
- {
- m_szUser.setUnicode(b,p-b);
- } else {
+ if(pChar2 != pChar)
+ m_szUser.setUnicode(pChar,pChar2-pChar);
+ else
m_szUser = szWild; // ???
- }
} else {
- if(p != b)m_szUser.setUnicode(b,p-b);
- else m_szUser = szWild; // ???
+ if(pChar2 != pChar)
+ m_szUser.setUnicode(pChar,pChar2-pChar);
+ else
+ m_szUser = szWild; // ???
m_szHost = szWild;
return;
}
- p++;
- b=p;
- while(p->unicode())p++;
- if(p != b)
- {
- m_szHost.setUnicode(b,p-b);
- } else {
+ pChar2++;
+ pChar = pChar2;
+ while(pChar2->unicode())
+ pChar2++;
+ if(pChar2 != pChar)
+ m_szHost.setUnicode(pChar,pChar2-pChar);
+ else
m_szHost = szWild; // ???
- }
} else {
m_szUser = szWild;
@@ -285,119 +188,44 @@ QString KviIrcMask::m_szWild("*");
bool KviIrcMask::hasNumericHost() const
{
- const QChar * p = KviQString::nullTerminatedArray(m_szHost);
- if(!p)return false;
- int nPoints = 0;
- int nDoublePoints = 0;
+ const QChar * pChar = KviQString::nullTerminatedArray(m_szHost);
+ if(!pChar)
+ return false;
+ int iPoints = 0;
+ int iDoublePoints = 0;
unsigned short uc;
if(m_szHost.endsWith("=")) // for CR servers, see ticket #358
return true;
- while((uc = p->unicode()))
+ while((uc = pChar->unicode()))
{
- if(uc == '.')nPoints++; // ipv6 masks can contain dots too!
+ if(uc == '.')
+ iPoints++; // ipv6 masks can contain dots too!
else {
- if(uc == ':')nDoublePoints++;
+ if(uc == ':')
+ iDoublePoints++;
else {
if((uc < '0') || (uc > '9'))
{
- uc = p->toUpper().unicode();
- if((uc < 'A') || (uc > 'F'))return false;
+ uc = pChar->toUpper().unicode();
+ if((uc < 'A') || (uc > 'F'))
+ return false;
}
}
}
- p++;
+ pChar++;
}
- return ((nPoints == 3) || (nDoublePoints > 1));
+ return ((iPoints == 3) || (iDoublePoints > 1));
}
-
-/**
-* Returns in szMask the specified (if possible) mask of this user.<br>
-* If the host or username are not known, the mask may contain less information
-* than requested.<br>
-* Mask types:<br>
-* 0 : nick!user@machine.host.top (nick!user@XXX.XXX.XXX.XXX) (default)<br>
-* 1 : nick!user@*.host.top (nick!user@XXX.XXX.XXX.*)<br>
-* 2 : nick!user@*<br>
-* 3 : nick!*@machine.host.top (nick!user@XXX.XXX.XXX.XXX)<br>
-* 4 : nick!*@*.host.top (nick!user@XXX.XXX.XXX.*)<br>
-* 5 : nick!*@*<br>
-* 6 : *!user@machine.host.top (*!user@XXX.XXX.XXX.XX)<br>
-* 7 : *!user@*.host.top (*!user@XXX.XXX.XXX.*)<br>
-* 8 : *!user@*<br>
-* 9 : *!*@machine.host.top (*!*@XXX.XXX.XXX.XXX)<br>
-* 10: *!*@*.host.top (*!*@XXX.XXX.XXX.*)<br>
-* 11: nick!*user@machine.host.top (nick!*user@machine.host.top)<br>
-* 12: nick!*user@*.host.top (nick!*user@*.host.top)<br>
-* 13: nick!*user@*<br>
-* 14: *!*user@machine.host.top (*!*user@machine.host.top)<br>
-* 15: *!*user@*.host.top (*!*user@*.host.top)<br>
-* 16: *!*user@*<br>
-* 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:<br>
-* 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
-*/
-
-static unsigned char maskTable[27][3] = {
- { 0 , 0 , 0 }, //0 means normal block
- { 0 , 0 , 2 }, //2 in the third field means type *.abc.host.top (or XXX.XXX.XXX.*) host mask
- { 0 , 0 , 1 }, //2 in the second field means *user (strip prefixes)
- { 0 , 1 , 0 }, //1 means *
- { 0 , 1 , 2 }, //3 in the third field means type *.host.top (or XXX.XXX.*) host mask
- { 0 , 1 , 1 }, //4 in the third field is like 3 but tries to detect masked ip addresses too
- { 1 , 0 , 0 },
- { 1 , 0 , 2 },
- { 1 , 0 , 1 },
- { 1 , 1 , 0 },
- { 1 , 1 , 2 },
- { 0 , 2 , 0 },
- { 0 , 2 , 2 },
- { 0 , 2 , 1 },
- { 1 , 2 , 0 },
- { 1 , 2 , 2 },
- { 1 , 2 , 1 },
- { 0 , 0 , 3 },
- { 0 , 1 , 3 },
- { 1 , 0 , 3 },
- { 0 , 2 , 3 },
- { 1 , 2 , 3 },
- { 0 , 0 , 4 },
- { 0 , 1 , 4 },
- { 1 , 0 , 4 },
- { 0 , 2 , 4 },
- { 1 , 2 , 4 }
-};
-
-void KviIrcMask::mask(QString &szMask,MaskType eMaskType) const
+void KviIrcMask::mask(QString & szMask, MaskType eMaskType) const
{
- if((((int)eMaskType) > 26)||(((int)eMaskType) < 0))eMaskType = NickUserHost;
- szMask = maskTable[((int)eMaskType)][0] ? m_szWild : m_szNick;
+ if((((int)eMaskType) > 26)||(((int)eMaskType) < 0))
+ eMaskType = NickUserHost;
+ szMask = ucMaskTable[((int)eMaskType)][0] ? m_szWild : m_szNick;
szMask.append("!");
- switch(maskTable[((int)eMaskType)][1])
+ switch(ucMaskTable[((int)eMaskType)][1])
{
case 0:
szMask.append(m_szUser);
@@ -406,21 +234,23 @@ void KviIrcMask::mask(QString &szMask,MaskType eMaskType) const
szMask.append(m_szWild);
break;
default:
- if (m_szUser.length() > 0) {
+ if(m_szUser.length() > 0)
+ {
if(m_szUser[0].unicode() != '*')
szMask.append(m_szWild);
- if ((m_szUser[0].unicode() == '~') ||
+ if((m_szUser[0].unicode() == '~') ||
(m_szUser[0].unicode() == '^') ||
(m_szUser[0].unicode() == '+') ||
(m_szUser[0].unicode() == '-') ||
- (m_szUser[0].unicode() == '='))szMask.append(m_szUser.right(m_szUser.length() - 1));
+ (m_szUser[0].unicode() == '='))
+ szMask.append(m_szUser.right(m_szUser.length() - 1));
else
szMask.append(m_szUser);
}
break;
}
szMask.append('@');
- switch(maskTable[((int)eMaskType)][2])
+ switch(ucMaskTable[((int)eMaskType)][2])
{
case 0:
szMask.append(m_szHost);
@@ -479,237 +309,150 @@ void KviIrcMask::mask(QString &szMask,MaskType eMaskType) const
}
}
-
-/*
-bool KviIrcMask::matches(const char *szMask)
-{
- const char * ret1;
- const char * ret2;
-
- if(kvi_matchWildExprWithTerminator(szMask,m_nick_ptr,'!',&ret1,&ret2))
- {
- if(*ret1 == '!')
- {
- ret1++;
- if(kvi_matchWildExprWithTerminator(ret1,m_user_ptr,'@',&ret1,&ret2))
- {
- if(*ret1 == '@')
- {
- ret1++;
- return kvi_matchWildExpr(ret1,m_host_ptr);
- }
- }
- }
- }
- return false;
-}
-*/
-
-/*
-bool KviIrcMask::matchesFixed(const char *szMask) const
-{
- const char * ret1;
- const char * ret2;
-
- if(kvi_matchStringWithTerminator(m_nick_ptr,szMask,'!',&ret1,&ret2))
- {
- if(*ret2 == '!')
- {
- ret2++;
- if(kvi_matchStringWithTerminator(m_user_ptr,ret2,'@',&ret1,&ret2))
- {
- if(*ret2 == '@')
- {
- ret2++;
- return kvi_matchString(m_host_ptr,ret2);
- }
- }
- }
- }
- return false;
-}
-*/
-
-/*
-bool KviIrcMask::matchedBy(const QString &szMask) const
-{
- const char * ret1;
- const char * ret2;
-
- if(kvi_matchStringWithTerminator(szMask,m_nick_ptr,'!',&ret1,&ret2))
- {
- if(*ret1 == '!')
- {
- ret1++;
- if(kvi_matchStringWithTerminator(ret1,m_user_ptr,'@',&ret1,&ret2))
- {
- if(*ret1 == '@')
- {
- ret1++;
- return kvi_matchString(ret1,m_host_ptr);
- }
- }
- }
- }
- return false;
-}
-*/
-
-bool KviIrcMask::matches(const KviIrcMask &mask) const
+bool KviIrcMask::matches(const KviIrcMask & mask) const
{
if(KviQString::matchWildExpressions(m_szNick,mask.m_szNick))
{
if(KviQString::matchWildExpressions(m_szUser,mask.m_szUser))
{
- if(KviQString::matchWildExpressions(m_szHost,mask.m_szHost))return true;
+ if(KviQString::matchWildExpressions(m_szHost,mask.m_szHost))
+ return true;
}
}
return false;
}
-bool KviIrcMask::matchesFixed(const KviIrcMask &mask) const
+bool KviIrcMask::matchesFixed(const KviIrcMask & mask) const
{
if(KviQString::matchString(m_szNick,mask.m_szNick,false,true))
{
if(KviQString::matchString(m_szUser,mask.m_szUser,false,true))
{
if(KviQString::matchString(m_szHost,mask.m_szHost,false,true))
- {
return true;
- }
}
}
return false;
}
-/*
-bool KviIrcMask::matches(const char * nick,const char * user,const char * host)
-{
- if(nick)
- {
- if(!kvi_matchWildExpr(m_nick_ptr,nick))return false;
- }
-
- if(user)
- {
- if(!kvi_matchWildExpr(m_user_ptr,user))return false;
- }
-
- if(host)
- {
- if(!kvi_matchWildExpr(m_host_ptr,host))return false;
- }
- return true;
-}
-*/
-
-bool KviIrcMask::matchesFixed(const QString &nick,const QString &user,const QString &host) const
+bool KviIrcMask::matchesFixed(const QString & szNick, const QString & szUser, const QString & szHost) const
{
- if(!KviQString::matchString(m_szNick,nick,false,true)) return false;
- if(!KviQString::matchString(m_szUser,user,false,true)) return false;
- if(!KviQString::matchString(m_szHost,host,false,true)) return false;
+ if(!KviQString::matchString(m_szNick,szNick,false,true))
+ return false;
+ if(!KviQString::matchString(m_szUser,szUser,false,true))
+ return false;
+ if(!KviQString::matchString(m_szHost,szHost,false,true))
+ return false;
return true;
}
-//Internals for mask()
-
int KviIrcMask::getIpDomainMaskLen() const
{
- int len = m_szHost.length();
- const QChar *p = m_szHost.unicode();
- const QChar *b = p;
- p += len;
- if(b < p)
+ int iLen = m_szHost.length();
+ const QChar * pChar = m_szHost.unicode();
+ const QChar * pChar2 = pChar;
+ pChar += iLen;
+ if(pChar2 < pChar)
{
- p--;
- while((b < p) && (p->unicode() != '.') && (p->unicode() != ':'))p--;
+ pChar--;
+ while((pChar2 < pChar) && (pChar->unicode() != '.') && (pChar->unicode() != ':'))
+ pChar--;
}
// 000.000.000.000
- // p
+ // pChar
//
- return (p == b) ? 0 : ((p-b) + 1);
+ return (pChar == pChar2) ? 0 : ((pChar-pChar2) + 1);
}
int KviIrcMask::getLargeIpDomainMaskLen() const
{
- int len = m_szHost.length();
- const QChar *p = m_szHost.unicode();
- const QChar *b = p;
- p += len;
- if(b < p)
+ int iLen = m_szHost.length();
+ const QChar * pChar = m_szHost.unicode();
+ const QChar * pChar2 = pChar;
+ pChar += iLen;
+ if(pChar2 < pChar)
{
- p--;
- while((b < p) && (p->unicode() != '.') && (p->unicode() != ':'))p--;
- if(b < p)
+ pChar--;
+ while((pChar2 < pChar) && (pChar->unicode() != '.') && (pChar->unicode() != ':'))
+ pChar--;
+ if(pChar2 < pChar)
{
- p--;
- while((b < p) && (p->unicode() != '.') && (p->unicode() != ':'))p--;
+ pChar--;
+ while((pChar2 < pChar) && (pChar->unicode() != '.') && (pChar->unicode() != ':'))
+ pChar--;
}
}
// 000.000.000.000
- // p
+ // pChar
//
- return (p == b) ? 0 : ((p-b) + 1);
+ return (pChar == pChar2) ? 0 : ((pChar-pChar2) + 1);
}
QString KviIrcMask::getHostDomainMask() const
{
- int len = m_szHost.length();
- const QChar *p=KviQString::nullTerminatedArray(m_szHost);
- if(!p)return QString();
- const QChar *b = p;
- while(p->unicode() && p->unicode() != '.')p++;
- QString ret(p,len - (p - b));
- return ret;
+ int iLen = m_szHost.length();
+ const QChar * pChar = KviQString::nullTerminatedArray(m_szHost);
+ if(!pChar)
+ return QString();
+ const QChar * pChar2 = pChar;
+ while(pChar->unicode() && pChar->unicode() != '.')
+ pChar++;
+ QString szRet(pChar,iLen - (pChar - pChar2));
+ return szRet;
}
QString KviIrcMask::getLargeHostDomainMask() const
{
- int len = m_szHost.length();
- const QChar *p = m_szHost.unicode();
- const QChar *b = p;
- p += len;
+ int iLen = m_szHost.length();
+ const QChar * pChar = m_szHost.unicode();
+ const QChar * pChar2 = pChar;
+ pChar += iLen;
- if(b < p)
+ if(pChar2 < pChar)
{
- p--;
- while((b < p) && (p->unicode() != '.'))p--;
- if(b < p)
+ pChar--;
+ while((pChar2 < pChar) && (pChar->unicode() != '.'))
+ pChar--;
+ if(pChar2 < pChar)
{
- p--;
- while((b < p) && (p->unicode() != '.'))p--;
+ pChar--;
+ while((pChar2 < pChar) && (pChar->unicode() != '.'))
+ pChar--;
}
}
// xyz.klm.abc.host.top
- // p
+ // pChar
- QString ret(p,len - (p - b));
- return ret;
+ QString szRet(pChar,iLen - (pChar - pChar2));
+ return szRet;
}
bool KviIrcMask::hasMaskedIp() const
{
- int len = m_szHost.length();
- const QChar *p = m_szHost.unicode();
- const QChar *b = p;
- if(len == 0)return false;
+ int iLen = m_szHost.length();
+ const QChar * pChar = m_szHost.unicode();
+ const QChar * pChar2 = pChar;
+ if(iLen == 0)
+ return false;
//run to the end
- p += len;
- const QChar *e = p;
- p--;
- while((b < p) && (p->unicode() != '.'))p--;
- return ((e - p) > 4); // at the moment 4 should be enough : the largest top part is "name"
+ pChar += iLen;
+ const QChar * pChar3 = pChar;
+ pChar--;
+ while((pChar2 < pChar) && (pChar->unicode() != '.'))
+ pChar--;
+ return ((pChar3 - pChar) > 4); // at the moment 4 should be enough : the largest top part is "name"
}
-bool KviIrcMask::operator==(const KviIrcMask &user)
+bool KviIrcMask::operator==(const KviIrcMask & user)
{
if(KviQString::equalCI(m_szNick,user.m_szNick))
{
if(KviQString::equalCI(m_szUser,user.m_szUser))
{
- if(KviQString::equalCI(m_szHost,user.m_szHost))return true;
+ if(KviQString::equalCI(m_szHost,user.m_szHost))
+ return true;
}
}
return false;
@@ -717,13 +460,15 @@ bool KviIrcMask::operator==(const KviIrcMask &user)
bool KviIrcMask::hasWildNick()
{
- const QChar * aux = KviQString::nullTerminatedArray(m_szNick);
- if(!aux)return false;
+ const QChar * pAux = KviQString::nullTerminatedArray(m_szNick);
+ if(!pAux)
+ return false;
unsigned short uc;
- while((uc = aux->unicode()))
+ while((uc = pAux->unicode()))
{
- if((uc == '*') || (uc == '?'))return true;
- aux++;
+ if((uc == '*') || (uc == '?'))
+ return true;
+ pAux++;
}
return false;
}
@@ -731,28 +476,32 @@ bool KviIrcMask::hasWildNick()
int KviIrcMask::nonWildChars()
{
int iCnt = 0;
- const QChar * aux = KviQString::nullTerminatedArray(m_szNick);
- if(!aux)return 0;
+ const QChar * pAux = KviQString::nullTerminatedArray(m_szNick);
+ if(!pAux)
+ return 0;
unsigned short uc;
- while((uc = aux->unicode()))
+ while((uc = pAux->unicode()))
{
- if((uc != '*') && (uc != '?'))iCnt++;
- aux++;
+ if((uc != '*') && (uc != '?'))
+ iCnt++;
+ pAux++;
}
- aux = KviQString::nullTerminatedArray(m_szUser);
- while((uc = aux->unicode()))
+ pAux = KviQString::nullTerminatedArray(m_szUser);
+ while((uc = pAux->unicode()))
{
- if((uc != '*') && (uc != '?'))iCnt++;
- aux++;
+ if((uc != '*') && (uc != '?'))
+ iCnt++;
+ pAux++;
}
- aux = KviQString::nullTerminatedArray(m_szHost);
- while((uc = aux->unicode()))
+ pAux = KviQString::nullTerminatedArray(m_szHost);
+ while((uc = pAux->unicode()))
{
- if((uc != '*') && (uc != '?'))iCnt++;
- aux++;
+ if((uc != '*') && (uc != '?'))
+ iCnt++;
+ pAux++;
}
return iCnt;
}
diff --git a/src/kvilib/irc/KviIrcMask.h b/src/kvilib/irc/KviIrcMask.h
index a74aa5f32..79b82fa36 100644
--- a/src/kvilib/irc/KviIrcMask.h
+++ b/src/kvilib/irc/KviIrcMask.h
@@ -85,10 +85,11 @@ public:
/**
* \enum MaskType
+ * \brief Defines the type of the masks
*/
enum MaskType
{
- NickUserHost = 0, /**< nick!~user@machine.host.top (default) */
+ NickUserHost = 0, /**< 0 : nick!~user@machine.host.top (default) */
NickUserNet = 1, /**< 1 : nick!~user@*.abc.host.top */
NickUser = 2, /**< 2 : nick!~user@* */
NickHost = 3, /**< 3 : nick!*@machine.host.top */
@@ -143,7 +144,7 @@ public:
* \param szUser The username of the user
* \return void
*/
- void setUser(const QString &szUser){ m_szUser = szUser.isEmpty() ? m_szWild : szUser; };
+ void setUser(const QString & szUser){ m_szUser = szUser.isEmpty() ? m_szWild : szUser; };
/**
* \brief Sets the host for this user.
@@ -152,21 +153,7 @@ public:
* \param szHost The hostname of the user
* \return void
*/
- void setHost(const QString &szHost){ m_szHost = szHost.isEmpty() ? m_szWild : szHost; };
-
- // Sets the host, nick and username extracting it from an irc mask:
- // nick!user@host
- // The mask is terminated by end-of string null character or a character equal to c in the string.
- // Returns the pointer to the end of the mask in the szMask string.(c or null-terminator)
- //const char * setMask(const QString &szMask,char c=' ');
-
- // Sets the host, nick and username extracting it from an userhost mask:
- // nick[*]=<+|->user@host
- // The mask is terminated by end-of string null char or a space character.
- // Returns the pointer to the next non-space char in the szMask string or to the null-terminator
- // If there are no more masks avaiable.
- // WARNING : the szMask pointer can NOT be NULL
- //const char *setUserhostMask(const QString &szMask);
+ void setHost(const QString & szHost){ m_szHost = szHost.isEmpty() ? m_szWild : szHost; };
/**
* \brief Returns the nickname of this user.
@@ -215,8 +202,51 @@ public:
*
* 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
* \param szMask The mask of the user
* \param eMaskType The mask type
+ * \return void
*/
void mask(QString & szMask, MaskType eMaskType = NickCleanUserHost) const;
@@ -231,9 +261,6 @@ public:
* \param mask The mask of the user
* \return bool
*/
- //bool matches(const char *szMask);
- // passing 0 as one of params here means that it is a match by default
- //bool matches(const char *nick,const char *user,const char *host);
bool matches(const KviIrcMask & mask) const;
/**
@@ -243,8 +270,7 @@ public:
* \param host The hostname of the user
* \return bool
*/
- bool matchesFixed(const QString & nick, const QString & user, const QString & host) const;
- //bool matchesFixed(const QString &szMask) const;
+ bool matchesFixed(const QString & szNick, const QString & szUser, const QString & szHost) const;
/**
* \brief Fixed external matches (this is wild, external is fixed)
@@ -258,7 +284,6 @@ public:
* \param mask The mask of the user
* \return bool
*/
- //bool matchedBy(const QString &szMask) const;
bool matchedBy(const KviIrcMask & mask) const { return mask.matchesFixed(*this); };
/**
diff --git a/src/kvilib/irc/KviIrcNetwork.h b/src/kvilib/irc/KviIrcNetwork.h
index d4c169ad4..88ff3ab44 100644
--- a/src/kvilib/irc/KviIrcNetwork.h
+++ b/src/kvilib/irc/KviIrcNetwork.h
@@ -39,7 +39,7 @@
class KviNickServRuleSet;
class KviIrcServer;
-class QStringList;
+
/**
* \class KviIrcNetwork
@@ -70,20 +70,18 @@ public:
protected:
QString m_szName;
QString m_szDescription;
- QString m_szEncoding; // if empty, use system default
- QString m_szTextEncoding; // if empty, use system default
- QString m_szNickName; // preferred nick name
- QString m_szUserName; // preferred user name
- QString m_szRealName; // preferred real name
- QString m_szPass; // special password
- QString m_szOnConnectCommand; // the command to run on connect
- QString m_szOnLoginCommand; // the command to run after login
- QStringList * m_pChannelList; // Channels to auto join
- KviNickServRuleSet * m_pNickServRuleSet; // set of nick serv rules
- bool m_bAutoConnect; // autoconnect
- QString m_szUserIdentityId; // The user identity to use for this server: if empty
- // Then use the global primary identity
- //moved from KviIrcServerDataBaseRecord
+ QString m_szEncoding; /**< if empty, use system default */
+ QString m_szTextEncoding; /**< if empty, use system default */
+ QString m_szNickName; /**< preferred nick name */
+ QString m_szUserName; /**< preferred user name */
+ QString m_szRealName; /**< preferred real name */
+ QString m_szPass; /**< special password */
+ QString m_szOnConnectCommand; /**< the command to run on connect */
+ QString m_szOnLoginCommand; /**< the command to run after login */
+ QStringList * m_pChannelList; /**< Channels to auto join */
+ KviNickServRuleSet * m_pNickServRuleSet; /**< set of nick serv rules */
+ bool m_bAutoConnect; /**< autoconnect */
+ QString m_szUserIdentityId; /**< The user identity to use for this server: if empty then use the global primary identity moved from KviIrcServerDataBaseRecord */
KviPointerList<KviIrcServer> * m_pServerList;
KviIrcServer * m_pCurrentServer;
public:
@@ -187,14 +185,14 @@ public:
* \param s The rule set where to add rules
* \return void
*/
- void setNickServRuleSet(KviNickServRuleSet * s);
+ void setNickServRuleSet(KviNickServRuleSet * pSet);
/**
* \brief Carbon copy
- * \param d The source network to copy from
+ * \param net The source network to copy from
* \return void
*/
- void copyFrom(const KviIrcNetwork & d);
+ void copyFrom(const KviIrcNetwork & net);
/**
* \brief Sets the name of the network
@@ -231,44 +229,45 @@ public:
/**
* \brief Sets the list of commands to run on network connection
- * \param cmd The commands list to run
+ * \param szCmd The commands list to run
* \return void
*/
- inline void setOnConnectCommand(const QString & cmd){ m_szOnConnectCommand = cmd; };
+ inline void setOnConnectCommand(const QString & szCmd){ m_szOnConnectCommand = szCmd; };
/**
* \brief Sets the list of commands to run on network login
- * \param cmd The commands list to run
+ * \param szCmd The commands list to run
* \return void
*/
- inline void setOnLoginCommand(const QString & cmd){ m_szOnLoginCommand = cmd; };
+ inline void setOnLoginCommand(const QString & szCmd){ m_szOnLoginCommand = szCmd; };
/**
* \brief Sets the nickname of the user associated to the network
- * \param n The nickname
+ * \param szNick The nickname
* \return void
*/
- inline void setNickName(const QString & n){ m_szNickName = n; };
+ inline void setNickName(const QString & szNick){ m_szNickName = szNick; };
/**
* \brief Sets the realname of the user associated to the network
- * \param r The realname
+ * \param szReal The realname
* \return void
*/
- inline void setRealName(const QString & r){ m_szRealName = r; };
+ inline void setRealName(const QString & szReal){ m_szRealName = szReal; };
/**
* \brief Sets the username of the user associated to the network
- * \param u The username
+ * \param szUser The username
* \return void
*/
- inline void setUserName(const QString & u){ m_szUserName = u; };
+ inline void setUserName(const QString & szUser){ m_szUserName = szUser; };
/**
* \brief Sets the password of the user associated to the network
+ * \param szPass The password
* \return void
*/
- inline void setPassword(const QString & p){ m_szPass = p; };
+ inline void setPassword(const QString & szPass){ m_szPass = szPass; };
/**
* \brief Sets the list of channels to mark for autojoin
@@ -312,10 +311,10 @@ public:
/**
* \brief Adds a new server to the network
- * \param srv The source server to add
+ * \param pServer The source server to add
* \return void
*/
- void insertServer(KviIrcServer * srv);
+ void insertServer(KviIrcServer * pServer);
/**
* \brief Searches for a server in the network
@@ -333,10 +332,10 @@ public:
/**
* \brief Sets the current server
- * \param srv The source server
+ * \param pServer The source server
* \return void
*/
- void setCurrentServer(KviIrcServer * srv);
+ void setCurrentServer(KviIrcServer * pServer);
};
#endif // KVI_NETWORK_H_
diff --git a/src/kvilib/irc/KviNickServRule.h b/src/kvilib/irc/KviNickServRule.h
index fb7f63182..35e49ffab 100644
--- a/src/kvilib/irc/KviNickServRule.h
+++ b/src/kvilib/irc/KviNickServRule.h
@@ -1,5 +1,5 @@
-#ifndef _KviNickServRule_h_
-#define _KviNickServRule_h_
+#ifndef _KVI_NICKSERV_RULE_H_
+#define _KVI_NICKSERV_RULE_H_
//=============================================================================
//
// File : KviNickServRule.h
@@ -81,4 +81,4 @@ public:
};
-#endif // _KviNickServRule_h_
+#endif // _KVI_NICKSERV_RULE_H_
diff --git a/src/kvilib/irc/KviNickServRuleSet.h b/src/kvilib/irc/KviNickServRuleSet.h
index a32d87d8e..00bf1c151 100644
--- a/src/kvilib/irc/KviNickServRuleSet.h
+++ b/src/kvilib/irc/KviNickServRuleSet.h
@@ -1,5 +1,5 @@
-#ifndef _KviNickServRuleSet_h_
-#define _KviNickServRuleSet_h_
+#ifndef _KVI_NICKSERV_RULE_SET_H_
+#define _KVI_NICKSERV_RULE_SET_H_
//=============================================================================
//
// File : KviNickServRuleSet.h
@@ -62,4 +62,4 @@ protected:
};
-#endif //!_KviNickServRuleSet_h_
+#endif // _KVI_NICKSERV_RULE_SET_H_
diff --git a/src/kvirc/kernel/KviApplication.cpp b/src/kvirc/kernel/KviApplication.cpp
index 086dc8874..ec21593bd 100644
--- a/src/kvirc/kernel/KviApplication.cpp
+++ b/src/kvirc/kernel/KviApplication.cpp
@@ -52,7 +52,7 @@
#include "kvi_out.h"
#include "KviSplashScreen.h"
#include "KviNickServRuleSet.h"
-#include "KviIdentityProfile.h"
+#include "KviIdentityProfileSet.h"
#include "KviDefaultScript.h"
#include "KviXlib.h"
#include "KviTextIconManager.h"
diff --git a/src/kvirc/kernel/KviIrcConnection.cpp b/src/kvirc/kernel/KviIrcConnection.cpp
index 20474f787..028322b2b 100644
--- a/src/kvirc/kernel/KviIrcConnection.cpp
+++ b/src/kvirc/kernel/KviIrcConnection.cpp
@@ -67,7 +67,7 @@
#include "KviKvsScript.h"
#include "KviMircCntrl.h"
#include "KviUserIdentity.h"
-#include "KviIdentityProfile.h"
+#include "KviIdentityProfileSet.h"
#include "KviSASL.h"
#include "KviNickColors.h"
diff --git a/src/kvirc/sparser/KviIrcServerParser_numericHandlers.cpp b/src/kvirc/sparser/KviIrcServerParser_numericHandlers.cpp
index cedc8ea2a..1d0062ee9 100644
--- a/src/kvirc/sparser/KviIrcServerParser_numericHandlers.cpp
+++ b/src/kvirc/sparser/KviIrcServerParser_numericHandlers.cpp
@@ -54,7 +54,7 @@
#include "KviKvsEventTriggers.h"
#include "KviKvsScript.h"
#include "KviKvsVariantList.h"
-#include "KviIdentityProfile.h"
+#include "KviIdentityProfileSet.h"
#include <QPixmap>
#include <QDateTime>
diff --git a/src/modules/options/optw_identity.cpp b/src/modules/options/optw_identity.cpp
index 6550a9ff3..7ef4ac1d3 100644
--- a/src/modules/options/optw_identity.cpp
+++ b/src/modules/options/optw_identity.cpp
@@ -26,6 +26,7 @@
#include "kvi_defaults.h"
#include "kvi_settings.h"
+#include "kvi_fileextensions.h"
#include "KviOptions.h"
#include "KviLocale.h"
#include "KviApplication.h"
@@ -33,14 +34,13 @@
#include "KviConsoleWindow.h"
#include "KviOptionsWidget.h"
#include "KviFileDialog.h"
-#include "kvi_fileextensions.h"
#include "KviIconManager.h"
#include "KviHttpRequest.h"
-#include "KviIdentityProfile.h"
+#include "KviIdentityProfileSet.h"
#include "KviTalToolTip.h"
#include "KviTalHBox.h"
-#include <QTreeWidget>
+#include <QTreeWidget>
#include <QCheckBox>
#include <QLineEdit>
#include <QPushButton>