• Skip to sidebar navigation
  • Skip to content
Linked Applications
  • Jira
  • Confluence
  • Bitbucket
  • Atlassian Bamboo
  • Почта

Bitbucket

  • More
    ProjectsRepositories
  • Help
    • Online help
    • Learn Git
    • Welcome to Bitbucket
    • Keyboard shortcuts
  • Log In
Redkit
  1. Redkit

QtIFW

Public
Actions
  • Clone
  • Compare

Learn more about cloning repositories

You have read-only access

Navigation
  • Source
  • Commits
  • Branches
  • All Branches Graph
  • Forks
  1. Redkit
  2. QtIFW

Source

QtIFW/src/libs/installer/protocol.cpp
Katja MarttilaKatja Marttila committed c9d11cc991526 Jan 2017
Raw file
Source viewDiff to previous
xxxxxxxxxx
    Returns \c false if the packet in the device buffer is yet incomplete, \c true otherwise.
 
1
/**************************************************************************
2
**
3
** Copyright (C) 2017 The Qt Company Ltd.
4
** Contact: https://www.qt.io/licensing/
5
**
6
** This file is part of the Qt Installer Framework.
7
**
8
** $QT_BEGIN_LICENSE:GPL-EXCEPT$
9
** Commercial License Usage
10
** Licensees holding valid commercial Qt licenses may use this file in
11
** accordance with the commercial license agreement provided with the
12
** Software or, alternatively, in accordance with the terms contained in
13
** a written agreement between you and The Qt Company. For licensing terms
14
** and conditions see https://www.qt.io/terms-conditions. For further
15
** information use the contact form at https://www.qt.io/contact-us.
16
**
17
** GNU General Public License Usage
18
** Alternatively, this file may be used under the terms of the GNU
19
** General Public License version 3 as published by the Free Software
20
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
21
** included in the packaging of this file. Please review the following
22
** information to ensure the GNU General Public License requirements will
23
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
24
**
25
** $QT_END_LICENSE$
26
**
27
**************************************************************************/
28
​
29
#include "protocol.h"
30
#include <QIODevice>
31
​
32
namespace QInstaller {
33
​
34
typedef qint32 PackageSize;
35
​
36
/*!
37
    Write a packet containing \a command and \a data to \a device.
38
​
39
    \note Both client and server need to have the same endianness.
40
 */
41
void sendPacket(QIODevice *device, const QByteArray &command, const QByteArray &data)
42
{
43
    // use aliasing for writing payload size into bytes
44
    char payloadBytes[sizeof(PackageSize)];
45
    PackageSize *payloadSize = reinterpret_cast<PackageSize*>(&payloadBytes);
46
    *payloadSize = command.size() + sizeof(char) + data.size();
47
​
48
    QByteArray packet;
49
    packet.reserve(sizeof(PackageSize) + *payloadSize);
50
    packet.append(payloadBytes, sizeof(PackageSize));
51
    packet.append(command);
52
    packet.append('\0');
53
    packet.append(data);
54
​
55
    forever {
56
        const int bytesWritten = device->write(packet);
57
        Q_ASSERT(bytesWritten >= 0);
58
        if (bytesWritten == packet.size())
59
            break;
60
        packet.remove(0, bytesWritten);
61
    }
62
}
63
​
  • Git repository management for enterprise teams powered by Atlassian Bitbucket
  • Atlassian Bitbucket v6.8.0
  • Documentation
  • Request a feature
  • About
  • Contact Atlassian
Atlassian

Everything looks good. We'll let you know here if there's anything you should know about.