Changeset 846 for trunk/examples/network/fortuneserver
- Timestamp:
- May 5, 2011, 5:36:53 AM (14 years ago)
- Location:
- trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
/branches/vendor/nokia/qt/4.7.2 (added) merged: 845 /branches/vendor/nokia/qt/current merged: 844 /branches/vendor/nokia/qt/4.6.3 removed
- Property svn:mergeinfo changed
-
trunk/examples/network/fortuneserver/fortuneserver.pro
r769 r846 11 11 12 12 symbian { 13 TARGET.UID3 = 0xA000 CF7113 TARGET.UID3 = 0xA000E406 14 14 include($$QT_SOURCE_TREE/examples/symbianpkgrules.pri) 15 HEADERS += $$QT_SOURCE_TREE/examples/network/qftp/sym_iap_util.h 16 LIBS += -lesock -lcommdb -linsock # For IAP selection 17 TARGET.CAPABILITY = "All -TCB" 15 TARGET.CAPABILITY = "NetworkServices ReadUserData" 18 16 TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 19 17 } -
trunk/examples/network/fortuneserver/main.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 7 7 ** This file is part of the examples of the Qt Toolkit. 8 8 ** 9 ** $QT_BEGIN_LICENSE:LGPL$ 10 ** Commercial Usage 11 ** Licensees holding valid Qt Commercial licenses may use this file in 12 ** accordance with the Qt Commercial License Agreement provided with the 13 ** Software or, alternatively, in accordance with the terms contained in 14 ** a written agreement between you and Nokia. 9 ** $QT_BEGIN_LICENSE:BSD$ 10 ** You may use this file under the terms of the BSD license as follows: 15 11 ** 16 ** GNU Lesser General Public License Usage 17 ** Alternatively, this file may be used under the terms of the GNU Lesser 18 ** General Public License version 2.1 as published by the Free Software 19 ** Foundation and appearing in the file LICENSE.LGPL included in the 20 ** packaging of this file. Please review the following information to 21 ** ensure the GNU Lesser General Public License version 2.1 requirements 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 12 ** "Redistribution and use in source and binary forms, with or without 13 ** modification, are permitted provided that the following conditions are 14 ** met: 15 ** * Redistributions of source code must retain the above copyright 16 ** notice, this list of conditions and the following disclaimer. 17 ** * Redistributions in binary form must reproduce the above copyright 18 ** notice, this list of conditions and the following disclaimer in 19 ** the documentation and/or other materials provided with the 20 ** distribution. 21 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 22 ** the names of its contributors may be used to endorse or promote 23 ** products derived from this software without specific prior written 24 ** permission. 23 25 ** 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 ** 28 ** GNU General Public License Usage 29 ** Alternatively, this file may be used under the terms of the GNU 30 ** General Public License version 3.0 as published by the Free Software 31 ** Foundation and appearing in the file LICENSE.GPL included in the 32 ** packaging of this file. Please review the following information to 33 ** ensure the GNU General Public License version 3.0 requirements will be 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 ** 36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 26 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 38 37 ** $QT_END_LICENSE$ 39 38 ** … … 47 46 #include "server.h" 48 47 49 #ifdef Q_OS_SYMBIAN50 #include "sym_iap_util.h"51 #endif52 53 48 int main(int argc, char *argv[]) 54 49 { 55 #ifdef Q_OS_SYMBIAN56 qt_SetDefaultIap();57 #endif58 50 QApplication app(argc, argv); 59 51 Server server; -
trunk/examples/network/fortuneserver/server.cpp
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 7 7 ** This file is part of the examples of the Qt Toolkit. 8 8 ** 9 ** $QT_BEGIN_LICENSE:LGPL$ 10 ** Commercial Usage 11 ** Licensees holding valid Qt Commercial licenses may use this file in 12 ** accordance with the Qt Commercial License Agreement provided with the 13 ** Software or, alternatively, in accordance with the terms contained in 14 ** a written agreement between you and Nokia. 9 ** $QT_BEGIN_LICENSE:BSD$ 10 ** You may use this file under the terms of the BSD license as follows: 15 11 ** 16 ** GNU Lesser General Public License Usage 17 ** Alternatively, this file may be used under the terms of the GNU Lesser 18 ** General Public License version 2.1 as published by the Free Software 19 ** Foundation and appearing in the file LICENSE.LGPL included in the 20 ** packaging of this file. Please review the following information to 21 ** ensure the GNU Lesser General Public License version 2.1 requirements 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 12 ** "Redistribution and use in source and binary forms, with or without 13 ** modification, are permitted provided that the following conditions are 14 ** met: 15 ** * Redistributions of source code must retain the above copyright 16 ** notice, this list of conditions and the following disclaimer. 17 ** * Redistributions in binary form must reproduce the above copyright 18 ** notice, this list of conditions and the following disclaimer in 19 ** the documentation and/or other materials provided with the 20 ** distribution. 21 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 22 ** the names of its contributors may be used to endorse or promote 23 ** products derived from this software without specific prior written 24 ** permission. 23 25 ** 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 ** 28 ** GNU General Public License Usage 29 ** Alternatively, this file may be used under the terms of the GNU 30 ** General Public License version 3.0 as published by the Free Software 31 ** Foundation and appearing in the file LICENSE.GPL included in the 32 ** packaging of this file. Please review the following information to 33 ** ensure the GNU General Public License version 3.0 requirements will be 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 ** 36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 26 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 38 37 ** $QT_END_LICENSE$ 39 38 ** … … 48 47 49 48 Server::Server(QWidget *parent) 50 : QDialog(parent)49 : QDialog(parent), tcpServer(0), networkSession(0) 51 50 { 52 51 statusLabel = new QLabel; 53 52 quitButton = new QPushButton(tr("Quit")); 54 53 quitButton->setAutoDefault(false); 54 55 QNetworkConfigurationManager manager; 56 if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { 57 // Get saved network configuration 58 QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); 59 settings.beginGroup(QLatin1String("QtNetwork")); 60 const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); 61 settings.endGroup(); 62 63 // If the saved network configuration is not currently discovered use the system default 64 QNetworkConfiguration config = manager.configurationFromIdentifier(id); 65 if ((config.state() & QNetworkConfiguration::Discovered) != 66 QNetworkConfiguration::Discovered) { 67 config = manager.defaultConfiguration(); 68 } 69 70 networkSession = new QNetworkSession(config, this); 71 connect(networkSession, SIGNAL(opened()), this, SLOT(sessionOpened())); 72 73 statusLabel->setText(tr("Opening network session.")); 74 networkSession->open(); 75 } else { 76 sessionOpened(); 77 } 78 79 //! [2] 80 fortunes << tr("You've been leading a dog's life. Stay off the furniture.") 81 << tr("You've got to think about tomorrow.") 82 << tr("You will be surprised by a loud noise.") 83 << tr("You will feel hungry again in another hour.") 84 << tr("You might have mail.") 85 << tr("You cannot kill time without injuring eternity.") 86 << tr("Computers are not intelligent. They only think they are."); 87 //! [2] 88 89 connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); 90 //! [3] 91 connect(tcpServer, SIGNAL(newConnection()), this, SLOT(sendFortune())); 92 //! [3] 93 94 QHBoxLayout *buttonLayout = new QHBoxLayout; 95 buttonLayout->addStretch(1); 96 buttonLayout->addWidget(quitButton); 97 buttonLayout->addStretch(1); 98 99 QVBoxLayout *mainLayout = new QVBoxLayout; 100 mainLayout->addWidget(statusLabel); 101 mainLayout->addLayout(buttonLayout); 102 setLayout(mainLayout); 103 104 setWindowTitle(tr("Fortune Server")); 105 } 106 107 void Server::sessionOpened() 108 { 109 // Save the used configuration 110 if (networkSession) { 111 QNetworkConfiguration config = networkSession->configuration(); 112 QString id; 113 if (config.type() == QNetworkConfiguration::UserChoice) 114 id = networkSession->sessionProperty(QLatin1String("UserChoiceConfiguration")).toString(); 115 else 116 id = config.identifier(); 117 118 QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); 119 settings.beginGroup(QLatin1String("QtNetwork")); 120 settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); 121 settings.endGroup(); 122 } 55 123 56 124 //! [0] //! [1] … … 81 149 .arg(ipAddress).arg(tcpServer->serverPort())); 82 150 //! [1] 83 84 //! [2]85 fortunes << tr("You've been leading a dog's life. Stay off the furniture.")86 << tr("You've got to think about tomorrow.")87 << tr("You will be surprised by a loud noise.")88 << tr("You will feel hungry again in another hour.")89 << tr("You might have mail.")90 << tr("You cannot kill time without injuring eternity.")91 << tr("Computers are not intelligent. They only think they are.");92 //! [2]93 94 connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));95 //! [3]96 connect(tcpServer, SIGNAL(newConnection()), this, SLOT(sendFortune()));97 //! [3]98 99 QHBoxLayout *buttonLayout = new QHBoxLayout;100 buttonLayout->addStretch(1);101 buttonLayout->addWidget(quitButton);102 buttonLayout->addStretch(1);103 104 QVBoxLayout *mainLayout = new QVBoxLayout;105 mainLayout->addWidget(statusLabel);106 mainLayout->addLayout(buttonLayout);107 setLayout(mainLayout);108 109 setWindowTitle(tr("Fortune Server"));110 151 } 111 152 -
trunk/examples/network/fortuneserver/server.h
r651 r846 1 1 /**************************************************************************** 2 2 ** 3 ** Copyright (C) 201 0Nokia Corporation and/or its subsidiary(-ies).3 ** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies). 4 4 ** All rights reserved. 5 5 ** Contact: Nokia Corporation (qt-info@nokia.com) … … 7 7 ** This file is part of the examples of the Qt Toolkit. 8 8 ** 9 ** $QT_BEGIN_LICENSE:LGPL$ 10 ** Commercial Usage 11 ** Licensees holding valid Qt Commercial licenses may use this file in 12 ** accordance with the Qt Commercial License Agreement provided with the 13 ** Software or, alternatively, in accordance with the terms contained in 14 ** a written agreement between you and Nokia. 9 ** $QT_BEGIN_LICENSE:BSD$ 10 ** You may use this file under the terms of the BSD license as follows: 15 11 ** 16 ** GNU Lesser General Public License Usage 17 ** Alternatively, this file may be used under the terms of the GNU Lesser 18 ** General Public License version 2.1 as published by the Free Software 19 ** Foundation and appearing in the file LICENSE.LGPL included in the 20 ** packaging of this file. Please review the following information to 21 ** ensure the GNU Lesser General Public License version 2.1 requirements 22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. 12 ** "Redistribution and use in source and binary forms, with or without 13 ** modification, are permitted provided that the following conditions are 14 ** met: 15 ** * Redistributions of source code must retain the above copyright 16 ** notice, this list of conditions and the following disclaimer. 17 ** * Redistributions in binary form must reproduce the above copyright 18 ** notice, this list of conditions and the following disclaimer in 19 ** the documentation and/or other materials provided with the 20 ** distribution. 21 ** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor 22 ** the names of its contributors may be used to endorse or promote 23 ** products derived from this software without specific prior written 24 ** permission. 23 25 ** 24 ** In addition, as a special exception, Nokia gives you certain additional 25 ** rights. These rights are described in the Nokia Qt LGPL Exception 26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. 27 ** 28 ** GNU General Public License Usage 29 ** Alternatively, this file may be used under the terms of the GNU 30 ** General Public License version 3.0 as published by the Free Software 31 ** Foundation and appearing in the file LICENSE.GPL included in the 32 ** packaging of this file. Please review the following information to 33 ** ensure the GNU General Public License version 3.0 requirements will be 34 ** met: http://www.gnu.org/copyleft/gpl.html. 35 ** 36 ** If you have questions regarding the use of this file, please contact 37 ** Nokia at qt-info@nokia.com. 26 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28 ** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29 ** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30 ** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31 ** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32 ** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33 ** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34 ** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35 ** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36 ** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." 38 37 ** $QT_END_LICENSE$ 39 38 ** … … 49 48 class QPushButton; 50 49 class QTcpServer; 50 class QNetworkSession; 51 51 QT_END_NAMESPACE 52 52 … … 60 60 61 61 private slots: 62 void sessionOpened(); 62 63 void sendFortune(); 63 64 … … 67 68 QTcpServer *tcpServer; 68 69 QStringList fortunes; 70 QNetworkSession *networkSession; 69 71 }; 70 72 //! [0]
Note:
See TracChangeset
for help on using the changeset viewer.