QCA::Console Class Reference
[QCA user API]

QCA Console system More...

#include <QtCrypto>

Inheritance diagram for QCA::Console:

QObject
Collaboration diagram for QCA::Console:

Collaboration graph
[legend]

List of all members.

Public Types

enum  ChannelMode { Read, ReadWrite }
enum  TerminalMode { Default, Interactive }
enum  Type { Tty, Stdio }

Public Member Functions

QByteArray bytesLeftToRead ()
QByteArray bytesLeftToWrite ()
ChannelMode channelMode () const
 Console (Type type, ChannelMode cmode, TerminalMode tmode, QObject *parent=0)
void release ()
TerminalMode terminalMode () const
Type type () const

Static Public Member Functions

static bool isStdinRedirected ()
static bool isStdoutRedirected ()
static ConsolestdioInstance ()
static ConsolettyInstance ()

Friends

class ConsolePrivate
class ConsoleReference


Detailed Description

QCA Console system

QCA provides an API for asynchronous, event-based access to the console and stdin/stdout, as these facilities are otherwise not portable. The primary use of this system within QCA is for passphrase prompting in command-line applications, using the tty console type.

How it works: Create a Console object for the type of console desired, and then use ConsoleReference to act on the console. Only one ConsoleReference may operate on a Console at a time.

A Console object takes over either the physical console (Console::Tty type) or stdin/stdout (Console::Stdio type). Only one of each type may be created at a time.

Whenever code is written that needs a tty or stdio object, the code should first call one of the static methods (ttyInstance() or stdioInstance()) to see if a console object for the desired type exists already. If the object exists, use it. If it does not exist, the rule is that the relevant code should create the object, use the object, and then destroy the object when the operation is completed.

By following the above rule, you can write code that utilizes a console without the application having to create some master console object for you. Of course, if the application has created a console then it will be used.

The reason why there is a master console object is that it is not guaranteed that all I/O will survive creation and destruction of a console object. If you are using the Stdio Type, then you probably want a long-lived console object. It is possible to capture unprocessed I/O by calling bytesLeftToRead or bytesLeftToWrite. However, it is not expected that general console-needing code will call these functions when utilizing a temporary console. Thus, an application developer would need to create his own console object, invoke the console-needing code, and then do his own extraction of the unprocessed I/O if necessary. Another reason to extract unprocessed I/O is if you need to switch from Console back to standard functions (e.g. fgets() ).


Member Enumeration Documentation

The type of I/O to use with the console object.

Enumerator:
Read  Read only (equivalent to stdin).
ReadWrite  Read/write (equivalent to stdin and stdout).

The nature of the console operation.

Enumerator:
Default  use default terminal settings
Interactive  char-by-char input, no echo

The type of console object.

Enumerator:
Tty  physical console
Stdio  stdin/stdout


Constructor & Destructor Documentation

pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, TerminalMode pe, Te
QCA::Console::Console ( Type  type,
ChannelMode  cmode,
TerminalMode