KVIrc 5.2.4
Developer APIs
Public Types | Public Slots | Signals | Public Member Functions | Protected Member Functions | Private Slots | Private Member Functions | Private Attributes | Friends | List of all members
KviIrcConnection Class Reference

An abstraction of a connection to an IRC server. More...

#include <KviIrcConnection.h>

+ Inheritance diagram for KviIrcConnection:

Public Types

enum  CreateQueryVisibilityMode { CreateQueryVisibilityMinimized , CreateQueryVisibilityVisible , CreateQueryVisibilityFollowSettings }
 
enum  State { Idle , Connecting , Connected }
 The possible "high level" states of this connection. More...
 

Public Slots

void restartNotifyList ()
 Called to restart the notify list.
 
void unhighlightAllChannels ()
 Called when we unhighlight all channels.
 
void unhighlightAllQueries ()
 Called when we unhighlight all queries.
 

Signals

void awayStateChanged ()
 Emitted when the away state changes.
 
void chanListChanged ()
 Emitted when the channels list change.
 
void channelRegistered (KviChannelWindow *pChan)
 Emitted when we register a channel.
 
void channelUnregistered (KviChannelWindow *pChan)
 Emitted when we unregister a channel.
 
void nickNameChanged ()
 Emitted when the nickname changes.
 
void userModeChanged ()
 Emitted when the user modes change.
 

Public Member Functions

KviIrcConnectionAntiCtcpFloodDataantiCtcpFloodData () const
 Returns a pointer to the KviIrcConnectionAntiCtcpFloodData object.
 
KviIrcConnectionAsyncWhoisDataasyncWhoisData () const
 Returns a pointer to the KviIrcConnectionAsyncWhoisData object.
 
std::vector< KviChannelWindow * > & channelList ()
 Returns the list of the channels bound to the current connection.
 
void clearOutputQueue (bool bPrivateMessagesOnly)
 
void closeAllChannels ()
 Closes all the currently open channels not marked as dead.
 
void closeAllQueries ()
 Closes all the currently open queries not marked as dead.
 
KviConsoleWindowconsole () const
 Returns a pointer to the owning console.
 
KviIrcContextcontext () const
 Returns a pointer to the owning KviIrcContext.
 
KviChannelWindowcreateChannel (const QString &szName)
 Creates a new channel with the specified name.
 
KviQueryWindowcreateQuery (const QString &szNick, CreateQueryVisibilityMode eVisibilityMode=CreateQueryVisibilityFollowSettings)
 Creates a query with the specified nick as target.
 
const QString & currentNetworkName () const
 Helper that provides a shortcut for really common access to serverInfo()->networkName()
 
const QString & currentNickName () const
 Helper that provides a shortcut for really common access to userInfo()->nickName()
 
const QString & currentServerName () const
 Helper that provides a shortcut for really common access to serverInfo()->name()
 
const QString & currentUserName () const
 Helper that provides a shortcut for really common access to userInfo()->userName()
 
QString decodeText (const char *szText)
 Decodes the specified text by using the server codec.
 
QByteArray encodeText (const QString &szText)
 Encodes the specified text by using the local text codec.
 
KviChannelWindowfindChannel (const QString &szName)
 Finds the channel with the specified unicode name.
 
KviQueryWindowfindQuery (const QString &szNick)
 Finds the query with the specified nick.
 
int getCommonChannels (const QString &szNick, QString &szChansBuffer, bool bAddEscapeSequences=true)
 Returns a list of channels bound to the current connection.
 
void incomingMessage (const char *pcMessage)
 This function is part of the networking stack.
 
void incomingMessageNoFilter (const char *pcMessage)
 This function is part of the networking stack.
 
void keepChannelsOpenAfterDisconnect ()
 Marks all the currently existing channels as DEAD.
 
void keepQueriesOpenAfterDisconnect ()
 Marks all the currently open queries as DEAD.
 
KviLagMeterlagMeter () const
 Returns a pointer to the current KviLagMeter.
 
KviIrcLinklink () const
 Returns the underlying KviIrcLink object.
 
KviIrcConnectionNetsplitDetectorDatanetsplitDetectorData () const
 Returns a pointer to the KviIrcConnectionNetsplitDetectorData object.
 
KviNotifyListManagernotifyListManager () const
 Returns a pointer to the current KviNotifyListManager.
 
unsigned int outputQueueSize ()
 Returns the current size of the output queue.
 
std::vector< KviQueryWindow * > & queryList ()
 Returns the list of the currently open queries.
 
void registerChannel (KviChannelWindow *c)
 
void registerQuery (KviQueryWindow *q)
 
KviIrcConnectionRequestQueuerequestQueue () const
 Returns a pointer to the current KviIrcConnectionRequestQueue.
 
void restartLagMeter ()
 
void resurrectDeadQueries ()
 This is the inverse of keepQueriesOpenAfterDisconnect().
 
bool sendData (const char *pcBuffer, int iBuflen=-1)
 Sends the specified text on the connected link (and thus socket).
 
bool sendFmtData (const char *pcFmt,...)
 Sends the specified text on the connected link (and thus socket).
 
QTextCodec * serverCodec () const
 Returns a pointer to the current global codec for inbound data.
 
KviIrcConnectionServerInfoserverInfo () const
 Returns a pointer to the KviIrcConnectionServerInfo object.
 
void setEncoding (const QString &szEncoding)
 Sets the global encoding for this connection.
 
State state () const
 Returns the current state of the connection.
 
KviIrcConnectionStateDatastateData () const
 Returns a pointer to the KviIrcConnectionStateData object.
 
KviIrcConnectionStatisticsstatistics () const
 Returns a pointer to the KviIrcConnectionStatistics object.
 
KviIrcConnectionTargettarget () const
 Returns the target of this connection.
 
QTextCodec * textCodec () const
 Returns a pointer to the current global codec for outbound text.
 
void unregisterChannel (KviChannelWindow *c)
 
void unregisterQuery (KviQueryWindow *q)
 
KviIrcUserDataBaseuserDataBase () const
 Returns a pointer to the big connection user database.
 
KviIrcConnectionUserInfouserInfo () const
 Returns a pointer to the KviIrcConnectionUserInfo object.
 

Protected Member Functions

void abort ()
 Kills any running connection or attempt.
 
void changeAwayState (bool bAway)
 Called to update the away state.
 
bool changeUserMode (char cMode, bool bSet)
 Called when MODE is received for each mode character.
 
void delayedStartNotifyList ()
 Starts the notify list in 15 seconds.
 
void endInitialCapNegotiation ()
 Called when we want to end CAP negotiation and go on wi the login.
 
void endOfMotdReceived ()
 Called to start the notify lists when RPL_ENDOFMOTD is received.
 
void gatherChannelAndPasswordPairs (std::vector< std::pair< QString, QString > > &lChannelsAndPasses)
 
void gatherQueryNames (QStringList &lQueryNames)
 
void handleAuthenticate (KviCString &szResponse)
 Called when AUTHENTICATE answer is received.
 
void handleFailedInitialCapLs ()
 Called when CAP LS negotiation fails.
 
void handleInitialCapAck ()
 Called when CAP ACK answer is received.
 
void handleInitialCapLs ()
 Called when CAP LS answer is received.
 
void handleInitialCapNak ()
 Called when CAP NAK answer is received.
 
void heartbeat (kvi_time_t tNow)
 Called once in a while (every 5 secs at the moment)
 
void joinChannels (const std::vector< std::pair< QString, QString > > &lChannelsAndPasses)
 
 KviIrcConnection (KviIrcContext *pContext, KviIrcConnectionTarget *pTarget, KviUserIdentity *pIdentity)
 Creates a KviIrcConnection object.
 
void linkAttemptFailed (int iError)
 This signals that the connection attempt has failed.
 
void linkEstablished ()
 Called by KviIrcLink when the socket state changes to Connected.
 
void linkTerminated ()
 Called by KviIrcLink when the socket state changes to Ready.
 
void loginComplete (const QString &szNickName)
 Called on the first numeric received from server.
 
void loginToIrcServer ()
 Logins to the irc server.
 
void nickChange (const QString &szNewNick)
 Called when NICK is received.
 
QString pickNextLoginNickName (bool bForceDefaultIfPrimaryNicknamesEmpty, const QString &szBaseNickForRandomChoices, QString &szChoiceDescriptionBuffer)
 
void resolveLocalHost ()
 Resolves the localhost into an IP address.
 
void serverInfoReceived (const QString &szServerName, const QString &szUserModes, const QString &szChanModes)
 Called when RPL_SERVINFO (004) is received and sets the info.
 
void start ()
 This starts an asynchronous connection attempt.
 
void useProfileData (KviIdentityProfileSet *pSet, const QString &szNetwork)
 Uses the profiles' data as connection data.
 
void useRealName (const QString &szRealName)
 
void userInfoReceived (const QString &szUserName, const QString &szHostName)
 Called on each JOIN and sets the info.
 
 ~KviIrcConnection ()
 Destroys a KviIrcConnection object. KviConsoleWindow uses this.
 

Private Slots

void hostNameLookupTerminated (KviDnsResolver *pDns)
 Called when the hostname lookup is finished.
 

Private Member Functions

