return QSocketNotifier::event(e);
}
-class QExceptionNotifier : public QSocketNotifier
-{
-public:
- QExceptionNotifier(int fd, QAbstractSocketEngine *parent)
- : QSocketNotifier(fd, QSocketNotifier::Exception, parent) { engine = parent; }
-
-protected:
- bool event(QEvent *);
-
- QAbstractSocketEngine *engine;
-};
-
-bool QExceptionNotifier::event(QEvent *e)
-{
- if (e->type() == QEvent::SockAct) {
- if (engine->state() == QAbstractSocket::ConnectingState)
- engine->connectionNotification();
- else
- engine->exceptionNotification();
- return true;
- }
- return QSocketNotifier::event(e);
-}
-
/*! \internal
Constructs the private class and initializes all data members.
*/
: socketDescriptor(-1)
, readNotifier(0)
, writeNotifier(0)
- , exceptNotifier(0)
, socketError(QAbstractSocket::UnknownSocketError)
, hasSetSocketError(false)
, socketErrorString(QLatin1String(QT_TRANSLATE_NOOP(QSocketLayer, "Unknown error")))
receiver->writeNotification();
}
-void QAbstractSocketEngine::exceptionNotification()
-{
- if (QAbstractSocketEngineReceiver *receiver = d_func()->receiver)
- receiver->exceptionNotification();
-}
-
/*!
If there's a connection activity on the socket, process it. Then
notify our parent if there really was activity.
d->readNotifier->setEnabled(false);
if (d->writeNotifier)
d->writeNotifier->setEnabled(false);
- if (d->exceptNotifier)
- d->exceptNotifier->setEnabled(false);
if(d->socketDescriptor != -1) {
d->nativeClose();
delete d->writeNotifier;
d->writeNotifier = 0;
}
- if (d->exceptNotifier) {
- delete d->exceptNotifier;
- d->exceptNotifier = 0;
- }
}
/*!
}
}
-bool QAbstractSocketEngine::isExceptionNotificationEnabled() const
-{
- Q_D(const QAbstractSocketEngine);
- return d->exceptNotifier && d->exceptNotifier->isEnabled();
-}
-
-void QAbstractSocketEngine::setExceptionNotificationEnabled(bool enable)
-{
- Q_D(QAbstractSocketEngine);
- if (d->exceptNotifier) {
- d->exceptNotifier->setEnabled(enable);
- } else if (enable && d->threadData->eventDispatcher) {
- d->exceptNotifier = new QExceptionNotifier(d->socketDescriptor, this);
- d->exceptNotifier->setEnabled(true);
- }
-}
-
QT_END_NAMESPACE
#include "moc_qabstractsocketengine_p.h"
class QAbstractSocketEngineReceiver {
public:
- virtual ~QAbstractSocketEngineReceiver(){}
- virtual void readNotification()= 0;
- virtual void writeNotification()= 0;
- virtual void exceptionNotification()= 0;
- virtual void connectionNotification()= 0;
+ virtual ~QAbstractSocketEngineReceiver() {}
+ virtual void readNotification() = 0;
+ virtual void writeNotification() = 0;
+ virtual void connectionNotification() = 0;
};
class Q_AUTOTEST_EXPORT QAbstractSocketEngine : public QObject
void setReadNotificationEnabled(bool enable);
bool isWriteNotificationEnabled() const;
void setWriteNotificationEnabled(bool enable);
- bool isExceptionNotificationEnabled() const;
- void setExceptionNotificationEnabled(bool enable);
public Q_SLOTS:
void readNotification();
void writeNotification();
- void exceptionNotification();
void connectionNotification();
public:
bool fetchConnectionParameters();
int socketDescriptor;
- QSocketNotifier *readNotifier, *writeNotifier, *exceptNotifier;
+ QSocketNotifier *readNotifier, *writeNotifier;
QAbstractSocket::SocketError socketError;
bool hasSetSocketError;
QString socketErrorString;