From 7eca53b51a2c7cae0b39fedb0b78205504bfd64b Mon Sep 17 00:00:00 2001 From: Casper van Donderen Date: Mon, 7 May 2012 11:10:29 +0200 Subject: Doc: Modularize QtNetwork documentation. This change moves the snippets and imagesto the modularized directories. Change-Id: If14912692a7f72d7de345eaf88d9ec9752310fca Reviewed-by: Marius Storm-Olsen --- doc/src/images/roaming-states.png | Bin 9527 -> 0 bytes doc/src/snippets/code/src_network_access_qftp.cpp | 99 ------------------- .../code/src_network_access_qhttpmultipart.cpp | 67 ------------- .../snippets/code/src_network_access_qhttppart.cpp | 65 ------------- .../src_network_access_qnetworkaccessmanager.cpp | 79 --------------- .../code/src_network_access_qnetworkdiskcache.cpp | 64 ------------ .../code/src_network_access_qnetworkreply.cpp | 50 ---------- .../code/src_network_access_qnetworkrequest.cpp | 43 --------- .../src_network_bearer_qnetworkconfigmanager.cpp | 48 --------- .../code/src_network_kernel_qdnslookup.cpp | 73 -------------- .../code/src_network_kernel_qhostaddress.cpp | 48 --------- .../snippets/code/src_network_kernel_qhostinfo.cpp | 90 ----------------- .../code/src_network_kernel_qnetworkproxy.cpp | 54 ----------- .../code/src_network_socket_qabstractsocket.cpp | 70 -------------- .../code/src_network_socket_qlocalsocket_unix.cpp | 52 ---------- .../src_network_socket_qnativesocketengine.cpp | 61 ------------ .../code/src_network_socket_qtcpserver.cpp | 43 --------- .../code/src_network_socket_qudpsocket.cpp | 65 ------------- .../code/src_network_ssl_qsslcertificate.cpp | 46 --------- .../code/src_network_ssl_qsslconfiguration.cpp | 45 --------- .../snippets/code/src_network_ssl_qsslsocket.cpp | 107 --------------------- doc/src/snippets/network/tcpwait.cpp | 69 ------------- 22 files changed, 1338 deletions(-) delete mode 100644 doc/src/images/roaming-states.png delete mode 100644 doc/src/snippets/code/src_network_access_qftp.cpp delete mode 100644 doc/src/snippets/code/src_network_access_qhttpmultipart.cpp delete mode 100644 doc/src/snippets/code/src_network_access_qhttppart.cpp delete mode 100644 doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp delete mode 100644 doc/src/snippets/code/src_network_access_qnetworkdiskcache.cpp delete mode 100644 doc/src/snippets/code/src_network_access_qnetworkreply.cpp delete mode 100644 doc/src/snippets/code/src_network_access_qnetworkrequest.cpp delete mode 100644 doc/src/snippets/code/src_network_bearer_qnetworkconfigmanager.cpp delete mode 100644 doc/src/snippets/code/src_network_kernel_qdnslookup.cpp delete mode 100644 doc/src/snippets/code/src_network_kernel_qhostaddress.cpp delete mode 100644 doc/src/snippets/code/src_network_kernel_qhostinfo.cpp delete mode 100644 doc/src/snippets/code/src_network_kernel_qnetworkproxy.cpp delete mode 100644 doc/src/snippets/code/src_network_socket_qabstractsocket.cpp delete mode 100644 doc/src/snippets/code/src_network_socket_qlocalsocket_unix.cpp delete mode 100644 doc/src/snippets/code/src_network_socket_qnativesocketengine.cpp delete mode 100644 doc/src/snippets/code/src_network_socket_qtcpserver.cpp delete mode 100644 doc/src/snippets/code/src_network_socket_qudpsocket.cpp delete mode 100644 doc/src/snippets/code/src_network_ssl_qsslcertificate.cpp delete mode 100644 doc/src/snippets/code/src_network_ssl_qsslconfiguration.cpp delete mode 100644 doc/src/snippets/code/src_network_ssl_qsslsocket.cpp delete mode 100644 doc/src/snippets/network/tcpwait.cpp (limited to 'doc/src') diff --git a/doc/src/images/roaming-states.png b/doc/src/images/roaming-states.png deleted file mode 100644 index bc61cac219..0000000000 Binary files a/doc/src/images/roaming-states.png and /dev/null differ diff --git a/doc/src/snippets/code/src_network_access_qftp.cpp b/doc/src/snippets/code/src_network_access_qftp.cpp deleted file mode 100644 index db1817ce9f..0000000000 --- a/doc/src/snippets/code/src_network_access_qftp.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -QFtp *ftp = new QFtp(parent); -ftp->connectToHost("ftp.qt.nokia.com"); -ftp->login(); -//! [0] - - -//! [1] -ftp->connectToHost("ftp.qt.nokia.com"); // id == 1 -ftp->login(); // id == 2 -ftp->cd("qt"); // id == 3 -ftp->get("INSTALL"); // id == 4 -ftp->close(); // id == 5 -//! [1] - - -//! [2] -start(1) -stateChanged(HostLookup) -stateChanged(Connecting) -stateChanged(Connected) -finished(1, false) - -start(2) -stateChanged(LoggedIn) -finished(2, false) - -start(3) -finished(3, false) - -start(4) -dataTransferProgress(0, 3798) -dataTransferProgress(2896, 3798) -readyRead() -dataTransferProgress(3798, 3798) -readyRead() -finished(4, false) - -start(5) -stateChanged(Closing) -stateChanged(Unconnected) -finished(5, false) - -done(false) -//! [2] - - -//! [3] -start(1) -stateChanged(HostLookup) -stateChanged(Connecting) -stateChanged(Connected) -finished(1, false) - -start(2) -finished(2, true) - -done(true) -//! [3] diff --git a/doc/src/snippets/code/src_network_access_qhttpmultipart.cpp b/doc/src/snippets/code/src_network_access_qhttpmultipart.cpp deleted file mode 100644 index 981a93a3ca..0000000000 --- a/doc/src/snippets/code/src_network_access_qhttpmultipart.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -QHttpMultiPart *multiPart = new QHttpMultiPart(QHttpMultiPart::FormDataType); - -QHttpPart textPart; -textPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"text\"")); -textPart.setBody("my text"); - -QHttpPart imagePart; -imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg")); -imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"image\"")); -QFile *file = new QFile("image.jpg"); -file->open(QIODevice::ReadOnly); -imagePart.setBodyDevice(file); -file->setParent(multiPart); // we cannot delete the file now, so delete it with the multiPart - -multiPart->append(textPart); -multiPart->append(imagePart); - -QUrl url("http://my.server.tld"); -QNetworkRequest request(url); - -QNetworkAccessManager manager; -QNetworkReply *reply = manager.post(request, multiPart); -multiPart->setParent(reply); // delete the multiPart with the reply -// here connect signals etc. -//! [0] diff --git a/doc/src/snippets/code/src_network_access_qhttppart.cpp b/doc/src/snippets/code/src_network_access_qhttppart.cpp deleted file mode 100644 index 1dca3d6683..0000000000 --- a/doc/src/snippets/code/src_network_access_qhttppart.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** GNU Lesser General Public License Usage -** This file may be used under the terms of the GNU Lesser General Public -** License version 2.1 as published by the Free Software Foundation and -** appearing in the file LICENSE.LGPL included in the packaging of this -** file. Please review the following information to ensure the GNU Lesser -** General Public License version 2.1 requirements will be met: -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU General -** Public License version 3.0 as published by the Free Software Foundation -** and appearing in the file LICENSE.GPL included in the packaging of this -** file. Please review the following information to ensure the GNU General -** Public License version 3.0 requirements will be met: -** http://www.gnu.org/copyleft/gpl.html. -** -** Other Usage -** Alternatively, this file may be used in accordance with the terms and -** conditions contained in a signed written agreement between you and Nokia. -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -Content-Type: text/plain -Content-Disposition: form-data; name="text" - -here goes the body -//! [0] - -//! [1] -QHttpPart textPart; -textPart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("text/plain")); -textPart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"text\"")); -textPart.setBody("here goes the body"); -//! [1] - -//! [2] -QHttpPart imagePart; -imagePart.setHeader(QNetworkRequest::ContentTypeHeader, QVariant("image/jpeg")); -imagePart.setHeader(QNetworkRequest::ContentDispositionHeader, QVariant("form-data; name=\"image\"")); -imagePart.setRawHeader("Content-ID", "my@content.id"); // add any headers you like via setRawHeader() -QFile *file = new QFile("image.jpg"); -file->open(QIODevice::ReadOnly); -imagePart.setBodyDevice(file); -//! [2] - diff --git a/doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp b/doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp deleted file mode 100644 index ab8fc97d04..0000000000 --- a/doc/src/snippets/code/src_network_access_qnetworkaccessmanager.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -QNetworkAccessManager *manager = new QNetworkAccessManager(this); -connect(manager, SIGNAL(finished(QNetworkReply*)), - this, SLOT(replyFinished(QNetworkReply*))); - -manager->get(QNetworkRequest(QUrl("http://qt.nokia.com"))); -//! [0] - - -//! [1] -QNetworkRequest request; -request.setUrl(QUrl("http://qt.nokia.com")); -request.setRawHeader("User-Agent", "MyOwnBrowser 1.0"); - -QNetworkReply *reply = manager->get(request); -connect(reply, SIGNAL(readyRead()), this, SLOT(slotReadyRead())); -connect(reply, SIGNAL(error(QNetworkReply::NetworkError)), - this, SLOT(slotError(QNetworkReply::NetworkError))); -connect(reply, SIGNAL(sslErrors(QList)), - this, SLOT(slotSslErrors(QList))); -//! [1] - -//! [2] -QNetworkConfigurationManager manager; -networkAccessManager->setConfiguration(manager.defaultConfiguration()); -//! [2] - -//! [3] -networkAccessManager->setConfiguration(QNetworkConfiguration()); -//! [3] - -//! [4] -networkAccessManager->setNetworkAccessible(QNetworkAccessManager::NotAccessible); -//! [4] - -//! [5] -networkAccessManager->setNetworkAccessible(QNetworkAccessManager::Accessible); -//! [5] - diff --git a/doc/src/snippets/code/src_network_access_qnetworkdiskcache.cpp b/doc/src/snippets/code/src_network_access_qnetworkdiskcache.cpp deleted file mode 100644 index bc272a2223..0000000000 --- a/doc/src/snippets/code/src_network_access_qnetworkdiskcache.cpp +++ /dev/null @@ -1,64 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -QNetworkAccessManager *manager = new QNetworkAccessManager(this); -QNetworkDiskCache *diskCache = new QNetworkDiskCache(this); -diskCache->setCacheDirectory("cacheDir"); -manager->setCache(diskCache); -//! [0] - -//! [1] -// do a normal request (preferred from network, as this is the default) -QNetworkRequest request(QUrl(QString("http://qt.nokia.com"))); -manager->get(request); - -// do a request preferred from cache -QNetworkRequest request2(QUrl(QString("http://qt.nokia.com"))); -request2.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache); -manager->get(request2); -//! [1] - -//! [2] -void replyFinished(QNetworkReply *reply) { - QVariant fromCache = reply->attribute(QNetworkRequest::SourceIsFromCacheAttribute); - qDebug() << "page from cache?" << fromCache.toBool(); -} -//! [2] diff --git a/doc/src/snippets/code/src_network_access_qnetworkreply.cpp b/doc/src/snippets/code/src_network_access_qnetworkreply.cpp deleted file mode 100644 index 0f1b4c2014..0000000000 --- a/doc/src/snippets/code/src_network_access_qnetworkreply.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -QList cert = QSslCertificate::fromPath(QLatin1String("server-certificate.pem")); -QSslError error(QSslError::SelfSignedCertificate, cert.at(0)); -QList expectedSslErrors; -expectedSslErrors.append(error); - -QNetworkReply *reply = manager.get(QNetworkRequest(QUrl("https://server.tld/index.html"))); -reply->ignoreSslErrors(expectedSslErrors); -// here connect signals etc. -//! [0] diff --git a/doc/src/snippets/code/src_network_access_qnetworkrequest.cpp b/doc/src/snippets/code/src_network_access_qnetworkrequest.cpp deleted file mode 100644 index bdf696e851..0000000000 --- a/doc/src/snippets/code/src_network_access_qnetworkrequest.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -request.setRawHeader("Last-Modified", "Sun, 06 Nov 1994 08:49:37 GMT"); -//! [0] diff --git a/doc/src/snippets/code/src_network_bearer_qnetworkconfigmanager.cpp b/doc/src/snippets/code/src_network_bearer_qnetworkconfigmanager.cpp deleted file mode 100644 index 2d62d758b7..0000000000 --- a/doc/src/snippets/code/src_network_bearer_qnetworkconfigmanager.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -QNetworkConfigurationManager mgr; -QList activeConfigs = mgr.allConfigurations(QNetworkConfiguration::Active) -if (activeConfigs.count() > 0) - Q_ASSERT(mgr.isOnline()) -else - Q_ASSERT(!mgr.isOnline()) -//! [0] diff --git a/doc/src/snippets/code/src_network_kernel_qdnslookup.cpp b/doc/src/snippets/code/src_network_kernel_qdnslookup.cpp deleted file mode 100644 index f2e530ff96..0000000000 --- a/doc/src/snippets/code/src_network_kernel_qdnslookup.cpp +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Jeremy Lainé -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -void MyObject::lookupServers() -{ - // Create a DNS lookup. - dns = new QDnsLookup(this); - connect(dns, SIGNAL(finished()), - this, SLOT(handleServers())); - - // Find the XMPP servers for gmail.com - dns->setType(QDnsLookup::SRV); - dns->setName("_xmpp-client._tcp.gmail.com"); - dns->lookup(); -} -//! [0] - - -//! [1] -void MyObject::handleServers() -{ - // Check the lookup succeeded. - if (dns->error() != QDnsLookup::NoError) { - qWarning("DNS lookup failed"); - dns->deleteLater(); - return; - } - - // Handle the results. - foreach (const QDnsServiceRecord &record, dns->serviceRecords()) { - ... - } - dns->deleteLater(); -} -//! [1] diff --git a/doc/src/snippets/code/src_network_kernel_qhostaddress.cpp b/doc/src/snippets/code/src_network_kernel_qhostaddress.cpp deleted file mode 100644 index c03054c243..0000000000 --- a/doc/src/snippets/code/src_network_kernel_qhostaddress.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -Q_IPV6ADDR addr = hostAddr.toIPv6Address(); -// addr contains 16 unsigned characters - -for (int i = 0; i < 16; ++i) { - // process addr[i] -} -//! [0] diff --git a/doc/src/snippets/code/src_network_kernel_qhostinfo.cpp b/doc/src/snippets/code/src_network_kernel_qhostinfo.cpp deleted file mode 100644 index 7607841ac5..0000000000 --- a/doc/src/snippets/code/src_network_kernel_qhostinfo.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -// To find the IP address of qt.nokia.com -QHostInfo::lookupHost("qt.nokia.com", - this, SLOT(printResults(QHostInfo))); - -// To find the host name for 4.2.2.1 -QHostInfo::lookupHost("4.2.2.1", - this, SLOT(printResults(QHostInfo))); -//! [0] - - -//! [1] -QHostInfo info = QHostInfo::fromName("qt.nokia.com"); -//! [1] - - -//! [2] -QHostInfo::lookupHost("www.kde.org", - this, SLOT(lookedUp(QHostInfo))); -//! [2] - - -//! [3] -void MyWidget::lookedUp(const QHostInfo &host) -{ - if (host.error() != QHostInfo::NoError) { - qDebug() << "Lookup failed:" << host.errorString(); - return; - } - - foreach (const QHostAddress &address, host.addresses()) - qDebug() << "Found address:" << address.toString(); -} -//! [3] - - -//! [4] -QHostInfo::lookupHost("4.2.2.1", - this, SLOT(lookedUp(QHostInfo))); -//! [4] - - -//! [5] -QHostInfo info; -... -if (!info.addresses().isEmpty()) { - QHostAddress address = info.addresses().first(); - // use the first IP address -} -//! [5] diff --git a/doc/src/snippets/code/src_network_kernel_qnetworkproxy.cpp b/doc/src/snippets/code/src_network_kernel_qnetworkproxy.cpp deleted file mode 100644 index eadf4f91a5..0000000000 --- a/doc/src/snippets/code/src_network_kernel_qnetworkproxy.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -QNetworkProxy proxy; -proxy.setType(QNetworkProxy::Socks5Proxy); -proxy.setHostName("proxy.example.com"); -proxy.setPort(1080); -proxy.setUser("username"); -proxy.setPassword("password"); -QNetworkProxy::setApplicationProxy(proxy); -//! [0] - - -//! [1] -serverSocket->setProxy(QNetworkProxy::NoProxy); -//! [1] diff --git a/doc/src/snippets/code/src_network_socket_qabstractsocket.cpp b/doc/src/snippets/code/src_network_socket_qabstractsocket.cpp deleted file mode 100644 index b419b33c92..0000000000 --- a/doc/src/snippets/code/src_network_socket_qabstractsocket.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -socket->connectToHost("imap", 143); -if (socket->waitForConnected(1000)) - qDebug("Connected!"); -//! [0] - - -//! [1] -socket->disconnectFromHost(); - if (socket->state() == QAbstractSocket::UnconnectedState || - socket->waitForDisconnected(1000)) - qDebug("Disconnected!"); -//! [1] - - -//! [2] - // This slot is connected to QAbstractSocket::readyRead() - void SocketClass::readyReadSlot() - { - while (!socket.atEnd()) { - QByteArray data = socket.read(100); - .... - } - } -//! [2] - - -//! [3] -socket->setProxy(QNetworkProxy::NoProxy); -//! [3] diff --git a/doc/src/snippets/code/src_network_socket_qlocalsocket_unix.cpp b/doc/src/snippets/code/src_network_socket_qlocalsocket_unix.cpp deleted file mode 100644 index 947e89900a..0000000000 --- a/doc/src/snippets/code/src_network_socket_qlocalsocket_unix.cpp +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -socket->connectToServer("market"); -if (socket->waitForConnected(1000)) - qDebug("Connected!"); -//! [0] - - -//! [1] -socket->disconnectFromServer(); -if (socket->waitForDisconnected(1000)) - qDebug("Disconnected!"); -//! [1] diff --git a/doc/src/snippets/code/src_network_socket_qnativesocketengine.cpp b/doc/src/snippets/code/src_network_socket_qnativesocketengine.cpp deleted file mode 100644 index 98ac70cc49..0000000000 --- a/doc/src/snippets/code/src_network_socket_qnativesocketengine.cpp +++ /dev/null @@ -1,61 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -QNativeSocketEngine socketLayer; -socketLayer.initialize(QAbstractSocket::TcpSocket, QAbstractSocket::IPv4Protocol); -socketLayer.connectToHost(QHostAddress::LocalHost, 22); -// returns false - -socketLayer.waitForWrite(); -socketLayer.connectToHost(QHostAddress::LocalHost, 22); -// returns true -//! [0] - - -//! [1] -QNativeSocketEngine socketLayer; -socketLayer.bind(QHostAddress::Any, 4000); -socketLayer.listen(); -if (socketLayer.waitForRead()) { - int clientSocket = socketLayer.accept(); - // a client is connected -} -//! [1] diff --git a/doc/src/snippets/code/src_network_socket_qtcpserver.cpp b/doc/src/snippets/code/src_network_socket_qtcpserver.cpp deleted file mode 100644 index 90c4a86836..0000000000 --- a/doc/src/snippets/code/src_network_socket_qtcpserver.cpp +++ /dev/null @@ -1,43 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -server->setProxy(QNetworkProxy::NoProxy); -//! [0] diff --git a/doc/src/snippets/code/src_network_socket_qudpsocket.cpp b/doc/src/snippets/code/src_network_socket_qudpsocket.cpp deleted file mode 100644 index 2a90772623..0000000000 --- a/doc/src/snippets/code/src_network_socket_qudpsocket.cpp +++ /dev/null @@ -1,65 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -void Server::initSocket() -{ - udpSocket = new QUdpSocket(this); - udpSocket->bind(QHostAddress::LocalHost, 7755); - - connect(udpSocket, SIGNAL(readyRead()), - this, SLOT(readPendingDatagrams())); -} - -void Server::readPendingDatagrams() -{ - while (udpSocket->hasPendingDatagrams()) { - QByteArray datagram; - datagram.resize(udpSocket->pendingDatagramSize()); - QHostAddress sender; - quint16 senderPort; - - udpSocket->readDatagram(datagram.data(), datagram.size(), - &sender, &senderPort); - - processTheDatagram(datagram); - } -} -//! [0] diff --git a/doc/src/snippets/code/src_network_ssl_qsslcertificate.cpp b/doc/src/snippets/code/src_network_ssl_qsslcertificate.cpp deleted file mode 100644 index 0538990a3d..0000000000 --- a/doc/src/snippets/code/src_network_ssl_qsslcertificate.cpp +++ /dev/null @@ -1,46 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -foreach (const QSslCertificate &cert, QSslCertificate::fromPath("C:/ssl/certificate.*.pem", QSsl::Pem, - QRegExp::Wildcard)) { - qDebug() << cert.issuerInfo(QSslCertificate::Organization); -} -//! [0] diff --git a/doc/src/snippets/code/src_network_ssl_qsslconfiguration.cpp b/doc/src/snippets/code/src_network_ssl_qsslconfiguration.cpp deleted file mode 100644 index a3a08f68d1..0000000000 --- a/doc/src/snippets/code/src_network_ssl_qsslconfiguration.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -QSslConfiguration config = sslSocket.sslConfiguration(); -config.setProtocol(QSsl::TlsV1_0); -sslSocket.setSslConfiguration(config); -//! [0] diff --git a/doc/src/snippets/code/src_network_ssl_qsslsocket.cpp b/doc/src/snippets/code/src_network_ssl_qsslsocket.cpp deleted file mode 100644 index 4d8e3668b5..0000000000 --- a/doc/src/snippets/code/src_network_ssl_qsslsocket.cpp +++ /dev/null @@ -1,107 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -//! [0] -QSslSocket *socket = new QSslSocket(this); -connect(socket, SIGNAL(encrypted()), this, SLOT(ready())); - -socket->connectToHostEncrypted("imap.example.com", 993); -//! [0] - - -//! [1] -void SslServer::incomingConnection(qintptr socketDescriptor) -{ - QSslSocket *serverSocket = new QSslSocket; - if (serverSocket->setSocketDescriptor(socketDescriptor)) { - connect(serverSocket, SIGNAL(encrypted()), this, SLOT(ready())); - serverSocket->startServerEncryption(); - } else { - delete serverSocket; - } -} -//! [1] - - -//! [2] -QSslSocket socket; -socket.connectToHostEncrypted("http.example.com", 443); -if (!socket.waitForEncrypted()) { - qDebug() << socket.errorString(); - return false; -} - -socket.write("GET / HTTP/1.0\r\n\r\n"); -while (socket.waitForReadyRead()) - qDebug() << socket.readAll().data(); -//! [2] - - -//! [3] -QSslSocket socket; -connect(&socket, SIGNAL(encrypted()), receiver, SLOT(socketEncrypted())); - -socket.connectToHostEncrypted("imap", 993); -socket->write("1 CAPABILITY\r\n"); -//! [3] - - -//! [4] -QSslSocket socket; -socket.setCiphers("DHE-RSA-AES256-SHA:DHE-DSS-AES256-SHA:AES256-SHA"); -//! [4] - - -//! [5] -socket->connectToHostEncrypted("imap", 993); -if (socket->waitForEncrypted(1000)) - qDebug("Encrypted!"); -//! [5] - -//! [6] -QList cert = QSslCertificate::fromPath(QLatin1String("server-certificate.pem")); -QSslError error(QSslError::SelfSignedCertificate, cert.at(0)); -QList expectedSslErrors; -expectedSslErrors.append(error); - -QSslSocket socket; -socket.ignoreSslErrors(expectedSslErrors); -socket.connectToHostEncrypted("server.tld", 443); -//! [6] diff --git a/doc/src/snippets/network/tcpwait.cpp b/doc/src/snippets/network/tcpwait.cpp deleted file mode 100644 index 9ee68e5b13..0000000000 --- a/doc/src/snippets/network/tcpwait.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:BSD$ -** You may use this file under the terms of the BSD license as follows: -** -** "Redistribution and use in source and binary forms, with or without -** modification, are permitted provided that the following conditions are -** met: -** * Redistributions of source code must retain the above copyright -** notice, this list of conditions and the following disclaimer. -** * Redistributions in binary form must reproduce the above copyright -** notice, this list of conditions and the following disclaimer in -** the documentation and/or other materials provided with the -** distribution. -** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor -** the names of its contributors may be used to endorse or promote -** products derived from this software without specific prior written -** permission. -** -** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include -#include - -#include "server.h" - -int main(int argv, char **args) -{ - QCoreApplication app(argv, args); - - QTcpSocket socket; - socket.connectToHost("localhost", 1025); - -//! [0] - int numRead = 0, numReadTotal = 0; - char buffer[50]; - - forever { - numRead = socket.read(buffer, 50); - - // do whatever with array - - numReadTotal += numRead; - if (numRead == 0 && !socket.waitForReadyRead()) - break; - } -//! [0] - - return app.exec(); -} -- cgit v1.2.3