void setupSrvCodec ()
 Setups the codec for the server.
 
void setupTextCodec ()
 Setups the codec for the text.
 

Private Attributes

bool m_bIdentdAttached = false
 
State m_eState = Idle
 
KviIrcConnectionAntiCtcpFloodDatam_pAntiCtcpFloodData
 
KviIrcConnectionAsyncWhoisDatam_pAsyncWhoisData
 
std::vector< KviChannelWindow * > m_pChannelList
 
KviConsoleWindowm_pConsole
 
KviIrcContextm_pContext
 
KviLagMeterm_pLagMeter = nullptr
 
KviIrcLinkm_pLink
 
KviDnsResolverm_pLocalhostDns = nullptr
 
KviIrcConnectionNetsplitDetectorDatam_pNetsplitDetectorData
 
KviNotifyListManagerm_pNotifyListManager = nullptr
 
QTimer * m_pNotifyListTimer = nullptr
 
std::vector< KviQueryWindow * > m_pQueryList
 
KviIrcConnectionRequestQueuem_pRequestQueue
 
KviIrcConnectionServerInfom_pServerInfo
 
QTextCodec * m_pSrvCodec
 
KviIrcConnectionStateDatam_pStateData
 
std::unique_ptr< KviIrcConnectionStatisticsm_pStatistics
 
KviIrcConnectionTargetm_pTarget
 
QTextCodec * m_pTextCodec
 
KviIrcUserDataBasem_pUserDataBase
 
KviUserIdentitym_pUserIdentity
 
KviIrcConnectionUserInfom_pUserInfo
 

Friends

class KviConsoleWindow
 
class KviIrcContext
 
class KviIrcLink
 
class KviIrcServerParser
 

Detailed Description

An abstraction of a connection to an IRC server.

This class deals with the high-level logic of a connection to an IRC server. It's always attached to a KviIrcContext and thus to a KviConsoleWindow window. The connection has a KviIrcConnectionTarget object which specifies the data of the server that needs to be contacted and a KviUserIdentity object which specifies the user data to use.

The connection is the upper layer of the KVIrc networking stack. It owns KviIrcLink which is the layer immediately below and which in turn contains a KviIrcSocket.

The connection creates and manages a lot of objects that handle runtime information. These objects include a KviIrcConnectionUserInfo which contains the ACTUAL user information, KviIrcConnectionServerInfo which contains the ACTUAL server information, KviIrcUserDataBase which is substantially a big hash table containing all the users visible to KVIrc in this connection, a list of channels, a list of queries etc...

Member Enumeration Documentation

◆ CreateQueryVisibilityMode

Visibility mode for createQuery()

Enumerator
CreateQueryVisibilityMinimized 

Create minimized query, overriding settings

CreateQueryVisibilityVisible 

Create visible query, overriding settings

CreateQueryVisibilityFollowSettings 

Follow global settings.

◆ State

The possible "high level" states of this connection.

Enumerator
Idle 

The connection is doing nothing

Connecting 

A connection attempt is in progress

Connected 

We're connected to an IRC server

Constructor & Destructor Documentation

◆ KviIrcConnection()

KviIrcConnection::KviIrcConnection ( KviIrcContext pContext,
KviIrcConnectionTarget pTarget,
KviUserIdentity pIdentity 
)
protected

Creates a KviIrcConnection object.

This is actually used only by KviConsoleWindow.

pContext must not be nullptr and is kept as shallow pointer (that is, it's not owned and must persists for the entire life of KviIrcConnection: caller is responsable for that).

pTarget must not be nullptr and must be allocated with new as this class takes the ownership.

pIdentity must not be nullptr and must be allocated with new as this class takes the ownership.

Parameters
pContextThe KviIrcContext we're attacched to
pTargetThe server data
pIdentityUser information to use in this connection
Returns
KviIrcConnection

References KviIrcContext::console(), KviIrcLink, m_pAntiCtcpFloodData, m_pAsyncWhoisData, m_pConsole, m_pLink, m_pNetsplitDetectorData, m_pRequestQueue, m_pServerInfo, m_pStateData, m_pStatistics, m_pUserDataBase, m_pUserInfo, setupSrvCodec(), and setupTextCodec().

◆ ~KviIrcConnection()

KviIrcConnection::~KviIrcConnection ( )
protected

Member Function Documentation

◆ abort()

void KviIrcConnection::abort ( )
protected

Kills any running connection or attempt.

Returns
void

References KviIrcLink::abort(), and m_pLink.

Referenced by KviIrcServerParser::parseNumericSaslFail(), and KviIrcContext::terminateConnectionRequest().

◆ antiCtcpFloodData()

KviIrcConnectionAntiCtcpFloodData * KviIrcConnection::antiCtcpFloodData ( ) const
inline

Returns a pointer to the KviIrcConnectionAntiCtcpFloodData object.

It contains data private to the Anti CTCP Flood engine. Very similar to KviIrcConnectionStateData but dedicated to Ctcp flood. The returned pointer is never nullptr. Include "KviIrcConnectionAntiCtcpFloodData.h" as the class is only forwarded here.

Returns
KviIrcConnectionAntiCtcpFloodData *

Referenced by KviIrcServerParser::checkCtcpFlood().

◆ asyncWhoisData()

KviIrcConnectionAsyncWhoisData * KviIrcConnection::asyncWhoisData ( ) const
inline

◆ awayStateChanged

void KviIrcConnection::awayStateChanged ( )
signal

Emitted when the away state changes.

Returns
void

Referenced by changeAwayState().

◆ changeAwayState()

void KviIrcConnection::changeAwayState ( bool  bAway)
protected

◆ changeUserMode()

bool KviIrcConnection::changeUserMode ( char  cMode,
bool  bSet 
)
protected

◆ chanListChanged

void KviIrcConnection::chanListChanged ( )
signal

Emitted when the channels list change.

Returns
void

Referenced by registerChannel(), and unregisterChannel().

◆ channelList()

std::vector< KviChannelWindow * > & KviIrcConnection::channelList ( )
inline

Returns the list of the channels bound to the current connection.

The pointer itself is never null (though the list may be empty).

Returns
& std::vector<KviChannelWindow *>

Referenced by KviConsoleWindow::avatarChangedUpdateWindows(), KviConsoleWindow::getWindowListTipText(), KviIsOnNotifyListManager::handleIsOn(), KviIrcServerParser::parseLiteralChghost(), KviIrcServerParser::parseLiteralNick(), KviIrcServerParser::parseLiteralQuit(), KviIrcUrl::run(), and KviConsoleWindow::updateUri().

◆ channelRegistered

void KviIrcConnection::channelRegistered ( KviChannelWindow pChan)
signal

Emitted when we register a channel.

Parameters
pChanThe channel :)
Returns
void

Referenced by registerChannel().

◆ channelUnregistered

void KviIrcConnection::channelUnregistered ( KviChannelWindow pChan)
signal

Emitted when we unregister a channel.

Parameters
pChanThe channel :)
Returns
void

Referenced by unregisterChannel().

◆ clearOutputQueue()

void KviIrcConnection::clearOutputQueue ( bool  bPrivateMessagesOnly)

Clears the underlying output queue. Exposed basically for /context.clearQueue You shouldn't need it for any other reason :)

References KviIrcLink::clearOutputQueue(), and m_pLink.

Referenced by context_kvs_cmd_clearQueue().

◆ closeAllChannels()

void KviIrcConnection::closeAllChannels ( )

Closes all the currently open channels not marked as dead.

Returns
void

References m_pChannelList.

Referenced by KviIrcContext::destroyConnection().

◆ closeAllQueries()

void KviIrcConnection::closeAllQueries ( )

Closes all the currently open queries not marked as dead.

Returns
void

References m_pChannelList, m_pQueryList, and q.

Referenced by KviIrcContext::destroyConnection().

◆ console()

KviConsoleWindow * KviIrcConnection::console ( ) const
inline

◆ context()

KviIrcContext * KviIrcConnection::context ( ) const
inline

◆ createChannel()

KviChannelWindow * KviIrcConnection::createChannel ( const QString &  szName)

Creates a new channel with the specified name.

This should be called in response to a JOIN message. This function assumes that such a channel doesn't exist yet (or if it exists then it's actually in DEAD state). You can assume that channel creation never fails: if the returned pointer is nullptr then we're screwed anyway as virtual memory is exausted.

Parameters
szNameThe name of the channel
Returns
KviChannelWindow *

References KviMainWindow::addWindow(), KviIrcContext::findDeadChannel(), g_pMainWindow, KVI_OPTION_BOOL, KviOption_boolCreateMinimizedChannels, m_pConsole, m_pContext, KviMainWindow::setActiveWindow(), and KviChannelWindow::setAliveChan().

Referenced by KviIrcServerParser::parseLiteralJoin().

◆ createQuery()

KviQueryWindow * KviIrcConnection::createQuery ( const QString &  szNick,
CreateQueryVisibilityMode  eVisibilityMode = CreateQueryVisibilityFollowSettings 
)

Creates a query with the specified nick as target.

This function assumes that such a query doesn't exist yet (or if it exists it's actually marked as dead and needs to be resurrected).

Parameters
szNickThe nickname of the user
eShowModeSpecifies the show mode for the window
Returns
KviQueryWindow *

