Move IDeviceFactory closer to IDevice implementation

Except for the DesktopDevice, which is kind of special. Also try
a bit to make (and partially fail at doing so) naming and code
structure (#include, use of namespaces) more similar to each other.

Change-Id: I9fe266e706b72c14f59ff03ca1ae02dba3adcc71
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-02-20 19:13:28 +01:00
parent 317ab49793
commit 9e965409d1
44 changed files with 492 additions and 910 deletions

View File

@@ -23,7 +23,6 @@ HEADERS += \
androidcreatekeystorecertificate.h \ androidcreatekeystorecertificate.h \
javaparser.h \ javaparser.h \
androidplugin.h \ androidplugin.h \
androiddevicefactory.h \
androiddevice.h \ androiddevice.h \
androidgdbserverkitinformation.h \ androidgdbserverkitinformation.h \
androidqmltoolingsupport.h \ androidqmltoolingsupport.h \
@@ -70,7 +69,6 @@ SOURCES += \
androidcreatekeystorecertificate.cpp \ androidcreatekeystorecertificate.cpp \
javaparser.cpp \ javaparser.cpp \
androidplugin.cpp \ androidplugin.cpp \
androiddevicefactory.cpp \
androiddevice.cpp \ androiddevice.cpp \
androidgdbserverkitinformation.cpp \ androidgdbserverkitinformation.cpp \
androidqmltoolingsupport.cpp \ androidqmltoolingsupport.cpp \

View File

@@ -46,8 +46,6 @@ Project {
"androiddevicedialog.ui", "androiddevicedialog.ui",
"androiddevice.cpp", "androiddevice.cpp",
"androiddevice.h", "androiddevice.h",
"androiddevicefactory.cpp",
"androiddevicefactory.h",
"androiderrormessage.h", "androiderrormessage.h",
"androiderrormessage.cpp", "androiderrormessage.cpp",
"androidextralibrarylistmodel.cpp", "androidextralibrarylistmodel.cpp",

View File

@@ -103,5 +103,18 @@ QUrl AndroidDevice::toolControlChannel(const ControlChannelHint &) const
return url; return url;
} }
// Factory
AndroidDeviceFactory::AndroidDeviceFactory()
: ProjectExplorer::IDeviceFactory(Constants::ANDROID_DEVICE_TYPE)
{
setObjectName(QLatin1String("AndroidDeviceFactory"));
setDisplayName(tr("Android Device"));
setCombinedIcon(":/android/images/androiddevicesmall.png",
":/android/images/androiddevice.png");
setConstructionFunction(&AndroidDevice::create);
}
} // namespace Internal } // namespace Internal
} // namespace Android } // namespace Android

View File

@@ -26,6 +26,7 @@
#pragma once #pragma once
#include <projectexplorer/devicesupport/idevice.h> #include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/devicesupport/idevicefactory.h>
namespace Android { namespace Android {
namespace Internal { namespace Internal {
@@ -50,5 +51,12 @@ private:
QUrl toolControlChannel(const ControlChannelHint &) const override; QUrl toolControlChannel(const ControlChannelHint &) const override;
}; };
class AndroidDeviceFactory : public ProjectExplorer::IDeviceFactory
{
Q_OBJECT
public:
AndroidDeviceFactory();
};
} // namespace Internal } // namespace Internal
} // namespace Android } // namespace Android

View File

@@ -1,45 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 BogDan Vatra <bog_dan_ro@yahoo.com>
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** 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 https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "androiddevicefactory.h"
#include "androiddevice.h"
#include "androidconstants.h"
namespace Android {
namespace Internal {
AndroidDeviceFactory::AndroidDeviceFactory()
: ProjectExplorer::IDeviceFactory(Constants::ANDROID_DEVICE_TYPE)
{
setObjectName(QLatin1String("AndroidDeviceFactory"));
setDisplayName(tr("Android Device"));
setCombinedIcon(":/android/images/androiddevicesmall.png",
":/android/images/androiddevice.png");
setConstructionFunction(&AndroidDevice::create);
}
} // namespace Internal
} // namespace Android

View File

@@ -1,41 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 BogDan Vatra <bog_dan_ro@yahoo.com>
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** 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 https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include <projectexplorer/devicesupport/idevicefactory.h>
namespace Android {
namespace Internal {
class AndroidDeviceFactory : public ProjectExplorer::IDeviceFactory
{
Q_OBJECT
public:
AndroidDeviceFactory();
};
} // namespace Internal
} // namespace Android

View File

@@ -30,7 +30,6 @@
#include "androiddebugsupport.h" #include "androiddebugsupport.h"
#include "androiddeployqtstep.h" #include "androiddeployqtstep.h"
#include "androiddevice.h" #include "androiddevice.h"
#include "androiddevicefactory.h"
#include "androidgdbserverkitinformation.h" #include "androidgdbserverkitinformation.h"
#include "androidmanager.h" #include "androidmanager.h"
#include "androidmanifesteditorfactory.h" #include "androidmanifesteditorfactory.h"

View File

@@ -11,7 +11,6 @@ SOURCES += baremetalplugin.cpp \
baremetaldeviceconfigurationwizardpages.cpp \ baremetaldeviceconfigurationwizardpages.cpp \
baremetaldeviceconfigurationwizard.cpp \ baremetaldeviceconfigurationwizard.cpp \
baremetaldeviceconfigurationwidget.cpp \ baremetaldeviceconfigurationwidget.cpp \
baremetaldeviceconfigurationfactory.cpp \
baremetaldebugsupport.cpp \ baremetaldebugsupport.cpp \
gdbserverproviderprocess.cpp \ gdbserverproviderprocess.cpp \
gdbserverproviderssettingspage.cpp \ gdbserverproviderssettingspage.cpp \
@@ -28,7 +27,6 @@ HEADERS += baremetalplugin.h \
baremetaldevice.h \ baremetaldevice.h \
baremetalrunconfiguration.h \ baremetalrunconfiguration.h \
baremetalgdbcommandsdeploystep.h \ baremetalgdbcommandsdeploystep.h \
baremetaldeviceconfigurationfactory.h \
baremetaldeviceconfigurationwidget.h \ baremetaldeviceconfigurationwidget.h \
baremetaldeviceconfigurationwizard.h \ baremetaldeviceconfigurationwizard.h \
baremetaldeviceconfigurationwizardpages.h \ baremetaldeviceconfigurationwizardpages.h \

View File

