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 #pragma once
27 
28 #include <projectexplorer/abi.h>
29 #include <projectexplorer/toolchain.h>
30 #include <utils/fileutils.h>
31 
32 #include <QDateTime>
33 #include <QObject>
34 #include <QString>
35 #include <QStringList>
36 #include <QVersionNumber>
37 
38 #include <memory>
39 
40 QT_BEGIN_NAMESPACE
41 class QSettings;
42 class QFileSystemWatcher;
43 QT_END_NAMESPACE
44 
45 namespace Ios {
46 namespace Internal {
47 
48 class DevelopmentTeam;
49 
50 class ProvisioningProfile
51 {
Q_DECLARE_TR_FUNCTIONS(ProvisioningProfile)52     Q_DECLARE_TR_FUNCTIONS(ProvisioningProfile)
53 public:
54     std::shared_ptr<DevelopmentTeam> developmentTeam() { return m_team; }
55     QString identifier() const;
56     QString displayName() const;
57     QString details() const;
expirationDate()58     const QDateTime &expirationDate() const { return m_expirationDate; }
59 
60 private:
61     std::shared_ptr<DevelopmentTeam> m_team;
62     QString m_identifier;
63     QString m_name;
64     QString m_appID;
65     QDateTime m_expirationDate;
66     friend class IosConfigurations;
67     friend QDebug &operator<<(QDebug &stream, std::shared_ptr<ProvisioningProfile> profile);
68 };
69 
70 using ProvisioningProfilePtr = std::shared_ptr<ProvisioningProfile>;
71 using ProvisioningProfiles = QList<ProvisioningProfilePtr>;
72 
73 class DevelopmentTeam
74 {
75     Q_DECLARE_TR_FUNCTIONS(DevelopmentTeam)
76 public:
77     QString identifier() const;
78     QString displayName() const;
79     QString details() const;
isFreeProfile()80     bool isFreeProfile() const { return m_freeTeam; }
hasProvisioningProfile()81     bool hasProvisioningProfile() const { return !m_profiles.isEmpty(); }
82 
83 private:
84     QString m_identifier;
85     QString m_name;
86     QString m_email;
87     bool m_freeTeam = false;
88     ProvisioningProfiles m_profiles;
89     friend class IosConfigurations;
90     friend QDebug &operator<<(QDebug &stream, std::shared_ptr<DevelopmentTeam> team);
91 };
92 
93 using DevelopmentTeamPtr = std::shared_ptr<DevelopmentTeam>;
94 using DevelopmentTeams = QList<DevelopmentTeamPtr>;
95 
96 class IosToolChainFactory : public ProjectExplorer::ToolChainFactory
97 {
98 public:
99     IosToolChainFactory();
100 
101     QList<ProjectExplorer::ToolChain *> autoDetect(
102             const QList<ProjectExplorer::ToolChain *> &existingToolChains,
103             const ProjectExplorer::IDevice::Ptr &device) override;
104 };
105 
106 class IosConfigurations : public QObject
107 {
108     Q_OBJECT
109 
110 public:
111     static IosConfigurations *instance();
112     static void initialize();
113     static bool ignoreAllDevices();
114     static void setIgnoreAllDevices(bool ignoreDevices);
115     static void setScreenshotDir(const Utils::FilePath &path);
116     static Utils::FilePath screenshotDir();
117     static Utils::FilePath developerPath();
118     static QVersionNumber xcodeVersion();
119     static Utils::FilePath lldbPath();
120     static void updateAutomaticKitList();
121     static const DevelopmentTeams &developmentTeams();
122     static DevelopmentTeamPtr developmentTeam(const QString &teamID);
123     static const ProvisioningProfiles &provisioningProfiles();
124     static ProvisioningProfilePtr provisioningProfile(const QString &profileID);
125 
126 signals:
127     void provisioningDataChanged();
128 
129 private:
130     IosConfigurations(QObject *parent);
131     void load();
132     void save();
133     void kitsRestored();
134     void updateSimulators();
135     static void setDeveloperPath(const Utils::FilePath &devPath);
136     void initializeProvisioningData();
137     void loadProvisioningData(bool notify = true);
138 
139     Utils::FilePath m_developerPath;
140     Utils::FilePath m_screenshotDir;
141     QVersionNumber m_xcodeVersion;
142     bool m_ignoreAllDevices;
143     QFileSystemWatcher *m_provisioningDataWatcher = nullptr;
144     ProvisioningProfiles m_provisioningProfiles;
145     DevelopmentTeams m_developerTeams;
146 };
147 QDebug &operator<<(QDebug &stream, std::shared_ptr<ProvisioningProfile> profile);
148 QDebug &operator<<(QDebug &stream, std::shared_ptr<DevelopmentTeam> team);
149 } // namespace Internal
150 } // namespace Ios
151