References KviMainWindow::addWindow(), CreateQueryVisibilityMinimized, CreateQueryVisibilityVisible, KviIrcContext::findDeadQuery(), findQuery(), g_pMainWindow, KVI_OPTION_BOOL, KviOption_boolCreateIncomingQueriesAsMinimized, m_pConsole, m_pContext, q, and KviMainWindow::setActiveWindow().

Referenced by loginComplete(), KviIrcServerParser::parseCtcpRequestAction(), KviIrcServerParser::parseLiteralNotice(), and KviIrcServerParser::parseLiteralPrivmsg().

◆ currentNetworkName()

const QString & KviIrcConnection::currentNetworkName ( ) const

Helper that provides a shortcut for really common access to serverInfo()->networkName()

Returns
const QString &

References m_pServerInfo, and KviIrcConnectionServerInfo::networkName().

Referenced by KviWindowListBase::getTextForConsole(), and KviStatusBar::mouseDoubleClickEvent().

◆ currentNickName()

const QString & KviIrcConnection::currentNickName ( ) const

◆ currentServerName()

const QString & KviIrcConnection::currentServerName ( ) const

◆ currentUserName()

const QString & KviIrcConnection::currentUserName ( ) const

Helper that provides a shortcut for really common access to userInfo()->userName()

Returns
const QString &

References userInfo(), and KviIrcConnectionUserInfo::userName().

◆ decodeText()

QString KviIrcConnection::decodeText ( const char *  szText)

Decodes the specified text by using the server codec.

You should first attempt to decode the text by using the window codec (if you belong to a window).

Parameters
szTextThe text to decode
Returns
QString

References m_pSrvCodec.

Referenced by KviIrcMessage::decodeAndSplitMask(), KviIrcServerParser::echoCtcpReply(), KviIrcServerParser::echoCtcpRequest(), KviIsOnNotifyListManager::handleIsOn(), KviStupidNotifyListManager::handleIsOn(), KviIsOnNotifyListManager::handleUserhost(), KviWatchNotifyListManager::handleWatchReply(), KviIrcServerParser::otherChannelError(), KviIrcServerParser::parseChannelHelp(), KviIrcServerParser::parseChannelMode(), KviIrcServerParser::parseCommandEndOfHelp(), KviIrcServerParser::parseCommandHelp(), KviIrcServerParser::parseCommandSyntaxHelp(), KviIrcServerParser::parseCtcpReply(), KviIrcServerParser::parseCtcpRequest(), KviIrcServerParser::parseCtcpRequestAction(), KviIrcServerParser::parseCtcpRequestPage(), KviIrcServerParser::parseLiteralAccount(), KviIrcServerParser::parseLiteralAway(), KviIrcServerParser::parseLiteralCap(), KviIrcServerParser::parseLiteralChghost(), KviIrcServerParser::parseLiteralError(), KviIrcServerParser::parseLiteralInvite(), KviIrcServerParser::parseLiteralJoin(), KviIrcServerParser::parseLiteralKick(), KviIrcServerParser::parseLiteralMode(), KviIrcServerParser::parseLiteralNick(), KviIrcServerParser::parseLiteralNotice(), KviIrcServerParser::parseLiteralPart(), KviIrcServerParser::parseLiteralPing(), KviIrcServerParser::parseLiteralPong(), KviIrcServerParser::parseLiteralPrivmsg(), KviIrcServerParser::parseLiteralQuit(), KviIrcServerParser::parseLiteralTopic(), KviIrcServerParser::parseLiteralWallops(), KviIrcServerParser::parseLoginNicknameProblem(), KviIrcServerParser::parseMessage(), KviIrcMessage::parseMessageTags(), KviIrcServerParser::parseNumeric001(), KviIrcServerParser::parseNumeric002(), KviIrcServerParser::parseNumeric003(), KviIrcServerParser::parseNumeric004(), KviIrcServerParser::parseNumeric005(), KviIrcServerParser::parseNumeric367(), KviIrcServerParser::parseNumeric368(), KviIrcServerParser::parseNumeric486(), KviIrcServerParser::parseNumeric742(), KviIrcServerParser::parseNumericAlreadyRegistered(), KviIrcServerParser::parseNumericAway(), KviIrcServerParser::parseNumericBackFromAway(), KviIrcServerParser::parseNumericBanOnChan(), KviIrcServerParser::parseNumericCannotSend(), KviIrcServerParser::parseNumericCannotSendColor(), KviIrcServerParser::parseNumericCantJoinChannel(), KviIrcServerParser::parseNumericChannelModeIs(), KviIrcServerParser::parseNumericChanUrl(), KviIrcServerParser::parseNumericCodePageScheme(), KviIrcServerParser::parseNumericCodePageSet(), KviIrcServerParser::parseNumericCommandSyntax(), KviIrcServerParser::parseNumericCreationTime(), KviIrcServerParser::parseNumericEndOfNames(), KviIrcServerParser::parseNumericEndOfQuietList(), KviIrcServerParser::parseNumericEndOfStats(), KviIrcServerParser::parseNumericEndOfWho(), KviIrcServerParser::parseNumericEndOfWhois(), KviIrcServerParser::parseNumericEndOfWhowas(), KviIrcServerParser::parseNumericForward(), KviIrcServerParser::parseNumericHiddenHost(), KviIrcServerParser::parseNumericInfo(), KviIrcServerParser::parseNumericInvited(), KviIrcServerParser::parseNumericInviting(), KviIrcServerParser::parseNumericIsOn(), KviIrcServerParser::parseNumericLinks(), KviIrcServerParser::parseNumericList(), KviIrcServerParser::parseNumericMotd(), KviIrcServerParser::parseNumericMotdMissing(), KviIrcServerParser::parseNumericNames(), KviIrcServerParser::parseNumericNeedSSL(), KviIrcServerParser::parseNumericNicknameProblem(), KviIrcServerParser::parseNumericNoPrivs(), KviIrcServerParser::parseNumericNoSuchChannel(), KviIrcServerParser::parseNumericNoSuchNick(), KviIrcServerParser::parseNumericNoSuchServer(), KviIrcServerParser::parseNumericNotEnoughParams(), KviIrcServerParser::parseNumericNotifyGeneric(), KviIrcServerParser::parseNumericNoTopic(), KviIrcServerParser::parseNumericNotRegistered(), KviIrcServerParser::parseNumericOftcEndOfQuietList(), KviIrcServerParser::parseNumericOftcQuietList(), KviIrcServerParser::parseNumericPasswordIncorrect(), KviIrcServerParser::parseNumericQuietList(), KviIrcServerParser::parseNumericSaslFail(), KviIrcServerParser::parseNumericSaslLogin(), KviIrcServerParser::parseNumericServerAdminInfoAdminContact(), KviIrcServerParser::parseNumericServerAdminInfoAdminName(), KviIrcServerParser::parseNumericServerAdminInfoServerName(), KviIrcServerParser::parseNumericServerAdminInfoTitle(), KviIrcServerParser::parseNumericStats(), KviIrcServerParser::parseNumericTime(), KviIrcServerParser::parseNumericTopic(), KviIrcServerParser::parseNumericTopicWhoTime(), KviIrcServerParser::parseNumericTryAgain(), KviIrcServerParser::parseNumericUnavailResource(), KviIrcServerParser::parseNumericUnknownCommand(), KviIrcServerParser::parseNumericUserhost(), KviIrcServerParser::parseNumericUserInChan(), KviIrcServerParser::parseNumericUsersDontMatch(), KviIrcServerParser::parseNumericWhoisActually(), KviIrcServerParser::parseNumericWhoisAuth(), KviIrcServerParser::parseNumericWhoisAway(), KviIrcServerParser::parseNumericWhoisChannels(), KviIrcServerParser::parseNumericWhoisIdle(), KviIrcServerParser::parseNumericWhoisOther(), KviIrcServerParser::parseNumericWhoisRegistered(), KviIrcServerParser::parseNumericWhoisServer(), KviIrcServerParser::parseNumericWhoisUser(), KviIrcServerParser::parseNumericWhospcrpl(), KviIrcServerParser::parseNumericWhowasUser(), KviIrcServerParser::parseNumericYouHaveCallerID(), KviIrcServerParser::parseNumericYoureOper(), KviIrcServerParser::parseNumericYourUID(), and ListWindow::processData().

◆ delayedStartNotifyList()

void KviIrcConnection::delayedStartNotifyList ( )
protected

Starts the notify list in 15 seconds.

We have this delay to wait an eventual RPL_PROTOCTL from the server telling us that the WATCH notify list method is supported

Returns
void

References connect(), KVI_ASSERT, m_pNotifyListTimer, and restartNotifyList().

Referenced by loginComplete().

◆ encodeText()

QByteArray KviIrcConnection::encodeText ( const QString &  szText)

Encodes the specified text by using the local text codec.

You should first attempt to encode the text by using the window codec (if you belong to a window).

Parameters
szTextThe text to encode
Returns
QByteArray

References m_pSrvCodec.