@@ -16,7 +16,6 @@ QtcPlugin {
"baremetalconstants.h", "baremetalconstants.h",
"baremetalcustomrunconfiguration.cpp", "baremetalcustomrunconfiguration.h", "baremetalcustomrunconfiguration.cpp", "baremetalcustomrunconfiguration.h",
"baremetaldevice.cpp", "baremetaldevice.h", "baremetaldevice.cpp", "baremetaldevice.h",
"baremetaldeviceconfigurationfactory.cpp", "baremetaldeviceconfigurationfactory.h",
"baremetaldeviceconfigurationwidget.cpp", "baremetaldeviceconfigurationwidget.h", "baremetaldeviceconfigurationwidget.cpp", "baremetaldeviceconfigurationwidget.h",
"baremetaldeviceconfigurationwizard.cpp", "baremetaldeviceconfigurationwizard.h", "baremetaldeviceconfigurationwizard.cpp", "baremetaldeviceconfigurationwizard.h",
"baremetaldeviceconfigurationwizardpages.cpp", "baremetaldeviceconfigurationwizardpages.h", "baremetaldeviceconfigurationwizardpages.cpp", "baremetaldeviceconfigurationwizardpages.h",

View File

@@ -25,7 +25,10 @@
****************************************************************************/ ****************************************************************************/
#include "baremetaldevice.h" #include "baremetaldevice.h"
#include "baremetalconstants.h"
#include "baremetaldeviceconfigurationwidget.h" #include "baremetaldeviceconfigurationwidget.h"
#include "baremetaldeviceconfigurationwizard.h"
#include "defaultgdbserverprovider.h" #include "defaultgdbserverprovider.h"
#include "gdbserverprovidermanager.h" #include "gdbserverprovidermanager.h"
#include "gdbserverproviderprocess.h" #include "gdbserverproviderprocess.h"
@@ -160,5 +163,26 @@ BareMetalDevice::BareMetalDevice(const BareMetalDevice &other)
setGdbServerProviderId(other.gdbServerProviderId()); setGdbServerProviderId(other.gdbServerProviderId());
} }
// Factory
BareMetalDeviceFactory::BareMetalDeviceFactory()
: IDeviceFactory(Constants::BareMetalOsType)
{
setDisplayName(tr("Bare Metal Device"));
setCombinedIcon(":/baremetal/images/baremetaldevicesmall.png",
":/baremetal/images/baremetaldevice.png");
setCanCreate(true);
setConstructionFunction(&BareMetalDevice::create);
}
IDevice::Ptr BareMetalDeviceFactory::create() const
{
BareMetalDeviceConfigurationWizard wizard;
if (wizard.exec() != QDialog::Accepted)
return IDevice::Ptr();
return wizard.device();
}
} //namespace Internal } //namespace Internal
} //namespace BareMetal } //namespace BareMetal

View File

@@ -27,6 +27,7 @@
#pragma once #pragma once
#include <projectexplorer/devicesupport/idevice.h> #include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/devicesupport/idevicefactory.h>
namespace BareMetal { namespace BareMetal {
namespace Internal { namespace Internal {
@@ -69,5 +70,15 @@ private:
QString m_gdbServerProviderId; QString m_gdbServerProviderId;
}; };
class BareMetalDeviceFactory : public ProjectExplorer::IDeviceFactory
{
Q_OBJECT
public:
BareMetalDeviceFactory();
ProjectExplorer::IDevice::Ptr create() const override;
};
} //namespace Internal } //namespace Internal
} //namespace BareMetal } //namespace BareMetal

View File

@@ -1,58 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 Tim Sander <tim@krieglstein.org>
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** 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 https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "baremetaldeviceconfigurationfactory.h"
#include "baremetaldeviceconfigurationwizard.h"
#include "baremetalconstants.h"
#include "baremetaldevice.h"
#include <utils/qtcassert.h>
using namespace ProjectExplorer;
namespace BareMetal {
namespace Internal {
BareMetalDeviceConfigurationFactory::BareMetalDeviceConfigurationFactory()
: IDeviceFactory(Constants::BareMetalOsType)
{
setDisplayName(tr("Bare Metal Device"));
setCombinedIcon(":/baremetal/images/baremetaldevicesmall.png",
":/baremetal/images/baremetaldevice.png");
setCanCreate(true);
setConstructionFunction(&BareMetalDevice::create);
}
IDevice::Ptr BareMetalDeviceConfigurationFactory::create() const
{
BareMetalDeviceConfigurationWizard wizard;
if (wizard.exec() != QDialog::Accepted)
return IDevice::Ptr();
return wizard.device();
}
} // namespace Internal
} // namespace BareMetal

View File

@@ -1,45 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 Tim Sander <tim@krieglstein.org>
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** 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 https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include <projectexplorer/devicesupport/idevicefactory.h>
namespace BareMetal {
namespace Internal {
class BareMetalDeviceConfigurationFactory
: public ProjectExplorer::IDeviceFactory
{
Q_OBJECT
public:
BareMetalDeviceConfigurationFactory();
ProjectExplorer::IDevice::Ptr create() const override;
};
} // namespace Internal
} // namespace BareMetal

View File

