summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Knight <andrew.knight@intopalo.com>2015-05-03 13:21:25 +0300
committerAndrew Knight <qt@panimo.net>2015-05-04 18:48:17 +0000
commit8b571c869eaeea4a158f9d8ed89454b9c90f5d46 (patch)
treebfb35966f532706b68e7985c47d9114fc36efaf3
parent30329ce24004a54e0bd1bbeff2b139ab13bb6946 (diff)
downloadqttools-8b571c869eaeea4a158f9d8ed89454b9c90f5d46.tar.gz
winrtrunner: Remove Xap engine
Windows 8.0 and Windows Phone 8.0 support have been removed from Qt, so remove references to them in winrtrunner. Change-Id: Ifcb6f60b6122b94ff453aa23334263d4b828608a Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
-rw-r--r--src/shared/corecon/corecon.pri2
-rw-r--r--src/winrtrunner/qzip/README4
-rw-r--r--src/winrtrunner/qzip/qzip.cpp1387
-rw-r--r--src/winrtrunner/qzip/qzipreader_p.h118
-rw-r--r--src/winrtrunner/qzip/qzipwriter_p.h111
-rw-r--r--src/winrtrunner/runner.cpp22
-rw-r--r--src/winrtrunner/winrtrunner.pro30
-rw-r--r--src/winrtrunner/xapengine.cpp640
-rw-r--r--src/winrtrunner/xapengine.h80
9 files changed, 7 insertions, 2387 deletions
diff --git a/src/shared/corecon/corecon.pri b/src/shared/corecon/corecon.pri
index 4d4abfd45..ea22d74bb 100644
--- a/src/shared/corecon/corecon.pri
+++ b/src/shared/corecon/corecon.pri
@@ -1,4 +1,4 @@
-win32-msvc2012|win32-msvc2013 {
+win32-msvc2013 {
INCLUDEPATH += $$PWD
HEADERS += $$PWD/ccapi.h $$PWD/ccapi_11.h $$PWD/ccapi_12.h $$PWD/corecon.h
SOURCES += $$PWD/corecon.cpp
diff --git a/src/winrtrunner/qzip/README b/src/winrtrunner/qzip/README
deleted file mode 100644
index 96826772c..000000000
--- a/src/winrtrunner/qzip/README
+++ /dev/null
@@ -1,4 +0,0 @@
-QZip
-
-These classes were imported from the QtGui module in the qtbase repository.
-The original files can be found at qtbase/src/gui/text.
diff --git a/src/winrtrunner/qzip/qzip.cpp b/src/winrtrunner/qzip/qzip.cpp
deleted file mode 100644
index 731020636..000000000
--- a/src/winrtrunner/qzip/qzip.cpp
+++ /dev/null
@@ -1,1387 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the tools module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qglobal.h>
-
-#ifndef QT_NO_TEXTODFWRITER
-
-#include "qzipreader_p.h"
-#include "qzipwriter_p.h"
-#include <qdatetime.h>
-#include <qplatformdefs.h>
-#include <qendian.h>
-#include <qdebug.h>
-#include <qdir.h>
-
-#include <zlib.h>
-
-// Zip standard version for archives handled by this API
-// (actually, the only basic support of this version is implemented but it is enough for now)
-#define ZIP_VERSION 20
-
-#if defined(Q_OS_WIN)
-# undef S_IFREG
-# define S_IFREG 0100000
-# ifndef S_IFDIR
-# define S_IFDIR 0040000
-# endif
-# ifndef S_ISDIR
-# define S_ISDIR(x) ((x) & S_IFDIR) > 0
-# endif
-# ifndef S_ISREG
-# define S_ISREG(x) ((x) & 0170000) == S_IFREG
-# endif
-# define S_IFLNK 020000
-# define S_ISLNK(x) ((x) & S_IFLNK) > 0
-# ifndef S_IRUSR
-# define S_IRUSR 0400
-# endif
-# ifndef S_IWUSR
-# define S_IWUSR 0200
-# endif
-# ifndef S_IXUSR
-# define S_IXUSR 0100
-# endif
-# define S_IRGRP 0040
-# define S_IWGRP 0020
-# define S_IXGRP 0010
-# define S_IROTH 0004
-# define S_IWOTH 0002
-# define S_IXOTH 0001
-#endif
-
-#ifndef FILE_ATTRIBUTE_READONLY
-# define FILE_ATTRIBUTE_READONLY 0x1
-#endif
-#ifndef FILE_ATTRIBUTE_DIRECTORY
-# define FILE_ATTRIBUTE_DIRECTORY 0x10
-#endif
-
-#if 0
-#define ZDEBUG qDebug
-#else
-#define ZDEBUG if (0) qDebug
-#endif
-
-QT_BEGIN_NAMESPACE
-
-static inline uint readUInt(const uchar *data)
-{
- return (data[0]) + (data[1]<<8) + (data[2]<<16) + (data[3]<<24);
-}
-
-static inline ushort readUShort(const uchar *data)
-{
- return (data[0]) + (data[1]<<8);
-}
-
-static inline void writeUInt(uchar *data, uint i)
-{
- data[0] = i & 0xff;
- data[1] = (i>>8) & 0xff;
- data[2] = (i>>16) & 0xff;
- data[3] = (i>>24) & 0xff;
-}
-
-static inline void writeUShort(uchar *data, ushort i)
-{
- data[0] = i & 0xff;
- data[1] = (i>>8) & 0xff;
-}
-
-static inline void copyUInt(uchar *dest, const uchar *src)
-{
- dest[0] = src[0];
- dest[1] = src[1];
- dest[2] = src[2];
- dest[3] = src[3];
-}
-
-static inline void copyUShort(uchar *dest, const uchar *src)
-{
- dest[0] = src[0];
- dest[1] = src[1];
-}
-
-static void writeMSDosDate(uchar *dest, const QDateTime& dt)
-{
- if (dt.isValid()) {
- quint16 time =
- (dt.time().hour() << 11) // 5 bit hour
- | (dt.time().minute() << 5) // 6 bit minute
- | (dt.time().second() >> 1); // 5 bit double seconds
-
- dest[0] = time & 0xff;
- dest[1] = time >> 8;
-
- quint16 date =
- ((dt.date().year() - 1980) << 9) // 7 bit year 1980-based
- | (dt.date().month() << 5) // 4 bit month
- | (dt.date().day()); // 5 bit day
-
- dest[2] = char(date);
- dest[3] = char(date >> 8);
- } else {
- dest[0] = 0;
- dest[1] = 0;
- dest[2] = 0;
- dest[3] = 0;
- }
-}
-
-static quint32 permissionsToMode(QFile::Permissions perms)
-{
- quint32 mode = 0;
- if (perms & QFile::ReadOwner)
- mode |= S_IRUSR;
- if (perms & QFile::WriteOwner)
- mode |= S_IWUSR;
- if (perms & QFile::ExeOwner)
- mode |= S_IXUSR;
- if (perms & QFile::ReadUser)
- mode |= S_IRUSR;
- if (perms & QFile::WriteUser)
- mode |= S_IWUSR;
- if (perms & QFile::ExeUser)
- mode |= S_IXUSR;
- if (perms & QFile::ReadGroup)
- mode |= S_IRGRP;
- if (perms & QFile::WriteGroup)
- mode |= S_IWGRP;
- if (perms & QFile::ExeGroup)
- mode |= S_IXGRP;
- if (perms & QFile::ReadOther)
- mode |= S_IROTH;
- if (perms & QFile::WriteOther)
- mode |= S_IWOTH;
- if (perms & QFile::ExeOther)
- mode |= S_IXOTH;
- return mode;
-}
-
-static int inflate(Bytef *dest, ulong *destLen, const Bytef *source, ulong sourceLen)
-{
- z_stream stream;
- int err;
-
- stream.next_in = (Bytef*)source;
- stream.avail_in = (uInt)sourceLen;
- if ((uLong)stream.avail_in != sourceLen)
- return Z_BUF_ERROR;
-
- stream.next_out = dest;
- stream.avail_out = (uInt)*destLen;
- if ((uLong)stream.avail_out != *destLen)
- return Z_BUF_ERROR;
-
- stream.zalloc = (alloc_func)0;
- stream.zfree = (free_func)0;
-
- err = inflateInit2(&stream, -MAX_WBITS);
- if (err != Z_OK)
- return err;
-
- err = inflate(&stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- inflateEnd(&stream);
- if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0))
- return Z_DATA_ERROR;
- return err;
- }
- *destLen = stream.total_out;
-
- err = inflateEnd(&stream);
- return err;
-}
-
-static int deflate (Bytef *dest, ulong *destLen, const Bytef *source, ulong sourceLen)
-{
- z_stream stream;
- int err;
-
- stream.next_in = (Bytef*)source;
- stream.avail_in = (uInt)sourceLen;
- stream.next_out = dest;
- stream.avail_out = (uInt)*destLen;
- if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR;
-
- stream.zalloc = (alloc_func)0;
- stream.zfree = (free_func)0;
- stream.opaque = (voidpf)0;
-
- err = deflateInit2(&stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, -MAX_WBITS, 8, Z_DEFAULT_STRATEGY);
- if (err != Z_OK) return err;
-
- err = deflate(&stream, Z_FINISH);
- if (err != Z_STREAM_END) {
- deflateEnd(&stream);
- return err == Z_OK ? Z_BUF_ERROR : err;
- }
- *destLen = stream.total_out;
-
- err = deflateEnd(&stream);
- return err;
-}
-
-static QFile::Permissions modeToPermissions(quint32 mode)
-{
- QFile::Permissions ret;
- if (mode & S_IRUSR)
- ret |= QFile::ReadOwner;
- if (mode & S_IWUSR)
- ret |= QFile::WriteOwner;
- if (mode & S_IXUSR)
- ret |= QFile::ExeOwner;
- if (mode & S_IRUSR)
- ret |= QFile::ReadUser;
- if (mode & S_IWUSR)
- ret |= QFile::WriteUser;
- if (mode & S_IXUSR)
- ret |= QFile::ExeUser;
- if (mode & S_IRGRP)
- ret |= QFile::ReadGroup;
- if (mode & S_IWGRP)
- ret |= QFile::WriteGroup;
- if (mode & S_IXGRP)
- ret |= QFile::ExeGroup;
- if (mode & S_IROTH)
- ret |= QFile::ReadOther;
- if (mode & S_IWOTH)
- ret |= QFile::WriteOther;
- if (mode & S_IXOTH)
- ret |= QFile::ExeOther;
- return ret;
-}
-
-static QDateTime readMSDosDate(const uchar *src)
-{
- uint dosDate = readUInt(src);
- quint64 uDate;
- uDate = (quint64)(dosDate >> 16);
- uint tm_mday = (uDate & 0x1f);
- uint tm_mon = ((uDate & 0x1E0) >> 5);
- uint tm_year = (((uDate & 0x0FE00) >> 9) + 1980);
- uint tm_hour = ((dosDate & 0xF800) >> 11);
- uint tm_min = ((dosDate & 0x7E0) >> 5);
- uint tm_sec = ((dosDate & 0x1f) << 1);
-
- return QDateTime(QDate(tm_year, tm_mon, tm_mday), QTime(tm_hour, tm_min, tm_sec));
-}
-
-// for details, see http://www.pkware.com/documents/casestudies/APPNOTE.TXT
-
-enum HostOS {
- HostFAT = 0,
- HostAMIGA = 1,
- HostVMS = 2, // VAX/VMS
- HostUnix = 3,
- HostVM_CMS = 4,
- HostAtari = 5, // what if it's a minix filesystem? [cjh]
- HostHPFS = 6, // filesystem used by OS/2 (and NT 3.x)
- HostMac = 7,
- HostZ_System = 8,
- HostCPM = 9,
- HostTOPS20 = 10, // pkzip 2.50 NTFS
- HostNTFS = 11, // filesystem used by Windows NT
- HostQDOS = 12, // SMS/QDOS
- HostAcorn = 13, // Archimedes Acorn RISC OS
- HostVFAT = 14, // filesystem used by Windows 95, NT
- HostMVS = 15,
- HostBeOS = 16, // hybrid POSIX/database filesystem
- HostTandem = 17,
- HostOS400 = 18,
- HostOSX = 19
-};
-
-enum GeneralPurposeFlag {
- Encrypted = 0x01,
- AlgTune1 = 0x02,
- AlgTune2 = 0x04,
- HasDataDescriptor = 0x08,
- PatchedData = 0x20,
- StrongEncrypted = 0x40,
- Utf8Names = 0x0800,
- CentralDirectoryEncrypted = 0x2000
-};
-
-enum CompressionMethod {
- CompressionMethodStored = 0,
- CompressionMethodShrunk = 1,
- CompressionMethodReduced1 = 2,
- CompressionMethodReduced2 = 3,
- CompressionMethodReduced3 = 4,
- CompressionMethodReduced4 = 5,
- CompressionMethodImploded = 6,
- CompressionMethodReservedTokenizing = 7, // reserved for tokenizing
- CompressionMethodDeflated = 8,
- CompressionMethodDeflated64 = 9,
- CompressionMethodPKImploding = 10,
-
- CompressionMethodBZip2 = 12,
-
- CompressionMethodLZMA = 14,
-
- CompressionMethodTerse = 18,
- CompressionMethodLz77 = 19,
-
- CompressionMethodJpeg = 96,
- CompressionMethodWavPack = 97,
- CompressionMethodPPMd = 98,
- CompressionMethodWzAES = 99
-};
-
-struct LocalFileHeader
-{
- uchar signature[4]; // 0x04034b50
- uchar version_needed[2];
- uchar general_purpose_bits[2];
- uchar compression_method[2];
- uchar last_mod_file[4];
- uchar crc_32[4];
- uchar compressed_size[4];
- uchar uncompressed_size[4];
- uchar file_name_length[2];
- uchar extra_field_length[2];
-};
-
-struct DataDescriptor
-{
- uchar crc_32[4];
- uchar compressed_size[4];
- uchar uncompressed_size[4];
-};
-
-struct CentralFileHeader
-{
- uchar signature[4]; // 0x02014b50
- uchar version_made[2];
- uchar version_needed[2];
- uchar general_purpose_bits[2];
- uchar compression_method[2];
- uchar last_mod_file[4];
- uchar crc_32[4];
- uchar compressed_size[4];
- uchar uncompressed_size[4];
- uchar file_name_length[2];
- uchar extra_field_length[2];
- uchar file_comment_length[2];
- uchar disk_start[2];
- uchar internal_file_attributes[2];
- uchar external_file_attributes[4];
- uchar offset_local_header[4];
- LocalFileHeader toLocalHeader() const;
-};
-
-struct EndOfDirectory
-{
- uchar signature[4]; // 0x06054b50
- uchar this_disk[2];
- uchar start_of_directory_disk[2];
- uchar num_dir_entries_this_disk[2];
- uchar num_dir_entries[2];
- uchar directory_size[4];
- uchar dir_start_offset[4];
- uchar comment_length[2];
-};
-
-struct FileHeader
-{
- CentralFileHeader h;
- QByteArray file_name;
- QByteArray extra_field;
- QByteArray file_comment;
-};
-
-QZipReader::FileInfo::FileInfo()
- : isDir(false), isFile(false), isSymLink(false), crc(0), size(0)
-{
-}
-
-QZipReader::FileInfo::~FileInfo()
-{
-}
-
-QZipReader::FileInfo::FileInfo(const FileInfo &other)
-{
- operator=(other);
-}
-
-QZipReader::FileInfo& QZipReader::FileInfo::operator=(const FileInfo &other)
-{
- filePath = other.filePath;
- isDir = other.isDir;
- isFile = other.isFile;
- isSymLink = other.isSymLink;
- permissions = other.permissions;
- crc = other.crc;
- size = other.size;
- lastModified = other.lastModified;
- return *this;
-}
-
-bool QZipReader::FileInfo::isValid() const
-{
- return isDir || isFile || isSymLink;
-}
-
-class QZipPrivate
-{
-public:
- QZipPrivate(QIODevice *device, bool ownDev)
- : device(device), ownDevice(ownDev), dirtyFileTree(true), start_of_directory(0)
- {
- }
-
- ~QZipPrivate()
- {
- if (ownDevice)
- delete device;
- }
-
- void fillFileInfo(int index, QZipReader::FileInfo &fileInfo) const;
-
- QIODevice *device;
- bool ownDevice;
- bool dirtyFileTree;
- QList<FileHeader> fileHeaders;
- QByteArray comment;
- uint start_of_directory;
-};
-
-void QZipPrivate::fillFileInfo(int index, QZipReader::FileInfo &fileInfo) const
-{
- FileHeader header = fileHeaders.at(index);
- quint32 mode = readUInt(header.h.external_file_attributes);
- const HostOS hostOS = HostOS(readUShort(header.h.version_made) >> 8);
- switch (hostOS) {
- case HostUnix:
- mode = (mode >> 16) & 0xffff;
- if (S_ISDIR(mode))
- fileInfo.isDir = true;
- else if (S_ISREG(mode))
- fileInfo.isFile = true;
- else if (S_ISLNK(mode))
- fileInfo.isSymLink = true;
- fileInfo.permissions = modeToPermissions(mode);
- break;
- case HostFAT:
- case HostNTFS:
- case HostHPFS:
- case HostVFAT:
- fileInfo.permissions |= QFile::ReadOwner | QFile::ReadUser | QFile::ReadGroup | QFile::ReadOther;
- if ((mode & FILE_ATTRIBUTE_READONLY) == 0)
- fileInfo.permissions |= QFile::WriteOwner | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOther;
- if ((mode & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY) {
- fileInfo.isDir = true;
- fileInfo.permissions |= QFile::ExeOwner | QFile::ExeUser | QFile::ExeGroup | QFile::ExeOther;
- } else {
- fileInfo.isFile = true;
- }
- break;
- default:
- qWarning("QZip: Zip entry format at %d is not supported.", index);
- return; // we don't support anything else
- }
-
- ushort general_purpose_bits = readUShort(header.h.general_purpose_bits);
- // if bit 11 is set, the filename and comment fields must be encoded using UTF-8
- const bool inUtf8 = (general_purpose_bits & Utf8Names) != 0;
- fileInfo.filePath = inUtf8 ? QString::fromUtf8(header.file_name) : QString::fromLocal8Bit(header.file_name);
- fileInfo.crc = readUInt(header.h.crc_32);
- fileInfo.size = readUInt(header.h.uncompressed_size);
- fileInfo.lastModified = readMSDosDate(header.h.last_mod_file);
-
- // fix the file path, if broken (convert separators, eat leading and trailing ones)
- fileInfo.filePath = QDir::fromNativeSeparators(fileInfo.filePath);
- while (!fileInfo.filePath.isEmpty() && (fileInfo.filePath.at(0) == QLatin1Char('.') || fileInfo.filePath.at(0) == QLatin1Char('/')))
- fileInfo.filePath = fileInfo.filePath.mid(1);
- while (!fileInfo.filePath.isEmpty() && fileInfo.filePath.at(fileInfo.filePath.size() - 1) == QLatin1Char('/'))
- fileInfo.filePath.chop(1);
-}
-
-class QZipReaderPrivate : public QZipPrivate
-{
-public:
- QZipReaderPrivate(QIODevice *device, bool ownDev)
- : QZipPrivate(device, ownDev), status(QZipReader::NoError)
- {
- }
-
- void scanFiles();
-
- QZipReader::Status status;
-};
-
-class QZipWriterPrivate : public QZipPrivate
-{
-public:
- QZipWriterPrivate(QIODevice *device, bool ownDev)
- : QZipPrivate(device, ownDev),
- status(QZipWriter::NoError),
- permissions(QFile::ReadOwner | QFile::WriteOwner),
- compressionPolicy(QZipWriter::AlwaysCompress)
- {
- }
-
- QZipWriter::Status status;
- QFile::Permissions permissions;
- QZipWriter::CompressionPolicy compressionPolicy;
-
- enum EntryType { Directory, File, Symlink };
-
- void addEntry(EntryType type, const QString &fileName, const QByteArray &contents);
-};
-
-LocalFileHeader CentralFileHeader::toLocalHeader() const
-{
- LocalFileHeader h;
- writeUInt(h.signature, 0x04034b50);
- copyUShort(h.version_needed, version_needed);
- copyUShort(h.general_purpose_bits, general_purpose_bits);
- copyUShort(h.compression_method, compression_method);
- copyUInt(h.last_mod_file, last_mod_file);
- copyUInt(h.crc_32, crc_32);
- copyUInt(h.compressed_size, compressed_size);
- copyUInt(h.uncompressed_size, uncompressed_size);
- copyUShort(h.file_name_length, file_name_length);
- copyUShort(h.extra_field_length, extra_field_length);
- return h;
-}
-
-void QZipReaderPrivate::scanFiles()
-{
- if (!dirtyFileTree)
- return;
-
- if (! (device->isOpen() || device->open(QIODevice::ReadOnly))) {
- status = QZipReader::FileOpenError;
- return;
- }
-
- if ((device->openMode() & QIODevice::ReadOnly) == 0) { // only read the index from readable files.
- status = QZipReader::FileReadError;
- return;
- }
-
- dirtyFileTree = false;
- uchar tmp[4];
- device->read((char *)tmp, 4);
- if (readUInt(tmp) != 0x04034b50) {
- qWarning() << "QZip: not a zip file!";
- return;
- }
-
- // find EndOfDirectory header
- int i = 0;
- int start_of_directory = -1;
- int num_dir_entries = 0;
- EndOfDirectory eod;
- while (start_of_directory == -1) {
- const int pos = device->size() - int(sizeof(EndOfDirectory)) - i;
- if (pos < 0 || i > 65535) {
- qWarning() << "QZip: EndOfDirectory not found";
- return;
- }
-
- device->seek(pos);
- device->read((char *)&eod, sizeof(EndOfDirectory));
- if (readUInt(eod.signature) == 0x06054b50)
- break;
- ++i;
- }
-
- // have the eod
- start_of_directory = readUInt(eod.dir_start_offset);
- num_dir_entries = readUShort(eod.num_dir_entries);
- ZDEBUG("start_of_directory at %d, num_dir_entries=%d", start_of_directory, num_dir_entries);
- int comment_length = readUShort(eod.comment_length);
- if (comment_length != i)
- qWarning() << "QZip: failed to parse zip file.";
- comment = device->read(qMin(comment_length, i));
-
-
- device->seek(start_of_directory);
- for (i = 0; i < num_dir_entries; ++i) {
- FileHeader header;
- int read = device->read((char *) &header.h, sizeof(CentralFileHeader));
- if (read < (int)sizeof(CentralFileHeader)) {
- qWarning() << "QZip: Failed to read complete header, index may be incomplete";
- break;
- }
- if (readUInt(header.h.signature) != 0x02014b50) {
- qWarning() << "QZip: invalid header signature, index may be incomplete";
- break;
- }
-
- int l = readUShort(header.h.file_name_length);
- header.file_name = device->read(l);
- if (header.file_name.length() != l) {
- qWarning() << "QZip: Failed to read filename from zip index, index may be incomplete";
- break;
- }
- l = readUShort(header.h.extra_field_length);
- header.extra_field = device->read(l);
- if (header.extra_field.length() != l) {
- qWarning() << "QZip: Failed to read extra field in zip file, skipping file, index may be incomplete";
- break;
- }
- l = readUShort(header.h.file_comment_length);
- header.file_comment = device->read(l);
- if (header.file_comment.length() != l) {
- qWarning() << "QZip: Failed to read read file comment, index may be incomplete";
- break;
- }
-
- ZDEBUG("found file '%s'", header.file_name.data());
- fileHeaders.append(header);
- }
-}
-
-void QZipWriterPrivate::addEntry(EntryType type, const QString &fileName, const QByteArray &contents/*, QFile::Permissions permissions, QZip::Method m*/)
-{
-#ifndef NDEBUG
- static const char *entryTypes[] = {
- "directory",
- "file ",
- "symlink " };
- ZDEBUG() << "adding" << entryTypes[type] <<":" << fileName.toUtf8().data() << (type == 2 ? QByteArray(" -> " + contents).constData() : "");
-#endif
-
- if (! (device->isOpen() || device->open(QIODevice::WriteOnly))) {
- status = QZipWriter::FileOpenError;
- return;
- }
- device->seek(start_of_directory);
-
- // don't compress small files
- QZipWriter::CompressionPolicy compression = compressionPolicy;
- if (compressionPolicy == QZipWriter::AutoCompress) {
- if (contents.length() < 64)
- compression = QZipWriter::NeverCompress;
- else
- compression = QZipWriter::AlwaysCompress;
- }
-
- FileHeader header;
- memset(&header.h, 0, sizeof(CentralFileHeader));
- writeUInt(header.h.signature, 0x02014b50);
-
- writeUShort(header.h.version_needed, ZIP_VERSION);
- writeUInt(header.h.uncompressed_size, contents.length());
- writeMSDosDate(header.h.last_mod_file, QDateTime::currentDateTime());
- QByteArray data = contents;
- if (compression == QZipWriter::AlwaysCompress) {
- writeUShort(header.h.compression_method, CompressionMethodDeflated);
-
- ulong len = contents.length();
- // shamelessly copied form zlib
- len += (len >> 12) + (len >> 14) + 11;
- int res;
- do {
- data.resize(len);
- res = deflate((uchar*)data.data(), &len, (const uchar*)contents.constData(), contents.length());
-
- switch (res) {
- case Z_OK:
- data.resize(len);
- break;
- case Z_MEM_ERROR:
- qWarning("QZip: Z_MEM_ERROR: Not enough memory to compress file, skipping");
- data.resize(0);
- break;
- case Z_BUF_ERROR:
- len *= 2;
- break;
- }
- } while (res == Z_BUF_ERROR);
- }
-// TODO add a check if data.length() > contents.length(). Then try to store the original and revert the compression method to be uncompressed
- writeUInt(header.h.compressed_size, data.length());
- uint crc_32 = ::crc32(0, 0, 0);
- crc_32 = ::crc32(crc_32, (const uchar *)contents.constData(), contents.length());
- writeUInt(header.h.crc_32, crc_32);
-
- // if bit 11 is set, the filename and comment fields must be encoded using UTF-8
- ushort general_purpose_bits = Utf8Names; // always use utf-8
- writeUShort(header.h.general_purpose_bits, general_purpose_bits);
-
- const bool inUtf8 = (general_purpose_bits & Utf8Names) != 0;
- header.file_name = inUtf8 ? fileName.toUtf8() : fileName.toLocal8Bit();
- if (header.file_name.size() > 0xffff) {
- qWarning("QZip: Filename is too long, chopping it to 65535 bytes");
- header.file_name = header.file_name.left(0xffff); // ### don't break the utf-8 sequence, if any
- }
- if (header.file_comment.size() + header.file_name.size() > 0xffff) {
- qWarning("QZip: File comment is too long, chopping it to 65535 bytes");
- header.file_comment.truncate(0xffff - header.file_name.size()); // ### don't break the utf-8 sequence, if any
- }
- writeUShort(header.h.file_name_length, header.file_name.length());
- //h.extra_field_length[2];
-
- writeUShort(header.h.version_made, HostUnix << 8);
- //uchar internal_file_attributes[2];
- //uchar external_file_attributes[4];
- quint32 mode = permissionsToMode(permissions);
- switch (type) {
- case File: mode |= S_IFREG; break;
- case Directory: mode |= S_IFDIR; break;
- case Symlink: mode |= S_IFLNK; break;
- }
- writeUInt(header.h.external_file_attributes, mode << 16);
- writeUInt(header.h.offset_local_header, start_of_directory);
-
-
- fileHeaders.append(header);
-
- LocalFileHeader h = header.h.toLocalHeader();
- device->write((const char *)&h, sizeof(LocalFileHeader));
- device->write(header.file_name);
- device->write(data);
- start_of_directory = device->pos();
- dirtyFileTree = true;
-}
-
-////////////////////////////// Reader
-
-/*!
- \class QZipReader::FileInfo
- \internal
- Represents one entry in the zip table of contents.
-*/
-
-/*!
- \variable FileInfo::filePath
- The full filepath inside the archive.
-*/
-
-/*!
- \variable FileInfo::isDir
- A boolean type indicating if the entry is a directory.
-*/
-
-/*!
- \variable FileInfo::isFile
- A boolean type, if it is one this entry is a file.
-*/
-
-/*!
- \variable FileInfo::isSymLink
- A boolean type, if it is one this entry is symbolic link.
-*/
-
-/*!
- \variable FileInfo::permissions
- A list of flags for the permissions of this entry.
-*/
-
-/*!
- \variable FileInfo::crc
- The calculated checksum as a crc type.
-*/
-
-/*!
- \variable FileInfo::size
- The total size of the unpacked content.
-*/
-
-/*!
- \variable FileInfo::d
- \internal
- private pointer.
-*/
-
-/*!
- \class QZipReader
- \internal
- \since 4.5
-
- \brief the QZipReader class provides a way to inspect the contents of a zip
- archive and extract individual files from it.
-
- QZipReader can be used to read a zip archive either from a file or from any
- device. An in-memory QBuffer for instance. The reader can be used to read
- which files are in the archive using fileInfoList() and entryInfoAt() but
- also to extract individual files using fileData() or even to extract all
- files in the archive using extractAll()
-*/
-
-/*!
- Create a new zip archive that operates on the \a fileName. The file will be
- opened with the \a mode.
-*/
-QZipReader::QZipReader(const QString &archive, QIODevice::OpenMode mode)
-{
- QScopedPointer<QFile> f(new QFile(archive));
- f->open(mode);
- QZipReader::Status status;
- if (f->error() == QFile::NoError)
- status = NoError;
- else {
- if (f->error() == QFile::ReadError)
- status = FileReadError;
- else if (f->error() == QFile::OpenError)
- status = FileOpenError;
- else if (f->error() == QFile::PermissionsError)
- status = FilePermissionsError;
- else
- status = FileError;
- }
-
- d = new QZipReaderPrivate(f.data(), /*ownDevice=*/true);
- f.take();
- d->status = status;
-}
-
-/*!
- Create a new zip archive that operates on the archive found in \a device.
- You have to open the device previous to calling the constructor and only a
- device that is readable will be scanned for zip filecontent.
- */
-QZipReader::QZipReader(QIODevice *device)
- : d(new QZipReaderPrivate(device, /*ownDevice=*/false))
-{
- Q_ASSERT(device);
-}
-
-/*!
- Desctructor
-*/
-QZipReader::~QZipReader()
-{
- close();
- delete d;
-}
-
-/*!
- Returns device used for reading zip archive.
-*/
-QIODevice* QZipReader::device() const
-{
- return d->device;
-}
-
-/*!
- Returns \c true if the user can read the file; otherwise returns \c false.
-*/
-bool QZipReader::isReadable() const
-{
- return d->device->isReadable();
-}
-
-/*!
- Returns \c true if the file exists; otherwise returns \c false.
-*/
-bool QZipReader::exists() const
-{
- QFile *f = static_cast<QFile*> (d->device);
- if (f == 0)
- return true;
- return f->exists();
-}
-
-/*!
- Returns the list of files the archive contains.
-*/
-QList<QZipReader::FileInfo> QZipReader::fileInfoList() const
-{
- d->scanFiles();
- QList<QZipReader::FileInfo> files;
- for (int i = 0; i < d->fileHeaders.size(); ++i) {
- QZipReader::FileInfo fi;
- d->fillFileInfo(i, fi);
- files.append(fi);
- }
- return files;
-
-}
-
-/*!
- Return the number of items in the zip archive.
-*/
-int QZipReader::count() const
-{
- d->scanFiles();
- return d->fileHeaders.count();
-}
-
-/*!
- Returns a FileInfo of an entry in the zipfile.
- The \a index is the index into the directory listing of the zipfile.
- Returns an invalid FileInfo if \a index is out of boundaries.
-
- \sa fileInfoList()
-*/
-QZipReader::FileInfo QZipReader::entryInfoAt(int index) const
-{
- d->scanFiles();
- QZipReader::FileInfo fi;
- if (index >= 0 && index < d->fileHeaders.count())
- d->fillFileInfo(index, fi);
- return fi;
-}
-
-/*!
- Fetch the file contents from the zip archive and return the uncompressed bytes.
-*/
-QByteArray QZipReader::fileData(const QString &fileName) const
-{
- d->scanFiles();
- int i;
- for (i = 0; i < d->fileHeaders.size(); ++i) {
- if (QString::fromLocal8Bit(d->fileHeaders.at(i).file_name) == fileName)
- break;
- }
- if (i == d->fileHeaders.size())
- return QByteArray();
-
- FileHeader header = d->fileHeaders.at(i);
-
- ushort version_needed = readUShort(header.h.version_needed);
- if (version_needed > ZIP_VERSION) {
- qWarning("QZip: .ZIP specification version %d implementationis needed to extract the data.", version_needed);
- return QByteArray();
- }
-
- ushort general_purpose_bits = readUShort(header.h.general_purpose_bits);
- int compressed_size = readUInt(header.h.compressed_size);
- int uncompressed_size = readUInt(header.h.uncompressed_size);
- int start = readUInt(header.h.offset_local_header);
- //qDebug("uncompressing file %d: local header at %d", i, start);
-
- d->device->seek(start);
- LocalFileHeader lh;
- d->device->read((char *)&lh, sizeof(LocalFileHeader));
- uint skip = readUShort(lh.file_name_length) + readUShort(lh.extra_field_length);
- d->device->seek(d->device->pos() + skip);
-
- int compression_method = readUShort(lh.compression_method);
- //qDebug("file=%s: compressed_size=%d, uncompressed_size=%d", fileName.toLocal8Bit().data(), compressed_size, uncompressed_size);
-
- if ((general_purpose_bits & Encrypted) != 0) {
- qWarning("QZip: Unsupported encryption method is needed to extract the data.");
- return QByteArray();
- }
-
- //qDebug("file at %lld", d->device->pos());
- QByteArray compressed = d->device->read(compressed_size);
- if (compression_method == CompressionMethodStored) {
- // no compression
- compressed.truncate(uncompressed_size);
- return compressed;
- } else if (compression_method == CompressionMethodDeflated) {
- // Deflate
- //qDebug("compressed=%d", compressed.size());
- compressed.truncate(compressed_size);
- QByteArray baunzip;
- ulong len = qMax(uncompressed_size, 1);
- int res;
- do {
- baunzip.resize(len);
- res = inflate((uchar*)baunzip.data(), &len,
- (uchar*)compressed.constData(), compressed_size);
-
- switch (res) {
- case Z_OK:
- if ((int)len != baunzip.size())
- baunzip.resize(len);
- break;
- case Z_MEM_ERROR:
- qWarning("QZip: Z_MEM_ERROR: Not enough memory");
- break;
- case Z_BUF_ERROR:
- len *= 2;
- break;
- case Z_DATA_ERROR:
- qWarning("QZip: Z_DATA_ERROR: Input data is corrupted");
- break;
- }
- } while (res == Z_BUF_ERROR);
- return baunzip;
- }
-
- qWarning("QZip: Unsupported compression method %d is needed to extract the data.", compression_method);
- return QByteArray();
-}
-
-/*!
- Extracts the full contents of the zip file into \a destinationDir on
- the local filesystem.
- In case writing or linking a file fails, the extraction will be aborted.
-*/
-bool QZipReader::extractAll(const QString &destinationDir) const
-{
- QDir baseDir(destinationDir);
-
- // create directories first
- QList<FileInfo> allFiles = fileInfoList();
- foreach (const FileInfo &fi, allFiles) {
- const QString absPath = destinationDir + QDir::separator() + fi.filePath;
- if (fi.isDir) {
- if (!baseDir.mkpath(fi.filePath))
- return false;
- if (!QFile::setPermissions(absPath, fi.permissions))
- return false;
- }
- }
-
- // set up symlinks
- foreach (const FileInfo &fi, allFiles) {
- const QString absPath = destinationDir + QDir::separator() + fi.filePath;
- if (fi.isSymLink) {
- QString destination = QFile::decodeName(fileData(fi.filePath));
- if (destination.isEmpty())
- return false;
- QFileInfo linkFi(absPath);
- if (!QFile::exists(linkFi.absolutePath()))
- QDir::root().mkpath(linkFi.absolutePath());
- if (!QFile::link(destination, absPath))
- return false;
- /* cannot change permission of links
- if (!QFile::setPermissions(absPath, fi.permissions))
- return false;
- */
- }
- }
-
- foreach (const FileInfo &fi, allFiles) {
- const QString absPath = destinationDir + QDir::separator() + fi.filePath;
- if (fi.isFile) {
- QFile f(absPath);
- if (!f.open(QIODevice::WriteOnly))
- return false;
- f.write(fileData(fi.filePath));
- f.setPermissions(fi.permissions);
- f.close();
- }
- }
-
- return true;
-}
-
-/*!
- \enum QZipReader::Status
-
- The following status values are possible:
-
- \value NoError No error occurred.
- \value FileReadError An error occurred when reading from the file.
- \value FileOpenError The file could not be opened.
- \value FilePermissionsError The file could not be accessed.
- \value FileError Another file error occurred.
-*/
-
-/*!
- Returns a status code indicating the first error that was met by QZipReader,
- or QZipReader::NoError if no error occurred.
-*/
-QZipReader::Status QZipReader::status() const
-{
- return d->status;
-}
-
-/*!
- Close the zip file.
-*/
-void QZipReader::close()
-{
- d->device->close();
-}
-
-////////////////////////////// Writer
-
-/*!
- \class QZipWriter
- \internal
- \since 4.5
-
- \brief the QZipWriter class provides a way to create a new zip archive.
-
- QZipWriter can be used to create a zip archive containing any number of files
- and directories. The files in the archive will be compressed in a way that is
- compatible with common zip reader applications.
-*/
-
-
-/*!
- Create a new zip archive that operates on the \a archive filename. The file will
- be opened with the \a mode.
- \sa isValid()
-*/
-QZipWriter::QZipWriter(const QString &fileName, QIODevice::OpenMode mode)
-{
- QScopedPointer<QFile> f(new QFile(fileName));
- f->open(mode);
- QZipWriter::Status status;
- if (f->error() == QFile::NoError)
- status = QZipWriter::NoError;
- else {
- if (f->error() == QFile::WriteError)
- status = QZipWriter::FileWriteError;
- else if (f->error() == QFile::OpenError)
- status = QZipWriter::FileOpenError;
- else if (f->error() == QFile::PermissionsError)
- status = QZipWriter::FilePermissionsError;
- else
- status = QZipWriter::FileError;
- }
-
- d = new QZipWriterPrivate(f.data(), /*ownDevice=*/true);
- f.take();
- d->status = status;
-}
-
-/*!
- Create a new zip archive that operates on the archive found in \a device.
- You have to open the device previous to calling the constructor and
- only a device that is readable will be scanned for zip filecontent.
- */
-QZipWriter::QZipWriter(QIODevice *device)
- : d(new QZipWriterPrivate(device, /*ownDevice=*/false))
-{
- Q_ASSERT(device);
-}
-
-QZipWriter::~QZipWriter()
-{
- close();
- delete d;
-}
-
-/*!
- Returns device used for writing zip archive.
-*/
-QIODevice* QZipWriter::device() const
-{
- return d->device;
-}
-
-/*!
- Returns \c true if the user can write to the archive; otherwise returns \c false.
-*/
-bool QZipWriter::isWritable() const
-{
- return d->device->isWritable();
-}
-
-/*!
- Returns \c true if the file exists; otherwise returns \c false.
-*/
-bool QZipWriter::exists() const
-{
- QFile *f = static_cast<QFile*> (d->device);
- if (f == 0)
- return true;
- return f->exists();
-}
-
-/*!
- \enum QZipWriter::Status
-
- The following status values are possible:
-
- \value NoError No error occurred.
- \value FileWriteError An error occurred when writing to the device.
- \value FileOpenError The file could not be opened.
- \value FilePermissionsError The file could not be accessed.
- \value FileError Another file error occurred.
-*/
-
-/*!
- Returns a status code indicating the first error that was met by QZipWriter,
- or QZipWriter::NoError if no error occurred.
-*/
-QZipWriter::Status QZipWriter::status() const
-{
- return d->status;
-}
-
-/*!
- \enum QZipWriter::CompressionPolicy
-
- \value AlwaysCompress A file that is added is compressed.
- \value NeverCompress A file that is added will be stored without changes.
- \value AutoCompress A file that is added will be compressed only if that will give a smaller file.
-*/
-
-/*!
- Sets the policy for compressing newly added files to the new \a policy.
-
- \note the default policy is AlwaysCompress
-
- \sa compressionPolicy()
- \sa addFile()
-*/
-void QZipWriter::setCompressionPolicy(CompressionPolicy policy)
-{
- d->compressionPolicy = policy;
-}
-
-/*!
- Returns the currently set compression policy.
- \sa setCompressionPolicy()
- \sa addFile()
-*/
-QZipWriter::CompressionPolicy QZipWriter::compressionPolicy() const
-{
- return d->compressionPolicy;
-}
-
-/*!
- Sets the permissions that will be used for newly added files.
-
- \note the default permissions are QFile::ReadOwner | QFile::WriteOwner.
-
- \sa creationPermissions()
- \sa addFile()
-*/
-void QZipWriter::setCreationPermissions(QFile::Permissions permissions)
-{
- d->permissions = permissions;
-}
-
-/*!
- Returns the currently set creation permissions.
-
- \sa setCreationPermissions()
- \sa addFile()
-*/
-QFile::Permissions QZipWriter::creationPermissions() const
-{
- return d->permissions;
-}
-
-/*!
- Add a file to the archive with \a data as the file contents.
- The file will be stored in the archive using the \a fileName which
- includes the full path in the archive.
-
- The new file will get the file permissions based on the current
- creationPermissions and it will be compressed using the zip compression
- based on the current compression policy.
-
- \sa setCreationPermissions()
- \sa setCompressionPolicy()
-*/
-void QZipWriter::addFile(const QString &fileName, const QByteArray &data)
-{
- d->addEntry(QZipWriterPrivate::File, QDir::fromNativeSeparators(fileName), data);
-}
-
-/*!
- Add a file to the archive with \a device as the source of the contents.
- The contents returned from QIODevice::readAll() will be used as the
- filedata.
- The file will be stored in the archive using the \a fileName which
- includes the full path in the archive.
-*/
-void QZipWriter::addFile(const QString &fileName, QIODevice *device)
-{
- Q_ASSERT(device);
- QIODevice::OpenMode mode = device->openMode();
- bool opened = false;
- if ((mode & QIODevice::ReadOnly) == 0) {
- opened = true;
- if (! device->open(QIODevice::ReadOnly)) {
- d->status = FileOpenError;
- return;
- }
- }
- d->addEntry(QZipWriterPrivate::File, QDir::fromNativeSeparators(fileName), device->readAll());
- if (opened)
- device->close();
-}
-
-/*!
- Create a new directory in the archive with the specified \a dirName and
- the \a permissions;
-*/
-void QZipWriter::addDirectory(const QString &dirName)
-{
- QString name(QDir::fromNativeSeparators(dirName));
- // separator is mandatory
- if (!name.endsWith(QLatin1Char('/')))
- name.append(QLatin1Char('/'));
- d->addEntry(QZipWriterPrivate::Directory, name, QByteArray());
-}
-
-/*!
- Create a new symbolic link in the archive with the specified \a dirName
- and the \a permissions;
- A symbolic link contains the destination (relative) path and name.
-*/
-void QZipWriter::addSymLink(const QString &fileName, const QString &destination)
-{
- d->addEntry(QZipWriterPrivate::Symlink, QDir::fromNativeSeparators(fileName), QFile::encodeName(destination));
-}
-
-/*!
- Closes the zip file.
-*/
-void QZipWriter::close()
-{
- if (!(d->device->openMode() & QIODevice::WriteOnly)) {
- d->device->close();
- return;
- }
-
- //qDebug("QZip::close writing directory, %d entries", d->fileHeaders.size());
- d->device->seek(d->start_of_directory);
- // write new directory
- for (int i = 0; i < d->fileHeaders.size(); ++i) {
- const FileHeader &header = d->fileHeaders.at(i);
- d->device->write((const char *)&header.h, sizeof(CentralFileHeader));
- d->device->write(header.file_name);
- d->device->write(header.extra_field);
- d->device->write(header.file_comment);
- }
- int dir_size = d->device->pos() - d->start_of_directory;
- // write end of directory
- EndOfDirectory eod;
- memset(&eod, 0, sizeof(EndOfDirectory));
- writeUInt(eod.signature, 0x06054b50);
- //uchar this_disk[2];
- //uchar start_of_directory_disk[2];
- writeUShort(eod.num_dir_entries_this_disk, d->fileHeaders.size());
- writeUShort(eod.num_dir_entries, d->fileHeaders.size());
- writeUInt(eod.directory_size, dir_size);
- writeUInt(eod.dir_start_offset, d->start_of_directory);
- writeUShort(eod.comment_length, d->comment.length());
-
- d->device->write((const char *)&eod, sizeof(EndOfDirectory));
- d->device->write(d->comment);
- d->device->close();
-}
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_TEXTODFWRITER
diff --git a/src/winrtrunner/qzip/qzipreader_p.h b/src/winrtrunner/qzip/qzipreader_p.h
deleted file mode 100644
index 775611736..000000000
--- a/src/winrtrunner/qzip/qzipreader_p.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the tools module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef QZIPREADER_H
-#define QZIPREADER_H
-
-#include <QtCore/qglobal.h>
-
-#ifndef QT_NO_TEXTODFWRITER
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QZipReader class. This header file may change from
-// version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qdatetime.h>
-#include <QtCore/qfile.h>
-#include <QtCore/qstring.h>
-
-QT_BEGIN_NAMESPACE
-
-class QZipReaderPrivate;
-
-class Q_GUI_EXPORT QZipReader
-{
-public:
- explicit QZipReader(const QString &fileName, QIODevice::OpenMode mode = QIODevice::ReadOnly );
-
- explicit QZipReader(QIODevice *device);
- ~QZipReader();
-
- QIODevice* device() const;
-
- bool isReadable() const;
- bool exists() const;
-
- struct Q_GUI_EXPORT FileInfo
- {
- FileInfo();
- FileInfo(const FileInfo &other);
- ~FileInfo();
- FileInfo &operator=(const FileInfo &other);
- bool isValid() const;
- QString filePath;
- uint isDir : 1;
- uint isFile : 1;
- uint isSymLink : 1;
- QFile::Permissions permissions;
- uint crc;
- qint64 size;
- QDateTime lastModified;
- void *d;
- };
-
- QList<FileInfo> fileInfoList() const;
- int count() const;
-
- FileInfo entryInfoAt(int index) const;
- QByteArray fileData(const QString &fileName) const;
- bool extractAll(const QString &destinationDir) const;
-
- enum Status {
- NoError,
- FileReadError,
- FileOpenError,
- FilePermissionsError,
- FileError
- };
-
- Status status() const;
-
- void close();
-
-private:
- QZipReaderPrivate *d;
- Q_DISABLE_COPY(QZipReader)
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_TEXTODFWRITER
-#endif // QZIPREADER_H
diff --git a/src/winrtrunner/qzip/qzipwriter_p.h b/src/winrtrunner/qzip/qzipwriter_p.h
deleted file mode 100644
index a86661b2b..000000000
--- a/src/winrtrunner/qzip/qzipwriter_p.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the tools module of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#ifndef QZIPWRITER_H
-#define QZIPWRITER_H
-
-#include <QtCore/qglobal.h>
-
-#ifndef QT_NO_TEXTODFWRITER
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists for the convenience
-// of the QZipWriter class. This header file may change from
-// version to version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qstring.h>
-#include <QtCore/qfile.h>
-
-QT_BEGIN_NAMESPACE
-
-class QZipWriterPrivate;
-
-
-class Q_GUI_EXPORT QZipWriter
-{
-public:
- explicit QZipWriter(const QString &fileName, QIODevice::OpenMode mode = (QIODevice::WriteOnly | QIODevice::Truncate) );
-
- explicit QZipWriter(QIODevice *device);
- ~QZipWriter();
-
- QIODevice* device() const;
-
- bool isWritable() const;
- bool exists() const;
-
- enum Status {
- NoError,
- FileWriteError,
- FileOpenError,
- FilePermissionsError,
- FileError
- };
-
- Status status() const;
-
- enum CompressionPolicy {
- AlwaysCompress,
- NeverCompress,
- AutoCompress
- };
-
- void setCompressionPolicy(CompressionPolicy policy);
- CompressionPolicy compressionPolicy() const;
-
- void setCreationPermissions(QFile::Permissions permissions);
- QFile::Permissions creationPermissions() const;
-
- void addFile(const QString &fileName, const QByteArray &data);
-
- void addFile(const QString &fileName, QIODevice *device);
-
- void addDirectory(const QString &dirName);
-
- void addSymLink(const QString &fileName, const QString &destination);
-
- void close();
-private:
- QZipWriterPrivate *d;
- Q_DISABLE_COPY(QZipWriter)
-};
-
-QT_END_NAMESPACE
-
-#endif // QT_NO_TEXTODFWRITER
-#endif // QZIPWRITER_H
diff --git a/src/winrtrunner/runner.cpp b/src/winrtrunner/runner.cpp
index 6eb306c01..6d529b557 100644
--- a/src/winrtrunner/runner.cpp
+++ b/src/winrtrunner/runner.cpp
@@ -41,9 +41,6 @@
#ifndef RTRUNNER_NO_APPXLOCAL
#include "appxlocalengine.h"
#endif
-#ifndef RTRUNNER_NO_XAP
-#include "xapengine.h"
-#endif
#include <QtCore/QDir>
#include <QtCore/QStandardPaths>
@@ -78,9 +75,6 @@ QMap<QString, QStringList> Runner::deviceNames()
#ifndef RTRUNNER_NO_APPXPHONE
deviceNames.insert(QStringLiteral("Phone"), AppxPhoneEngine::deviceNames());
#endif
-#ifndef RTRUNNER_NO_XAP
- deviceNames.insert(QStringLiteral("Xap"), XapEngine::deviceNames());
-#endif
return deviceNames;
}
@@ -128,22 +122,6 @@ Runner::Runner(const QString &app, const QStringList &arguments,
}
}
#endif
-#ifndef RTRUNNER_NO_XAP
- if (!deviceIndexKnown) {
- d->deviceIndex = XapEngine::deviceNames().indexOf(deviceName);
- if (d->deviceIndex < 0)
- d->deviceIndex = 0;
- }
- if ((d->profile.isEmpty() || d->profile.toLower() == QStringLiteral("xap"))
- && XapEngine::canHandle(this)) {
- if (RunnerEngine *engine = XapEngine::create(this)) {
- d->engine.reset(engine);
- d->isValid = true;
- qCWarning(lcWinRtRunner) << "Using the Xap profile.";
- return;
- }
- }
-#endif
// Place other engines here
qCWarning(lcWinRtRunner) << "Unable to find a run profile for" << app << ".";
diff --git a/src/winrtrunner/winrtrunner.pro b/src/winrtrunner/winrtrunner.pro
index e1b59846a..cae2c5a85 100644
--- a/src/winrtrunner/winrtrunner.pro
+++ b/src/winrtrunner/winrtrunner.pro
@@ -6,33 +6,15 @@ DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII WINRT_LIBRARY
SOURCES += main.cpp runner.cpp
HEADERS += runner.h runnerengine.h
-DEFINES += RTRUNNER_NO_APPXLOCAL RTRUNNER_NO_APPXPHONE RTRUNNER_NO_XAP
+DEFINES += RTRUNNER_NO_APPXLOCAL RTRUNNER_NO_APPXPHONE
-win32-msvc2012|win32-msvc2013 {
- SOURCES += appxengine.cpp appxlocalengine.cpp
- HEADERS += appxengine.h appxengine_p.h appxlocalengine.h
- LIBS += -lruntimeobject -lwsclient -lShlwapi
- DEFINES -= RTRUNNER_NO_APPXLOCAL
+win32-msvc2013 {
+ SOURCES += appxengine.cpp appxlocalengine.cpp appxphoneengine.cpp
+ HEADERS += appxengine.h appxengine_p.h appxlocalengine.h appxphoneengine.h
+ LIBS += -lruntimeobject -lwsclient -lShlwapi -lurlmon -lxmllite
+ DEFINES -= RTRUNNER_NO_APPXLOCAL RTRUNNER_NO_APPXPHONE
include(../shared/corecon/corecon.pri)
- SOURCES += xapengine.cpp
- HEADERS += xapengine.h
- DEFINES -= RTRUNNER_NO_XAP
-
- win32-msvc2013 {
- LIBS += -lurlmon -lxmllite
- SOURCES += appxphoneengine.cpp
- HEADERS += appxphoneengine.h
- DEFINES -= RTRUNNER_NO_APPXPHONE
- }
-
- # Use zip class from qtbase
- SOURCES += \
- qzip/qzip.cpp
- HEADERS += \
- qzip/qzipreader_p.h \
- qzip/qzipwriter_p.h
- INCLUDEPATH += qzip $$[QT_INSTALL_HEADERS/get]/QtZlib
}
load(qt_tool)
diff --git a/src/winrtrunner/xapengine.cpp b/src/winrtrunner/xapengine.cpp
deleted file mode 100644
index cc7256dff..000000000
--- a/src/winrtrunner/xapengine.cpp
+++ /dev/null
@@ -1,640 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include "xapengine.h"
-
-#include <QtCore/QDir>
-#include <QtCore/QDirIterator>
-#include <QtCore/QFile>
-#include <QtCore/QFileInfo>
-#include <QtCore/QHash>
-#include <QtCore/QUuid>
-#include <QtCore/QLoggingCategory>
-#ifndef RTRUNNER_NO_ZIP
-# include <qzipwriter_p.h>
-#endif
-
-#include <comdef.h>
-#include <psapi.h>
-#include <wrl.h>
-using namespace Microsoft::WRL;
-
-QT_USE_NAMESPACE
-
-#include <ccapi_11.h>
-#include <corecon.h>
-Q_GLOBAL_STATIC_WITH_ARGS(CoreConServer, coreConServer, (11))
-
-#define wchar(str) reinterpret_cast<LPCWSTR>(str.utf16())
-
-// Set a break handler for gracefully breaking long-running ops
-static bool g_ctrlReceived = false;
-static bool g_handleCtrl = false;
-static BOOL WINAPI ctrlHandler(DWORD type)
-{
- switch (type) {
- case CTRL_C_EVENT:
- case CTRL_CLOSE_EVENT:
- case CTRL_LOGOFF_EVENT:
- g_ctrlReceived = g_handleCtrl;
- return g_handleCtrl;
- case CTRL_BREAK_EVENT:
- case CTRL_SHUTDOWN_EVENT:
- default:
- break;
- }
- return false;
-}
-
-class XapEnginePrivate
-{
-public:
- Runner *runner;
- bool hasFatalError;
-
- QString manifest;
- QString genre;
- QString productId;
- QString executable;
- QString relativeExecutable;
- QStringList icons;
- qint64 pid;
- DWORD exitCode;
-
- ComPtr<ICcConnection> connection;
- CoreConDevice *device;
- QHash<QString, QString> installedApps;
-};
-
-static inline bool getManifestFile(const QString &fileName, QString *manifest = 0)
-{
- if (!QFile::exists(fileName)) {
- qCWarning(lcWinRtRunner) << fileName << "doesn't exist.";
- return false;
- }
-
- // If it looks like an winphone manifest, we're done
- if (fileName.endsWith(QStringLiteral("WMAppManifest.xml"))) {
- if (manifest)
- *manifest = fileName;
- return true;
- }
-
- // If it looks like an executable, check that manifest is next to it
- if (fileName.endsWith(QStringLiteral(".exe"))) {
- const QString manifestFileName = QFileInfo(fileName).absoluteDir()
- .absoluteFilePath(QStringLiteral("WMAppManifest.xml"));
- if (!QFile::exists(manifestFileName)) {
- qCWarning(lcWinRtRunner) << fileName << "doesn't exist.";
- return false;
- }
- if (manifest)
- *manifest = manifestFileName;
- return true;
- }
-
- // TODO: handle already-built package as well
-
- return false;
-}
-
-bool XapEngine::canHandle(Runner *runner)
-{
- return getManifestFile(runner->app());
-}
-
-RunnerEngine *XapEngine::create(Runner *runner)
-{
- XapEngine *engine = new XapEngine(runner);
- if (engine->d_ptr->hasFatalError) {
- delete engine;
- return 0;
- }
-
- return engine;
-}
-
-QStringList XapEngine::deviceNames()
-{
- QStringList deviceNames;
- foreach (const CoreConDevice *device, coreConServer->devices())
- deviceNames.append(device->name());
- return deviceNames;
-}
-
-XapEngine::XapEngine(Runner *runner)
- : d_ptr(new XapEnginePrivate)
-{
- Q_D(XapEngine);
- d->runner = runner;
- d->hasFatalError = false;
- d->pid = -1;
- d->exitCode = UINT_MAX;
-
- if (!getManifestFile(runner->app(), &d->manifest)) {
- d->hasFatalError = true;
- qCWarning(lcWinRtRunner) << "Unable to determine manifest file from" << runner->app();
- return;
- }
-
- // Examine manifest
- QFile manifestFile(d->manifest);
- if (!manifestFile.open(QFile::ReadOnly)) {
- qCWarning(lcWinRtRunner) << "Unable to open manifest:" << manifestFile.errorString();
- return;
- }
- const QString contents = QString::fromUtf8(manifestFile.readAll());
-
- // Product ID
- QRegExp productIdPattern(QStringLiteral("ProductID=\"(\\{[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}\\})\""));
- if (productIdPattern.indexIn(contents) < 0) {
- d->hasFatalError = true;
- qCWarning(lcWinRtRunner) << "Unable to determine product ID in manifest:" << d->manifest;
- return;
- }
- d->productId = productIdPattern.cap(1);
-
- // Executable
- QRegExp executablePattern(QStringLiteral("ImagePath=\"([a-zA-Z0-9_-]*\\.exe)\""));
- if (executablePattern.indexIn(contents) < 0) {
- d->hasFatalError = true;
- qCWarning(lcWinRtRunner) << "Unable to determine executable in manifest: " << d->manifest;
- return;
- }
- d->relativeExecutable = executablePattern.cap(1);
- d->executable = QFileInfo(d->manifest).absoluteDir().absoluteFilePath(d->relativeExecutable);
-
- // Icons
- QRegExp iconPattern(QStringLiteral("[\\\\/a-zA-Z0-9_\\-\\!]*\\.(png|jpg|jpeg)"));
- int iconIndex = 0;
- while ((iconIndex = iconPattern.indexIn(contents, iconIndex)) >= 0) {
- const QString icon = iconPattern.cap(0);
- d->icons.append(icon);
- iconIndex += icon.length();
- }
- // At least the first icon is required
- if (d->icons.isEmpty()) {
- d->hasFatalError = true;
- qCWarning(lcWinRtRunner) << "The application icon was not specified in the manifest.";
- return;
- }
-
- // Genre
- QRegExp genrePattern(QStringLiteral("Genre=\"(apps\\.(?:normal|games))\""));
- if (genrePattern.indexIn(contents) < 0) {
- d->hasFatalError = true;
- qCWarning(lcWinRtRunner) << "The application genre was not specified in the manifest.";
- return;
- }
- d->genre = genrePattern.cap(1);
-
- // Get the device
- d->device = coreConServer->devices().value(d->runner->deviceIndex());
- if (!d->device->handle()) {
- d->hasFatalError = true;
- qCWarning(lcWinRtRunner) << "Invalid device specified." << d->manifest;
- return;
- }
-
- // Set a break handler for gracefully exiting from long-running operations
- SetConsoleCtrlHandler(&ctrlHandler, true);
-}
-
-XapEngine::~XapEngine()
-{
-}
-
-bool XapEngine::connect()
-{
- Q_D(XapEngine);
- qCDebug(lcWinRtRunner) << __FUNCTION__;
-
- HRESULT hr;
- if (!d->connection) {
- _bstr_t connectionName;
- hr = static_cast<ICcServer *>(coreConServer->handle())->GetConnection(
- static_cast<ICcDevice *>(d->device->handle()), 5000, NULL, connectionName.GetAddress(), &d->connection);
- if (FAILED(hr)) {
- qCWarning(lcWinRtRunner) << "Unable to connect to device." << coreConServer->formatError(hr);
- return false;
- }
- }
-
- VARIANT_BOOL connected;
- hr = d->connection->IsConnected(&connected);
- if (FAILED(hr)) {
- qCWarning(lcWinRtRunner) << "Unable to determine connection state." << coreConServer->formatError(hr);
- return false;
- }
- if (connected)
- return true;
-
- hr = d->connection->ConnectDevice();
- if (FAILED(hr)) {
- qCWarning(lcWinRtRunner) << "Unable to connect to device." << coreConServer->formatError(hr);
- return false;
- }
-
- // Enumerate apps for later comparison
- ComPtr<ICcConnection3> connection;
- hr = d->connection.As(&connection);
- if (FAILED(hr)) {
- qCWarning(lcWinRtRunner) << "Unable to obtain connection object." << coreConServer->formatError(hr);
- return false;
- }
-
- SAFEARRAY *productIds, *instanceIds;
- hr = connection->GetInstalledApplicationIDs(&productIds, &instanceIds);
- if (FAILED(hr)) {
- qCWarning(lcWinRtRunner) << "Unable to get installed applications" << coreConServer->formatError(hr);
- return false;
- }
- d->installedApps.clear();
- if (productIds && instanceIds && productIds->rgsabound[0].cElements == instanceIds->rgsabound[0].cElements) {
- for (ulong i = 0; i < productIds->rgsabound[0].cElements; ++i) {
- LONG indices[] = { i };
- _bstr_t productId;
- _bstr_t instanceId;
- if (SUCCEEDED(SafeArrayGetElement(productIds, indices, productId.GetAddress()))
- && SUCCEEDED(SafeArrayGetElement(instanceIds, indices, instanceId.GetAddress()))) {
- d->installedApps.insert(QString::fromWCharArray(productId),
- QString::fromWCharArray(instanceId));
- }
- }
- SafeArrayDestroy(productIds);
- SafeArrayDestroy(instanceIds);
- }
- return SUCCEEDED(hr);
-}
-
-uint XapEngine::fetchPid()
-{
- Q_D(XapEngine);
- qCDebug(lcWinRtRunner) << __FUNCTION__;
-
- ComPtr<ICcConnection4> connection;
- HRESULT hr = d->connection.As(&connection);
-
- // Fetch the PID file from the remote directory
- QString dir = devicePath(QString());
- _bstr_t remoteDir(wchar(dir));
- SAFEARRAY *listing;
- hr = connection->GetDirectoryListing(remoteDir, &listing);
- if (FAILED(hr)) {
- qCWarning(lcWinRtRunner) << "Unable to obtain directory listing.";
- return 0;
- }
- uint pid = 0;
- if (listing) {
- for (ulong i = 0; i < listing->rgsabound[0].cElements; ++i) {
- LONG indices[] = { i };
- _bstr_t fileName;
- if (SUCCEEDED(SafeArrayGetElement(listing, indices, fileName.GetAddress()))) {
- QString possiblePidFile = QString::fromWCharArray(fileName);
- if (possiblePidFile.endsWith(QStringLiteral(".pid"))) {
- bool ok;
- pid = possiblePidFile.mid(0, possiblePidFile.length() - 4).toUInt(&ok);
- if (ok) {
- QString pidFile = dir + QLatin1Char('\\') + possiblePidFile;
- FileInfo fileInfo;
- hr = d->connection->GetFileInfo(_bstr_t(wchar(pidFile)), &fileInfo);
- if (FAILED(hr)) {
- qCWarning(lcWinRtRunner) << "Unable to obtain file info for the process ID.";
- return 0;
- }
- d->pid = pid;
- break;
- }
- }
- }
- }
- }
- return pid;
-}
-
-bool XapEngine::install(bool removeFirst)
-{
- Q_D(XapEngine);
- qCDebug(lcWinRtRunner) << __FUNCTION__;
-
- if (!connect())
- return false;
-
- ComPtr<ICcConnection3> connection;
- HRESULT hr = d->connection.As(&connection);
- if (FAILED(hr)) {
- qCWarning(lcWinRtRunner) << "Unable to obtain connection object." << coreConServer->formatError(hr);
- return false;
- }
-
- _bstr_t app = wchar(d->productId);
- VARIANT_BOOL isInstalled;
- hr = connection->IsApplicationInstalled(app, &isInstalled);
- if (isInstalled) {
- if (!removeFirst)
- return true;
- if (!remove())
- return false;
- }
-
- // Check for package map, or create one if needed
- QDir base = QFileInfo(d->manifest).absoluteDir();
- QFile xapFile(base.absoluteFilePath(d->productId + QStringLiteral(".xap")));
- if (!xapFile.open(QFile::ReadWrite)) {
- qCWarning(lcWinRtRunner) << "Unable to open Xap for writing: " << xapFile.errorString();
- return false;
- }
-
- QHash<QString, QString> xapFiles;
- QFile mappingFile(base.absoluteFilePath(QStringLiteral("WMAppManifest.map")));
- if (mappingFile.exists()) {
- if (mappingFile.open(QFile::ReadOnly)) {
- QRegExp pattern(QStringLiteral("^\"([^\"]*)\"\\s*\"([^\"]*)\"$"));
- bool inFileSection = false;
- while (!mappingFile.atEnd()) {
- const QString line = QString::fromUtf8(mappingFile.readLine()).trimmed();
- if (line.startsWith(QLatin1Char('['))) {
- inFileSection = line == QStringLiteral("[Files]");
- continue;
- }
- if (inFileSection && pattern.indexIn(line) >= 0 && pattern.captureCount() == 2)
- xapFiles.insert(pattern.cap(1), pattern.cap(2));
- }
- } else {
- qCWarning(lcWinRtRunner) << "Found, but unable to open mapping file.";
- }
- } else {
- qCWarning(lcWinRtRunner) << "No mapping file exists. Only recognized files will be packaged.";
- // Add manifest
- xapFiles.insert(d->manifest, QFileInfo(d->manifest).fileName());
- // Add executable
- xapFiles.insert(d->executable, QFileInfo(d->executable).fileName());
- // Add icons
- foreach (const QString &icon, d->icons)
- xapFiles.insert(base.absoluteFilePath(icon), icon);
- // Add potential Qt files
- const QStringList fileTypes = QStringList()
- << QStringLiteral("*.dll") << QStringLiteral("*.png") << QStringLiteral("*.qm")
- << QStringLiteral("*.qml") << QStringLiteral("*.qmldir");
- QDirIterator dirIterator(base.absolutePath(), fileTypes, QDir::Files, QDirIterator::Subdirectories);
- while (dirIterator.hasNext()) {
- const QString filePath = dirIterator.next();
- xapFiles.insert(filePath, base.relativeFilePath(filePath));
- }
- }
-
- QZipWriter xapPackage(&xapFile);
- for (QHash<QString, QString>::const_iterator i = xapFiles.begin(); i != xapFiles.end(); ++i) {
- QFile file(i.key());
- if (!file.open(QFile::ReadOnly))
- continue;
-
- if (QFileInfo(i.key()) == QFileInfo(d->manifest)) {
- const QStringList args = QStringList(d->relativeExecutable)
- << d->runner->arguments() << QStringLiteral("-qdevel");
- QByteArray manifestWithArgs = file.readAll();
- manifestWithArgs.replace(QByteArrayLiteral("ImageParams=\"\""),
- QByteArrayLiteral("ImageParams=\"")
- + args.join(QLatin1Char(' ')).toUtf8()
- + '"');
- xapPackage.addFile(i.value(), manifestWithArgs);
- continue;
- }
- xapPackage.addFile(i.value(), &file);
- }
- xapPackage.close();
-
- _bstr_t productId(wchar(d->productId));
- QString uuid = QUuid::createUuid().toString();
- _bstr_t instanceId(wchar(uuid));
- _bstr_t genre(wchar(d->genre));
- _bstr_t iconPath(wchar(QDir::toNativeSeparators(base.absoluteFilePath(d->icons.first()))));
- _bstr_t xapPath(wchar(QDir::toNativeSeparators(xapFile.fileName())));
- hr = connection->InstallApplication(productId, instanceId, genre, iconPath, xapPath);
- if (FAILED(hr)) {
- qCWarning(lcWinRtRunner) << "Unable to install application." << coreConServer->formatError(hr);
- return false;
- }
- d->installedApps.insert(d->productId, uuid);
- return true;
-}
-
-bool XapEngine::remove()
-{
- Q_D(XapEngine);
- qCDebug(lcWinRtRunner) << __FUNCTION__;
-
- if (!connect())
- return false;
-
- if (!d->connection)
- return false;
-
- ComPtr<ICcConnection3> connection;
- HRESULT hr = d->connection.As(&connection);
- if (FAILED(hr)) {
- qCWarning(lcWinRtRunner) << "Unable to obtain connection object." << coreConServer->formatError(hr);
- return false;
- }
-
- _bstr_t app = wchar(d->productId);
- hr = connection->UninstallApplication(app);
- if (FAILED(hr)) {
- qCWarning(lcWinRtRunner) << "Unable to uninstall the package." << coreConServer->formatError(hr);
- return false;
- }
-
- return true;
-}
-
-bool XapEngine::start()
-{
- Q_D(XapEngine);
- qCDebug(lcWinRtRunner) << __FUNCTION__;
-
- if (!connect())
- return false;
-
- ComPtr<ICcConnection3> connection;
- HRESULT hr = d->connection.As(&connection);
- if (FAILED(hr)) {
- qCWarning(lcWinRtRunner) << "Unable to obtain connection object." << coreConServer->formatError(hr);
- return false;
- }
-
- _bstr_t productId(wchar(d->productId));
- DWORD pid = 0;
- hr = connection->LaunchApplication(productId, &pid);
- if (FAILED(hr)) {
- qCWarning(lcWinRtRunner) << "Unable to start the package." << coreConServer->formatError(hr);
- return false;
- }
-
- // Wait up to 5 seconds for PID to appear
- int count = 0;
- while (!pid && count++ < 50) {
- Sleep(100); // Normally appears within first 100ms
- pid = fetchPid();
- }
- if (pid)
- d->pid = pid;
-
- return true;
-}
-
-bool XapEngine::enableDebugging(const QString &debuggerExecutable, const QString &debuggerArguments)
-{
- Q_UNUSED(debuggerExecutable);
- Q_UNUSED(debuggerArguments);
- return false;
-}
-
-bool XapEngine::disableDebugging()
-{
- return false;
-}
-
-bool XapEngine::suspend()
-{
- qCDebug(lcWinRtRunner) << __FUNCTION__;
-
- return false;
-}
-
-bool XapEngine::waitForFinished(int secs)
-{
- qCDebug(lcWinRtRunner) << __FUNCTION__;
-
- g_handleCtrl = true;
- int time = 0;
- forever {
- if (!fetchPid())
- break;
-
- ++time;
- if ((secs && time > secs) || g_ctrlReceived) {
- g_handleCtrl = false;
- return false;
- }
-
- Sleep(1000); // Wait one second between checks
- qCDebug(lcWinRtRunner) << "Waiting for app to quit - msecs to go: " << secs - time;
- }
- g_handleCtrl = false;
- return true;
-}
-
-bool XapEngine::stop()
-{
- Q_D(XapEngine);
- qCDebug(lcWinRtRunner) << __FUNCTION__;
-
- if (!connect())
- return false;
-
- ComPtr<ICcConnection3> connection;
- HRESULT hr = d->connection.As(&connection);
- if (FAILED(hr)) {
- qCWarning(lcWinRtRunner) << "Unable to obtain connection object." << coreConServer->formatError(hr);
- return false;
- }
-
- hr = connection->TerminateRunningApplicationInstances(_bstr_t(wchar(d->productId)));
- if (FAILED(hr)) {
- qCWarning(lcWinRtRunner) << "Unable to stop the package." << coreConServer->formatError(hr);
- return false;
- }
-
- return true;
-}
-
-qint64 XapEngine::pid() const
-{
- Q_D(const XapEngine);
- qCDebug(lcWinRtRunner) << __FUNCTION__;
-
- return d->pid;
-}
-
-int XapEngine::exitCode() const
-{
- // So far, no working implementation
- return -1;
-}
-
-QString XapEngine::executable() const
-{
- Q_D(const XapEngine);
- qCDebug(lcWinRtRunner) << __FUNCTION__;
-
- return d->executable;
-}
-
-QString XapEngine::devicePath(const QString &relativePath) const
-{
- Q_D(const XapEngine);
- qCDebug(lcWinRtRunner) << __FUNCTION__;
-
- return QStringLiteral("%FOLDERID_APPID_ISOROOT%\\") + d->productId
- + QStringLiteral("\\") + relativePath;
-}
-
-bool XapEngine::sendFile(const QString &localFile, const QString &deviceFile)
-{
- Q_D(const XapEngine);
- qCDebug(lcWinRtRunner) << __FUNCTION__;
-
- HRESULT hr = d->connection->SendFile(_bstr_t(wchar(localFile)), _bstr_t(wchar(deviceFile)),
- CREATE_ALWAYS, NULL);
- if (FAILED(hr)) {
- qCWarning(lcWinRtRunner) << "Unable to send the file." << coreConServer->formatError(hr);
- return false;
- }
-
- return true;
-}
-
-bool XapEngine::receiveFile(const QString &deviceFile, const QString &localFile)
-{
- Q_D(const XapEngine);
- qCDebug(lcWinRtRunner) << __FUNCTION__;
-
- HRESULT hr = d->connection->ReceiveFile(_bstr_t(wchar(deviceFile)),
- _bstr_t(wchar(localFile)), uint(2));
- if (FAILED(hr)) {
- qCWarning(lcWinRtRunner) << "Unable to receive the file." << coreConServer->formatError(hr);
- return false;
- }
-
- return true;
-}
diff --git a/src/winrtrunner/xapengine.h b/src/winrtrunner/xapengine.h
deleted file mode 100644
index ae28168b8..000000000
--- a/src/winrtrunner/xapengine.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the tools applications of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#ifndef XAPENGINE_H
-#define XAPENGINE_H
-
-#include "runnerengine.h"
-#include "runner.h"
-
-#include <QtCore/QScopedPointer>
-
-QT_USE_NAMESPACE
-
-class XapEnginePrivate;
-class XapEngine : public RunnerEngine
-{
-public:
- static bool canHandle(Runner *runner);
- static RunnerEngine *create(Runner *runner);
- static QStringList deviceNames();
-
- bool install(bool removeFirst = false) Q_DECL_OVERRIDE;
- bool remove() Q_DECL_OVERRIDE;
- bool start() Q_DECL_OVERRIDE;
- bool enableDebugging(const QString &debuggerExecutable,
- const QString &debuggerArguments) Q_DECL_OVERRIDE;
- bool disableDebugging() Q_DECL_OVERRIDE;
- bool suspend() Q_DECL_OVERRIDE;
- bool waitForFinished(int secs) Q_DECL_OVERRIDE;
- bool stop() Q_DECL_OVERRIDE;
- qint64 pid() const Q_DECL_OVERRIDE;
- int exitCode() const Q_DECL_OVERRIDE;
-
- QString executable() const Q_DECL_OVERRIDE;
- QString devicePath(const QString &relativePath) const Q_DECL_OVERRIDE;
- bool sendFile(const QString &localFile, const QString &deviceFile) Q_DECL_OVERRIDE;
- bool receiveFile(const QString &deviceFile, const QString &localFile) Q_DECL_OVERRIDE;
-
-private:
- explicit XapEngine(Runner *runner);
- ~XapEngine();
-
- uint fetchPid();
- bool connect();
-
- QScopedPointer<XapEnginePrivate> d_ptr;
- Q_DECLARE_PRIVATE(XapEngine)
-};
-
-#endif // XAPENGINE_H