Referenced by KviMaskInputDialog::accept(), avatar_kvs_cmd_notify(), avatar_kvs_cmd_query(), KviChannelWindow::closeEvent(), DccChatWindow::connectionInProgress(), DccFileTransfer::connectionInProgress(), DccVideoWindow::connectionInProgress(), DccVoiceWindow::connectionInProgress(), dcc_kvs_cmd_get(), dcc_module_reply_errmsg(), dccModuleParseDccGet(), KviTrayIconWidget::doAway(), DccFileTransfer::doResume(), KviKvsTreeNodeAliasSimpleCommand::execute(), handleAuthenticate(), DccBroker::handleResumeRequest(), heartbeat(), ListWindow::itemDoubleClicked(), joinChannels(), KviKvsCoreSimpleCommands::KVSCSC(), loginComplete(), loginToIrcServer(), KviChannelWindow::ownAction(), KviQueryWindow::ownAction(), KviChannelWindow::ownMessage(), KviQueryWindow::ownMessage(), KviIrcServerParser::parseCtcpReplyAvatar(), KviIrcServerParser::parseCtcpRequestPing(), KviIrcServerParser::parseLiteralKick(), KviIrcServerParser::parseLiteralPing(), KviIrcServerParser::parseLoginNicknameProblem(), KviUserInput::parseNonCommand(), KviIrcServerParser::parseNumericAway(), KviIrcServerParser::parseNumericBackFromAway(), KviIrcServerParser::parseNumericWhospcrpl(), KviChannelWindow::removeMasks(), KviIrcServerParser::replyCtcp(), ListWindow::requestList(), DccBroker::rsendExecute(), KviIrcUrl::run(), KviIsOnNotifyListManager::sendIsOn(), KviStupidNotifyListManager::sendIsOn(), KviIsOnNotifyListManager::sendUserhost(), KviChannelWindow::setAliveChan(), KviChannelWindow::setMode(), KviWatchNotifyListManager::start(), DccFileTransfer::startConnection(), KviIrcContext::terminateConnectionRequest(), KviLagMeter::timerEvent(), KviIrcConnectionRequestQueue::timerSlot(), KviChannelWindow::toggleListModeEditor(), and KviChannelWindow::topicSelected().

◆ endInitialCapNegotiation()

void KviIrcConnection::endInitialCapNegotiation ( )
protected

◆ endOfMotdReceived()

void KviIrcConnection::endOfMotdReceived ( )
protected

Called to start the notify lists when RPL_ENDOFMOTD is received.

Returns
void

References m_pNotifyListTimer, and restartNotifyList().

Referenced by KviIrcServerParser::parseNumericMotd().

◆ findChannel()

KviChannelWindow * KviIrcConnection::findChannel ( const QString &  szName)

Finds the channel with the specified unicode name.

Returns the pointer to the channel found or nullptr if there is no such channel.

Parameters
szNameThe name of the channel
Returns
KviChannelWindow *

References KviQString::equalCI(), and m_pChannelList.

Referenced by KviIrcServerParser::echoCtcpReply(), KviIrcServerParser::echoCtcpRequest(), KviApplication::fillRecentChannelsPopup(), KviKvsCoreFunctions::KVSCF(), KviIrcServerParser::otherChannelError(), KviIrcServerParser::parseChannelHelp(), KviIrcServerParser::parseCtcpReplyPing(), KviIrcServerParser::parseCtcpRequestAction(), KviIrcServerParser::parseLiteralJoin(), KviIrcServerParser::parseLiteralKick(), KviIrcServerParser::parseLiteralMode(), KviIrcServerParser::parseLiteralNotice(), KviIrcServerParser::parseLiteralPart(), KviIrcServerParser::parseLiteralPrivmsg(), KviIrcServerParser::parseLiteralTopic(), KviIrcServerParser::parseNumeric367(), KviIrcServerParser::parseNumeric368(), KviIrcServerParser::parseNumeric742(), KviIrcServerParser::parseNumericBanOnChan(), KviIrcServerParser::parseNumericCannotSend(), KviIrcServerParser::parseNumericCannotSendColor(), KviIrcServerParser::parseNumericCantJoinChannel(), KviIrcServerParser::parseNumericChannelModeIs(), KviIrcServerParser::parseNumericChanUrl(), KviIrcServerParser::parseNumericCreationTime(), KviIrcServerParser::parseNumericEndOfNames(), KviIrcServerParser::parseNumericEndOfQuietList(), KviIrcServerParser::parseNumericEndOfWho(), KviIrcServerParser::parseNumericInvited(), KviIrcServerParser::parseNumericInviting(), KviIrcServerParser::parseNumericNames(), KviIrcServerParser::parseNumericNeedSSL(), KviIrcServerParser::parseNumericNoTopic(), KviIrcServerParser::parseNumericOftcEndOfQuietList(), KviIrcServerParser::parseNumericOftcQuietList(), KviIrcServerParser::parseNumericQuietList(), KviIrcServerParser::parseNumericTopic(), KviIrcServerParser::parseNumericTopicWhoTime(), KviIrcServerParser::parseNumericUserInChan(), KviIrcServerParser::parseNumericWhoReply(), and KviIrcServerParser::parseNumericWhospcrpl().

◆ findQuery()

KviQueryWindow * KviIrcConnection::findQuery ( const QString &  szNick)

◆ gatherChannelAndPasswordPairs()

void KviIrcConnection::gatherChannelAndPasswordPairs ( std::vector< std::pair< QString, QString > > &  lChannelsAndPasses)
protected

Gather the list of currently joined channels with the relative passwords.

References m_pChannelList.

Referenced by KviIrcContext::connectionTerminated().

◆ gatherQueryNames()

void KviIrcConnection::gatherQueryNames ( QStringList &  lQueryNames)
protected

Gather the list of currently open query names.

References m_pQueryList, and q.

Referenced by KviIrcContext::connectionTerminated().

◆ getCommonChannels()

int KviIrcConnection::getCommonChannels ( const QString &  szNick,
QString &  szChansBuffer,
bool  bAddEscapeSequences = true 
)

Returns a list of channels bound to the current connection.

This is actually the list of channels that the local user has in common with the specified user. The list is returned as a comma separated string. If bAddEscapeSequences is true, then the string includes special escape sequences for KviIrcView that will make the channel names clickable.

Returns the number of channels found.

Parameters
szNickThe nickname of the user
szChansBufferThe buffer where to store data
bAddEscapeSequencesWhether to include escape sequences
Returns
int

References KviQString::appendFormatted(), KviChannelWindow::getUserFlag(), and m_pChannelList.

Referenced by chan_kvs_fnc_common(), KviIrcServerParser::parseLiteralJoin(), KviIrcServerParser::parseLiteralKick(), KviIrcServerParser::parseLiteralNick(), KviIrcServerParser::parseLiteralPart(), and KviQueryWindow::setTarget().

◆ handleAuthenticate()

void KviIrcConnection::handleAuthenticate ( KviCString szResponse)
protected

◆ handleFailedInitialCapLs()

void KviIrcConnection::handleFailedInitialCapLs ( )
protected

◆ handleInitialCapAck()

void KviIrcConnection::handleInitialCapAck ( )
protected

◆ handleInitialCapLs()

void KviIrcConnection::handleInitialCapLs ( )
protected

◆ handleInitialCapNak()

void KviIrcConnection::handleInitialCapNak ( )
protected

Called when CAP NAK answer is received.

Returns
void

References endInitialCapNegotiation().

Referenced by KviIrcServerParser::parseLiteralCap().

◆ heartbeat()

void KviIrcConnection::heartbeat ( kvi_time_t  tNow)
protected

◆ hostNameLookupTerminated

void KviIrcConnection::hostNameLookupTerminated ( KviDnsResolver pDns)
privateslot

◆ incomingMessage()

void KviIrcConnection::incomingMessage ( const char *  pcMessage)

This function is part of the networking stack.

It's called by KviIrcLink OR KviMexLinkFilter when a message is arriving from the server. Needs to be public because subclasses of KviMexLinkFilter may call it.

Parameters
pcMessageThe message :)
Returns
void

References context(), g_pServerParser, kvi_unixTime, m, m_pStatistics, KviIrcContext::monitorList(), and KviIrcServerParser::parseMessage().

Referenced by KviIrcLink::processData().

◆ incomingMessageNoFilter()

void KviIrcConnection::incomingMessageNoFilter ( const char *  pcMessage)

This function is part of the networking stack.

It's called by KviIrcDataStreamMonitor subclasses when they want to inject some message without getting it filtered again

Parameters
pcMessageThe message :)
Returns
void

References g_pServerParser, kvi_unixTime, m_pStatistics, and KviIrcServerParser::parseMessage().

◆ joinChannels()

void KviIrcConnection::joinChannels ( const std::vector< std::pair< QString, QString > > &  lChannelsAndPasses)
protected

Joins a list of channels. The first element of the pair is the channel name, the second element of the pair is the eventual password. May send multiple JOIN messages.

References encodeText(), and sendFmtData().

Referenced by loginComplete().

◆ keepChannelsOpenAfterDisconnect()

void KviIrcConnection::keepChannelsOpenAfterDisconnect ( )

Marks all the currently existing channels as DEAD.

They are preserved across connections. Marking a channel as dead actually removes the ownership of KviChannelWindow from KviIrcConnection and moves it to KviIrcContext (as the contex is preserved across connections).

