author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Mon, 04 Oct 2010 01:19:32 +0300 | |
changeset 37 | 758a864f9613 |
parent 33 | 3e2da88830cd |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
18
2f34d5167611
Revision: 201011
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 4 |
** All rights reserved. |
5 |
** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 |
** |
|
7 |
** This file is part of the examples of the Qt Toolkit. |
|
8 |
** |
|
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
9 |
** $QT_BEGIN_LICENSE:BSD$ |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
10 |
** You may use this file under the terms of the BSD license as follows: |
0 | 11 |
** |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
12 |
** "Redistribution and use in source and binary forms, with or without |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
13 |
** modification, are permitted provided that the following conditions are |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
14 |
** met: |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
15 |
** * Redistributions of source code must retain the above copyright |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
16 |
** notice, this list of conditions and the following disclaimer. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
17 |
** * Redistributions in binary form must reproduce the above copyright |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
18 |
** notice, this list of conditions and the following disclaimer in |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
19 |
** the documentation and/or other materials provided with the |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
20 |
** distribution. |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
21 |
** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
22 |
** the names of its contributors may be used to endorse or promote |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
23 |
** products derived from this software without specific prior written |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
24 |
** permission. |
0 | 25 |
** |
30
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
26 |
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
27 |
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
28 |
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
29 |
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
30 |
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
31 |
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
32 |
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
33 |
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
34 |
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
35 |
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
5dc02b23752f
Revision: 201025
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
18
diff
changeset
|
36 |
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE." |
0 | 37 |
** $QT_END_LICENSE$ |
38 |
** |
|
39 |
****************************************************************************/ |
|
40 |
||
41 |
#include <QtGui> |
|
42 |
#include <QtNetwork> |
|
43 |
||
44 |
#include "client.h" |
|
45 |
||
46 |
//! [0] |
|
47 |
Client::Client(QWidget *parent) |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
48 |
: QDialog(parent), networkSession(0) |
0 | 49 |
{ |
50 |
//! [0] |
|
51 |
hostLabel = new QLabel(tr("&Server name:")); |
|
52 |
portLabel = new QLabel(tr("S&erver port:")); |
|
53 |
||
54 |
// find out which IP to connect to |
|
55 |
QString ipAddress; |
|
56 |
QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses(); |
|
57 |
// use the first non-localhost IPv4 address |
|
58 |
for (int i = 0; i < ipAddressesList.size(); ++i) { |
|
59 |
if (ipAddressesList.at(i) != QHostAddress::LocalHost && |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
60 |
ipAddressesList.at(i).toIPv4Address()) { |
0 | 61 |
ipAddress = ipAddressesList.at(i).toString(); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
62 |
break; |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
63 |
} |
0 | 64 |
} |
65 |
// if we did not find one, use IPv4 localhost |
|
66 |
if (ipAddress.isEmpty()) |
|
67 |
ipAddress = QHostAddress(QHostAddress::LocalHost).toString(); |
|
68 |
||
69 |
hostLineEdit = new QLineEdit(ipAddress); |
|
70 |
portLineEdit = new QLineEdit; |
|
71 |
portLineEdit->setValidator(new QIntValidator(1, 65535, this)); |
|
72 |
||
73 |
hostLabel->setBuddy(hostLineEdit); |
|
74 |
portLabel->setBuddy(portLineEdit); |
|
75 |
||
76 |
statusLabel = new QLabel(tr("This examples requires that you run the " |
|
77 |
"Fortune Server example as well.")); |
|
78 |
||
79 |
getFortuneButton = new QPushButton(tr("Get Fortune")); |
|
80 |
getFortuneButton->setDefault(true); |
|
81 |
getFortuneButton->setEnabled(false); |
|
82 |
||
83 |
quitButton = new QPushButton(tr("Quit")); |
|
84 |
||
85 |
buttonBox = new QDialogButtonBox; |
|
86 |
buttonBox->addButton(getFortuneButton, QDialogButtonBox::ActionRole); |
|
87 |
buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole); |
|
88 |
||
89 |
//! [1] |
|
90 |
tcpSocket = new QTcpSocket(this); |
|
91 |
//! [1] |
|
92 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
93 |
connect(hostLineEdit, SIGNAL(textChanged(QString)), |
0 | 94 |
this, SLOT(enableGetFortuneButton())); |
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
95 |
connect(portLineEdit, SIGNAL(textChanged(QString)), |
0 | 96 |
this, SLOT(enableGetFortuneButton())); |
97 |
connect(getFortuneButton, SIGNAL(clicked()), |
|
98 |
this, SLOT(requestNewFortune())); |
|
99 |
connect(quitButton, SIGNAL(clicked()), this, SLOT(close())); |
|
100 |
//! [2] //! [3] |
|
101 |
connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(readFortune())); |
|
102 |
//! [2] //! [4] |
|
103 |
connect(tcpSocket, SIGNAL(error(QAbstractSocket::SocketError)), |
|
104 |
//! [3] |
|
105 |
this, SLOT(displayError(QAbstractSocket::SocketError))); |
|
106 |
//! [4] |
|
107 |
||
108 |
QGridLayout *mainLayout = new QGridLayout; |
|
109 |
mainLayout->addWidget(hostLabel, 0, 0); |
|
110 |
mainLayout->addWidget(hostLineEdit, 0, 1); |
|
111 |
mainLayout->addWidget(portLabel, 1, 0); |
|
112 |
mainLayout->addWidget(portLineEdit, 1, 1); |
|
113 |
mainLayout->addWidget(statusLabel, 2, 0, 1, 2); |
|
114 |
mainLayout->addWidget(buttonBox, 3, 0, 1, 2); |
|
115 |
setLayout(mainLayout); |
|
116 |
||
117 |
setWindowTitle(tr("Fortune Client")); |
|
118 |
portLineEdit->setFocus(); |
|
119 |
||
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
120 |
QNetworkConfigurationManager manager; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
121 |
if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) { |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
122 |
// Get saved network configuration |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
123 |
QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
124 |
settings.beginGroup(QLatin1String("QtNetwork")); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
125 |
const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString(); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
126 |
settings.endGroup(); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
127 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
128 |
// If the saved network configuration is not currently discovered use the system default |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
129 |
QNetworkConfiguration config = manager.configurationFromIdentifier(id); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
130 |
if ((config.state() & QNetworkConfiguration::Discovered) != |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
131 |
QNetworkConfiguration::Discovered) { |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
132 |
config = manager.defaultConfiguration(); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
133 |
} |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
134 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
135 |
networkSession = new QNetworkSession(config, this); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
136 |
connect(networkSession, SIGNAL(opened()), this, SLOT(sessionOpened())); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
137 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
138 |
getFortuneButton->setEnabled(false); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
139 |
statusLabel->setText(tr("Opening network session.")); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
140 |
networkSession->open(); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
141 |
} |
0 | 142 |
//! [5] |
143 |
} |
|
144 |
//! [5] |
|
145 |
||
146 |
//! [6] |
|
147 |
void Client::requestNewFortune() |
|
148 |
{ |
|
149 |
getFortuneButton->setEnabled(false); |
|
150 |
blockSize = 0; |
|
151 |
tcpSocket->abort(); |
|
152 |
//! [7] |
|
153 |
tcpSocket->connectToHost(hostLineEdit->text(), |
|
154 |
portLineEdit->text().toInt()); |
|
155 |
//! [7] |
|
156 |
} |
|
157 |
//! [6] |
|
158 |
||
159 |
//! [8] |
|
160 |
void Client::readFortune() |
|
161 |
{ |
|
162 |
//! [9] |
|
163 |
QDataStream in(tcpSocket); |
|
164 |
in.setVersion(QDataStream::Qt_4_0); |
|
165 |
||
166 |
if (blockSize == 0) { |
|
167 |
if (tcpSocket->bytesAvailable() < (int)sizeof(quint16)) |
|
168 |
return; |
|
169 |
//! [8] |
|
170 |
||
171 |
//! [10] |
|
172 |
in >> blockSize; |
|
173 |
} |
|
174 |
||
175 |
if (tcpSocket->bytesAvailable() < blockSize) |
|
176 |
return; |
|
177 |
//! [10] //! [11] |
|
178 |
||
179 |
QString nextFortune; |
|
180 |
in >> nextFortune; |
|
181 |
||
182 |
if (nextFortune == currentFortune) { |
|
183 |
QTimer::singleShot(0, this, SLOT(requestNewFortune())); |
|
184 |
return; |
|
185 |
} |
|
186 |
//! [11] |
|
187 |
||
188 |
//! [12] |
|
189 |
currentFortune = nextFortune; |
|
190 |
//! [9] |
|
191 |
statusLabel->setText(currentFortune); |
|
192 |
getFortuneButton->setEnabled(true); |
|
193 |
} |
|
194 |
//! [12] |
|
195 |
||
196 |
//! [13] |
|
197 |
void Client::displayError(QAbstractSocket::SocketError socketError) |
|
198 |
{ |
|
199 |
switch (socketError) { |
|
200 |
case QAbstractSocket::RemoteHostClosedError: |
|
201 |
break; |
|
202 |
case QAbstractSocket::HostNotFoundError: |
|
203 |
QMessageBox::information(this, tr("Fortune Client"), |
|
204 |
tr("The host was not found. Please check the " |
|
205 |
"host name and port settings.")); |
|
206 |
break; |
|
207 |
case QAbstractSocket::ConnectionRefusedError: |
|
208 |
QMessageBox::information(this, tr("Fortune Client"), |
|
209 |
tr("The connection was refused by the peer. " |
|
210 |
"Make sure the fortune server is running, " |
|
211 |
"and check that the host name and port " |
|
212 |
"settings are correct.")); |
|
213 |
break; |
|
214 |
default: |
|
215 |
QMessageBox::information(this, tr("Fortune Client"), |
|
216 |
tr("The following error occurred: %1.") |
|
217 |
.arg(tcpSocket->errorString())); |
|
218 |
} |
|
219 |
||
220 |
getFortuneButton->setEnabled(true); |
|
221 |
} |
|
222 |
//! [13] |
|
223 |
||
224 |
void Client::enableGetFortuneButton() |
|
225 |
{ |
|
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
226 |
getFortuneButton->setEnabled((!networkSession || networkSession->isOpen()) && |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
227 |
!hostLineEdit->text().isEmpty() && |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
228 |
!portLineEdit->text().isEmpty()); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
229 |
|
0 | 230 |
} |
33
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
231 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
232 |
void Client::sessionOpened() |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
233 |
{ |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
234 |
// Save the used configuration |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
235 |
QNetworkConfiguration config = networkSession->configuration(); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
236 |
QString id; |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
237 |
if (config.type() == QNetworkConfiguration::UserChoice) |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
238 |
id = networkSession->sessionProperty(QLatin1String("UserChoiceConfiguration")).toString(); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
239 |
else |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
240 |
id = config.identifier(); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
241 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
242 |
QSettings settings(QSettings::UserScope, QLatin1String("Trolltech")); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
243 |
settings.beginGroup(QLatin1String("QtNetwork")); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
244 |
settings.setValue(QLatin1String("DefaultNetworkConfiguration"), id); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
245 |
settings.endGroup(); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
246 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
247 |
statusLabel->setText(tr("This examples requires that you run the " |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
248 |
"Fortune Server example as well.")); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
249 |
|
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
250 |
enableGetFortuneButton(); |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
251 |
} |
3e2da88830cd
Revision: 201031
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
30
diff
changeset
|
252 |