KVIrc 5.2.6
Developer APIs
KviIrcLink Class Reference

Middle stack class for IRC connection. More...

#include <KviIrcLink.h>

+ Inheritance diagram for KviIrcLink:

Public Types

enum  State { Idle , Connecting , Connected }
 

Signals

void connectionFailed ()
 Emitted when the connection attempt has failed.
 

Public Member Functions

KviIrcConnectionconnection () const
 Returns the connection object.
 
KviConsoleWindowconsole () const
 Returns the console.
 
KviIrcSocketsocket () const
 Returns the socket.
 
State state () const
 Returns the state of the socket.
 

Protected Slots

void linkFilterDestroyed ()
 Called when the link filter has been destroyed without permission :D.
 

Protected Member Functions

void abort ()
 Aborts any connection or attempt.
 
virtual void clearOutputQueue (bool bPrivateMessagesOnly)
 Clears the output queue.
 
 KviIrcLink (KviIrcConnection *pConnection)
 Constructs the IrcLink object.
 
unsigned int outputQueueSize ()
 Returns the current size of the output queue.
 
void processData (char *buffer, int iLength)
 Process a packet of raw data from the server.
 
virtual bool sendPacket (KviDataBuffer *pData)
 Sends a data packet.
 
void socketStateChange ()
 Called at each state change.
 
void start ()
 Starts a connection attempt.
 
 ~KviIrcLink ()
 Destroys the IrcLink object.
 

Private Slots

void resolverTerminated ()
 Called when the DNS lookup has terminated.
 

Private Member Functions

void createSocket (const QString &szLinkFilterName)
 Creates the socket.
 
void destroySocket ()
 Destroys the socket.
 

Private Attributes

State m_eState = Idle
 
KviIrcConnectionm_pConnection
 
KviConsoleWindowm_pConsole
 
KviMexLinkFilterm_pLinkFilter = nullptr
 
char * m_pReadBuffer = nullptr
 
KviIrcConnectionTargetResolverm_pResolver = nullptr
 
KviIrcSocketm_pSocket = nullptr
 
KviIrcConnectionTargetm_pTarget
 
unsigned int m_uReadBufferLen = 0
 
unsigned int m_uReadPackets = 0
 

Friends

class KviIrcConnection
 
class KviIrcSocket
 

Detailed Description

Middle stack class for IRC connection.

This class gets data from KviIrcSocket and pass it to KviIrcConnection

Member Enumeration Documentation

◆ State

Enumerator
Idle 

Socket idling

Connecting 

Socket connecting

Connected 

Socket connected

Constructor & Destructor Documentation

◆ KviIrcLink()

KviIrcLink::KviIrcLink ( KviIrcConnection * pConnection)
protected

Constructs the IrcLink object.

Only KviConsoleWindow can create this. pConsole must NOT be null; pServer is a shallow pointer: Connection makes a copy of it internally, must NOT be null; pProxy may be null if a proxy is not desired. Connection makes a copy of it internally;

Parameters
pConnectionThe pointer to the KviIrcConnection class
Returns
KviIrcLink

References KviIrcConnection, m_pConnection, m_pConsole, m_pTarget, and KviIrcConnection::target().

◆ ~KviIrcLink()

KviIrcLink::~KviIrcLink ( )
protected

Destroys the IrcLink object.

References destroySocket(), KviMemory::free(), m_pReadBuffer, and m_pResolver.

Member Function Documentation

◆ abort()

void KviIrcLink::abort ( )
protected

Aborts any connection or attempt.

Returns
void

References m_pResolver, and m_pSocket.

◆ clearOutputQueue()

void KviIrcLink::clearOutputQueue ( bool bPrivateMessagesOnly)
protectedvirtual

Clears the output queue.

Requests to clear the underlying packet queue.

References m_pLinkFilter, and m_pSocket.

◆ connection()

KviIrcConnection * KviIrcLink::connection ( ) const
inline

Returns the connection object.

Never null

Returns
KviIrcConnection *

References KviIrcConnection, and m_pConnection.

Referenced by socketStateChange().

◆ connectionFailed

void KviIrcLink::connectionFailed ( )
signal

Emitted when the connection attempt has failed.

Returns
void

References resolverTerminated().

◆ console()

KviConsoleWindow * KviIrcLink::console ( ) const
inline

Returns the console.

Never null

Returns
KviConsoleWindow *

References m_pConsole.

◆ createSocket()

void KviIrcLink::createSocket ( const QString & szLinkFilterName)
private

Creates the socket.