Returns
void

References __tr2qs, KVI_OUT_SOCKETERROR, m_pChannelList, KviWindow::outputNoFmt(), and KviChannelWindow::setDeadChan().

Referenced by KviIrcContext::connectionTerminated().

◆ keepQueriesOpenAfterDisconnect()

void KviIrcConnection::keepQueriesOpenAfterDisconnect ( )

Marks all the currently open queries as DEAD.

They are kept open after a disconnect. Marking a query as dead removes ownership from this class and gives it to KviIrcContext (which survives disconnects).

Returns
void

References __tr2qs, KVI_OUT_SOCKETERROR, m_pQueryList, KviWindow::outputNoFmt(), and q.

Referenced by KviIrcContext::connectionTerminated().

◆ lagMeter()

KviLagMeter * KviIrcConnection::lagMeter ( ) const
inline

◆ link()

KviIrcLink * KviIrcConnection::link ( ) const
inline

◆ linkAttemptFailed()

void KviIrcConnection::linkAttemptFailed ( int  iError)
protected

This signals that the connection attempt has failed.

Parameters
iErrorThe error code
Returns
void

References KviIrcContext::connectionFailed(), context(), KviMainWindow::executeInternalCommand(), g_pMainWindow, Idle, KVI_INTERNALCOMMAND_IDENT_STOP, m_bIdentdAttached, and m_eState.

Referenced by KviIrcLink::resolverTerminated(), and KviIrcLink::socketStateChange().

◆ linkEstablished()

void KviIrcConnection::linkEstablished ( )
protected

◆ linkTerminated()

void KviIrcConnection::linkTerminated ( )
protected

◆ loginComplete()

void KviIrcConnection::loginComplete ( const QString &  szNickName)
protected

Called on the first numeric received from server.

Parameters
szNickNameThe nickname to use
Returns
void

References __tr2qs, _OUTPUT_VERBOSE, KviApplication::addRecentNickname(), KviIrcNetwork::autoJoinChannelList(), KviIrcServer::autoJoinChannelList(), KviIrcServer::clearReconnectInfo(), KviIrcConnectionStateData::commandToExecAfterConnect(), KviIrcContext::Connected, context(), createQuery(), delayedStartNotifyList(), e, encodeText(), KviMainWindow::executeInternalCommand(), KviIrcUserDataBase::find(), findQuery(), g_pApp, g_pMainWindow, KviIrcServer::initUMode(), KviIrcConnectionServerInfo::isSupportedChannelType(), joinChannels(), KVI_INTERNALCOMMAND_CHANNELSJOIN_OPEN, KVI_INTERNALCOMMAND_IDENT_STOP, KVI_OPTION_BOOL, KVI_OPTION_STRING, KVI_OUT_IRC, KVI_OUT_SYSTEMMESSAGE, KVI_OUT_VERBOSE, KviEvent_OnIRC, KviOption_boolShowChannelsJoinOnIrc, KviOption_stringDefaultUserMode, KVS_TRIGGER_EVENT_0_HALTED, l, KviIrcContext::loginComplete(), m_bIdentdAttached, KviIrcServerReconnectInfo::m_lOpenQueries, m_pConsole, m_pServerInfo, m_pStateData, m_pUserIdentity, m_pUserInfo, KviIrcConnectionTarget::network(), KviUserListView::nickChange(), KviIrcConnectionUserInfo::nickName(), KviConsoleWindow::notifyListView(), KviIrcNetwork::onLoginCommand(), KviIrcServer::onLoginCommand(), KviUserIdentity::onLoginCommand(), KviWindow::output(), KviWindow::outputNoFmt(), KviCString::ptr(), KviIrcServer::reconnectInfo(), restartLagMeter(), resurrectDeadQueries(), KviKvsScript::run(), sendFmtData(), KviIrcConnectionTarget::server(), KviIrcConnectionStateData::setIgnoreOneYouHaveNotRegisteredError(), KviIrcConnectionUserInfo::setNickName(), KviQueryWindow::setTarget(), state(), szHost, target(), KviIrcUserEntry::user(), and userDataBase().

Referenced by KviIrcServerParser::parseNumeric001(), KviIrcServerParser::parseNumeric002(), KviIrcServerParser::parseNumeric003(), KviIrcServerParser::parseNumeric004(), and KviIrcServerParser::parseNumeric005().

◆ loginToIrcServer()

void KviIrcConnection::loginToIrcServer ( )
protected

Logins to the irc server.

Returns
void

References __tr2qs, _OUTPUT_MUTE, _OUTPUT_VERBOSE, KviUserListView::avatarChanged(), KviConsoleWindow::defaultAvatarFromOptions(), e, encodeText(), KviIrcUserEntry::Female, KviIrcUserDataBase::find(), KviIrcServer::hostName(), KviIdentityProfileSet::instance(), KviIdentityProfileSet::isEmpty(), KviIdentityProfileSet::isEnabled(), KviUserListView::join(), KVI_ASSERT, KVI_DEFAULT_USERNAME, KVI_OPTION_BOOL, KVI_OPTION_STRING, KVI_OPTION_UINT, KVI_OUT_SYSTEMMESSAGE, KVI_OUT_VERBOSE, KviOption_boolPrependAvatarInfoToRealname, KviOption_boolPrependGenderInfoToRealname, KviOption_boolPrependNickColorInfoToRealname, KviOption_boolUseSpecifiedSmartColorForOwnNick, KviOption_stringCtcpUserInfoGender, KviOption_stringMyAvatar, KviOption_stringRealname, KviOption_stringUsername, KviOption_uintUserIrcViewOwnBackground, KviOption_uintUserIrcViewOwnForeground, m_pConsole, m_pServerInfo, m_pStateData, m_pUserIdentity, m_pUserInfo, KviIrcServerReconnectInfo::m_szNick, KviIrcServerReconnectInfo::m_szPass, KviIrcUserEntry::Male, KviIrcNetwork::name(), KviIrcConnectionTarget::network(), KviIrcConnectionUserInfo::nickName(), KviConsoleWindow::notifyListView(), KviIrcNetwork::onConnectCommand(), KviIrcServer::onConnectCommand(), KviUserIdentity::onConnectCommand(), KviWindow::output(), KviWindow::outputNoFmt(), KviIrcNetwork::password(), KviIrcServer::password(), KviIrcConnectionUserInfo::password(), pickNextLoginNickName(), KviIrcNetwork::realName(), KviIrcServer::realName(), KviIrcConnectionUserInfo::realName(), KviIrcServer::reconnectInfo(), KviControlCodes::Reset, KviKvsScript::run(), sendFmtData(), KviIrcConnectionTarget::server(), KviIrcConnectionStateData::setLoginNickNameState(), KviIrcConnectionServerInfo::setName(), KviIrcConnectionUserInfo::setNickName(), KviIrcConnectionUserInfo::setPassword(), setupTextCodec(), KviIrcConnectionUserInfo::setUserName(), target(), KviControlCodes::Transparent, KviIrcConnectionStateData::UsedConnectionSpecificNickName, useProfileData(), userDataBase(), useRealName(), userInfo(), KviIrcNetwork::userName(), KviIrcServer::userName(), and KviIrcConnectionUserInfo::userName().

Referenced by endInitialCapNegotiation(), handleFailedInitialCapLs(), and linkEstablished().

◆ netsplitDetectorData()

KviIrcConnectionNetsplitDetectorData * KviIrcConnection::netsplitDetectorData ( ) const
inline

Returns a pointer to the KviIrcConnectionNetsplitDetectorData object.

It contains data private to the netsplit detector engine. Very similar to KviIrcConnectionStateData but dedicated to netsplit detection. The returned pointer is never nullptr. Include "KviIrcConnectionNetsplitDetectorData.h" as the class is only forwarded here.

Returns
KviIrcConnectionNetsplitDetectorData *

Referenced by KviIrcServerParser::parseLiteralQuit().

◆ nickChange()

void KviIrcConnection::nickChange ( const QString &  szNewNick)
protected

◆ nickNameChanged

void KviIrcConnection::nickNameChanged ( )
signal

Emitted when the nickname changes.

Returns
void

Referenced by nickChange().

◆ notifyListManager()

KviNotifyListManager * KviIrcConnection::notifyListManager ( ) const
inline

Returns a pointer to the current KviNotifyListManager.

The returned pointer is nullptr if notify list management is disabled for the current connection.

Returns
KviNotifyListManager *

Referenced by KviIrcServerParser::parseNumericIsOn(), KviIrcServerParser::parseNumericUserhost(), and KviIrcServerParser::parseNumericWatch().

◆ outputQueueSize()

unsigned int KviIrcConnection::outputQueueSize ( )

Returns the current size of the output queue.

Returns
unsigned int

References m_pLink, and KviIrcLink::outputQueueSize().

◆ pickNextLoginNickName()

QString KviIrcConnection::pickNextLoginNickName ( bool  bForceDefaultIfPrimaryNicknamesEmpty,
const QString &  szBaseNickForRandomChoices,
QString &  szChoiceDescriptionBuffer 
)
protected

