1 /****************************************************************************
2 **
3 ** Copyright (C) 2016 The Qt Company Ltd.
4 ** Contact: https://www.qt.io/licensing/
5 **
6 ** This file is part of Qt Creator.
7 **
8 ** Commercial License Usage
9 ** Licensees holding valid commercial Qt licenses may use this file in
10 ** accordance with the commercial license agreement provided with the
11 ** Software or, alternatively, in accordance with the terms contained in
12 ** a written agreement between you and The Qt Company. For licensing terms
13 ** and conditions see https://www.qt.io/terms-conditions. For further
14 ** information use the contact form at https://www.qt.io/contact-us.
15 **
16 ** GNU General Public License Usage
17 ** Alternatively, this file may be used under the terms of the GNU
18 ** General Public License version 3 as published by the Free Software
19 ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
20 ** included in the packaging of this file. Please review the following
21 ** information to ensure the GNU General Public License requirements will
22 ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
23 **
24 ****************************************************************************/
25 
26 #include "uploadandinstalltarpackagestep.h"
27 
28 #include "remotelinux_constants.h"
29 #include "remotelinuxdeployconfiguration.h"
30 #include "remotelinuxpackageinstaller.h"
31 #include "tarpackagecreationstep.h"
32 
33 using namespace ProjectExplorer;
34 
35 namespace RemoteLinux {
36 namespace Internal {
37 
38 class UploadAndInstallTarPackageServicePrivate
39 {
40 public:
41     RemoteLinuxTarPackageInstaller installer;
42 };
43 
44 } // namespace Internal
45 
46 using namespace Internal;
47 
UploadAndInstallTarPackageService()48 UploadAndInstallTarPackageService::UploadAndInstallTarPackageService()
49     : d(new UploadAndInstallTarPackageServicePrivate)
50 {
51 }
52 
~UploadAndInstallTarPackageService()53 UploadAndInstallTarPackageService::~UploadAndInstallTarPackageService()
54 {
55     delete d;
56 }
57 
packageInstaller() const58 AbstractRemoteLinuxPackageInstaller *UploadAndInstallTarPackageService::packageInstaller() const
59 {
60     return &d->installer;
61 }
62 
63 
UploadAndInstallTarPackageStep(BuildStepList * bsl,Utils::Id id)64 UploadAndInstallTarPackageStep::UploadAndInstallTarPackageStep(BuildStepList *bsl, Utils::Id id)
65     : AbstractRemoteLinuxDeployStep(bsl, id)
66 {
67     auto service = createDeployService<UploadAndInstallTarPackageService>();
68 
69     setWidgetExpandedByDefault(false);
70 
71     setInternalInitializer([this, service] {
72         const TarPackageCreationStep *pStep = nullptr;
73 
74         for (BuildStep *step : deployConfiguration()->stepList()->steps()) {
75             if (step == this)
76                 break;
77             if ((pStep = dynamic_cast<TarPackageCreationStep *>(step)))
78                 break;
79         }
80         if (!pStep)
81             return CheckResult::failure(tr("No tarball creation step found."));
82 
83         service->setPackageFilePath(pStep->packageFilePath());
84         return service->isDeploymentPossible();
85     });
86 }
87 
stepId()88 Utils::Id UploadAndInstallTarPackageStep::stepId()
89 {
90     return Constants::UploadAndInstallTarPackageStepId;
91 }
92 
displayName()93 QString UploadAndInstallTarPackageStep::displayName()
94 {
95     return tr("Deploy tarball via SFTP upload");
96 }
97 
98 } //namespace RemoteLinux
99