Parameters
szLinkFilterNameThe source linkfilter name
Returns
void

References __tr2qs, connect(), destroySocket(), KviQString::equalCI(), g_pModuleExtensionManager, KVI_OUT_SYSTEMMESSAGE, KVI_OUT_SYSTEMWARNING, KviIrcSocket, linkFilterDestroyed(), m_pConsole, m_pLinkFilter, and m_pSocket.

Referenced by resolverTerminated().

◆ destroySocket()

void KviIrcLink::destroySocket ( )
private

Destroys the socket.

Returns
void

References m_pLinkFilter, and m_pSocket.

Referenced by createSocket(), and ~KviIrcLink().

◆ linkFilterDestroyed

void KviIrcLink::linkFilterDestroyed ( )
protectedslot

Called when the link filter has been destroyed without permission :D.

This should NEVER happen (?) This is part of the KviIrcSocket management

Returns
void

References __tr2qs, KVI_OUT_SYSTEMWARNING, m_pConsole, and m_pLinkFilter.

Referenced by createSocket().

◆ outputQueueSize()

unsigned int KviIrcLink::outputQueueSize ( )
protected

Returns the current size of the output queue.

Returns
unsigned int

References m_pLinkFilter, and m_pSocket.

◆ processData()

void KviIrcLink::processData ( char * buffer,
int iLength )
protected

Process a packet of raw data from the server.

This is called by KviIrcSocket. The buffer is iLength+1 bytes long and contains a null terminator It's an interface for KviIrcSocket (lower protocol in stack)

Parameters
bufferThe buffer :)
iLengthThe length of the buffer
Returns
void

References KviMemory::allocate(), KviIrcSocket::Connected, KviMemory::free(), KVI_ASSERT, m_pConnection, m_pLinkFilter, m_pReadBuffer, m_pSocket, m_uReadBufferLen, m_uReadPackets, KviMemory::move(), p, and KviMemory::reallocate().

◆ resolverTerminated

void KviIrcLink::resolverTerminated ( )
privateslot

◆ sendPacket()

bool KviIrcLink::sendPacket ( KviDataBuffer * pData)
protectedvirtual

Sends a data packet.

This is used by KviIrcConnection::send*() This should be used to intercept the outgoing packets when implementing a new protocol. It's an interface for KviIrcConnection (upper protocol in stack)

Parameters
pDataThe pointer to the data packet
Returns
bool

References m_pLinkFilter, and m_pSocket.

◆ socket()

KviIrcSocket * KviIrcLink::socket ( ) const
inline

Returns the socket.

May be null!

Returns
KviIrcSocket *

References KviIrcSocket, and m_pSocket.

Referenced by context_kvs_fnc_getSSLCertInfo(), dcc_kvs_get_listen_ip_address(), and socketStateChange().

◆ socketStateChange()

◆ start()

void KviIrcLink::start ( )
protected

Starts a connection attempt.

It starts the server or proxy DNS lookup. The function MUST be asynchronous: it must return successfully and report any error by using m_pConnection->linkAttemptFailed() It's called internally and it's overridable

Returns
void

References connect(), Connecting, m_eState, m_pConnection, m_pResolver, m_pTarget, and resolverTerminated().

◆ state()

State KviIrcLink::state ( ) const
inline

Returns the state of the socket.

Returns
State

References m_eState.

Friends And Related Symbol Documentation

◆ KviIrcConnection

friend class KviIrcConnection
friend

References KviIrcConnection.

Referenced by connection(), KviIrcConnection, and KviIrcLink().

◆ KviIrcSocket

friend class KviIrcSocket
friend

References KviIrcSocket.

Referenced by createSocket(), KviIrcSocket, and socket().

Member Data Documentation

◆ m_eState

State KviIrcLink::m_eState = Idle
private

◆ m_pConnection

KviIrcConnection* KviIrcLink::m_pConnection
private

◆ m_pConsole

◆ m_pLinkFilter

◆ m_pReadBuffer

char* KviIrcLink::m_pReadBuffer = nullptr
private

Referenced by processData(), and ~KviIrcLink().

◆ m_pResolver

KviIrcConnectionTargetResolver* KviIrcLink::m_pResolver = nullptr
private

◆ m_pSocket

◆ m_pTarget

KviIrcConnectionTarget* KviIrcLink::m_pTarget
private

◆ m_uReadBufferLen

unsigned int KviIrcLink::m_uReadBufferLen = 0
private

Referenced by processData().

◆ m_uReadPackets

unsigned int KviIrcLink::m_uReadPackets = 0
private

Referenced by processData().


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