Picks the next login nickname to be tried. If bForceDefaultIfPrimaryNicknamesEmpty is true then the algorithm will return a default nickname in case the primary setting in the options is empty. If bForceDefaultIfPrimaryNicknamesEmpty is false then the algorithm will try the alternative nicknames instead, then try some random options and finally return an empty string signaling that no suitable choice could be made. bForceDefaultIfPrimaryNicknamesEmpty should be set to true only in loginToIrcServer(), that is, the first time this function is called (otherwise there exists a possibility of infinite nickname loop because of the repeated fallback choice). szBaseNickForRandomChoices will be used for the random alternatives as the first left 7 characters. Upon return szChoiceDescriptionBuffer will contain the textual description of the choice made (network specific, alternative, server specific, global etc...).

References __tr2qs, KviIrcNetwork::alternativeNickName(), KviIrcServer::alternativeNickName(), KviIdentityProfileSet::findNetwork(), KviIdentityProfileSet::instance(), KviIdentityProfileSet::isEmpty(), KviIdentityProfileSet::isEnabled(), KVI_ASSERT, KVI_DEFAULT_NICKNAME1, KVI_OPTION_STRING, KviOption_stringNickname1, KviOption_stringNickname2, KviOption_stringNickname3, KviOption_stringNickname4, KviIrcConnectionStateData::loginNickNameState(), m_pStateData, KviIrcNetwork::name(), KviIrcConnectionTarget::network(), KviIdentityProfile::nick(), KviIrcNetwork::nickName(), KviIrcServer::nickName(), KviIrcConnectionTarget::server(), KviIrcConnectionStateData::setLoginNickNameState(), target(), KviIrcConnectionStateData::UsedAlternativeNetworkSpecificNickName, KviIrcConnectionStateData::UsedAlternativeProfileSpecificNickName, KviIrcConnectionStateData::UsedAlternativeServerSpecificNickName, KviIrcConnectionStateData::UsedGlobalNickName1, KviIrcConnectionStateData::UsedGlobalNickName2, KviIrcConnectionStateData::UsedGlobalNickName3, KviIrcConnectionStateData::UsedGlobalNickName4, KviIrcConnectionStateData::UsedManualNickname, KviIrcConnectionStateData::UsedNetworkSpecificNickName, KviIrcConnectionStateData::UsedProfileSpecificNickName, KviIrcConnectionStateData::UsedRandomNickName1, KviIrcConnectionStateData::UsedRandomNickName2, KviIrcConnectionStateData::UsedRandomNickName3, KviIrcConnectionStateData::UsedRandomNickName4, and KviIrcConnectionStateData::UsedServerSpecificNickName.

Referenced by loginToIrcServer(), and KviIrcServerParser::parseLoginNicknameProblem().

◆ queryList()

std::vector< KviQueryWindow * > & KviIrcConnection::queryList ( )
inline

Returns the list of the currently open queries.

The returned pointer is never nullptr (the list may be empty though).

Returns
std::vector<KviQueryWindow *> &

Referenced by KviConsoleWindow::avatarChangedUpdateWindows(), KviConsoleWindow::getWindowListTipText(), and KviIrcServerParser::parseLiteralNick().

◆ registerChannel()

void KviIrcConnection::registerChannel ( KviChannelWindow c)

◆ registerQuery()

void KviIrcConnection::registerQuery ( KviQueryWindow q)

This is called by KviQueryWindow upon creation, you shouldn't need to use it.

FIXME: Could be made protected.

References m_pQueryList, and q.

Referenced by KviQueryWindow::KviQueryWindow(), and KviQueryWindow::setAliveQuery().

◆ requestQueue()

KviIrcConnectionRequestQueue * KviIrcConnection::requestQueue ( ) const
inline

◆ resolveLocalHost()

void KviIrcConnection::resolveLocalHost ( )
protected

◆ restartLagMeter()

void KviIrcConnection::restartLagMeter ( )

This function actually restarts the lag meter.

FIXME: Why ?

References KVI_OPTION_BOOL, KviOption_boolUseLagMeterEngine, and m_pLagMeter.

Referenced by loginComplete(), and KviApplication::restartLagMeters().

◆ restartNotifyList

void KviIrcConnection::restartNotifyList ( )
slot

◆ resurrectDeadQueries()

void KviIrcConnection::resurrectDeadQueries ( )

This is the inverse of keepQueriesOpenAfterDisconnect().

It's meant to be called upon reconnection (as queries don't need a JOIN message to be opened).

Returns
void

References __tr2qs, KviIrcContext::firstDeadQuery(), KVI_OUT_SOCKETMESSAGE, m_pContext, and q.

Referenced by loginComplete().

◆ sendData()

bool KviIrcConnection::sendData ( const char *  pcBuffer,
int  iBuflen = -1 
)

Sends the specified text on the connected link (and thus socket).

This function basically works like sprintf(). Please note that you should send only ENCODED text to the server. This is why the accepted parameter is a const char *. IRC is an 8 (I'd say even 7 sometimes) bit protocol.

Please note that you don't actually need to append a CRLF pair to your buffer: the implementation of the networking stack will do it for you. Hovewer you can send multiple IRC commands by separating them by CRLF pairs. Just take care of avoiding a CRLF after the last command you specify.

Returns true on success or false if the data can't be actually enqueued/sent (and this usually means that there is no connection at the moment). Please note that it MAY happen that a send attempt on a correctly connected link causes the link to actually disconnect (or rather "discover" the fact that it's disconnected at OS level).

Parameters
pcBufferThe encoded text data to send
iBuflenThe length of the data: if -1 the length is determined via strlen().
Returns
bool

References __tr2qs, _OUTPUT_MUTE, KviConsoleWindow::activeWindow(), context(), KviDataBuffer::data(), KVI_OUT_SOCKETWARNING, KviEvent_OnOutboundTraffic, KVS_TRIGGER_EVENT_1, m, m_pConsole, m_pLink, KviIrcContext::monitorList(), KviMemory::move(), KviWindow::outputNoFmt(), and KviIrcLink::sendPacket().

Referenced by DccChatWindow::connectionInProgress(), KviKvsTreeNodeAliasSimpleCommand::execute(), LinksWindow::hostPopupClicked(), and KviIrcUrl::run().

◆ sendFmtData()

bool KviIrcConnection::sendFmtData ( const char *  pcFmt,
  ... 
)

Sends the specified text on the connected link (and thus socket).

This function basically works like sprintf(). Please note that you should send only ENCODED text to the server. This is why the accepted parameter is a const char *. IRC is an 8 (I'd say even 7 sometimes) bit protocol.

Please note that you don't actually need to append a CRLF pair to your buffer: the implementation of the networking stack will do it for you. Hovewer you can send multiple IRC commands by separating them by CRLF pairs. Just take care of avoiding a CRLF after the last command you specify.

Returns true on success or false if the data can't be actually enqueued/sent (and this usually means that there is no connection at the moment). Please note that it MAY happen that a send attempt on a correctly connected link causes the link to actually disconnect (or rather "discover" the fact that it's disconnected at OS level).

Parameters
pcFmtThe format string to be first sprintf'ed with the variadic params and then sent
...The variadic arguments (see man sprintf for an explanation)
Returns
bool

FIXME: change name to sendFormattedData() ?

References __tr2qs, _OUTPUT_MUTE, KviConsoleWindow::activeWindow(), context(), KviDataBuffer::data(), kvi_irc_vsnprintf(), KVI_OUT_SOCKETWARNING, kvi_va_end, kvi_va_list, kvi_va_start, KviEvent_OnOutboundTraffic, KVS_TRIGGER_EVENT_1, m, m_pConsole, m_pLink, KviIrcContext::monitorList(), KviWindow::outputNoFmt(), KviDataBuffer::resize(), and KviIrcLink::sendPacket().

Referenced by KviMaskInputDialog::accept(), avatar_kvs_cmd_notify(), avatar_kvs_cmd_query(), KviChannelWindow::closeEvent(), DccFileTransfer::connectionInProgress(), DccVideoWindow::connectionInProgress(), DccVoiceWindow::connectionInProgress(), dcc_kvs_cmd_get(), dcc_module_reply_errmsg(), dccModuleParseDccGet(), KviTrayIconWidget::doAway(), DccFileTransfer::doResume(), endInitialCapNegotiation(), handleAuthenticate(), handleInitialCapAck(), handleInitialCapLs(), DccBroker::handleResumeRequest(), heartbeat(), ListWindow::itemDoubleClicked(), joinChannels(), KviKvsCoreSimpleCommands::KVSCSC(), KviKvsCoreSimpleCommands::KVSCSC(), linkEstablished(), loginComplete(), loginToIrcServer(), KviChannelWindow::ownAction(), KviChannelWindow::ownMessage(), KviQueryWindow::ownMessage(), KviIrcServerParser::parseCtcpReplyAvatar(), KviIrcServerParser::parseLiteralInvite(), KviIrcServerParser::parseLiteralKick(), KviIrcServerParser::parseLiteralPing(), KviIrcServerParser::parseLoginNicknameProblem(), KviIrcServerParser::parseNumeric005(), KviIrcServerParser::parseNumericAway(), KviIrcServerParser::parseNumericBackFromAway(), KviIrcServerParser::parseNumericSaslFail(), KviIrcServerParser::parseNumericWhospcrpl(), KviChannelWindow::removeMasks(), KviIrcServerParser::replyCtcp(), LinksWindow::requestLinks(), ListWindow::requestList(), DccBroker::rsendExecute(), KviIsOnNotifyListManager::sendIsOn(), KviStupidNotifyListManager::sendIsOn(), KviIsOnNotifyListManager::sendUserhost(), KviChannelWindow::setAliveChan(), KviChannelWindow::setMode(), KviWatchNotifyListManager::start(), DccFileTransfer::startConnection(), KviWatchNotifyListManager::stop(), ListWindow::stoplistdownload(), KviIrcContext::terminateConnectionRequest(), KviLagMeter::timerEvent(), KviIrcConnectionRequestQueue::timerSlot(), KviChannelWindow::toggleListModeEditor(), and KviChannelWindow::topicSelected().