@@ -27,7 +27,7 @@
#include "baremetalplugin.h" #include "baremetalplugin.h"
#include "baremetalconstants.h" #include "baremetalconstants.h"
#include "baremetalcustomrunconfiguration.h" #include "baremetalcustomrunconfiguration.h"
#include "baremetaldeviceconfigurationfactory.h" #include "baremetaldevice.h"
#include "baremetaldebugsupport.h" #include "baremetaldebugsupport.h"
#include "baremetalrunconfiguration.h" #include "baremetalrunconfiguration.h"
@@ -49,7 +49,7 @@ namespace Internal {
class BareMetalPluginRunData class BareMetalPluginRunData
{ {
public: public:
BareMetalDeviceConfigurationFactory deviceConfigurationFactory; BareMetalDeviceFactory deviceFactory;
BareMetalRunConfigurationFactory runConfigurationFactory; BareMetalRunConfigurationFactory runConfigurationFactory;
BareMetalCustomRunConfigurationFactory customRunConfigurationFactory; BareMetalCustomRunConfigurationFactory customRunConfigurationFactory;
GdbServerProvidersSettingsPage gdbServerProviderSettinsPage; GdbServerProvidersSettingsPage gdbServerProviderSettinsPage;

View File

@@ -17,10 +17,8 @@ HEADERS += \
iosdsymbuildstep.h \ iosdsymbuildstep.h \
iosqtversion.h \ iosqtversion.h \
iosplugin.h \ iosplugin.h \
iosdevicefactory.h \
iosdevice.h \ iosdevice.h \
iossimulator.h \ iossimulator.h \
iossimulatorfactory.h \
iosprobe.h \ iosprobe.h \
iosbuildstep.h \ iosbuildstep.h \
iostoolhandler.h \ iostoolhandler.h \
@@ -43,10 +41,8 @@ SOURCES += \
iosdsymbuildstep.cpp \ iosdsymbuildstep.cpp \
iosqtversion.cpp \ iosqtversion.cpp \
iosplugin.cpp \ iosplugin.cpp \
iosdevicefactory.cpp \
iosdevice.cpp \ iosdevice.cpp \
iossimulator.cpp \ iossimulator.cpp \
iossimulatorfactory.cpp \
iosprobe.cpp \ iosprobe.cpp \
iosbuildstep.cpp \ iosbuildstep.cpp \
iostoolhandler.cpp \ iostoolhandler.cpp \

View File

@@ -36,8 +36,6 @@ QtcPlugin {
"iosdeploystepwidget.ui", "iosdeploystepwidget.ui",
"iosdevice.cpp", "iosdevice.cpp",
"iosdevice.h", "iosdevice.h",
"iosdevicefactory.cpp",
"iosdevicefactory.h",
"iosdsymbuildstep.cpp", "iosdsymbuildstep.cpp",
"iosdsymbuildstep.h", "iosdsymbuildstep.h",
"iosplugin.cpp", "iosplugin.cpp",
@@ -58,8 +56,6 @@ QtcPlugin {
"iossettingswidget.ui", "iossettingswidget.ui",
"iossimulator.cpp", "iossimulator.cpp",
"iossimulator.h", "iossimulator.h",
"iossimulatorfactory.cpp",
"iossimulatorfactory.h",
"iostoolhandler.cpp", "iostoolhandler.cpp",
"iostoolhandler.h", "iostoolhandler.h",
"simulatorcontrol.cpp", "simulatorcontrol.cpp",

View File

@@ -547,5 +547,27 @@ IosDevice::ConstPtr IosKitAspect::device(Kit *kit)
return res; return res;
} }
// Factory
IosDeviceFactory::IosDeviceFactory()
: IDeviceFactory(Constants::IOS_DEVICE_ID)
{
setObjectName(QLatin1String("IosDeviceFactory"));
setDisplayName(IosDevice::name());
setCombinedIcon(":/ios/images/iosdevicesmall.png",
":/ios/images/iosdevice.png");
setConstructionFunction([] { return IDevice::Ptr(new IosDevice); });
}
bool IosDeviceFactory::canRestore(const QVariantMap &map) const
{
QVariantMap vMap = map.value(QLatin1String(Constants::EXTRA_INFO_KEY)).toMap();
if (vMap.isEmpty()
|| vMap.value(QLatin1String("deviceName")).toString() == QLatin1String("*unknown*"))
return false; // transient device (probably generated during an activation)
return true;
}
} // namespace Internal } // namespace Internal
} // namespace Ios } // namespace Ios

View File

@@ -28,11 +28,11 @@
#include "iostoolhandler.h" #include "iostoolhandler.h"
#include <projectexplorer/devicesupport/idevice.h> #include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/devicesupport/idevicefactory.h>
#include <QVariantMap> #include <QVariantMap>
#include <QMap> #include <QMap>
#include <QString> #include <QString>
#include <QSharedPointer>
#include <QStringList> #include <QStringList>
#include <QTimer> #include <QTimer>
@@ -79,6 +79,15 @@ protected:
mutable quint16 m_lastPort; mutable quint16 m_lastPort;
}; };
class IosDeviceFactory : public ProjectExplorer::IDeviceFactory
{
Q_OBJECT
public:
IosDeviceFactory();
bool canRestore(const QVariantMap &map) const override;
};
class IosDeviceManager : public QObject { class IosDeviceManager : public QObject {
Q_OBJECT Q_OBJECT
public: public:

View File

@@ -1,54 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** 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 https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "iosdevicefactory.h"
#include "iosdevice.h"
#include "iosconstants.h"
namespace Ios {
namespace Internal {
IosDeviceFactory::IosDeviceFactory()
: ProjectExplorer::IDeviceFactory(Constants::IOS_DEVICE_ID)
{
setObjectName(QLatin1String("IosDeviceFactory"));
setDisplayName(IosDevice::name());
setCombinedIcon(":/ios/images/iosdevicesmall.png",
":/ios/images/iosdevice.png");
setConstructionFunction([] { return ProjectExplorer::IDevice::Ptr(new IosDevice); });
}
bool IosDeviceFactory::canRestore(const QVariantMap &map) const
{
QVariantMap vMap = map.value(QLatin1String(Constants::EXTRA_INFO_KEY)).toMap();
if (vMap.isEmpty()
|| vMap.value(QLatin1String("deviceName")).toString() == QLatin1String("*unknown*"))
return false; // transient device (probably generated during an activation)
return true;
}
} // namespace Internal
} // namespace Ios

View File

@@ -1,43 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** 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 https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include <projectexplorer/devicesupport/idevicefactory.h>
namespace Ios {
namespace Internal {
class IosDeviceFactory : public ProjectExplorer::IDeviceFactory
{
Q_OBJECT
public:
IosDeviceFactory();
bool canRestore(const QVariantMap &map) const override;
};
} // namespace Internal
} // namespace Ios

View File

@@ -30,13 +30,12 @@
#include "iosconfigurations.h" #include "iosconfigurations.h"
#include "iosconstants.h" #include "iosconstants.h"
#include "iosdeploystep.h" #include "iosdeploystep.h"
#include "iosdevicefactory.h" #include "iosdevice.h"
#include "iosdsymbuildstep.h" #include "iosdsymbuildstep.h"
#include "iosqtversion.h" #include "iosqtversion.h"
#include "iosrunner.h" #include "iosrunner.h"
#include "iossettingspage.h" #include "iossettingspage.h"
#include "iossimulator.h" #include "iossimulator.h"
#include "iossimulatorfactory.h"
#include "iostoolhandler.h" #include "iostoolhandler.h"
#include "iosrunconfiguration.h" #include "iosrunconfiguration.h"

View File

@@ -281,5 +281,17 @@ QDebug operator <<(QDebug debug, const IosDeviceType &deviceType)
return debug; return debug;
} }
// Factory
IosSimulatorFactory::IosSimulatorFactory()
: ProjectExplorer::IDeviceFactory(Constants::IOS_SIMULATOR_TYPE)
{
setObjectName(QLatin1String("IosSimulatorFactory"));
setDisplayName(tr("iOS Simulator"));
setCombinedIcon(":/ios/images/iosdevicesmall.png",
":/ios/images/iosdevice.png");
setConstructionFunction([] { return ProjectExplorer::IDevice::Ptr(new IosSimulator()); });
}
} // namespace Internal } // namespace Internal
} // namespace Ios } // namespace Ios

View File

@@ -26,11 +26,11 @@
#pragma once #pragma once
#include <projectexplorer/devicesupport/idevice.h> #include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/devicesupport/idevicefactory.h>
#include <utils/fileutils.h> #include <utils/fileutils.h>
#include <QMutex>
#include <QDebug> #include <QDebug>
#include <QSharedPointer>
namespace ProjectExplorer { class Kit; } namespace ProjectExplorer { class Kit; }
namespace Ios { namespace Ios {
@@ -87,6 +87,13 @@ private:
mutable quint16 m_lastPort; mutable quint16 m_lastPort;
}; };
class IosSimulatorFactory : public ProjectExplorer::IDeviceFactory
{
Q_OBJECT
public:
IosSimulatorFactory();
};
namespace IosKitInformation { namespace IosKitInformation {
IosSimulator::ConstPtr simulator(ProjectExplorer::Kit *kit); IosSimulator::ConstPtr simulator(ProjectExplorer::Kit *kit);
} // namespace IosKitInformation } // namespace IosKitInformation

View File

@@ -1,47 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** 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 https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "iossimulatorfactory.h"
#include "iosconstants.h"
#include "iossimulator.h"
#include <utils/qtcassert.h>
namespace Ios {
namespace Internal {
IosSimulatorFactory::IosSimulatorFactory()
: ProjectExplorer::IDeviceFactory(Constants::IOS_SIMULATOR_TYPE)
{
setObjectName(QLatin1String("IosSimulatorFactory"));
setDisplayName(tr("iOS Simulator"));
setCombinedIcon(":/ios/images/iosdevicesmall.png",
":/ios/images/iosdevice.png");
setConstructionFunction([] { return ProjectExplorer::IDevice::Ptr(new IosSimulator()); });
}
} // namespace Internal
} // namespace Ios

View File

@@ -1,41 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** 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 https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include <projectexplorer/devicesupport/idevicefactory.h>
namespace Ios {
namespace Internal {
class IosSimulatorFactory : public ProjectExplorer::IDeviceFactory
{
Q_OBJECT
public:
IosSimulatorFactory();
};
} // namespace Internal
} // namespace Ios

View File

@@ -24,11 +24,14 @@
****************************************************************************/ ****************************************************************************/
#include "qnxdevice.h" #include "qnxdevice.h"
#include "qnxconstants.h"
#include "qnxdevicetester.h" #include "qnxdevicetester.h"
#include "qnxdeviceprocesslist.h" #include "qnxdeviceprocesslist.h"
#include "qnxdeviceprocesssignaloperation.h" #include "qnxdeviceprocesssignaloperation.h"
#include "qnxdeployqtlibrariesdialog.h" #include "qnxdeployqtlibrariesdialog.h"
#include "qnxdeviceprocess.h" #include "qnxdeviceprocess.h"
#include "qnxdevicewizard.h"
#include <projectexplorer/devicesupport/sshdeviceprocess.h> #include <projectexplorer/devicesupport/sshdeviceprocess.h>
@@ -46,8 +49,7 @@ using namespace ProjectExplorer;
using namespace Utils; using namespace Utils;
namespace Qnx { namespace Qnx {
namespace Internal {
using namespace Internal;
const char QnxVersionKey[] = "QnxVersion"; const char QnxVersionKey[] = "QnxVersion";
@@ -179,4 +181,30 @@ DeviceProcessSignalOperation::Ptr QnxDevice::signalOperation() const
new QnxDeviceProcessSignalOperation(sshParameters())); new QnxDeviceProcessSignalOperation(sshParameters()));
} }
// Factory
QnxDeviceFactory::QnxDeviceFactory()
: ProjectExplorer::IDeviceFactory(Constants::QNX_QNX_OS_TYPE)
{
setDisplayName(tr("QNX Device"));
setCombinedIcon(":/qnx/images/qnxdevicesmall.png",
":/qnx/images/qnxdevice.png");
setCanCreate(true);
setConstructionFunction(&QnxDevice::create);
}
ProjectExplorer::IDevice::Ptr QnxDeviceFactory::create() const
{
QnxDeviceWizard wizard;
if (wizard.exec() != QDialog::Accepted)
return ProjectExplorer::IDevice::Ptr();
return wizard.device();
}
Core::Id QnxDeviceFactory::deviceType()
{
return Core::Id(Constants::QNX_QNX_OS_TYPE);
}
} // namespace Internal
} // namespace Qnx } // namespace Qnx

