2011-02-17 17:53:52 +01:00
|
|
|
/**************************************************************************
|
2009-11-27 16:40:07 +01:00
|
|
|
**
|
2011-02-17 17:53:52 +01:00
|
|
|
** This file is part of Qt Creator
|
|
|
|
|
**
|
|
|
|
|
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
|
2009-11-27 16:40:07 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Contact: Nokia Corporation (info@qt.nokia.com)
|
2009-11-27 16:40:07 +01:00
|
|
|
**
|
|
|
|
|
**
|
|
|
|
|
** GNU Lesser General Public License Usage
|
2011-02-17 17:53:52 +01:00
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** This file may be used under the terms of the GNU Lesser General Public
|
|
|
|
|
** License version 2.1 as published by the Free Software Foundation and
|
|
|
|
|
** appearing in the file LICENSE.LGPL included in the packaging of this file.
|
|
|
|
|
** Please review the following information to ensure the GNU Lesser General
|
|
|
|
|
** Public License version 2.1 requirements will be met:
|
|
|
|
|
** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
2009-11-27 16:40:07 +01:00
|
|
|
**
|
|
|
|
|
** In addition, as a special exception, Nokia gives you certain additional
|
2011-04-13 08:42:33 +02:00
|
|
|
** rights. These rights are described in the Nokia Qt LGPL Exception
|
2009-11-27 16:40:07 +01:00
|
|
|
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
|
|
|
|
**
|
2011-04-13 08:42:33 +02:00
|
|
|
** Other Usage
|
|
|
|
|
**
|
|
|
|
|
** Alternatively, this file may be used in accordance with the terms and
|
|
|
|
|
** conditions contained in a signed written agreement between you and Nokia.
|
|
|
|
|
**
|
2009-11-27 16:40:07 +01:00
|
|
|
** If you have questions regarding the use of this file, please contact
|
|
|
|
|
** Nokia at qt-info@nokia.com.
|
|
|
|
|
**
|
2011-02-17 17:53:52 +01:00
|
|
|
**************************************************************************/
|
2009-11-27 16:40:07 +01:00
|
|
|
|
|
|
|
|
#ifndef MAEMODEVICECONFIGURATIONS_H
|
|
|
|
|
#define MAEMODEVICECONFIGURATIONS_H
|
|
|
|
|
|
2011-02-14 16:34:17 +01:00
|
|
|
#include <utils/ssh/sshconnection.h>
|
2010-04-26 11:43:25 +02:00
|
|
|
|
2011-01-13 13:49:23 +01:00
|
|
|
#include <QtCore/QAbstractListModel>
|
2009-11-27 16:40:07 +01:00
|
|
|
#include <QtCore/QList>
|
2010-08-12 19:12:12 +02:00
|
|
|
#include <QtCore/QPair>
|
2011-01-13 13:49:23 +01:00
|
|
|
#include <QtCore/QSharedPointer>
|
2009-11-27 16:40:07 +01:00
|
|
|
#include <QtCore/QString>
|
|
|
|
|
|
|
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
class QSettings;
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
|
|
namespace Qt4ProjectManager {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2010-08-12 19:12:12 +02:00
|
|
|
class MaemoPortList
|
|
|
|
|
{
|
2010-08-12 19:46:58 +02:00
|
|
|
public:
|
2011-01-13 16:24:05 +01:00
|
|
|
void addPort(int port);
|
|
|
|
|
void addRange(int startPort, int endPort);
|
|
|
|
|
bool hasMore() const;
|
|
|
|
|
int count() const;
|
|
|
|
|
int getNext();
|
|
|
|
|
QString toString() const;
|
2010-08-12 19:12:12 +02:00
|
|
|
|
|
|
|
|
private:
|
2011-01-13 16:24:05 +01:00
|
|
|
typedef QPair<int, int> Range;
|
2010-08-12 19:12:12 +02:00
|
|
|
QList<Range> m_ranges;
|
|
|
|
|
};
|
|
|
|
|
|
2011-01-13 16:24:05 +01:00
|
|
|
|
2009-12-23 10:53:57 +01:00
|
|
|
class MaemoDeviceConfig
|
2009-11-27 16:40:07 +01:00
|
|
|
{
|
2011-01-13 13:49:23 +01:00
|
|
|
friend class MaemoDeviceConfigurations;
|
2009-11-27 16:40:07 +01:00
|
|
|
public:
|
2011-01-13 13:49:23 +01:00
|
|
|
typedef QSharedPointer<const MaemoDeviceConfig> ConstPtr;
|
|
|
|
|
typedef quint64 Id;
|
2011-04-21 14:39:57 +02:00
|
|
|
enum OsVersion { Maemo5, Maemo6, Meego, GenericLinux };
|
2011-02-14 13:56:39 +01:00
|
|
|
enum DeviceType { Physical, Emulator };
|
2011-01-13 13:49:23 +01:00
|
|
|
|
2010-08-12 19:12:12 +02:00
|
|
|
MaemoPortList freePorts() const;
|
2011-02-14 16:34:17 +01:00
|
|
|
Utils::SshConnectionParameters sshParameters() const { return m_sshParameters; }
|
2011-01-13 13:49:23 +01:00
|
|
|
QString name() const { return m_name; }
|
2011-04-21 14:39:57 +02:00
|
|
|
OsVersion osVersion() const { return m_osVersion; }
|
2011-01-13 13:49:23 +01:00
|
|
|
DeviceType type() const { return m_type; }
|
|
|
|
|
QString portsSpec() const { return m_portsSpec; }
|
2011-02-04 15:04:20 +01:00
|
|
|
Id internalId() const { return m_internalId; }
|
2011-01-13 15:00:48 +01:00
|
|
|
bool isDefault() const { return m_isDefault; }
|
2010-08-12 17:10:39 +02:00
|
|
|
static QString portsRegExpr();
|
2011-04-21 14:39:57 +02:00
|
|
|
static QString defaultHost(DeviceType type, OsVersion osVersion);
|
2011-02-02 17:53:36 +01:00
|
|
|
static QString defaultPrivateKeyFilePath();
|
2011-02-10 15:37:12 +01:00
|
|
|
static QString defaultPublicKeyFilePath();
|
2011-04-21 14:39:57 +02:00
|
|
|
static QString defaultUser(OsVersion osVersion);
|
2011-02-03 14:17:13 +01:00
|
|
|
static int defaultSshPort(DeviceType type);
|
2011-04-21 14:39:57 +02:00
|
|
|
static QString defaultQemuPassword(OsVersion osVersion);
|
2010-04-26 11:43:25 +02:00
|
|
|
|
2011-01-13 16:24:05 +01:00
|
|
|
static const Id InvalidId;
|
2009-12-01 14:04:25 +01:00
|
|
|
|
2009-12-23 10:53:57 +01:00
|
|
|
private:
|
2011-01-13 13:49:23 +01:00
|
|
|
typedef QSharedPointer<MaemoDeviceConfig> Ptr;
|
|
|
|
|
|
2011-04-21 14:39:57 +02:00
|
|
|
MaemoDeviceConfig(const QString &name, OsVersion osVersion,
|
2011-02-14 16:34:17 +01:00
|
|
|
DeviceType type, const Utils::SshConnectionParameters &sshParams,
|
2011-02-03 16:09:35 +01:00
|
|
|
Id &nextId);
|
2011-01-13 13:49:23 +01:00
|
|
|
MaemoDeviceConfig(const QSettings &settings, Id &nextId);
|
2011-01-13 14:32:15 +01:00
|
|
|
MaemoDeviceConfig(const ConstPtr &other);
|
2011-01-13 13:49:23 +01:00
|
|
|
|
|
|
|
|
MaemoDeviceConfig(const MaemoDeviceConfig &);
|
|
|
|
|
MaemoDeviceConfig &operator=(const MaemoDeviceConfig &);
|
|
|
|
|
|
2011-04-21 14:39:57 +02:00
|
|
|
static Ptr createHardwareConfig(const QString &name, OsVersion osVersion,
|
|
|
|
|
const QString &hostName, const QString &privateKeyFilePath, Id &nextId);
|
2011-03-09 12:07:35 +01:00
|
|
|
static Ptr createGenericLinuxConfigUsingPassword(const QString &name,
|
|
|
|
|
const QString &hostName, const QString &userName,
|
|
|
|
|
const QString &password, Id &nextId);
|
|
|
|
|
static Ptr createGenericLinuxConfigUsingKey(const QString &name,
|
|
|
|
|
const QString &hostName, const QString &userName,
|
|
|
|
|
const QString &privateKeyFilePath, Id &nextId);
|
2011-04-21 14:39:57 +02:00
|
|
|
static Ptr createEmulatorConfig(const QString &name, OsVersion osVersion,
|
|
|
|
|
Id &nextId);
|
2011-01-13 13:49:23 +01:00
|
|
|
static Ptr create(const QSettings &settings, Id &nextId);
|
2011-01-13 14:32:15 +01:00
|
|
|
static Ptr create(const ConstPtr &other);
|
2011-01-13 13:49:23 +01:00
|
|
|
|
|
|
|
|
void save(QSettings &settings) const;
|
2010-08-12 19:12:12 +02:00
|
|
|
QString defaultPortsSpec(DeviceType type) const;
|
2010-04-08 17:31:55 +02:00
|
|
|
|
2011-02-14 16:34:17 +01:00
|
|
|
Utils::SshConnectionParameters m_sshParameters;
|
2011-01-13 13:49:23 +01:00
|
|
|
QString m_name;
|
2011-04-21 14:39:57 +02:00
|
|
|
OsVersion m_osVersion;
|
2011-01-13 13:49:23 +01:00
|
|
|
DeviceType m_type;
|
|
|
|
|
QString m_portsSpec;
|
|
|
|
|
bool m_isDefault;
|
2011-01-13 14:32:15 +01:00
|
|
|
Id m_internalId;
|
2009-12-23 10:53:57 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
2011-01-13 13:49:23 +01:00
|
|
|
class MaemoDeviceConfigurations : public QAbstractListModel
|
2009-12-23 10:53:57 +01:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
Q_DISABLE_COPY(MaemoDeviceConfigurations)
|
|
|
|
|
public:
|
2011-01-13 13:49:23 +01:00
|
|
|
static MaemoDeviceConfigurations *instance(QObject *parent = 0);
|
2009-11-30 14:09:08 +01:00
|
|
|
|
2011-01-13 13:49:23 +01:00
|
|
|
static void replaceInstance(const MaemoDeviceConfigurations *other);
|
|
|
|
|
static MaemoDeviceConfigurations *cloneInstance();
|
2010-12-06 15:28:16 +01:00
|
|
|
|
2011-01-13 15:01:46 +01:00
|
|
|
MaemoDeviceConfig::ConstPtr deviceAt(int index) const;
|
2011-01-13 13:49:23 +01:00
|
|
|
MaemoDeviceConfig::ConstPtr find(MaemoDeviceConfig::Id id) const;
|
2011-04-21 14:39:57 +02:00
|
|
|
MaemoDeviceConfig::ConstPtr defaultDeviceConfig(const MaemoDeviceConfig::OsVersion osVersion) const;
|
2011-01-13 13:49:23 +01:00
|
|
|
bool hasConfig(const QString &name) const;
|
|
|
|
|
int indexForInternalId(MaemoDeviceConfig::Id internalId) const;
|
|
|
|
|
MaemoDeviceConfig::Id internalId(MaemoDeviceConfig::ConstPtr devConf) const;
|
2009-12-01 14:04:25 +01:00
|
|
|
|
2010-12-06 15:28:16 +01:00
|
|
|
void setDefaultSshKeyFilePath(const QString &path) { m_defaultSshKeyFilePath = path; }
|
|
|
|
|
QString defaultSshKeyFilePath() const { return m_defaultSshKeyFilePath; }
|
|
|
|
|
|
2011-02-03 16:09:35 +01:00
|
|
|
void addHardwareDeviceConfiguration(const QString &name,
|
2011-04-21 14:39:57 +02:00
|
|
|
MaemoDeviceConfig::OsVersion osVersion, const QString &hostName,
|
2011-03-09 12:07:35 +01:00
|
|
|
const QString &privateKeyFilePath);
|
|
|
|
|
void addGenericLinuxConfigurationUsingPassword(const QString &name,
|
|
|
|
|
const QString &hostName, const QString &userName,
|
|
|
|
|
const QString &password);
|
|
|
|
|
void addGenericLinuxConfigurationUsingKey(const QString &name,
|
|
|
|
|
const QString &hostName, const QString &userName,
|
|
|
|
|
const QString &privateKeyFilePath);
|
2011-02-03 16:09:35 +01:00
|
|
|
void addEmulatorDeviceConfiguration(const QString &name,
|
2011-04-21 14:39:57 +02:00
|
|
|
MaemoDeviceConfig::OsVersion osVersion);
|
2011-01-13 15:01:46 +01:00
|
|
|
void removeConfiguration(int index);
|
2011-01-13 13:49:23 +01:00
|
|
|
void setConfigurationName(int i, const QString &name);
|
2011-02-14 16:34:17 +01:00
|
|
|
void setSshParameters(int i, const Utils::SshConnectionParameters ¶ms);
|
2011-01-13 13:49:23 +01:00
|
|
|
void setPortsSpec(int i, const QString &portsSpec);
|
2011-01-13 15:00:48 +01:00
|
|
|
void setDefaultDevice(int index);
|
2011-01-13 13:49:23 +01:00
|
|
|
|
|
|
|
|
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
|
|
|
|
|
virtual QVariant data(const QModelIndex &index,
|
|
|
|
|
int role = Qt::DisplayRole) const;
|
|
|
|
|
|
2009-12-01 14:04:25 +01:00
|
|
|
signals:
|
|
|
|
|
void updated();
|
2009-11-27 16:40:07 +01:00
|
|
|
|
|
|
|
|
private:
|
2009-12-01 14:04:25 +01:00
|
|
|
MaemoDeviceConfigurations(QObject *parent);
|
2009-11-27 16:40:07 +01:00
|
|
|
void load();
|
|
|
|
|
void save();
|
2011-01-13 13:49:23 +01:00
|
|
|
static void copy(const MaemoDeviceConfigurations *source,
|
2011-01-13 14:32:15 +01:00
|
|
|
MaemoDeviceConfigurations *target, bool deep);
|
2011-02-03 16:09:35 +01:00
|
|
|
void addConfiguration(const MaemoDeviceConfig::Ptr &devConfig);
|
2011-04-21 14:39:57 +02:00
|
|
|
void ensureDefaultExists(MaemoDeviceConfig::OsVersion osVersion);
|
2009-11-27 16:40:07 +01:00
|
|
|
|
2009-12-01 14:04:25 +01:00
|
|
|
static MaemoDeviceConfigurations *m_instance;
|
2011-01-13 13:49:23 +01:00
|
|
|
MaemoDeviceConfig::Id m_nextId;
|
|
|
|
|
QList<MaemoDeviceConfig::Ptr> m_devConfigs;
|
2010-12-06 15:28:16 +01:00
|
|
|
QString m_defaultSshKeyFilePath;
|
2009-11-27 16:40:07 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Qt4ProjectManager
|
|
|
|
|
|
|
|
|
|
#endif // MAEMODEVICECONFIGURATIONS_H
|