◆ serverCodec()

QTextCodec * KviIrcConnection::serverCodec ( ) const
inline

Returns a pointer to the current global codec for inbound data.

This codec is a global setting and may be overridden by specific windows. The returned pointer may be null if things really went wrong.

Returns
QTextCodec *

◆ serverInfo()

KviIrcConnectionServerInfo * KviIrcConnection::serverInfo ( ) const
inline

Returns a pointer to the KviIrcConnectionServerInfo object.

It contains runtime information about the current server. This includes the current servername, the server capabilities and other stuff that KviConnectionTarget actually doesn't contain (or has only "default" values for). The returned pointer is never nullptr. Include "KviIrcConnectionServerInfo.h" as the class is only forwarded here.

Returns
KviIrcConnectionServerInfo *

Referenced by currentServerName(), KviConsoleWindow::fillStatusString(), KviUserListView::getUserFlag(), handleInitialCapLs(), heartbeat(), KviUserListView::insertUserEntry(), KviIrcServerParser::parseChannelMode(), KviIrcServerParser::parseCtcpRequestAction(), KviIrcServerParser::parseLiteralCap(), KviIrcServerParser::parseLiteralJoin(), KviIrcServerParser::parseLiteralNotice(), KviIrcServerParser::parseLiteralPrivmsg(), KviIrcServerParser::parseNumeric004(), KviIrcServerParser::parseNumeric005(), KviIrcServerParser::parseNumeric344(), KviIrcServerParser::parseNumeric345(), KviIrcServerParser::parseNumeric480(), KviIrcServerParser::parseNumeric486(), KviIrcServerParser::parseNumeric728(), KviIrcServerParser::parseNumeric729(), KviIrcServerParser::parseNumericCodePageScheme(), KviIrcServerParser::parseNumericCodePageSet(), KviIrcServerParser::parseNumericNames(), KviIrcServerParser::parseNumericSaslLogin(), KviIrcServerParser::parseUserMode(), KviWindow::preprocessMessage(), restartNotifyList(), KviChannelWindow::serverInfo(), serverInfoReceived(), KviTopicWidget::switchMode(), KviLagMeter::timerEvent(), and KviChannelWindow::updateModeLabel().

◆ serverInfoReceived()

void KviIrcConnection::serverInfoReceived ( const QString &  szServerName,
const QString &  szUserModes,
const QString &  szChanModes 
)
protected

Called when RPL_SERVINFO (004) is received and sets the info.

Parameters
szServerNameThe name of the server
szUserModesThe user modes supported by the server
szChanModesThe chan modes supported by the server
Returns
void

References KviMainWindow::childConnectionServerInfoChange(), g_pMainWindow, m_pConsole, serverInfo(), KviIrcConnectionServerInfo::setName(), KviIrcConnectionServerInfo::setSupportedChannelModes(), KviIrcConnectionServerInfo::setSupportedUserModes(), and KviWindow::updateCaption().

Referenced by KviIrcServerParser::parseNumeric004().

◆ setEncoding()

void KviIrcConnection::setEncoding ( const QString &  szEncoding)

Sets the global encoding for this connection.

This is a default value and can be overridden by specific windows. This is tipically called upon a successful CODEPAGE change (numerical 222) response from a server; from now on, the server will translate (encode) everything (including IDN hostnames, channel names, messages) using this encoding. So we expect this encoding to be the new default for the server (connection), the console, each other channel and query.

Parameters
szEncodingThe encoding to use
Returns
void

References __tr2qs, _OUTPUT_VERBOSE, KviLocale::codecForName(), KviLocale::instance(), KVI_OUT_SYSTEMERROR, KVI_OUT_VERBOSE, m_pChannelList, m_pConsole, m_pQueryList, m_pSrvCodec, m_pTextCodec, KviWindow::output(), q, and KviWindow::setTextEncoding().

Referenced by KviIrcServerParser::parseNumeric005(), and KviIrcServerParser::parseNumericCodePageSet().

◆ setupSrvCodec()

void KviIrcConnection::setupSrvCodec ( )
private

◆ setupTextCodec()

void KviIrcConnection::setupTextCodec ( )
private

◆ start()

void KviIrcConnection::start ( )
protected

This starts an asynchronous connection attempt.

You must return control to the Qt core for the connection operations to be initiated

Returns
void

References Connecting, KviMainWindow::executeInternalCommand(), g_pMainWindow, KVI_INTERNALCOMMAND_IDENT_START, KVI_OPTION_BOOL, KviOption_boolUseIdentService, KviOption_boolUseIdentServiceOnlyOnConnect, m_bIdentdAttached, m_eState, m_pLink, and KviIrcLink::start().

Referenced by KviIrcContext::connectToCurrentServer().

◆ state()

State KviIrcConnection::state ( ) const
inline

◆ stateData()

KviIrcConnectionStateData * KviIrcConnection::stateData ( ) const
inline

Returns a pointer to the KviIrcConnectionStateData object.

It contains generic connection state data. This includes the current nickname index at login time, flags that signal "micro-states" etc... This data could be part of KviIrcConnection itself but we prefer to keep it in a separate class in order to cleanup the implementation. The returned pointer is never nullptr. Include "KviIrcConnectionStateData.h" as the class is only forwarded here.

Returns
KviIrcConnectionStateData *

Referenced by KviIrcContext::connectionTerminated(), KviIrcContext::connectToCurrentServer(), heartbeat(), KviIrcServerParser::parseLiteralCap(), KviIrcServerParser::parseLiteralJoin(), KviIrcServerParser::parseLiteralPrivmsg(), KviIrcServerParser::parseMessage(), KviIrcServerParser::parseNumericCodePageScheme(), KviIrcServerParser::parseNumericEndOfWho(), KviIrcServerParser::parseNumericEndOfWhois(), KviIrcServerParser::parseNumericEndOfWhowas(), KviIrcServerParser::parseNumericNotRegistered(), KviIrcServerParser::parseNumericSaslFail(), KviIrcServerParser::parseNumericSaslLogin(), KviIrcServerParser::parseNumericSaslSuccess(), KviIrcServerParser::parseNumericStartTls(), KviIrcServerParser::parseNumericWhoisActually(), KviIrcServerParser::parseNumericWhoisAuth(), KviIrcServerParser::parseNumericWhoisAway(), KviIrcServerParser::parseNumericWhoisChannels(), KviIrcServerParser::parseNumericWhoisIdle(), KviIrcServerParser::parseNumericWhoisOther(), KviIrcServerParser::parseNumericWhoisRegistered(), KviIrcServerParser::parseNumericWhoisServer(), KviIrcServerParser::parseNumericWhoisUser(), KviIrcServerParser::parseNumericWhowasUser(), KviIrcContext::terminateConnectionRequest(), and KviIrcConnectionRequestQueue::timerSlot().

◆ statistics()

KviIrcConnectionStatistics * KviIrcConnection::statistics ( ) const
inline

Returns a pointer to the KviIrcConnectionStatistics object.

It contains runtime statistics about the connection. Very similar to KviIrcConnectionStateData but dedicated to statistics. The returned pointer is never nullptr. Include "KviIrcConnectionStatistics.h" as the class is only forwarded here.

Returns
KviIrcConnectionStatistics *

◆ target()

KviIrcConnectionTarget * KviIrcConnection::target ( ) const
inline

◆ textCodec()

QTextCodec * KviIrcConnection::textCodec ( ) const
inline

Returns a pointer to the current global codec for outbound text.

This codec is a global setting and may be overridden by specific windows. The returned pointer may be null if things really went wrong.

Returns
QTextCodec *

Referenced by KviWindow::defaultTextCodec().

◆ unhighlightAllChannels

void KviIrcConnection::unhighlightAllChannels ( )
slot

Called when we unhighlight all channels.

Returns
void

References m_pChannelList.

◆ unhighlightAllQueries

void KviIrcConnection::unhighlightAllQueries ( )
slot

Called when we unhighlight all queries.

Returns
void

References m_pQueryList.

◆ unregisterChannel()

void KviIrcConnection::unregisterChannel ( KviChannelWindow c)

This is called by KviChannelWindow just before destruction. You shouldn't need to call it.

FIXME: Could be made protected.

References chanListChanged(), channelUnregistered(), KviIrcConnectionRequestQueue::dequeueChannel(), m_pChannelList, and requestQueue().

Referenced by KviChannelWindow::setDeadChan(), and KviChannelWindow::~KviChannelWindow().

