From 128ac3dd722b24f161501ab6ab63e2f4dd89f7cf Mon Sep 17 00:00:00 2001 From: Fabio Bas Date: Fri, 19 Feb 2010 11:08:09 +0000 Subject: added a specialized serverinfo structure for ircd-seven; added funzion $context.serverSoftware() git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@3989 17fca916-40b9-46aa-a4ea-0a15b648b75c --- src/kvirc/kernel/kvi_ircconnectionserverinfo.cpp | 2 + src/kvirc/kernel/kvi_ircconnectionserverinfo.h | 14 +++++++ src/modules/context/libkvicontext.cpp | 47 ++++++++++++++++++++++++ 3 files changed, 63 insertions(+) (limited to 'src') diff --git a/src/kvirc/kernel/kvi_ircconnectionserverinfo.cpp b/src/kvirc/kernel/kvi_ircconnectionserverinfo.cpp index 040d309a6..466d80073 100644 --- a/src/kvirc/kernel/kvi_ircconnectionserverinfo.cpp +++ b/src/kvirc/kernel/kvi_ircconnectionserverinfo.cpp @@ -223,6 +223,8 @@ void KviIrcConnectionServerInfo::setServerVersion(const QString & version) m_pServInfo = new KviBahamutIrcServerInfo(version); else if(version.contains("hyperion",Qt::CaseInsensitive)) m_pServInfo = new KviHyperionIrcServerInfo(version); + else if(version.contains("ircd-seven",Qt::CaseInsensitive)) + m_pServInfo = new KviIrcdSevenIrcServerInfo(version); else m_pServInfo = new KviBasicIrcServerInfo(version); } diff --git a/src/kvirc/kernel/kvi_ircconnectionserverinfo.h b/src/kvirc/kernel/kvi_ircconnectionserverinfo.h index 293564940..0e32bfa13 100644 --- a/src/kvirc/kernel/kvi_ircconnectionserverinfo.h +++ b/src/kvirc/kernel/kvi_ircconnectionserverinfo.h @@ -47,6 +47,7 @@ public: const QString & getChannelModeDescription(QChar mode); const QString & getUserModeDescription(QChar mode); virtual char getRegisterModeChar() { return 0; }; + virtual const char * getSoftware() { return "Ircd"; }; }; class KVIRC_API KviUnrealIrcServerInfo : public KviBasicIrcServerInfo @@ -55,6 +56,7 @@ public: KviUnrealIrcServerInfo(const QString & version = KviQString::Empty) :KviBasicIrcServerInfo(version) {;}; virtual char getRegisterModeChar() { return 'r'; }; + virtual const char * getSoftware() { return "Unreal"; }; }; class KVIRC_API KviBahamutIrcServerInfo : public KviBasicIrcServerInfo @@ -63,6 +65,7 @@ public: KviBahamutIrcServerInfo(const QString & version = KviQString::Empty) :KviBasicIrcServerInfo(version) {;}; virtual char getRegisterModeChar() { return 'r'; }; + virtual const char * getSoftware() { return "Bahamut"; }; }; class KVIRC_API KviHyperionIrcServerInfo : public KviBasicIrcServerInfo @@ -71,6 +74,16 @@ public: KviHyperionIrcServerInfo(const QString & version = KviQString::Empty) :KviBasicIrcServerInfo(version) {;}; virtual char getRegisterModeChar() { return 'e'; }; + virtual const char * getSoftware() { return "Hyperion"; }; +}; + +class KVIRC_API KviIrcdSevenIrcServerInfo : public KviBasicIrcServerInfo +{ +public: + KviIrcdSevenIrcServerInfo(const QString & version = KviQString::Empty) + :KviBasicIrcServerInfo(version) {;}; + virtual char getRegisterModeChar() { return 0; }; + virtual const char * getSoftware() { return "Ircd-seven"; }; }; class KVIRC_API KviIrcConnectionServerInfo @@ -104,6 +117,7 @@ private: QStringList m_szaEnabledCaps; public: char registerModeChar() { return m_pServInfo ? m_pServInfo->getRegisterModeChar() : 0; }; + const char * software(){ return m_pServInfo ? m_pServInfo->getSoftware() : 0; }; const QString & name(){ return m_szName; }; const QString & supportedUserModes(){ return m_szSupportedUserModes; }; const QString & supportedChannelModes(){ return m_szSupportedChannelModes; }; diff --git a/src/modules/context/libkvicontext.cpp b/src/modules/context/libkvicontext.cpp index 5be368633..eae3af7d7 100644 --- a/src/modules/context/libkvicontext.cpp +++ b/src/modules/context/libkvicontext.cpp @@ -72,6 +72,22 @@ return true; \ } +#define STANDARD_SERVERINFO_TARGET_PARAMETER(_fncName,_setCall) \ + static bool _fncName(KviKvsModuleFunctionCall * c) \ + { \ + GET_CONNECTION_FROM_STANDARD_PARAMS \ + if(pConnection) \ + { \ + if(pConnection->serverInfo()) \ + { \ + _setCall; \ + return true; \ + } \ + } \ + c->returnValue()->setNothing(); \ + return true; \ + } + /* @doc: context.networkName @type: @@ -218,6 +234,36 @@ STANDARD_IRC_CONNECTION_TARGET_PARAMETER( c->returnValue()->setBoolean(pConnection->target()->server()->useSSL()) ) +/* + @doc: context.serverSoftware + @type: + function + @title: + $context.serverSoftware + @short: + Returns the software running on the irc server, if recognized + @syntax: + $context.serverSoftware + $context.serverSoftware() + @description: + Returns the software running on the irc server, if it has been + recognized at connection time. + If no irc_context_id is specified then the current irc_context is used. + If the irc_context_id specification is not valid then this function + returns nothing (that evaluates to false). If the specified IRC context + is not currently connected then this function returns nothing (that + evaluates to false). + @seealso: + [fnc]$context.serverPort[/fnc], + [fnc]$context.serverHostName[/fnc], + [fnc]$context.serverPassword[/fnc] +*/ + +STANDARD_SERVERINFO_TARGET_PARAMETER( + context_kvs_fnc_serverSoftware, + c->returnValue()->setString(pConnection->serverInfo()->software()) + ) + /* @doc: context.serverPassword @type: @@ -380,6 +426,7 @@ static bool context_module_init(KviModule * m) KVSM_REGISTER_FUNCTION(m,"networkName",context_kvs_fnc_networkName); KVSM_REGISTER_FUNCTION(m,"state",context_kvs_fnc_state); KVSM_REGISTER_FUNCTION(m,"list",context_kvs_fnc_list); + KVSM_REGISTER_FUNCTION(m,"serverSoftware",context_kvs_fnc_serverSoftware); return true; } -- cgit v1.3.1-10-gc9f91