Home

QtTelnet Class Reference

The QtTelnet class proveds an API to connect to Telnet servers, issue commands and receive replies. More...

#include <qttelnet.h>

List of all member functions.

Public Members

Public Slots

Signals

Protected Members


Detailed Description

The QtTelnet class proveds an API to connect to Telnet servers, issue commands and receive replies.

When a QtTelnet object has been created, you need to call connectToHost() to establish a connection with a Telnet server. When the connection is established the connected() signal is emitted. At this point you should call login(). The QtTelnet object will emit connectionError() if the connection fails, and authenticationFailed() if the login() failed.

Once the connection has been successfully established and you've logged in you can send control messages using sendControl() and data using sendData(). Connect to the message() signal to receive data from the Telnet server. The connection is closed with close().

You can use your own socket if you call setSocket() before connecting. The socket used by QtTelnet is available from socket().


Member Type Documentation

QtTelnet::Control

This enum specifies control messages you can send to the Telnet server using sendControl().

See also sendControl().


Member Function Documentation

QtTelnet::QtTelnet ( QObject * parent = 0, const char * name = 0 )

Constructs a QtTelnet object.

You must call connectToHost() before calling any of the other member functions.

See also connectToHost().

QtTelnet::~QtTelnet ()

Destroys the QtTelnet object. This will also close the connection to the server.

See also logout().

void QtTelnet::close () [slot]

Closes the connection to a Telnet server.

See also connectToHost() and login().

void QtTelnet::connectToHost ( const QString & host, Q_UINT16 port = 23 )

Calling this function will make the QtTelnet object attempt to connect to a Telnet server specified by the given host and port.

The connected() signal is emitted if the connection succeeds, and the connectionError() signal is emitted if the connection fails. Once the connection is establishe you must call login().

See also close().

void QtTelnet::connectionError ( int code ) [signal]

This signal is emitted if the underlying socket implementation receives an error. The code argument is the same as being used in QSocket::connectionError()

bool QtTelnet::isValidWindowSize () const

Returns true if the window size is valid, i.e. windowSize().isValid() returns true; otherwise returns false.

See also setWindowSize().

void QtTelnet::loggedIn () [signal]

This signal is emitted when you have been logged in to the server as a result of the login() command being called. Do note that you might never see this signal even if you have been logged in, due to the Telnet specification not requiring Telnet servers to notify clients when users are logged in.

See also login() and setPromptPattern().

void QtTelnet::loggedOut () [signal]

This signal is emitted when you have called logout() and the Telnet server has actually logged you out.

See also logout() and login().

void QtTelnet::login ( const QCString & user, const QCString & pass )

Sets the credentials to use for logging in to the server. This function makes a shallow copy of the username/password if the input parameters are actually a QCString and a deep copy if they are a const char *. The data will be overwritten after a successfull login for security reasons, so call QCString::detach() on the data after calling this function if you wish to keep them.

See also setPrompts().

void QtTelnet::loginFailed () [signal]

This signal is emitted when the login has failed. Do note that you might in certain cases see several loginRequired() signals being emitted but no loginFailed() signals. This is due to the Telnet specification not requiring the Telnet server to support reliable authentication methods.

See also login() and loginRequired().

void QtTelnet::loginRequired () [signal]

This signal is emitted when the QtTelnet class sees that the Telnet server expects authentication and you have not already called login().

As a reply to this signal you should either call login() or logout()

See also login() and logout().

void QtTelnet::logout () [slot]

This function will log you out of the Telnet server. You cannot send any other data after sending this command.

See also login(), sendData(), and sendControl().

void QtTelnet::message ( const QString & data ) [signal]

This signal is emitted when the QtTelnet object receives data from the Telnet server.

See also sendData().

void QtTelnet::sendControl ( Control ctrl ) [slot]

Sends the control message ctrl to the Telnet server the QtTelnet object is connected to.

See also Control, sendData(), and sendSync().

void QtTelnet::sendData ( const QString & data ) [slot]

Sends the string data to the Telnet server. This is often a command the Telnet server will execute.

See also sendControl().

void QtTelnet::sendSync () [slot]

Sends the Telnet SYNC sequence, meaning that the Telnet server should discard any data waiting to be processed once the SYNC sequence has been received. This is sent using a TCP urgent notification

See also sendControl().

void QtTelnet::setLoginPattern ( const QRegExp & login ) [protected]

Sets the login prompt to check for automated login if QtTelnet cannot otherwise determine when the username/password combination should be sent to the server.

See also login().

void QtTelnet::setLoginString ( const QString & login ) [protected]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

void QtTelnet::setPasswordPattern ( const QRegExp & password ) [protected]

Sets the password prompt to check for automated login if QtTelnet cannot otherwise determine when the username/password combination should be sent to the server.

See also login().

void QtTelnet::setPasswordString ( const QString & password ) [protected]

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

void QtTelnet::setPromptPattern ( const QRegExp & prompt )

Sets the prompt to check for automated login if QtTelnet cannot otherwise determine when the user has successfully logged in.

See also login().

void QtTelnet::setPromptString ( const QString & prompt )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

void QtTelnet::setSocket ( QSocket * socket )

This function allows you to use your own QSocket subclass. You should call this function before calling connectToHost(); if you call it after a connection has been established the connection will be closed, so in all cases you will need to call connectToHost() after calling this function.

See also socket(), connectToHost(), and logout().

void QtTelnet::setWindowSize ( const QSize & size )

Sets the client window's size to be size; the size's width and height are given in characters. For non-visible clients pass an invalid size (i.e. QSize()).

See also isValidWindowSize().

void QtTelnet::setWindowSize ( int width, int height )

This is an overloaded member function, provided for convenience. It behaves essentially like the above function.

QSocket * QtTelnet::socket () const

Returns the socket instance used by this telnet object.

See also setSocket().

QSize QtTelnet::windowSize () const

Returns the window's size. This will be an invalid size (QSize::isValid() will return false) if the Telnet server is not using the NAWS option (RFC1073).

See also isValidWindowSize().


This file is part of the Qt Solutions. Copyright © 2003-2005 Trolltech. All Rights Reserved.

Copyright © 2003-2005 TrolltechTrademarks
Qt Solutions