equal
deleted
inserted
replaced
1 /**************************************************************************** |
1 /**************************************************************************** |
2 ** |
2 ** |
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
4 ** All rights reserved. |
4 ** All rights reserved. |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
6 ** |
6 ** |
7 ** This file is part of the examples of the Qt Toolkit. |
7 ** This file is part of the examples of the Qt Toolkit. |
8 ** |
8 ** |
81 { |
81 { |
82 if (message.isEmpty()) |
82 if (message.isEmpty()) |
83 return false; |
83 return false; |
84 |
84 |
85 QByteArray msg = message.toUtf8(); |
85 QByteArray msg = message.toUtf8(); |
86 QByteArray data = "MESSAGE " + QByteArray::number(msg.size()) + " " + msg; |
86 QByteArray data = "MESSAGE " + QByteArray::number(msg.size()) + ' ' + msg; |
87 return write(data) == data.size(); |
87 return write(data) == data.size(); |
88 } |
88 } |
89 |
89 |
90 void Connection::timerEvent(QTimerEvent *timerEvent) |
90 void Connection::timerEvent(QTimerEvent *timerEvent) |
91 { |
91 { |
116 if (buffer.size() != numBytesForCurrentDataType) { |
116 if (buffer.size() != numBytesForCurrentDataType) { |
117 abort(); |
117 abort(); |
118 return; |
118 return; |
119 } |
119 } |
120 |
120 |
121 username = QString(buffer) + "@" + peerAddress().toString() + ":" |
121 username = QString(buffer) + '@' + peerAddress().toString() + ':' |
122 + QString::number(peerPort()); |
122 + QString::number(peerPort()); |
123 currentDataType = Undefined; |
123 currentDataType = Undefined; |
124 numBytesForCurrentDataType = 0; |
124 numBytesForCurrentDataType = 0; |
125 buffer.clear(); |
125 buffer.clear(); |
126 |
126 |
160 } |
160 } |
161 |
161 |
162 void Connection::sendGreetingMessage() |
162 void Connection::sendGreetingMessage() |
163 { |
163 { |
164 QByteArray greeting = greetingMessage.toUtf8(); |
164 QByteArray greeting = greetingMessage.toUtf8(); |
165 QByteArray data = "GREETING " + QByteArray::number(greeting.size()) + " " + greeting; |
165 QByteArray data = "GREETING " + QByteArray::number(greeting.size()) + ' ' + greeting; |
166 if (write(data) == data.size()) |
166 if (write(data) == data.size()) |
167 isGreetingMessageSent = true; |
167 isGreetingMessageSent = true; |
168 } |
168 } |
169 |
169 |
170 int Connection::readDataIntoBuffer(int maxSize) |
170 int Connection::readDataIntoBuffer(int maxSize) |