View File

@@ -30,8 +30,9 @@
#include <remotelinux/linuxdevice.h> #include <remotelinux/linuxdevice.h>
namespace Qnx { namespace Qnx {
namespace Internal {
class QNX_EXPORT QnxDevice : public RemoteLinux::LinuxDevice class QnxDevice : public RemoteLinux::LinuxDevice
{ {
Q_DECLARE_TR_FUNCTIONS(Qnx::Internal::QnxDevice) Q_DECLARE_TR_FUNCTIONS(Qnx::Internal::QnxDevice)
@@ -69,4 +70,17 @@ private:
mutable int m_versionNumber = 0; mutable int m_versionNumber = 0;
}; };
class QnxDeviceFactory : public ProjectExplorer::IDeviceFactory
{
Q_OBJECT
public:
QnxDeviceFactory();
ProjectExplorer::IDevice::Ptr create() const override;
static Core::Id deviceType();
};
} // namespace Internal
} // namespace Qnx } // namespace Qnx

View File

@@ -34,28 +34,5 @@
namespace Qnx { namespace Qnx {
namespace Internal { namespace Internal {
QnxDeviceFactory::QnxDeviceFactory()
: ProjectExplorer::IDeviceFactory(Constants::QNX_QNX_OS_TYPE)
{
setDisplayName(tr("QNX Device"));
setCombinedIcon(":/qnx/images/qnxdevicesmall.png",
":/qnx/images/qnxdevice.png");
setCanCreate(true);
setConstructionFunction(&QnxDevice::create);
}
ProjectExplorer::IDevice::Ptr QnxDeviceFactory::create() const
{
QnxDeviceWizard wizard;
if (wizard.exec() != QDialog::Accepted)
return ProjectExplorer::IDevice::Ptr();
return wizard.device();
}
Core::Id QnxDeviceFactory::deviceType()
{
return Core::Id(Constants::QNX_QNX_OS_TYPE);
}
} // namespace Internal } // namespace Internal
} // namespace Qnx } // namespace Qnx

View File

@@ -30,17 +30,6 @@
namespace Qnx { namespace Qnx {
namespace Internal { namespace Internal {
class QnxDeviceFactory : public ProjectExplorer::IDeviceFactory
{
Q_OBJECT
public:
QnxDeviceFactory();
ProjectExplorer::IDevice::Ptr create() const override;
static Core::Id deviceType();
};
} // namespace Internal } // namespace Internal
} // namespace Qnx } // namespace Qnx

View File

@@ -28,8 +28,6 @@
#include <remotelinux/remotelinuxsignaloperation.h> #include <remotelinux/remotelinuxsignaloperation.h>
namespace Qnx { namespace Qnx {
class QnxDevice;
namespace Internal { namespace Internal {
class QnxDeviceProcessSignalOperation : public RemoteLinux::RemoteLinuxSignalOperation class QnxDeviceProcessSignalOperation : public RemoteLinux::RemoteLinuxSignalOperation
@@ -42,7 +40,7 @@ private:
QString killProcessByNameCommandLine(const QString &filePath) const override; QString killProcessByNameCommandLine(const QString &filePath) const override;
QString interruptProcessByNameCommandLine(const QString &filePath) const override; QString interruptProcessByNameCommandLine(const QString &filePath) const override;
friend class Qnx::QnxDevice; friend class QnxDevice;
}; };
} // namespace Internal } // namespace Internal

View File

@@ -1,57 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** 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 https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "genericlinuxdeviceconfigurationfactory.h"
#include "genericlinuxdeviceconfigurationwizard.h"
#include "linuxdevice.h"
#include "remotelinux_constants.h"
#include <coreplugin/icore.h>
#include <utils/qtcassert.h>
using namespace ProjectExplorer;
namespace RemoteLinux {
GenericLinuxDeviceConfigurationFactory::GenericLinuxDeviceConfigurationFactory()
: IDeviceFactory(Constants::GenericLinuxOsType)
{
setDisplayName(tr("Generic Linux Device"));
setIcon(QIcon());
setCanCreate(true);
setConstructionFunction(&LinuxDevice::create);
}
IDevice::Ptr GenericLinuxDeviceConfigurationFactory::create() const
{
GenericLinuxDeviceConfigurationWizard wizard(Core::ICore::mainWindow());
if (wizard.exec() != QDialog::Accepted)
return IDevice::Ptr();
return wizard.device();
}
} // namespace RemoteLinux

View File

@@ -1,45 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** 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 https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include "remotelinux_export.h"
#include <projectexplorer/devicesupport/idevicefactory.h>
namespace RemoteLinux {
class REMOTELINUX_EXPORT GenericLinuxDeviceConfigurationFactory
: public ProjectExplorer::IDeviceFactory
{
Q_OBJECT
public:
GenericLinuxDeviceConfigurationFactory();
ProjectExplorer::IDevice::Ptr create() const override;
};
} // namespace RemoteLinux

View File

@@ -26,6 +26,7 @@
#include "linuxdevice.h" #include "linuxdevice.h"
#include "genericlinuxdeviceconfigurationwidget.h" #include "genericlinuxdeviceconfigurationwidget.h"
#include "genericlinuxdeviceconfigurationwizard.h"
#include "linuxdeviceprocess.h" #include "linuxdeviceprocess.h"
#include "linuxdevicetester.h" #include "linuxdevicetester.h"
#include "publickeydeploymentdialog.h" #include "publickeydeploymentdialog.h"
@@ -33,6 +34,7 @@
#include "remotelinuxsignaloperation.h" #include "remotelinuxsignaloperation.h"
#include "remotelinuxenvironmentreader.h" #include "remotelinuxenvironmentreader.h"
#include <coreplugin/icore.h>
#include <coreplugin/id.h> #include <coreplugin/id.h>
#include <coreplugin/messagemanager.h> #include <coreplugin/messagemanager.h>
#include <projectexplorer/devicesupport/sshdeviceprocesslist.h> #include <projectexplorer/devicesupport/sshdeviceprocesslist.h>
@@ -284,4 +286,27 @@ bool LinuxDevice::supportsRSync() const
return extraData("RemoteLinux.SupportsRSync").toBool(); return extraData("RemoteLinux.SupportsRSync").toBool();
} }
namespace Internal {
// Factory
LinuxDeviceFactory::LinuxDeviceFactory()
: IDeviceFactory(Constants::GenericLinuxOsType)
{
setDisplayName(tr("Generic Linux Device"));
setIcon(QIcon());
setCanCreate(true);
setConstructionFunction(&LinuxDevice::create);
}
IDevice::Ptr LinuxDeviceFactory::create() const
{
GenericLinuxDeviceConfigurationWizard wizard(Core::ICore::mainWindow());
if (wizard.exec() != QDialog::Accepted)
return IDevice::Ptr();
return wizard.device();
}
}
} // namespace RemoteLinux } // namespace RemoteLinux

View File

@@ -28,6 +28,7 @@
#include "remotelinux_export.h" #include "remotelinux_export.h"
#include <projectexplorer/devicesupport/idevice.h> #include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/devicesupport/idevicefactory.h>
#include <QCoreApplication> #include <QCoreApplication>
@@ -66,4 +67,17 @@ protected:
LinuxDevice(); LinuxDevice();
}; };
namespace Internal {
class LinuxDeviceFactory : public ProjectExplorer::IDeviceFactory
{
Q_OBJECT
public:
LinuxDeviceFactory();
ProjectExplorer::IDevice::Ptr create() const override;
};
} // namespace Internal
} // namespace RemoteLinux } // namespace RemoteLinux

