//============================================================================= // // File : kvi_ircconnectionserverinfo.cpp // Created on Tue 22 Jun 2004 03:57:32 by Szymon Stefanek // // This file is part of the KVIrc IRC client distribution // Copyright (C) 2004 Szymon Stefanek // // 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. // //============================================================================= #define __KVIRC__ #include "kvi_ircconnectionserverinfo.h" #include "kvi_locale.h" #include "kvi_malloc.h" #include "kvi_ircuserdb.h" KviIrcConnectionServerInfo::KviIrcConnectionServerInfo() { // default assumptions m_szSupportedChannelTypes = "#&!+"; m_szSupportedModePrefixes = "@+"; m_szSupportedModeFlags = "ov"; m_pModePrefixTable = 0; buildModePrefixTable(); m_bSupportsModesIe = true; m_bSupportsWatchList = false; m_bSupportsCodePages = false; m_iMaxTopicLen=-1; m_szListModes=""; m_szPlainModes=""; m_iMaxModeChanges=3; m_pServInfo = new KviBasicIrcServerInfo(); } KviIrcConnectionServerInfo::~KviIrcConnectionServerInfo() { if(m_pServInfo) delete m_pServInfo; if(m_pModePrefixTable) kvi_free(m_pModePrefixTable); } void KviIrcConnectionServerInfo::setSupportedChannelModes(const TQString &szSupportedChannelModes) { int pos=-1; pos=szSupportedChannelModes.find(','); if(pos>=0) m_szListModes=szSupportedChannelModes.left(pos); pos=szSupportedChannelModes.findRev(','); if(pos>=0) m_szPlainModes=szSupportedChannelModes.right(szSupportedChannelModes.length()+pos-1); m_szSupportedChannelModes = szSupportedChannelModes; m_bSupportsModesIe = (szSupportedChannelModes.contains('e') && szSupportedChannelModes.contains('I')); TQChar* aux=(TQChar*)szSupportedChannelModes.ucs2(); while(aux->unicode()) { if(!m_szSupportedChannelModes.contains(*aux)) m_szSupportedChannelModes.append(*aux); aux++; } } void KviIrcConnectionServerInfo::setSupportedModePrefixes(const TQString &szSupportedModePrefixes,const TQString &szSupportedModeFlags) { m_szSupportedModeFlags = szSupportedModeFlags; m_szSupportedModePrefixes = szSupportedModePrefixes; buildModePrefixTable(); } void KviIrcConnectionServerInfo::buildModePrefixTable() { if(m_pModePrefixTable) kvi_free(m_pModePrefixTable); const TQChar * cPrefix = KviTQString::nullTerminatedArray(m_szSupportedModePrefixes); const TQChar * cFlag = KviTQString::nullTerminatedArray(m_szSupportedModeFlags); if(!cPrefix || !cFlag)return; // eh ? m_uPrefixes=TQMIN(m_szSupportedModePrefixes.length(),m_szSupportedModePrefixes.length()); m_pModePrefixTable=(kvi_u32_t*)kvi_malloc(sizeof(kvi_u32_t)*3*m_uPrefixes); unsigned short uPrefix,uFlag; // Pragma: FIXME: The whole mode handling needs rethinking! // Alexey: FIXED: rethinked:) // Pragma: LOL :DDDD int i=0; while( (uPrefix = cPrefix->unicode()) && (uFlag = cFlag->unicode()) && i