source: trunk/src/network/socket/qlocalsocket_p.h@ 788

Last change on this file since 788 was 769, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.6.3 sources from branches/vendor/nokia/qt.

File size: 5.5 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtNetwork module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QLOCALSOCKET_P_H
43#define QLOCALSOCKET_P_H
44
45//
46// W A R N I N G
47// -------------
48//
49// This file is not part of the Qt API. It exists for the convenience
50// of the QLocalSocket class. This header file may change from
51// version to version without notice, or even be removed.
52//
53// We mean it.
54//
55
56#ifndef QT_NO_LOCALSOCKET
57
58#include "qlocalsocket.h"
59#include "private/qiodevice_p.h"
60
61#include <qtimer.h>
62
63#if defined(QT_LOCALSOCKET_TCP)
64# include "qtcpsocket.h"
65#elif defined(Q_OS_WIN)
66# include "private/qwindowspipewriter_p.h"
67# include "private/qringbuffer_p.h"
68# include <private/qwineventnotifier_p.h>
69#else
70# include "private/qnativesocketengine_p.h"
71# include <qtcpsocket.h>
72# include <qsocketnotifier.h>
73# include <errno.h>
74#endif
75
76QT_BEGIN_NAMESPACE
77
78#if !defined(Q_OS_WIN) || defined(QT_LOCALSOCKET_TCP)
79class QLocalUnixSocket : public QTcpSocket
80{
81
82public:
83 QLocalUnixSocket() : QTcpSocket()
84 {
85 };
86
87 inline void setSocketState(QAbstractSocket::SocketState state)
88 {
89 QTcpSocket::setSocketState(state);
90 };
91
92 inline void setErrorString(const QString &string)
93 {
94 QTcpSocket::setErrorString(string);
95 }
96
97 inline void setSocketError(QAbstractSocket::SocketError error)
98 {
99 QTcpSocket::setSocketError(error);
100 }
101
102 inline qint64 readData(char *data, qint64 maxSize)
103 {
104 return QTcpSocket::readData(data, maxSize);
105 }
106
107 inline qint64 writeData(const char *data, qint64 maxSize)
108 {
109 return QTcpSocket::writeData(data, maxSize);
110 }
111};
112#endif //#if !defined(Q_OS_WIN) || defined(QT_LOCALSOCKET_TCP)
113
114class QLocalSocketPrivate : public QIODevicePrivate
115{
116 Q_DECLARE_PUBLIC(QLocalSocket)
117
118public:
119 QLocalSocketPrivate();
120 void init();
121
122#if defined(QT_LOCALSOCKET_TCP)
123 QLocalUnixSocket* tcpSocket;
124 bool ownsTcpSocket;
125 void setSocket(QLocalUnixSocket*);
126 QString generateErrorString(QLocalSocket::LocalSocketError, const QString &function) const;
127 void errorOccurred(QLocalSocket::LocalSocketError, const QString &function);
128 void _q_stateChanged(QAbstractSocket::SocketState newState);
129 void _q_error(QAbstractSocket::SocketError newError);
130#elif defined(Q_OS_WIN)
131 ~QLocalSocketPrivate();
132 void destroyPipeHandles();
133 void setErrorString(const QString &function);
134 void _q_notified();
135 void _q_canWrite();
136 void _q_pipeClosed();
137 void _q_emitReadyRead();
138 DWORD bytesAvailable();
139 void startAsyncRead();
140 bool completeAsyncRead();
141 void checkReadyRead();
142 HANDLE handle;
143 OVERLAPPED overlapped;
144 QWindowsPipeWriter *pipeWriter;
145 qint64 readBufferMaxSize;
146 QRingBuffer readBuffer;
147 int actualReadBufferSize;
148 QWinEventNotifier *dataReadNotifier;
149 QLocalSocket::LocalSocketError error;
150 bool readSequenceStarted;
151 bool pendingReadyRead;
152 bool pipeClosed;
153 static const qint64 initialReadBufferSize = 4096;
154#else
155 QLocalUnixSocket unixSocket;
156 QString generateErrorString(QLocalSocket::LocalSocketError, const QString &function) const;
157 void errorOccurred(QLocalSocket::LocalSocketError, const QString &function);
158 void _q_stateChanged(QAbstractSocket::SocketState newState);
159 void _q_error(QAbstractSocket::SocketError newError);
160 void _q_connectToSocket();
161 void _q_abortConnectionAttempt();
162 void cancelDelayedConnect();
163 QSocketNotifier *delayConnect;
164 QTimer *connectTimer;
165 int connectingSocket;
166 QString connectingName;
167 QIODevice::OpenMode connectingOpenMode;
168#endif
169
170 QString serverName;
171 QString fullServerName;
172 QLocalSocket::LocalSocketState state;
173};
174
175QT_END_NAMESPACE
176
177#endif // QT_NO_LOCALSOCKET
178
179#endif // QLOCALSOCKET_P_H
180
Note: See TracBrowser for help on using the repository browser.