View File

@@ -12,7 +12,6 @@ HEADERS += \
remotelinuxrunconfiguration.h \ remotelinuxrunconfiguration.h \
publickeydeploymentdialog.h \ publickeydeploymentdialog.h \
genericlinuxdeviceconfigurationwizard.h \ genericlinuxdeviceconfigurationwizard.h \
genericlinuxdeviceconfigurationfactory.h \
remotelinuxdebugsupport.h \ remotelinuxdebugsupport.h \
genericlinuxdeviceconfigurationwizardpages.h \ genericlinuxdeviceconfigurationwizardpages.h \
abstractremotelinuxdeploystep.h \ abstractremotelinuxdeploystep.h \
@@ -55,7 +54,6 @@ SOURCES += \
remotelinuxrunconfiguration.cpp \ remotelinuxrunconfiguration.cpp \
publickeydeploymentdialog.cpp \ publickeydeploymentdialog.cpp \
genericlinuxdeviceconfigurationwizard.cpp \ genericlinuxdeviceconfigurationwizard.cpp \
genericlinuxdeviceconfigurationfactory.cpp \
remotelinuxdebugsupport.cpp \ remotelinuxdebugsupport.cpp \
genericlinuxdeviceconfigurationwizardpages.cpp \ genericlinuxdeviceconfigurationwizardpages.cpp \
abstractremotelinuxdeploystep.cpp \ abstractremotelinuxdeploystep.cpp \

View File

