summaryrefslogtreecommitdiff
path: root/src/plugins/madde/maemodeploystepfactory.cpp
blob: b1ea5655e4704c9dcbe4e210dfda569eeec2c0a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: http://www.qt-project.org/
**
**
** GNU Lesser General Public License Usage
**
** 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.
**
** In addition, as a special exception, Nokia gives you certain additional
** rights. These rights are described in the Nokia Qt LGPL Exception
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
** 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.
**
**
**************************************************************************/

#include "maemodeploystepfactory.h"

#include "maemoconstants.h"
#include "maddeuploadandinstallpackagesteps.h"
#include "maemodeploybymountsteps.h"
#include "maemoinstalltosysrootstep.h"
#include "qt4maemodeployconfiguration.h"

#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/buildsteplist.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/target.h>
#include <qtsupport/qtprofileinformation.h>
#include <qtsupport/qtsupportconstants.h>
#include <remotelinux/genericdirectuploadstep.h>
#include <remotelinux/remotelinuxcheckforfreediskspacestep.h>
#include <remotelinux/uploadandinstalltarpackagestep.h>

#include <QCoreApplication>

using namespace ProjectExplorer;
using namespace RemoteLinux;

namespace Madde {
namespace Internal {

const char OldMaemoDeployStepId[] = "Qt4ProjectManager.MaemoDeployStep";

MaemoDeployStepFactory::MaemoDeployStepFactory(QObject *parent)
    : IBuildStepFactory(parent)
{
}

QList<Core::Id> MaemoDeployStepFactory::availableCreationIds(BuildStepList *parent) const
{
    QList<Core::Id> ids;
    if (!qobject_cast<Qt4MaemoDeployConfiguration *>(parent->parent()))
        return ids;

    QString platform;
    QtSupport::BaseQtVersion *version = QtSupport::QtProfileInformation::qtVersion(parent->target()->profile());
    if (version)
        platform = version->platformName();

    if (platform == QtSupport::Constants::MAEMO_FREMANTLE_PLATFORM) {
        ids << Core::Id(MaemoMakeInstallToSysrootStep::Id)
            << Core::Id(MaemoInstallDebianPackageToSysrootStep::Id)
            << Core::Id(MaemoUploadAndInstallPackageStep::stepId())
            << Core::Id(MaemoInstallPackageViaMountStep::stepId())
            << Core::Id(MaemoCopyFilesViaMountStep::stepId());
    } else if (platform == QtSupport::Constants::MEEGO_HARMATTAN_PLATFORM) {
        ids << Core::Id(MaemoMakeInstallToSysrootStep::Id)
            << Core::Id(MaemoInstallDebianPackageToSysrootStep::Id)
            << Core::Id(MaemoUploadAndInstallPackageStep::stepId())
            << Core::Id(GenericDirectUploadStep::stepId());
    }

    return ids;
}

QString MaemoDeployStepFactory::displayNameForId(const Core::Id id) const
{
    if (id == MaemoInstallPackageViaMountStep::stepId())
        return MaemoInstallPackageViaMountStep::displayName();
    if (id == MaemoCopyFilesViaMountStep::stepId())
        return MaemoCopyFilesViaMountStep::displayName();
    if (id == MaemoUploadAndInstallPackageStep::stepId())
        return MaemoUploadAndInstallPackageStep::displayName();
    if (id == MaemoInstallDebianPackageToSysrootStep::Id)
        return MaemoInstallDebianPackageToSysrootStep::displayName();
    if (id == MaemoCopyToSysrootStep::Id)
        return MaemoCopyToSysrootStep::displayName();
    if (id == MaemoMakeInstallToSysrootStep::Id)
        return MaemoMakeInstallToSysrootStep::displayName();
    if (id == GenericDirectUploadStep::stepId())
        return GenericDirectUploadStep::displayName();
    if (id == RemoteLinuxCheckForFreeDiskSpaceStep::stepId())
        return RemoteLinuxCheckForFreeDiskSpaceStep::stepDisplayName();
    return QString();
}

bool MaemoDeployStepFactory::canCreate(BuildStepList *parent, const Core::Id id) const
{
    return availableCreationIds(parent).contains(id) && !parent->contains(id);
}

BuildStep *MaemoDeployStepFactory::create(BuildStepList *parent, const Core::Id id)
{
    Core::Id deviceType = DeviceTypeProfileInformation::deviceTypeId(parent->target()->profile());

    if (id == MaemoInstallDebianPackageToSysrootStep::Id)
        return new MaemoInstallDebianPackageToSysrootStep(parent);
    if (id == MaemoCopyToSysrootStep::Id)
        return new MaemoCopyToSysrootStep(parent);
    if (id == MaemoMakeInstallToSysrootStep::Id)
        return new MaemoMakeInstallToSysrootStep(parent);
    if (id == MaemoInstallPackageViaMountStep::stepId()
        || (id == OldMaemoDeployStepId && deviceType == Maemo5OsType))
        return new MaemoInstallPackageViaMountStep(parent);
    if (id == MaemoCopyFilesViaMountStep::stepId())
        return new MaemoCopyFilesViaMountStep(parent);
    if (id == MaemoUploadAndInstallPackageStep::stepId()
        || (id == OldMaemoDeployStepId && deviceType == HarmattanOsType))
        return new MaemoUploadAndInstallPackageStep(parent);
    if (id == GenericDirectUploadStep::stepId())
        return new GenericDirectUploadStep(parent, id);
    if (id == RemoteLinuxCheckForFreeDiskSpaceStep::stepId())
        return new RemoteLinuxCheckForFreeDiskSpaceStep(parent);

    return 0;
}

bool MaemoDeployStepFactory::canRestore(BuildStepList *parent, const QVariantMap &map) const
{
    return canCreate(parent, idFromMap(map)) || idFromMap(map) == OldMaemoDeployStepId;
}

BuildStep *MaemoDeployStepFactory::restore(BuildStepList *parent, const QVariantMap &map)
{
    Q_ASSERT(canRestore(parent, map));
    BuildStep * const step = create(parent, idFromMap(map));
    if (!step->fromMap(map)) {
        delete step;
        return 0;
    }
    return step;
}

bool MaemoDeployStepFactory::canClone(BuildStepList *parent, BuildStep *product) const
{
    return canCreate(parent, product->id());
}

BuildStep *MaemoDeployStepFactory::clone(BuildStepList *parent, BuildStep *product)
{
    Q_ASSERT(canClone(parent, product));
    if (product->id() == MaemoInstallPackageViaMountStep::stepId()) {
        return new MaemoInstallPackageViaMountStep(parent,
            qobject_cast<MaemoInstallPackageViaMountStep *>(product));
    } else if (product->id() == MaemoCopyFilesViaMountStep::stepId()) {
        return new MaemoCopyFilesViaMountStep(parent,
            qobject_cast<MaemoCopyFilesViaMountStep *>(product));
    } else if (product->id() == MaemoUploadAndInstallPackageStep::stepId()) {
        return new MaemoUploadAndInstallPackageStep(parent,
            qobject_cast<MaemoUploadAndInstallPackageStep*>(product));
    } else if (product->id() == MaemoInstallDebianPackageToSysrootStep::Id) {
        return new MaemoInstallDebianPackageToSysrootStep(parent,
            qobject_cast<MaemoInstallDebianPackageToSysrootStep *>(product));
    } else if (product->id() == MaemoCopyToSysrootStep::Id) {
        return new MaemoCopyToSysrootStep(parent,
            qobject_cast<MaemoCopyToSysrootStep *>(product));
    } else if (product->id() == MaemoMakeInstallToSysrootStep::Id) {
        return new MaemoMakeInstallToSysrootStep(parent,
            qobject_cast<MaemoMakeInstallToSysrootStep *>(product));
    } else if (product->id() == GenericDirectUploadStep::stepId()) {
        return new GenericDirectUploadStep(parent,
             qobject_cast<GenericDirectUploadStep *>(product));
    } else if (RemoteLinuxCheckForFreeDiskSpaceStep * const other = qobject_cast<RemoteLinuxCheckForFreeDiskSpaceStep *>(product)) {
        return new RemoteLinuxCheckForFreeDiskSpaceStep(parent, other);
    }

    return 0;
}

} // namespace Internal
} // namespace Madde