diff options
| author | 2008-10-22 17:30:39 +0000 | |
|---|---|---|
| committer | 2008-10-22 17:30:39 +0000 | |
| commit | eed837f0ff4f2553d3089449b4c3a7d8d7f30663 (patch) | |
| tree | cc3f1993884d8c4367fe39ccf7d5b6e313d7cc7b /src | |
| parent | another fix in the input completition. (diff) | |
| download | KVIrc-eed837f0ff4f2553d3089449b4c3a7d8d7f30663.tar.gz KVIrc-eed837f0ff4f2553d3089449b4c3a7d8d7f30663.tar.bz2 KVIrc-eed837f0ff4f2553d3089449b4c3a7d8d7f30663.zip | |
more work on identity profiles (wip);
updated changelog;
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@2768 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src')
| -rw-r--r-- | src/kvilib/irc/kvi_identityprofile.cpp | 18 | ||||
| -rw-r--r-- | src/kvilib/irc/kvi_identityprofile.h | 13 | ||||
| -rw-r--r-- | src/kvirc/kernel/kvi_ircconnection.cpp | 17 | ||||
| -rw-r--r-- | src/kvirc/kernel/kvi_ircconnection.h | 12 | ||||
| -rw-r--r-- | src/modules/options/optw_identity.cpp | 2 |
5 files changed, 56 insertions, 6 deletions
diff --git a/src/kvilib/irc/kvi_identityprofile.cpp b/src/kvilib/irc/kvi_identityprofile.cpp index 98c6fb5be..ff0ebe1b9 100644 --- a/src/kvilib/irc/kvi_identityprofile.cpp +++ b/src/kvilib/irc/kvi_identityprofile.cpp @@ -141,14 +141,28 @@ void KviIdentityProfileSet::clear() m_bEnabled = false; } -KviIdentityProfile * KviIdentityProfileSet::findProfile(const QString & szProfile) +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::matchStringCI(pProfile->name(),szProfile,false,true)) + if(KviQString::matchStringCI(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::matchStringCI(pProfile->network(),szNetwork,false,true)) return pProfile; } diff --git a/src/kvilib/irc/kvi_identityprofile.h b/src/kvilib/irc/kvi_identityprofile.h index c1a9617f5..b13548fbe 100644 --- a/src/kvilib/irc/kvi_identityprofile.h +++ b/src/kvilib/irc/kvi_identityprofile.h @@ -231,11 +231,18 @@ public: KviPointerList<KviIdentityProfile> * profiles(){ return m_pProfiles; }; /** - * \brief Searches a profile. Returns true if the profile exists - * \param szProfile The name of the profile + * \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 * findProfile(const QString & szProfile); + KviIdentityProfile * findNetwork(const QString & szNetwork); /** * \brief Clears the list diff --git a/src/kvirc/kernel/kvi_ircconnection.cpp b/src/kvirc/kernel/kvi_ircconnection.cpp index 4ed4fd8ff..9c989dca8 100644 --- a/src/kvirc/kernel/kvi_ircconnection.cpp +++ b/src/kvirc/kernel/kvi_ircconnection.cpp @@ -65,6 +65,7 @@ #include "kvi_kvs_script.h" #include "kvi_mirccntrl.h" #include "kvi_useridentity.h" +#include "kvi_identityprofile.h" #include <QTimer> #include <QTextCodec> @@ -994,6 +995,17 @@ void KviIrcConnection::enableStartTlsSupport(bool bEnable) } #endif // COMPILE_SSL_SUPPORT +void KviIrcConnection::useProfileData(KviIdentityProfileSet * pSet, const QString & szNetwork) +{ + KviIdentityProfile * pProfile = pSet->findNetwork(szNetwork); + if(!pProfile) return; + + // Update connection data + m_pUserInfo->setNickName(pProfile->nick()); + m_pUserInfo->setUserName(pProfile->userName()); + m_pUserInfo->setRealName(pProfile->realName()); +} + void KviIrcConnection::loginToIrcServer() { debug("Loggin' in..."); @@ -1073,6 +1085,11 @@ void KviIrcConnection::loginToIrcServer() } } + // Check for identity profiles + KviIdentityProfileSet * pSet = KviIdentityProfileSet::instance(); + bool bProfilesEnabled = pSet ? (pSet->isEnabled() && !pSet->isEmpty()) : false; + if(bProfilesEnabled) useProfileData(pSet,pNet->name()); + // FIXME: The server's encoding! setupTextCodec(); KviQCString szNick = encodeText(m_pUserInfo->nickName()); // never empty diff --git a/src/kvirc/kernel/kvi_ircconnection.h b/src/kvirc/kernel/kvi_ircconnection.h index 2091cb4af..49aa44648 100644 --- a/src/kvirc/kernel/kvi_ircconnection.h +++ b/src/kvirc/kernel/kvi_ircconnection.h @@ -66,6 +66,7 @@ class KviLagMeter; class KviNotifyListManager; class KviDns; class KviUserIdentity; +class KviIdentityProfileSet; /** @@ -680,6 +681,17 @@ protected: #endif /** + * \brief Uses the profiles' data as connection data + * + * It checks if the identity profiles are enabled and updates the data + * of the connection if a profile rule matches the network name + * \param pSet The instance of the network identity profile set + * \param szNetwork The name of the network + * \return void + */ + void useProfileData(KviIdentityProfileSet * pSet, const QString & szNetwork); + + /** * \brief Logins to the irc server * \return void */ diff --git a/src/modules/options/optw_identity.cpp b/src/modules/options/optw_identity.cpp index aacdd20f6..08d2e53f2 100644 --- a/src/modules/options/optw_identity.cpp +++ b/src/modules/options/optw_identity.cpp @@ -969,7 +969,7 @@ void KviIdentityProfileEditor::okPressed() { KviIdentityProfileSet * pSet = KviIdentityProfileSet::instance(); - if(pSet->findProfile(m_pNameEdit->text())) + if(pSet->findName(m_pNameEdit->text())) { QMessageBox::warning(this,__tr2qs_ctx("Invalid Profile Rule","options"),__tr2qs_ctx("There is already a profile with that name","options"),__tr2qs_ctx("OK","options")); return; |