@@ -33,8 +33,6 @@ Project {
"genericdirectuploadservice.h", "genericdirectuploadservice.h",
"genericdirectuploadstep.cpp", "genericdirectuploadstep.cpp",
"genericdirectuploadstep.h", "genericdirectuploadstep.h",
"genericlinuxdeviceconfigurationfactory.cpp",
"genericlinuxdeviceconfigurationfactory.h",
"genericlinuxdeviceconfigurationwidget.cpp", "genericlinuxdeviceconfigurationwidget.cpp",
"genericlinuxdeviceconfigurationwidget.h", "genericlinuxdeviceconfigurationwidget.h",
"genericlinuxdeviceconfigurationwidget.ui", "genericlinuxdeviceconfigurationwidget.ui",

View File

@@ -26,7 +26,7 @@
#include "remotelinuxplugin.h" #include "remotelinuxplugin.h"
#include "embeddedlinuxqtversion.h" #include "embeddedlinuxqtversion.h"
#include "genericlinuxdeviceconfigurationfactory.h" #include "linuxdevice.h"
#include "remotelinux_constants.h" #include "remotelinux_constants.h"
#include "remotelinuxqmltoolingsupport.h" #include "remotelinuxqmltoolingsupport.h"
#include "remotelinuxcustomrunconfiguration.h" #include "remotelinuxcustomrunconfiguration.h"
@@ -67,7 +67,7 @@ public:
class RemoteLinuxPluginPrivate class RemoteLinuxPluginPrivate
{ {
public: public:
GenericLinuxDeviceConfigurationFactory deviceConfigurationFactory; LinuxDeviceFactory linuxDeviceFactory;
RemoteLinuxRunConfigurationFactory runConfigurationFactory; RemoteLinuxRunConfigurationFactory runConfigurationFactory;
RemoteLinuxCustomRunConfigurationFactory customRunConfigurationFactory; RemoteLinuxCustomRunConfigurationFactory customRunConfigurationFactory;
RemoteLinuxDeployConfigurationFactory deployConfigurationFactory; RemoteLinuxDeployConfigurationFactory deployConfigurationFactory;

View File

@@ -5,7 +5,6 @@ HEADERS += \
winrtdebugsupport.h \ winrtdebugsupport.h \
winrtdeployconfiguration.h \ winrtdeployconfiguration.h \
winrtdevice.h \ winrtdevice.h \
winrtdevicefactory.h \
winrtpackagedeploymentstep.h \ winrtpackagedeploymentstep.h \
winrtphoneqtversion.h \ winrtphoneqtversion.h \
winrtplugin.h \ winrtplugin.h \
@@ -18,7 +17,6 @@ SOURCES += \
winrtdebugsupport.cpp \ winrtdebugsupport.cpp \
winrtdeployconfiguration.cpp \ winrtdeployconfiguration.cpp \
winrtdevice.cpp \ winrtdevice.cpp \
winrtdevicefactory.cpp \
winrtpackagedeploymentstep.cpp \ winrtpackagedeploymentstep.cpp \
winrtphoneqtversion.cpp \ winrtphoneqtversion.cpp \
winrtplugin.cpp \ winrtplugin.cpp \

View File

@@ -20,8 +20,6 @@ QtcPlugin {
"winrtdeployconfiguration.h", "winrtdeployconfiguration.h",
"winrtdevice.cpp", "winrtdevice.cpp",
"winrtdevice.h", "winrtdevice.h",
"winrtdevicefactory.cpp",
"winrtdevicefactory.h",
"winrtpackagedeploymentstep.cpp", "winrtpackagedeploymentstep.cpp",
"winrtpackagedeploymentstep.h", "winrtpackagedeploymentstep.h",
"winrtphoneqtversion.cpp", "winrtphoneqtversion.cpp",

View File

@@ -25,23 +25,39 @@
#include "winrtdevice.h" #include "winrtdevice.h"
#include "winrtconstants.h" #include "winrtconstants.h"
#include "winrtqtversion.h"
#include <coreplugin/messagemanager.h>
#include <projectexplorer/devicesupport/desktopprocesssignaloperation.h> #include <projectexplorer/devicesupport/desktopprocesssignaloperation.h>
#include <projectexplorer/devicesupport/devicemanager.h> #include <projectexplorer/devicesupport/devicemanager.h>
#include <projectexplorer/devicesupport/deviceprocesslist.h> #include <projectexplorer/devicesupport/deviceprocesslist.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
#include <qtsupport/qtversionmanager.h>
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/portlist.h> #include <utils/portlist.h>
#include <QFileInfo> #include <QFileInfo>
#include <QCoreApplication> #include <QCoreApplication>
#include <QIcon>
#include <QLoggingCategory>
#include <QWizard> #include <QWizard>
using QtSupport::BaseQtVersion;
using QtSupport::QtVersionManager;
using namespace Core;
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils;
namespace WinRt { namespace WinRt {
namespace Internal { namespace Internal {
Q_LOGGING_CATEGORY(winrtDeviceLog, "qtc.winrt.deviceParser", QtWarningMsg)
WinRtDevice::WinRtDevice() WinRtDevice::WinRtDevice()
{ {
Utils::PortList portList; Utils::PortList portList;
@@ -109,5 +125,258 @@ QString WinRtDevice::displayNameForType(Core::Id type)
return QString(); return QString();
} }
// Factory
WinRtDeviceFactory::WinRtDeviceFactory(Core::Id deviceType)
: ProjectExplorer::IDeviceFactory(deviceType)
{
if (allPrerequisitesLoaded()) {
onPrerequisitesLoaded();
} else {
connect(DeviceManager::instance(), &DeviceManager::devicesLoaded,
this, &WinRtDeviceFactory::onPrerequisitesLoaded, Qt::QueuedConnection);
connect(QtVersionManager::instance(),
&QtVersionManager::qtVersionsLoaded,
this, &WinRtDeviceFactory::onPrerequisitesLoaded, Qt::QueuedConnection);
}
setDisplayName(WinRtDevice::displayNameForType(deviceType));
setConstructionFunction(&WinRtDevice::create);
setCombinedIcon(":/winrt/images/winrtdevicesmall.png",
":/winrt/images/winrtdevice.png");
}
void WinRtDeviceFactory::autoDetect()
{
qCDebug(winrtDeviceLog) << __FUNCTION__;
MessageManager::write(tr("Running Windows Runtime device detection."));
const QString runnerFilePath = findRunnerFilePath();
if (runnerFilePath.isEmpty()) {
MessageManager::write(tr("No winrtrunner.exe found."));
return;
}
if (!m_process) {
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Creating process";
m_process = new Utils::QtcProcess(this);
connect(m_process, &QProcess::errorOccurred, this, &WinRtDeviceFactory::onProcessError);
connect(m_process,
static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
this, &WinRtDeviceFactory::onProcessFinished);
}
const QString args = QStringLiteral("--list-devices");
m_process->setCommand(runnerFilePath, args);
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Starting process" << runnerFilePath
<< "with arguments" << args;
MessageManager::write(runnerFilePath + QLatin1Char(' ') + args);
m_process->start();
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Process started";
}
void WinRtDeviceFactory::onPrerequisitesLoaded()
{
if (!allPrerequisitesLoaded() || m_initialized)
return;
qCDebug(winrtDeviceLog) << __FUNCTION__;
m_initialized = true;
disconnect(DeviceManager::instance(), &DeviceManager::devicesLoaded,
this, &WinRtDeviceFactory::onPrerequisitesLoaded);
disconnect(QtVersionManager::instance(), &QtVersionManager::qtVersionsLoaded,
this, &WinRtDeviceFactory::onPrerequisitesLoaded);
autoDetect();
connect(QtVersionManager::instance(), &QtVersionManager::qtVersionsChanged,
this, &WinRtDeviceFactory::autoDetect);
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Done";
}
void WinRtDeviceFactory::onProcessError()
{
MessageManager::write(tr("Error while executing winrtrunner: %1")
.arg(m_process->errorString()), MessageManager::Flash);
}
void WinRtDeviceFactory::onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
{
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Exit code:" << exitCode <<"\tExit status:"
<< exitStatus;
if (exitStatus == QProcess::CrashExit) {
// already handled in onProcessError
return;
}
if (exitCode != 0) {
MessageManager::write(tr("winrtrunner returned with exit code %1.")
.arg(exitCode), MessageManager::Flash);
return;
}
const QByteArray stdOut = m_process->readAllStandardOutput();
const QByteArray stdErr = m_process->readAllStandardError();
qCDebug(winrtDeviceLog) << __FUNCTION__ << "winrtrunner's stdout:" << stdOut;
if (!stdErr.isEmpty())
qCDebug(winrtDeviceLog) << __FUNCTION__ << "winrtrunner's stderr:" << stdErr;
parseRunnerOutput(stdOut);
}
bool WinRtDeviceFactory::allPrerequisitesLoaded()
{
return QtVersionManager::isLoaded() && DeviceManager::instance()->isLoaded();
}
QString WinRtDeviceFactory::findRunnerFilePath() const
{
qCDebug(winrtDeviceLog) << __FUNCTION__;
const QString winRtRunnerExe = QStringLiteral("/winrtrunner.exe");
const QList<BaseQtVersion *> winrtVersions
= QtVersionManager::sortVersions(
QtVersionManager::versions(BaseQtVersion::isValidPredicate([](const BaseQtVersion *v) {
return v->type() == QLatin1String(Constants::WINRT_WINRTQT)
|| v->type() == QLatin1String(Constants::WINRT_WINPHONEQT);
})));
QString filePath;
BaseQtVersion *qt = nullptr;
for (BaseQtVersion *v : winrtVersions) {
if (!qt || qt->qtVersion() < v->qtVersion()) {
QFileInfo fi(v->binPath().toString() + winRtRunnerExe);
if (fi.isFile() && fi.isExecutable()) {
qt = v;
filePath = fi.absoluteFilePath();
}
}
}
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Found" << filePath;
return filePath;
}
static int extractDeviceId(QByteArray *line)
{
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Line:" << *line;
int pos = line->indexOf(' ');
if (pos < 0) {
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Could not find space, returning -1";
return -1;
}
bool ok;
int id = line->left(pos).toInt(&ok);
if (!ok) {
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Could not extract ID";
return -1;
}
line->remove(0, pos + 1);
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Found ID" << id;
return id;
}
static IDevice::MachineType machineTypeFromLine(const QByteArray &line)
{
return line.contains("Emulator ") ? IDevice::Emulator : IDevice::Hardware;
}
/*
* The output of "winrtrunner --list-devices" looks like this:
*
* Available devices:
* Appx:
* 0 local
* Phone:
* 0 Device
* 1 Emulator 8.1 WVGA 4 inch 512MB
* 2 Emulator 8.1 WVGA 4 inch
* 3 Emulator 8.1 WXGA 4 inch
* 4 Emulator 8.1 720P 4.7 inch
* 5 Emulator 8.1 1080P 5.5 inch
* 6 Emulator 8.1 1080P 6 inch
* 7 WE8.1H Emulator WVGA 512MB
* 8 WE8.1H Emulator WVGA
* 9 WE8.1H Emulator WXGA
* 10 WE8.1H Emulator 720P
* 11 WE8.1H Emulator 1080P
* Xap:
* 0 Device
* 1 Emulator WVGA 512MB
* 2 Emulator WVGA
* 3 Emulator WXGA
* 4 Emulator 720P
*/
void WinRtDeviceFactory::parseRunnerOutput(const QByteArray &output) const
{
qCDebug(winrtDeviceLog) << __FUNCTION__;
ProjectExplorer::DeviceManager *deviceManager = ProjectExplorer::DeviceManager::instance();
enum State { StartState, AppxState, PhoneState, XapState };
State state = StartState;
int numFound = 0;
int numSkipped = 0;
foreach (QByteArray line, output.split('\n')) {
line = line.trimmed();
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Line:" << line;
if (line == "Appx:") {
qCDebug(winrtDeviceLog) << __FUNCTION__ << "state = AppxState";
state = AppxState;
} else if (line == "Phone:") {
qCDebug(winrtDeviceLog) << __FUNCTION__ << "state = PhoneState";
state = PhoneState;
} else if (line == "Xap:") {
qCDebug(winrtDeviceLog) << __FUNCTION__ << "state = XapState";
state = XapState;
} else {
const int deviceId = extractDeviceId(&line);
if (deviceId < 0) {
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Could not extract device ID";
continue;
}
const IDevice::MachineType machineType = machineTypeFromLine(line);
Core::Id deviceType;
QString name;
QString internalName = QStringLiteral("WinRT.");
if (state == AppxState) {
internalName += QStringLiteral("appx.");
deviceType = Constants::WINRT_DEVICE_TYPE_LOCAL;
name = tr("Windows Runtime local UI");
} else if (state == PhoneState) {
internalName += QStringLiteral("phone.");
name = QString::fromLocal8Bit(line);
if (machineType == IDevice::Emulator)
deviceType = Constants::WINRT_DEVICE_TYPE_EMULATOR;
else
deviceType = Constants::WINRT_DEVICE_TYPE_PHONE;
} else if (state == XapState) {
internalName += QStringLiteral("xap.");
name = QString::fromLocal8Bit(line);
if (machineType == IDevice::Emulator)
deviceType = Constants::WINRT_DEVICE_TYPE_EMULATOR;
else
deviceType = Constants::WINRT_DEVICE_TYPE_PHONE;
}
internalName += QString::number(deviceId);
const Core::Id internalId = Core::Id::fromString(internalName);
++numFound;
if (DeviceManager::instance()->find(internalId)) {
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Skipping device with ID" << deviceId;
++numSkipped;
continue;
}
auto device = WinRtDevice::create();
device->setupId(IDevice::AutoDetected, internalId);
device->setDeviceId(deviceId);
device->setType(deviceType);
device->setMachineType(machineType);
device->setDisplayName(name);
deviceManager->addDevice(ProjectExplorer::IDevice::ConstPtr(device));
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Added device" << name << "(internal name:"
<< internalName << ")";
}
}
QString message = tr("Found %n Windows Runtime devices.", 0, numFound);
if (const int numNew = numFound - numSkipped) {
message += QLatin1Char(' ');
message += tr("%n of them are new.", 0, numNew);
}
MessageManager::write(message);
}
} // Internal } // Internal
} // WinRt } // WinRt

View File

@@ -26,6 +26,9 @@
#pragma once #pragma once
#include <projectexplorer/devicesupport/idevice.h> #include <projectexplorer/devicesupport/idevice.h>
#include <projectexplorer/devicesupport/idevicefactory.h>
#include <utils/qtcprocess.h>
namespace WinRt { namespace WinRt {
namespace Internal { namespace Internal {
@@ -56,5 +59,26 @@ private:
int m_deviceId = -1; int m_deviceId = -1;
}; };
class WinRtDeviceFactory : public ProjectExplorer::IDeviceFactory
{
Q_OBJECT
public:
explicit WinRtDeviceFactory(Core::Id deviceType);
void autoDetect();
void onPrerequisitesLoaded();
private:
void onProcessError();
void onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
static bool allPrerequisitesLoaded();
QString findRunnerFilePath() const;
void parseRunnerOutput(const QByteArray &output) const;
Utils::QtcProcess *m_process = nullptr;
bool m_initialized = false;
};
} // Internal } // Internal
} // WinRt } // WinRt

View File

@@ -1,304 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** 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 https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#include "winrtdevicefactory.h"
#include "winrtconstants.h"
#include "winrtdevice.h"
#include "winrtqtversion.h"
#include <coreplugin/messagemanager.h>
#include <projectexplorer/devicesupport/devicemanager.h>
#include <qtsupport/qtversionmanager.h>
#include <utils/qtcassert.h>
#include <QFileInfo>
#include <QIcon>
#include <QLoggingCategory>
using Core::MessageManager;
using ProjectExplorer::DeviceManager;
using ProjectExplorer::IDevice;
using QtSupport::BaseQtVersion;
using QtSupport::QtVersionManager;
Q_LOGGING_CATEGORY(winrtDeviceLog, "qtc.winrt.deviceParser", QtWarningMsg)
namespace WinRt {
namespace Internal {
WinRtDeviceFactory::WinRtDeviceFactory(Core::Id deviceType)
: ProjectExplorer::IDeviceFactory(deviceType)
{
if (allPrerequisitesLoaded()) {
onPrerequisitesLoaded();
} else {
connect(DeviceManager::instance(), &DeviceManager::devicesLoaded,
this, &WinRtDeviceFactory::onPrerequisitesLoaded, Qt::QueuedConnection);
connect(QtVersionManager::instance(),
&QtVersionManager::qtVersionsLoaded,
this, &WinRtDeviceFactory::onPrerequisitesLoaded, Qt::QueuedConnection);
}
setDisplayName(WinRtDevice::displayNameForType(deviceType));
setConstructionFunction(&WinRtDevice::create);
setCombinedIcon(":/winrt/images/winrtdevicesmall.png",
":/winrt/images/winrtdevice.png");
}
void WinRtDeviceFactory::autoDetect()
{
qCDebug(winrtDeviceLog) << __FUNCTION__;
MessageManager::write(tr("Running Windows Runtime device detection."));
const QString runnerFilePath = findRunnerFilePath();
if (runnerFilePath.isEmpty()) {
MessageManager::write(tr("No winrtrunner.exe found."));
return;
}
if (!m_process) {
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Creating process";
m_process = new Utils::QtcProcess(this);
connect(m_process, &QProcess::errorOccurred, this, &WinRtDeviceFactory::onProcessError);
connect(m_process,
static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished),
this, &WinRtDeviceFactory::onProcessFinished);
}
const QString args = QStringLiteral("--list-devices");
m_process->setCommand(runnerFilePath, args);
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Starting process" << runnerFilePath
<< "with arguments" << args;
MessageManager::write(runnerFilePath + QLatin1Char(' ') + args);
m_process->start();
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Process started";
}
void WinRtDeviceFactory::onPrerequisitesLoaded()
{
if (!allPrerequisitesLoaded() || m_initialized)
return;
qCDebug(winrtDeviceLog) << __FUNCTION__;
m_initialized = true;
disconnect(DeviceManager::instance(), &DeviceManager::devicesLoaded,
this, &WinRtDeviceFactory::onPrerequisitesLoaded);
disconnect(QtVersionManager::instance(), &QtVersionManager::qtVersionsLoaded,
this, &WinRtDeviceFactory::onPrerequisitesLoaded);
autoDetect();
connect(QtVersionManager::instance(), &QtVersionManager::qtVersionsChanged,
this, &WinRtDeviceFactory::autoDetect);
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Done";
}
void WinRtDeviceFactory::onProcessError()
{
MessageManager::write(tr("Error while executing winrtrunner: %1")
.arg(m_process->errorString()), MessageManager::Flash);
}
void WinRtDeviceFactory::onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus)
{
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Exit code:" << exitCode <<"\tExit status:"
<< exitStatus;
if (exitStatus == QProcess::CrashExit) {
// already handled in onProcessError
return;
}
if (exitCode != 0) {
MessageManager::write(tr("winrtrunner returned with exit code %1.")
.arg(exitCode), MessageManager::Flash);
return;
}
const QByteArray stdOut = m_process->readAllStandardOutput();
const QByteArray stdErr = m_process->readAllStandardError();
qCDebug(winrtDeviceLog) << __FUNCTION__ << "winrtrunner's stdout:" << stdOut;
if (!stdErr.isEmpty())
qCDebug(winrtDeviceLog) << __FUNCTION__ << "winrtrunner's stderr:" << stdErr;
parseRunnerOutput(stdOut);
}
bool WinRtDeviceFactory::allPrerequisitesLoaded()
{
return QtVersionManager::isLoaded() && DeviceManager::instance()->isLoaded();
}
QString WinRtDeviceFactory::findRunnerFilePath() const
{
qCDebug(winrtDeviceLog) << __FUNCTION__;
const QString winRtRunnerExe = QStringLiteral("/winrtrunner.exe");
const QList<BaseQtVersion *> winrtVersions
= QtVersionManager::sortVersions(
QtVersionManager::versions(BaseQtVersion::isValidPredicate([](const BaseQtVersion *v) {
return v->type() == QLatin1String(Constants::WINRT_WINRTQT)
|| v->type() == QLatin1String(Constants::WINRT_WINPHONEQT);
})));
QString filePath;
BaseQtVersion *qt = nullptr;
for (BaseQtVersion *v : winrtVersions) {
if (!qt || qt->qtVersion() < v->qtVersion()) {
QFileInfo fi(v->binPath().toString() + winRtRunnerExe);
if (fi.isFile() && fi.isExecutable()) {
qt = v;
filePath = fi.absoluteFilePath();
}
}
}
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Found" << filePath;
return filePath;
}
static int extractDeviceId(QByteArray *line)
{
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Line:" << *line;
int pos = line->indexOf(' ');
if (pos < 0) {
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Could not find space, returning -1";
return -1;
}
bool ok;
int id = line->left(pos).toInt(&ok);
if (!ok) {
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Could not extract ID";
return -1;
}
line->remove(0, pos + 1);
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Found ID" << id;
return id;
}
static IDevice::MachineType machineTypeFromLine(const QByteArray &line)
{
return line.contains("Emulator ") ? IDevice::Emulator : IDevice::Hardware;
}
/*
* The output of "winrtrunner --list-devices" looks like this:
*
* Available devices:
* Appx:
* 0 local
* Phone:
* 0 Device
* 1 Emulator 8.1 WVGA 4 inch 512MB
* 2 Emulator 8.1 WVGA 4 inch
* 3 Emulator 8.1 WXGA 4 inch
* 4 Emulator 8.1 720P 4.7 inch
* 5 Emulator 8.1 1080P 5.5 inch
* 6 Emulator 8.1 1080P 6 inch
* 7 WE8.1H Emulator WVGA 512MB
* 8 WE8.1H Emulator WVGA
* 9 WE8.1H Emulator WXGA
* 10 WE8.1H Emulator 720P
* 11 WE8.1H Emulator 1080P
* Xap:
* 0 Device
* 1 Emulator WVGA 512MB
* 2 Emulator WVGA
* 3 Emulator WXGA
* 4 Emulator 720P
*/
void WinRtDeviceFactory::parseRunnerOutput(const QByteArray &output) const
{
qCDebug(winrtDeviceLog) << __FUNCTION__;
ProjectExplorer::DeviceManager *deviceManager = ProjectExplorer::DeviceManager::instance();
enum State { StartState, AppxState, PhoneState, XapState };
State state = StartState;
int numFound = 0;
int numSkipped = 0;
foreach (QByteArray line, output.split('\n')) {
line = line.trimmed();
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Line:" << line;
if (line == "Appx:") {
qCDebug(winrtDeviceLog) << __FUNCTION__ << "state = AppxState";
state = AppxState;
} else if (line == "Phone:") {
qCDebug(winrtDeviceLog) << __FUNCTION__ << "state = PhoneState";
state = PhoneState;
} else if (line == "Xap:") {
qCDebug(winrtDeviceLog) << __FUNCTION__ << "state = XapState";
state = XapState;
} else {
const int deviceId = extractDeviceId(&line);
if (deviceId < 0) {
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Could not extract device ID";
continue;
}
const IDevice::MachineType machineType = machineTypeFromLine(line);
Core::Id deviceType;
QString name;
QString internalName = QStringLiteral("WinRT.");
if (state == AppxState) {
internalName += QStringLiteral("appx.");
deviceType = Constants::WINRT_DEVICE_TYPE_LOCAL;
name = tr("Windows Runtime local UI");
} else if (state == PhoneState) {
internalName += QStringLiteral("phone.");
name = QString::fromLocal8Bit(line);
if (machineType == IDevice::Emulator)
deviceType = Constants::WINRT_DEVICE_TYPE_EMULATOR;
else
deviceType = Constants::WINRT_DEVICE_TYPE_PHONE;
} else if (state == XapState) {
internalName += QStringLiteral("xap.");
name = QString::fromLocal8Bit(line);
if (machineType == IDevice::Emulator)
deviceType = Constants::WINRT_DEVICE_TYPE_EMULATOR;
else
deviceType = Constants::WINRT_DEVICE_TYPE_PHONE;
}
internalName += QString::number(deviceId);
const Core::Id internalId = Core::Id::fromString(internalName);
++numFound;
if (DeviceManager::instance()->find(internalId)) {
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Skipping device with ID" << deviceId;
++numSkipped;
continue;
}
auto device = WinRtDevice::create();
device->setupId(IDevice::AutoDetected, internalId);
device->setDeviceId(deviceId);
device->setType(deviceType);
device->setMachineType(machineType);
device->setDisplayName(name);
deviceManager->addDevice(ProjectExplorer::IDevice::ConstPtr(device));
qCDebug(winrtDeviceLog) << __FUNCTION__ << "Added device" << name << "(internal name:"
<< internalName << ")";
}
}
QString message = tr("Found %n Windows Runtime devices.", 0, numFound);
if (const int numNew = numFound - numSkipped) {
message += QLatin1Char(' ');
message += tr("%n of them are new.", 0, numNew);
}
MessageManager::write(message);
}
} // Internal
} // WinRt

View File

@@ -1,56 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of Qt Creator.
**
** 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 https://www.qt.io/terms-conditions. For further
** information use the contact form at https://www.qt.io/contact-us.
**
** GNU General Public License Usage
** Alternatively, this file may be used under the terms of the GNU
** General Public License version 3 as published by the Free Software
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
** included in the packaging of this file. Please review the following
** information to ensure the GNU General Public License requirements will
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
**
****************************************************************************/
#pragma once
#include <projectexplorer/devicesupport/idevicefactory.h>
#include <utils/qtcprocess.h>
namespace WinRt {
namespace Internal {
class WinRtDeviceFactory : public ProjectExplorer::IDeviceFactory
{
Q_OBJECT
public:
explicit WinRtDeviceFactory(Core::Id deviceType);
void autoDetect();
void onPrerequisitesLoaded();
private:
void onProcessError();
void onProcessFinished(int exitCode, QProcess::ExitStatus exitStatus);
static bool allPrerequisitesLoaded();
QString findRunnerFilePath() const;
void parseRunnerOutput(const QByteArray &output) const;
Utils::QtcProcess *m_process = nullptr;
bool m_initialized = false;
};
} // Internal
} // WinRt

View File

@@ -26,7 +26,6 @@
#include "winrtplugin.h" #include "winrtplugin.h"
#include "winrtconstants.h" #include "winrtconstants.h"
#include "winrtdevice.h" #include "winrtdevice.h"
#include "winrtdevicefactory.h"
#include "winrtdeployconfiguration.h" #include "winrtdeployconfiguration.h"
#include "winrtqtversion.h" #include "winrtqtversion.h"
#include "winrtphoneqtversion.h" #include "winrtphoneqtversion.h"