◆ unregisterQuery()

void KviIrcConnection::unregisterQuery ( KviQueryWindow q)

This is called by KviQueryWindow just before destruction, you shouldn't need to use it.

FIXME: Could be made protected.

References m_pQueryList, and q.

Referenced by KviQueryWindow::setDeadQuery(), and KviQueryWindow::~KviQueryWindow().

◆ useProfileData()

void KviIrcConnection::useProfileData ( KviIdentityProfileSet pSet,
const QString &  szNetwork 
)
protected

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

Parameters
pSetThe instance of the network identity profile set
szNetworkThe name of the network
Returns
void

References KviIdentityProfileSet::findNetwork(), m_pUserInfo, KviIdentityProfile::realName(), KviIrcConnectionUserInfo::setUserName(), useRealName(), and KviIdentityProfile::userName().

Referenced by loginToIrcServer().

◆ userDataBase()

KviIrcUserDataBase * KviIrcConnection::userDataBase ( ) const
inline

Returns a pointer to the big connection user database.

The database contains ALL the users KVIrc can "see" in this connection. The returned pointer is never nullptr.

Returns
KviIrcUserDataBase *

Referenced by KviConsoleWindow::applyHighlighting(), avatar_kvs_cmd_notify(), avatar_kvs_cmd_set(), avatar_kvs_cmd_unset(), avatar_kvs_fnc_name(), avatar_kvs_fnc_path(), KviConsoleWindow::avatarChanged(), changeAwayState(), KviConsoleWindow::checkDefaultAvatar(), KviUserListEntry::color(), KviConsoleWindow::currentAvatar(), KviQueryWindow::getInfoLabelText(), KviQueryWindow::getWindowListTipText(), KviIsOnNotifyListManager::handleIsOn(), loginComplete(), loginToIrcServer(), KviConsoleWindow::outputPrivmsg(), KviUserListViewArea::paintEvent(), KviIrcServerParser::parseCtcpReplyAvatar(), KviIrcServerParser::parseCtcpReplyUserinfo(), KviIrcServerParser::parseCtcpRequest(), KviIrcServerParser::parseCtcpRequestDcc(), KviIrcServerParser::parseLiteralAccount(), KviIrcServerParser::parseLiteralAway(), KviIrcServerParser::parseLiteralChghost(), KviIrcServerParser::parseLiteralInvite(), KviIrcServerParser::parseLiteralJoin(), KviIrcServerParser::parseLiteralKick(), KviIrcServerParser::parseLiteralNick(), KviIrcServerParser::parseLiteralNotice(), KviIrcServerParser::parseLiteralPrivmsg(), KviIrcServerParser::parseNumericWhoisAway(), KviIrcServerParser::parseNumericWhoisServer(), KviIrcServerParser::parseNumericWhoisUser(), KviIrcServerParser::parseNumericWhospcrpl(), KviQueryWindow::setAliveQuery(), KviConsoleWindow::setAvatar(), KviConsoleWindow::setAvatarFromOptions(), KviConsoleWindow::triggerOnHighlight(), and userInfoReceived().

◆ useRealName()

void KviIrcConnection::useRealName ( const QString &  szRealName)
protected

Sets the specified real name in the user information set after evaluating it via KVS engine (so identifiers are substituted). Call this function instead of m_pUserInfo->setRealName().

References KviKvsVariant::asString(), console(), KviQString::escapeKvs(), KviKvsScript::evaluate(), m_pUserInfo, KviQString::PermitFunctions, KviQString::PermitVariables, and KviIrcConnectionUserInfo::setRealName().

Referenced by loginToIrcServer(), and useProfileData().

◆ userInfo()

KviIrcConnectionUserInfo * KviIrcConnection::userInfo ( ) const
inline

Returns a pointer to the KviIrcConnectionUserInfo object.

It contains runtime information about the user. This includes the current nickname, username, flags and other stuff that KviUserIdentity actually doesn't contain (or has only "default" values for). The returned pointer is never nullptr. Include "KviIrcConnectionUserInfo.h" as the class is only forwarded here.

Returns
KviIrcConnectionUserInfo *

Referenced by KviMaskEditor::addClicked(), avatar_kvs_cmd_set(), avatar_kvs_cmd_unset(), changeAwayState(), KviIrcContext::connectionFailed(), DccChatWindow::connectionInProgress(), DccFileTransfer::connectionInProgress(), KviIrcContext::connectionTerminated(), currentNickName(), currentUserName(), dcc_fill_local_nick_user_host(), KviTrayIconWidget::doAway(), KviIrcContextDisplay::drawContents(), KviTrayIconWidget::fillContextPopup(), KviConsoleWindow::fillStatusString(), KviMaskEditor::itemDoubleClicked(), loginToIrcServer(), KviModeWidget::mouseDoubleClickEvent(), KviStatusBar::mouseDoubleClickEvent(), KviConsoleWindow::outputPrivmsg(), KviChannelWindow::ownAction(), KviQueryWindow::ownAction(), KviChannelWindow::ownMessage(), KviQueryWindow::ownMessage(), KviIrcServerParser::parseChannelMode(), KviIrcServerParser::parseCtcpRequestFinger(), KviIrcServerParser::parseLoginNicknameProblem(), KviUserInput::parseNonCommand(), KviIrcServerParser::parseNumeric001(), KviIrcServerParser::parseNumericBackFromAway(), KviStatusBar::setPermanentMessage(), KviTopicWidget::switchMode(), KviLagMeter::timerEvent(), KviIrcContextDisplay::tipRequest(), KviStatusBarAwayIndicator::tipText(), KviStatusBarAwayIndicator::updateDisplay(), KviMaskEditor::updateOpStatus(), KviModeEditor::updateOpStatus(), and userInfoReceived().

◆ userInfoReceived()

void KviIrcConnection::userInfoReceived ( const QString &  szUserName,
const QString &  szHostName 
)
protected

◆ userModeChanged

void KviIrcConnection::userModeChanged ( )
signal

Emitted when the user modes change.

Returns
void

Referenced by changeUserMode().

Friends And Related Symbol Documentation

◆ KviConsoleWindow

friend class KviConsoleWindow
friend

◆ KviIrcContext

friend class KviIrcContext
friend

◆ KviIrcLink

friend class KviIrcLink
friend

Referenced by KviIrcConnection().

◆ KviIrcServerParser

friend class KviIrcServerParser
friend

Member Data Documentation

◆ m_bIdentdAttached

bool KviIrcConnection::m_bIdentdAttached = false
private

◆ m_eState

State KviIrcConnection::m_eState = Idle
private

◆ m_pAntiCtcpFloodData

KviIrcConnectionAntiCtcpFloodData* KviIrcConnection::m_pAntiCtcpFloodData
private

◆ m_pAsyncWhoisData

KviIrcConnectionAsyncWhoisData* KviIrcConnection::m_pAsyncWhoisData
private

◆ m_pChannelList

std::vector<KviChannelWindow *> KviIrcConnection::m_pChannelList
private

◆ m_pConsole

KviConsoleWindow* KviIrcConnection::m_pConsole
private

◆ m_pContext

KviIrcContext* KviIrcConnection::m_pContext
private

◆ m_pLagMeter

KviLagMeter* KviIrcConnection::m_pLagMeter = nullptr
private

◆ m_pLink

KviIrcLink* KviIrcConnection::m_pLink
private

◆ m_pLocalhostDns

KviDnsResolver* KviIrcConnection::m_pLocalhostDns = nullptr
private

◆ m_pNetsplitDetectorData

KviIrcConnectionNetsplitDetectorData* KviIrcConnection::m_pNetsplitDetectorData
private

◆ m_pNotifyListManager

KviNotifyListManager* KviIrcConnection::m_pNotifyListManager = nullptr
private

◆ m_pNotifyListTimer

QTimer* KviIrcConnection::m_pNotifyListTimer = nullptr
private

◆ m_pQueryList

std::vector<KviQueryWindow *> KviIrcConnection::m_pQueryList
private

◆ m_pRequestQueue

KviIrcConnectionRequestQueue* KviIrcConnection::m_pRequestQueue
private

◆ m_pServerInfo

KviIrcConnectionServerInfo* KviIrcConnection::m_pServerInfo
private

◆ m_pSrvCodec

QTextCodec* KviIrcConnection::m_pSrvCodec
private

◆ m_pStateData

KviIrcConnectionStateData* KviIrcConnection::m_pStateData
private

◆ m_pStatistics

std::unique_ptr<KviIrcConnectionStatistics> KviIrcConnection::m_pStatistics
private

◆ m_pTarget

KviIrcConnectionTarget* KviIrcConnection::m_pTarget
private

◆ m_pTextCodec

QTextCodec* KviIrcConnection::m_pTextCodec
private

Referenced by setEncoding(), and setupTextCodec().

◆ m_pUserDataBase

KviIrcUserDataBase* KviIrcConnection::m_pUserDataBase
private

◆ m_pUserIdentity

KviUserIdentity* KviIrcConnection::m_pUserIdentity
private

◆ m_pUserInfo

KviIrcConnectionUserInfo* KviIrcConnection::m_pUserInfo
private

The documentation for this class was generated from the following files: