KVIrc  4.9.2
DeveloperAPIs
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. More...
 
void unhighlightAllChannels ()
 Called when we unhighlight all channels. More...
 
void unhighlightAllQueries ()
 Called when we unhighlight all queries. More...
 

Signals

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

Public Member Functions

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

Protected Member Functions

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

Private Slots

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

Private Member Functions

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

Private Attributes

bool m_bIdentdAttached
 
State m_eState
 
KviIrcConnectionAntiCtcpFloodDatam_pAntiCtcpFloodData
 
KviIrcConnectionAsyncWhoisDatam_pAsyncWhoisData
 
KviPointerList
< KviChannelWindow > * 
m_pChannelList
 
KviConsoleWindowm_pConsole
 
KviIrcContextm_pContext
 
KviLagMeterm_pLagMeter
 
KviIrcLinkm_pLink
 
KviDnsResolverm_pLocalhostDns
 
KviIrcConnectionNetsplitDetectorDatam_pNetsplitDetectorData
 
KviNotifyListManagerm_pNotifyListManager
 
QTimer * m_pNotifyListTimer
 
KviPointerList< KviQueryWindow > * m_pQueryList
 
KviIrcConnectionRequestQueuem_pRequestQueue
 
KviIrcConnectionServerInfom_pServerInfo
 
QTextCodec * m_pSrvCodec
 
KviIrcConnectionStateDatam_pStateData
 
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

Visibility mode for createQuery()

Enumerator
CreateQueryVisibilityMinimized 

Create minimized query, overriding settings

CreateQueryVisibilityVisible 

Create visible query, overriding settings

CreateQueryVisibilityFollowSettings 

Follow global settings.

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 ( KviIrcContext pContext,
KviIrcConnectionTarget pTarget,
KviUserIdentity pIdentity 
)
protected

Creates a KviIrcConnection object.

This is actually used only by KviConsoleWindow.

pContext must not be NULL 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 NULL and must be allocated with new as this class takes the ownership.

pIdentity must not be NULL 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(), Idle, KviIrcLink, m_bIdentdAttached, m_eState, m_pAntiCtcpFloodData, m_pAsyncWhoisData, m_pChannelList, m_pConsole, m_pContext, m_pLagMeter, m_pLink, m_pLocalhostDns, m_pNetsplitDetectorData, m_pNotifyListManager, m_pNotifyListTimer, m_pQueryList, m_pRequestQueue, m_pServerInfo, m_pStateData, m_pStatistics, m_pTarget, m_pUserDataBase, m_pUserIdentity, m_pUserInfo, KviPointerList< T >::setAutoDelete(), setupSrvCodec(), and setupTextCodec().

KviIrcConnection::~KviIrcConnection ( )
protected

Member Function Documentation

void KviIrcConnection::abort ( )
protected

Kills any running connection or attempt.

Returns
void

References KviIrcLink::abort(), and m_pLink.

Referenced by KviIrcContext::terminateConnectionRequest().

KviIrcConnectionAntiCtcpFloodData* KviIrcConnection::antiCtcpFloodData ( )
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 NULL. Include "KviIrcConnectionAntiCtcpFloodData.h" as the class is only forwarded here.

Returns
KviIrcConnectionAntiCtcpFloodData *

Referenced by KviIrcServerParser::checkCtcpFlood().

KviIrcConnectionAsyncWhoisData* KviIrcConnection::asyncWhoisData ( )
inline
void KviIrcConnection::awayStateChanged ( )
signal

Emitted when the away state changes.

Returns
void

Referenced by changeAwayState().

void KviIrcConnection::changeAwayState ( bool  bAway)
protected
bool KviIrcConnection::changeUserMode ( char  cMode,
bool  bSet 
)
protected
void KviIrcConnection::chanListChanged ( )
signal

Emitted when the channels list change.

Returns
void

Referenced by registerChannel(), and unregisterChannel().

KviPointerList<KviChannelWindow>* KviIrcConnection::channelList ( )
inline
void KviIrcConnection::channelRegistered ( KviChannelWindow pChan)
signal

Emitted when we register a channel.

Parameters
pChanThe channel :)
Returns
void

Referenced by registerChannel().

void KviIrcConnection::channelUnregistered ( KviChannelWindow pChan)
signal

Emitted when we unregister a channel.

Parameters
pChanThe channel :)
Returns
void

Referenced by unregisterChannel().

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().

void KviIrcConnection::closeAllChannels ( )

Closes all the currently open channels not marked as dead.

Returns
void

References KviPointerList< T >::first(), and m_pChannelList.

Referenced by KviIrcContext::destroyConnection().

void KviIrcConnection::closeAllQueries ( )

Closes all the currently open queries not marked as dead.

Returns
void

References KviPointerList< T >::first(), and m_pQueryList.

Referenced by KviIrcContext::destroyConnection().

KviConsoleWindow* KviIrcConnection::console ( )
inline
KviIrcContext* KviIrcConnection::context ( )
inline
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 NULL then we're screwed anyway as virtual memory is exausted.

Parameters
szNameThe name of the channel
Returns
KviChannelWindow *

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

Referenced by KviIrcServerParser::parseLiteralJoin().

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, KviMainWindow::setActiveWindow(), and KviQueryWindow::setAliveQuery().

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

const QString & KviIrcConnection::currentNetworkName ( )

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().

const QString & KviIrcConnection::currentNickName ( )
const QString & KviIrcConnection::currentServerName ( )
const QString & KviIrcConnection::currentUserName ( )

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

Returns
const QString &

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

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().

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().

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(), DccVoiceWindow::connectionInProgress(), DccVideoWindow::connectionInProgress(), DccFileTransfer::connectionInProgress(), dcc_kvs_cmd_chat(), 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::ownMessage(), KviChannelWindow::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().

void KviIrcConnection::endInitialCapNegotiation ( )
protected
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().

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

Finds the channel with the specified unicode name.

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

Parameters
szNameThe name of the channel
Returns
KviChannelWindow *

References c, KviQString::equalCI(), KviPointerList< T >::first(), m_pChannelList, and KviPointerList< T >::next().

Referenced by KviIrcView::doLinkToolTip(), 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().

KviQueryWindow * KviIrcConnection::findQuery ( const QString &  szNick)
void KviIrcConnection::gatherChannelAndPasswordPairs ( QList< QPair< QString, QString >> &  lChannelsAndPasses)
protected

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

References c, KviPointerList< T >::first(), m_pChannelList, and KviPointerList< T >::next().

Referenced by KviIrcContext::connectionTerminated().

void KviIrcConnection::gatherQueryNames ( QStringList &  lQueryNames)
protected

Gather the list of currently open query names.

References KviPointerList< T >::first(), m_pQueryList, KviPointerList< T >::next(), and q.

Referenced by KviIrcContext::connectionTerminated().

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(), c, KviPointerList< T >::first(), m_pChannelList, and KviPointerList< T >::next().

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

void KviIrcConnection::handleAuthenticate ( KviCString szResponse)
protected
void KviIrcConnection::handleFailedInitialCapLs ( )
protected
void KviIrcConnection::handleInitialCapAck ( )
protected
void KviIrcConnection::handleInitialCapLs ( )
protected
void KviIrcConnection::handleInitialCapNak ( )
protected

Called when CAP NAK answer is received.

Returns
void

References endInitialCapNegotiation().

Referenced by KviIrcServerParser::parseLiteralCap().

void KviIrcConnection::heartbeat ( kvi_time_t  tNow)
protected
void KviIrcConnection::hostNameLookupTerminated ( KviDnsResolver pDns)
privateslot
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, l, m, m_pStatistics, KviIrcServerParser::parseMessage(), and KviIrcConnectionStatistics::setLastMessageTime().

Referenced by KviIrcLink::processData().

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, KviIrcServerParser::parseMessage(), and KviIrcConnectionStatistics::setLastMessageTime().

void KviIrcConnection::joinChannels ( const QList< QPair< 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().

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, c, KviPointerList< T >::first(), KVI_OUT_SOCKETERROR, and m_pChannelList.

Referenced by KviIrcContext::connectionTerminated().

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, KviPointerList< T >::first(), KVI_OUT_SOCKETERROR, m_pQueryList, and q.

Referenced by KviIrcContext::connectionTerminated().

KviLagMeter* KviIrcConnection::lagMeter ( )
inline
KviIrcLink* KviIrcConnection::link ( )
inline

Returns the underlying KviIrcLink object.

The returned pointer is never NULL.

Returns
KviIrcLink *

Referenced by context_kvs_fnc_getSSLCertInfo(), dcc_kvs_get_listen_ip_address(), handleInitialCapLs(), linkEstablished(), and resolveLocalHost().

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().

void KviIrcConnection::linkEstablished ( )
protected
void KviIrcConnection::linkTerminated ( )
protected
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, KviIrcUserEntry::host(), 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_lJoinChannels, m_pConsole, m_pServerInfo, m_pStateData, m_pUserIdentity, m_pUserInfo, KviIrcConnectionTarget::network(), KviUserListView::nickChange(), KviIrcConnectionUserInfo::nickName(), KviConsoleWindow::notifyListView(), KviIrcNetwork::onLoginCommand(), KviUserIdentity::onLoginCommand(), KviIrcServer::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().

void KviIrcConnection::loginToIrcServer ( )
protected

Logins to the irc server.

Returns
void

References __tr2qs, _OUTPUT_MUTE, _OUTPUT_VERBOSE, KviIrcUserEntry::avatar(), 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(), KviUserIdentity::onConnectCommand(), KviIrcServer::onConnectCommand(), KviWindow::output(), KviWindow::outputNoFmt(), KviIrcConnectionUserInfo::password(), KviIrcNetwork::password(), KviIrcServer::password(), pickNextLoginNickName(), KviIrcConnectionUserInfo::realName(), KviIrcNetwork::realName(), KviIrcServer::realName(), KviIrcServer::reconnectInfo(), KviControlCodes::Reset, KviKvsScript::run(), sendFmtData(), KviIrcConnectionTarget::server(), KviIrcUserEntry::setAvatar(), KviIrcUserEntry::setGender(), KviIrcConnectionStateData::setLoginNickNameState(), KviIrcConnectionServerInfo::setName(), KviIrcConnectionUserInfo::setNickName(), KviIrcConnectionUserInfo::setPassword(), setupTextCodec(), KviIrcConnectionUserInfo::setUserName(), target(), KviControlCodes::Transparent, KviIrcConnectionStateData::UsedConnectionSpecificNickName, useProfileData(), userDataBase(), useRealName(), userInfo(), KviIrcConnectionUserInfo::userName(), KviIrcNetwork::userName(), and KviIrcServer::userName().

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

KviIrcConnectionNetsplitDetectorData* KviIrcConnection::netsplitDetectorData ( )
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 NULL. Include "KviIrcConnectionNetsplitDetectorData.h" as the class is only forwarded here.

Returns
KviIrcConnectionNetsplitDetectorData *

Referenced by KviIrcServerParser::parseLiteralQuit().

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

Emitted when the nickname changes.

Returns
void

Referenced by nickChange().

KviNotifyListManager* KviIrcConnection::notifyListManager ( )
inline

Returns a pointer to the current KviNotifyListManager.

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

Returns
KviNotifyListManager *

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

unsigned int KviIrcConnection::outputQueueSize ( )

Returns the current size of the output queue.

Returns
unsigned int

References m_pLink, and KviIrcLink::outputQueueSize().

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().

KviPointerList<KviQueryWindow>* KviIrcConnection::queryList ( )
inline

Returns the list of the currently open queries.

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

Returns
KviPointerList<KviQueryWindow> *

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

void KviIrcConnection::registerChannel ( KviChannelWindow c)
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 KviPointerList< T >::append(), and m_pQueryList.

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

KviIrcConnectionRequestQueue* KviIrcConnection::requestQueue ( )
inline
void KviIrcConnection::resolveLocalHost ( )
protected
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().

void KviIrcConnection::restartNotifyList ( )
slot
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().

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, l, m, m_pConsole, m_pLink, KviMemory::move(), KviWindow::outputNoFmt(), and KviIrcLink::sendPacket().

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

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, l, m, m_pConsole, m_pLink, KviWindow::outputNoFmt(), KviDataBuffer::resize(), and KviIrcLink::sendPacket().

Referenced by KviMaskInputDialog::accept(), avatar_kvs_cmd_notify(), avatar_kvs_cmd_query(), KviChannelWindow::closeEvent(), DccVoiceWindow::connectionInProgress(), DccVideoWindow::connectionInProgress(), DccFileTransfer::connectionInProgress(), dcc_kvs_cmd_chat(), 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(), linkEstablished(), loginComplete(), loginToIrcServer(), KviQueryWindow::ownAction(), KviQueryWindow::ownMessage(), KviChannelWindow::ownMessage(), KviIrcServerParser::parseCtcpReplyAvatar(), KviIrcServerParser::parseLiteralInvite(), KviIrcServerParser::parseLiteralKick(), KviIrcServerParser::parseLiteralPing(), KviIrcServerParser::parseLoginNicknameProblem(), KviIrcServerParser::parseNumeric005(), KviIrcServerParser::parseNumericAway(), KviIrcServerParser::parseNumericBackFromAway(), 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().

QTextCodec* KviIrcConnection::serverCodec ( )
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 *
KviIrcConnectionServerInfo* KviIrcConnection::serverInfo ( )
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 NULL. 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::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(), KviChangeUserModeAction::popupAboutToShow(), KviWindow::preprocessMessage(), restartNotifyList(), KviChannelWindow::serverInfo(), serverInfoReceived(), KviTopicWidget::switchMode(), KviLagMeter::timerEvent(), and KviChannelWindow::updateModeLabel().

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().

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, c, KviLocale::codecForName(), KviPointerList< T >::first(), KviLocale::instance(), KVI_OUT_SYSTEMERROR, KVI_OUT_VERBOSE, m_pChannelList, m_pConsole, m_pQueryList, m_pSrvCodec, m_pTextCodec, KviPointerList< T >::next(), KviWindow::output(), q, and KviWindow::setTextEncoding().

Referenced by KviIrcServerParser::parseNumericCodePageSet().

void KviIrcConnection::setupSrvCodec ( )
private
void KviIrcConnection::setupTextCodec ( )
private
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 KviIrcConnection::state ( )
inline
KviIrcConnectionStateData* KviIrcConnection::stateData ( )
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 NULL. 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::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(), KviIrcContext::terminateConnectionRequest(), and KviIrcConnectionRequestQueue::timerSlot().

KviIrcConnectionStatistics* KviIrcConnection::statistics ( )
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 NULL. Include "KviIrcConnectionStatistics.h" as the class is only forwarded here.

Returns
KviIrcConnectionStatistics *

Referenced by KviStatusBarConnectionTimer::timerEvent().

KviIrcConnectionTarget* KviIrcConnection::target ( )
inline
QTextCodec* KviIrcConnection::textCodec ( )
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().

void KviIrcConnection::unhighlightAllChannels ( )
slot

Called when we unhighlight all channels.

Returns
void

References c, KviPointerList< T >::first(), m_pChannelList, and KviPointerList< T >::next().

void KviIrcConnection::unhighlightAllQueries ( )
slot

Called when we unhighlight all queries.

Returns
void

References c, KviPointerList< T >::first(), m_pQueryList, and KviPointerList< T >::next().

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, KviPointerList< T >::removeRef(), and requestQueue().

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

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 KviPointerList< T >::removeRef().

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

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().

KviIrcUserDataBase* KviIrcConnection::userDataBase ( )
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 NULL.

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(), KviConsoleWindow::checkDefaultAvatar(), KviUserListEntry::color(), KviConsoleWindow::currentAvatar(), KviIrcView::doLinkToolTip(), 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().

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().

KviIrcConnectionUserInfo* KviIrcConnection::userInfo ( )
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 NULL. Include "KviIrcConnectionUserInfo.h" as the class is only forwarded here.

Returns
KviIrcConnectionUserInfo *

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

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

Emitted when the user modes change.

Returns
void

Referenced by changeUserMode().

Friends And Related Function Documentation

friend class KviConsoleWindow
friend
friend class KviIrcContext
friend
friend class KviIrcLink
friend

Referenced by KviIrcConnection().

friend class KviIrcServerParser
friend

Member Data Documentation

bool KviIrcConnection::m_bIdentdAttached
private
State KviIrcConnection::m_eState
private
KviIrcConnectionAntiCtcpFloodData* KviIrcConnection::m_pAntiCtcpFloodData
private
KviIrcConnectionAsyncWhoisData* KviIrcConnection::m_pAsyncWhoisData
private
KviPointerList<KviChannelWindow>* KviIrcConnection::m_pChannelList
private
KviConsoleWindow* KviIrcConnection::m_pConsole
private
KviIrcContext* KviIrcConnection::m_pContext
private
KviLagMeter* KviIrcConnection::m_pLagMeter
private
KviIrcLink* KviIrcConnection::m_pLink
private
KviDnsResolver* KviIrcConnection::m_pLocalhostDns
private
KviIrcConnectionNetsplitDetectorData* KviIrcConnection::m_pNetsplitDetectorData
private
KviNotifyListManager* KviIrcConnection::m_pNotifyListManager
private
QTimer* KviIrcConnection::m_pNotifyListTimer
private
KviPointerList<KviQueryWindow>* KviIrcConnection::m_pQueryList
private
KviIrcConnectionRequestQueue* KviIrcConnection::m_pRequestQueue
private
KviIrcConnectionServerInfo* KviIrcConnection::m_pServerInfo
private
QTextCodec* KviIrcConnection::m_pSrvCodec
private
KviIrcConnectionStateData* KviIrcConnection::m_pStateData
private
KviIrcConnectionStatistics* KviIrcConnection::m_pStatistics
private
KviIrcConnectionTarget* KviIrcConnection::m_pTarget
private
QTextCodec* KviIrcConnection::m_pTextCodec
private

Referenced by setEncoding(), and setupTextCodec().

KviIrcUserDataBase* KviIrcConnection::m_pUserDataBase
private
KviUserIdentity* KviIrcConnection::m_pUserIdentity
private
KviIrcConnectionUserInfo* KviIrcConnection::m_pUserInfo
private

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