Ignore:
Timestamp:
Aug 2, 2010, 9:27:30 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

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

Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/network/socket/qabstractsocket.cpp

    r651 r769  
    156156    examples for an overview of both approaches.
    157157
     158    \note We discourage the use of the blocking functions together
     159    with signals. One of the two possibilities should be used.
     160
    158161    QAbstractSocket can be used with QTextStream and QDataStream's
    159162    stream operators (operator<<() and operator>>()). There is one
     
    170173    the host lookup has succeeded.
    171174
     175    \note Since Qt 4.6.3 QAbstractSocket may emit hostFound()
     176    directly from the connectToHost() call since a DNS result could have been
     177    cached.
     178
    172179    \sa connected()
    173180*/
     
    178185    This signal is emitted after connectToHost() has been called and
    179186    a connection has been successfully established.
     187
     188    \note On some operating systems the connected() signal may
     189    be directly emitted from the connectToHost() call for connections
     190    to the localhost.
    180191
    181192    \sa connectToHost(), disconnected()
     
    352363#include "qabstractsocket_p.h"
    353364
     365#include "private/qhostinfo_p.h"
     366
    354367#include <qabstracteventdispatcher.h>
    355368#include <qdatetime.h>
     
    13671380#endif
    13681381    } else {
    1369         if (d->threadData->eventDispatcher)
    1370             d->hostLookupId = QHostInfo::lookupHost(hostName, this, SLOT(_q_startConnecting(QHostInfo)));
     1382        if (d->threadData->eventDispatcher) {
     1383            // this internal API for QHostInfo either immediatly gives us the desired
     1384            // QHostInfo from cache or later calls the _q_startConnecting slot.
     1385            bool immediateResultValid = false;
     1386            QHostInfo hostInfo = qt_qhostinfo_lookup(hostName,
     1387                                                     this,
     1388                                                     SLOT(_q_startConnecting(QHostInfo)),
     1389                                                     &immediateResultValid,
     1390                                                     &d->hostLookupId);
     1391            if (immediateResultValid) {
     1392                d->hostLookupId = -1;
     1393                d->_q_startConnecting(hostInfo);
     1394            }
     1395        }
    13711396    }
    13721397
     
    16831708    If msecs is -1, this function will not time out.
    16841709
    1685     Note: This function may wait slightly longer than \a msecs,
     1710    \note This function may wait slightly longer than \a msecs,
    16861711    depending on the time it takes to complete the host lookup.
     1712
     1713    \note Multiple calls to this functions do not accumulate the time.
     1714    If the function times out, the connecting process will be aborted.
    16871715
    16881716    \sa connectToHost(), connected()
     
    17231751    }
    17241752    if (state() == UnconnectedState)
    1725         return false;
     1753        return false; // connect not im progress anymore!
    17261754
    17271755    bool timedOut = true;
     
    23552383        qDebug("QAbstractSocket::disconnectFromHost() aborting immediately");
    23562384#endif
     2385        if (d->state == HostLookupState) {
     2386            QHostInfo::abortHostLookup(d->hostLookupId);
     2387            d->hostLookupId = -1;
     2388        }
    23572389    } else {
    23582390        // Perhaps emit closing()
  • trunk/src/network/socket/qlocalserver.cpp

    r755 r769  
    123123    d->pendingConnections.clear();
    124124    d->closeServer();
    125     d->serverName = QString();
    126     d->fullServerName = QString();
    127     d->errorString = QString();
     125    d->serverName.clear();
     126    d->fullServerName.clear();
     127    d->errorString.clear();
    128128    d->error = QAbstractSocket::UnknownSocketError;
    129129}
     
    229229
    230230    if (!d->listen(name)) {
    231         d->serverName = QString();
    232         d->fullServerName = QString();
     231        d->serverName.clear();
     232        d->fullServerName.clear();
    233233        return false;
    234234    }
  • trunk/src/network/socket/qlocalserver_win.cpp

    r651 r769  
    168168        } else {
    169169            if (GetLastError() != ERROR_IO_INCOMPLETE) {
     170                q->close();
    170171                setError(QLatin1String("QLocalServerPrivate::_q_onNewConnection"));
    171                 closeServer();
    172172                return;
    173173            }
  • trunk/src/network/socket/qlocalsocket_p.h

    r651 r769  
    129129    void _q_error(QAbstractSocket::SocketError newError);
    130130#elif defined(Q_OS_WIN)
    131     ~QLocalSocketPrivate() {
    132         CloseHandle(overlapped.hEvent);
    133     }
    134 
     131    ~QLocalSocketPrivate();
     132    void destroyPipeHandles();
    135133    void setErrorString(const QString &function);
    136134    void _q_notified();
  • trunk/src/network/socket/qlocalsocket_tcp.cpp

    r651 r769  
    103103    case QAbstractSocket::UnconnectedState:
    104104        state = QLocalSocket::UnconnectedState;
    105         serverName = QString();
    106         fullServerName = QString();
     105        serverName.clear();
     106        fullServerName.clear();
    107107        break;
    108108    case QAbstractSocket::ConnectingState:
     
    219219        return;
    220220
    221     d->errorString = QString();
     221    d->errorString.clear();
    222222    d->state = ConnectingState;
    223223    emit stateChanged(d->state);
     
    334334    Q_D(QLocalSocket);
    335335    d->tcpSocket->close();
    336     d->serverName = QString();
    337     d->fullServerName = QString();
     336    d->serverName.clear();
     337    d->fullServerName.clear();
    338338    QIODevice::close();
    339339}
  • trunk/src/network/socket/qlocalsocket_unix.cpp

    r651 r769  
    110110    case QAbstractSocket::UnconnectedState:
    111111        state = QLocalSocket::UnconnectedState;
    112         serverName = QString();
    113         fullServerName = QString();
     112        serverName.clear();
     113        fullServerName.clear();
    114114        break;
    115115    case QAbstractSocket::ConnectingState:
     
    226226        return;
    227227
    228     d->errorString = QString();
     228    d->errorString.clear();
    229229    d->unixSocket.setSocketState(QAbstractSocket::ConnectingState);
    230230    d->state = ConnectingState;
     
    342342    }
    343343    connectingSocket = -1;
    344     connectingName = QString();
     344    connectingName.clear();
    345345    connectingOpenMode = 0;
    346346}
     
    439439        ::close(d->connectingSocket);
    440440    d->connectingSocket = -1;
    441     d->connectingName = QString();
     441    d->connectingName.clear();
    442442    d->connectingOpenMode = 0;
    443     d->serverName = QString();
    444     d->fullServerName = QString();
     443    d->serverName.clear();
     444    d->fullServerName.clear();
    445445    QIODevice::close();
    446446}
  • trunk/src/network/socket/qlocalsocket_win.cpp

    r651 r769  
    4040****************************************************************************/
    4141
    42 #include "qlocalsocket.h"
    4342#include "qlocalsocket_p.h"
    4443
     
    109108       state(QLocalSocket::UnconnectedState)
    110109{
     110}
     111
     112QLocalSocketPrivate::~QLocalSocketPrivate()
     113{
     114    destroyPipeHandles();
     115    CloseHandle(overlapped.hEvent);
     116}
     117
     118void QLocalSocketPrivate::destroyPipeHandles()
     119{
     120    if (handle != INVALID_HANDLE_VALUE) {
     121        DisconnectNamedPipe(handle);
     122        CloseHandle(handle);
     123    }
    111124}
    112125
     
    389402    d->pendingReadyRead = false;
    390403    d->pipeClosed = false;
    391     DisconnectNamedPipe(d->handle);
    392     CloseHandle(d->handle);
     404    d->destroyPipeHandles();
    393405    d->handle = INVALID_HANDLE_VALUE;
    394406    ResetEvent(d->overlapped.hEvent);
     
    413425{
    414426    Q_D(QLocalSocket);
     427
     428    // Are we still connected?
     429    if (!isValid()) {
     430        // If we have unwritten data, the pipeWriter is still present.
     431        // It must be destroyed before close() to prevent an infinite loop.
     432        delete d->pipeWriter;
     433        d->pipeWriter = 0;
     434    }
     435
    415436    flush();
    416437    if (d->pipeWriter && d->pipeWriter->bytesToWrite() != 0) {
     
    525546{
    526547    Q_D(const QLocalSocket);
    527     return (d->handle != INVALID_HANDLE_VALUE);
     548    if (d->handle == INVALID_HANDLE_VALUE)
     549        return false;
     550
     551    return PeekNamedPipe(d->handle, NULL, 0, NULL, NULL, NULL);
    528552}
    529553
  • trunk/src/network/socket/qnativesocketengine.cpp

    r651 r769  
    780780        return -1;
    781781    } else if (readBytes == -1) {
    782         d->setError(QAbstractSocket::NetworkError,
    783                     QNativeSocketEnginePrivate::ReadErrorString);
     782        if (!d->hasSetSocketError) {
     783            d->hasSetSocketError = true;
     784            d->socketError = QAbstractSocket::NetworkError;
     785            d->socketErrorString = qt_error_string();
     786        }
    784787        close();
    785788        return -1;
  • trunk/src/network/socket/qnativesocketengine_unix.cpp

    r651 r769  
    602602    // well be 0, so we can't check recvfrom's return value.
    603603    ssize_t readBytes;
     604#ifdef Q_OS_SYMBIAN
     605    char c;
     606    readBytes = ::recvfrom(socketDescriptor, &c, 1, MSG_PEEK, &storage.a, &storageSize);
     607#else
    604608    do {
    605609        char c;
    606610        readBytes = ::recvfrom(socketDescriptor, &c, 1, MSG_PEEK, &storage.a, &storageSize);
    607611    } while (readBytes == -1 && errno == EINTR);
     612#endif
    608613
    609614    // If there's no error, or if our buffer was too small, there must be a
     
    662667
    663668    ssize_t recvFromResult = 0;
     669#ifdef Q_OS_SYMBIAN
     670    char c;
     671    recvFromResult = ::recvfrom(socketDescriptor, maxSize ? data : &c, maxSize ? maxSize : 1,
     672                                0, &aa.a, &sz);
     673#else
    664674    do {
    665675        char c;
     
    667677                                    0, &aa.a, &sz);
    668678    } while (recvFromResult == -1 && errno == EINTR);
     679#endif
    669680
    670681    if (recvFromResult == -1) {
     
    833844    qt_ignore_sigpipe();
    834845
    835     // loop while ::write() returns -1 and errno == EINTR, in case
    836     // of an interrupting signal.
    837846    ssize_t writtenBytes;
    838     do {
    839 #ifdef Q_OS_SYMBIAN
    840             writtenBytes = ::write(socketDescriptor, data, len);
    841 #else
    842         writtenBytes = qt_safe_write(socketDescriptor, data, len);
    843 #endif
    844         // writtenBytes = QT_WRITE(socketDescriptor, data, len); ### TODO S60: Should this line be removed or the one above it?
    845     } while (writtenBytes < 0 && errno == EINTR);
     847#ifdef Q_OS_SYMBIAN
     848    // Symbian does not support signals natively and Open C returns EINTR when moving to offline
     849    writtenBytes = ::write(socketDescriptor, data, len);
     850#else
     851    writtenBytes = qt_safe_write(socketDescriptor, data, len);
     852#endif
    846853
    847854    if (writtenBytes < 0) {
     
    883890
    884891    ssize_t r = 0;
    885     do {
    886 #ifdef Q_OS_SYMBIAN
    887         r = ::read(socketDescriptor, data, maxSize);
    888 #else
    889         r = qt_safe_read(socketDescriptor, data, maxSize);
    890 #endif
    891     } while (r == -1 && errno == EINTR);
     892#ifdef Q_OS_SYMBIAN
     893    r = ::read(socketDescriptor, data, maxSize);
     894#else
     895    r = qt_safe_read(socketDescriptor, data, maxSize);
     896#endif
    892897
    893898    if (r < 0) {
     
    904909        case EINVAL:
    905910        case EIO:
    906             setError(QAbstractSocket::NetworkError, ReadErrorString);
     911            //error string is now set in read(), not here in nativeRead()
    907912            break;
    908913#ifdef Q_OS_SYMBIAN
  • trunk/src/network/socket/qnativesocketengine_win.cpp

    r651 r769  
    10691069        case WSAEBADF:
    10701070        case WSAEINVAL:
    1071             setError(QAbstractSocket::NetworkError, ReadErrorString);
     1071            //error string is now set in read(), not here in nativeRead()
    10721072            break;
    10731073        case WSAECONNRESET:
  • trunk/src/network/socket/qtcpserver.cpp

    r651 r769  
    7979    use waitForNewConnection(), which blocks until either a
    8080    connection is available or a timeout expires.
     81
     82    \section1 Symbian Platform Security Requirements
     83
     84    On Symbian, processes which use this class must have the
     85    \c NetworkServices platform security capability. If the client
     86    process lacks this capability, it will lead to a panic.
     87
     88    Platform security capabilities are added via the
     89    \l{qmake-variable-reference.html#target-capability}{TARGET.CAPABILITY}
     90    qmake variable.
    8191
    8292    \sa QTcpSocket, {Fortune Server Example}, {Threaded Fortune Server Example},
     
    514524    connections.
    515525
     526    \note The returned QTcpSocket object cannot be used from another
     527    thread. If you want to use an incoming connection from another thread,
     528    you need to override incomingConnection().
     529
    516530    \sa hasPendingConnections()
    517531*/
     
    543557    may not be usable with native socket functions, and should only be
    544558    used with QTcpSocket::setSocketDescriptor().
     559
     560    \note If you want to handle an incoming connection as a new QTcpSocket
     561    object in another thread you have to pass the socketDescriptor
     562    to the other thread and create the QTcpSocket object there and
     563    use its setSocketDescriptor() method.
    545564
    546565    \sa newConnection(), nextPendingConnection()
  • trunk/src/network/socket/qtcpsocket.cpp

    r651 r769  
    6161    \bold{Note:} TCP sockets cannot be opened in QIODevice::Unbuffered mode.
    6262
     63    \section1 Symbian Platform Security Requirements
     64
     65    On Symbian, processes which use this class must have the
     66    \c NetworkServices platform security capability. If the client
     67    process lacks this capability, it will result in a panic.
     68
     69    Platform security capabilities are added via the
     70    \l{qmake-variable-reference.html#target-capability}{TARGET.CAPABILITY}
     71    qmake variable.
     72
    6373    \sa QTcpServer, QUdpSocket, QFtp, QNetworkAccessManager,
    6474    {Fortune Server Example}, {Fortune Client Example},
  • trunk/src/network/socket/qudpsocket.cpp

    r651 r769  
    8686    \l{network/broadcastreceiver}{Broadcast Receiver} examples
    8787    illustrate how to use QUdpSocket in applications.
     88
     89    \section1 Symbian Platform Security Requirements
     90
     91    On Symbian, processes which use this class must have the
     92    \c NetworkServices platform security capability. If the client
     93    process lacks this capability, operations will result in a panic.
     94
     95    Platform security capabilities are added via the
     96    \l{qmake-variable-reference.html#target-capability}{TARGET.CAPABILITY}
     97    qmake variable.
    8898
    8999    \sa QTcpSocket
Note: See TracChangeset for help on using the changeset viewer.