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
     159
     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
     176
     177
     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
     189
     190
    180191
    181192    \sa connectToHost(), disconnected()
     
    352363#include "qabstractsocket_p.h"
    353364
     365
     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    This function may wait slightly longer than \a msecs,
    16861711    depending on the time it takes to complete the host lookup.
     1712
     1713
     1714
    16871715
    16881716    \sa connectToHost(), connected()
     
    17231751    }
    17241752    if (state() == UnconnectedState)
    1725         return false;
     1753        return false;
    17261754
    17271755    bool timedOut = true;
     
    23552383        qDebug("QAbstractSocket::disconnectFromHost() aborting immediately");
    23562384#endif
     2385
     2386
     2387
     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();
     126    d->fullServerName();
     127    d->errorString();
    128128    d->error = QAbstractSocket::UnknownSocketError;
    129129}
     
    229229
    230230    if (!d->listen(name)) {
    231         d->serverName = QString();
    232         d->fullServerName = QString();
     231        d->serverName();
     232        d->fullServerName();
    233233        return false;
    234234    }
  • trunk/src/network/socket/qlocalserver_win.cpp

    r651 r769  
    168168        } else {
    169169            if (GetLastError() != ERROR_IO_INCOMPLETE) {
     170
    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();
     106        fullServerName();
    107107        break;
    108108    case QAbstractSocket::ConnectingState:
     
    219219        return;
    220220
    221     d->errorString = QString();
     221    d->errorString();
    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();
     337    d->fullServerName();
    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();
     113        fullServerName();
    114114        break;
    115115    case QAbstractSocket::ConnectingState:
     
    226226        return;
    227227
    228     d->errorString = QString();
     228    d->errorString();
    229229    d->unixSocket.setSocketState(QAbstractSocket::ConnectingState);
    230230    d->state = ConnectingState;
     
    342342    }
    343343    connectingSocket = -1;
    344     connectingName = QString();
     344    connectingName();
    345345    connectingOpenMode = 0;
    346346}
     
    439439        ::close(d->connectingSocket);
    440440    d->connectingSocket = -1;
    441     d->connectingName = QString();
     441    d->connectingName();
    442442    d->connectingOpenMode = 0;
    443     d->serverName = QString();
    444     d->fullServerName = QString();
     443    d->serverName();
     444    d->fullServerName();
    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
     112
     113
     114
     115
     116
     117
     118
     119
     120
     121
     122
     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
     429
     430
     431
     432
     433
     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
     605
     606
     607
    604608    do {
    605609        char c;
    606610        readBytes = ::recvfrom(socketDescriptor, &c, 1, MSG_PEEK, &storage.a, &storageSize);
    607611    } while (readBytes == -1 && errno == EINTR);
     612
    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
     670
     671
     672
     673
    664674    do {
    665675        char c;
     
    667677                                    0, &aa.a, &sz);
    668678    } while (recvFromResult == -1 && errno == EINTR);
     679
    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           
    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           
    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
     83
     84
     85
     86
     87
     88
     89
     90
    8191
    8292    \sa QTcpSocket, {Fortune Server Example}, {Threaded Fortune Server Example},
     
    514524    connections.
    515525
     526
     527
     528
     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
     561
     562
     563
    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
     64
     65
     66
     67
     68
     69
     70
     71
     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
     90
     91
     92
     93
     94
     95
     96
     97
    8898
    8999    \sa QTcpSocket
Note: See TracChangeset for help on using the changeset viewer.