OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / plugins / qt4projectmanager / wizards / abstractmobileapp.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32
33 #ifndef ABSTRACTMOBILEAPP_H
34 #define ABSTRACTMOBILEAPP_H
35
36 #include "../qt4projectmanager_global.h"
37 #include <QtCore/QFileInfo>
38 #include <QtCore/QPair>
39
40 #ifndef CREATORLESSTEST
41 #include <coreplugin/basefilewizard.h>
42 #endif // CREATORLESSTEST
43
44 QT_FORWARD_DECLARE_CLASS(QTextStream)
45
46 namespace Qt4ProjectManager {
47
48 /// \internal
49 struct QT4PROJECTMANAGER_EXPORT AbstractGeneratedFileInfo
50 {
51     enum FileType {
52         MainCppFile,
53         AppProFile,
54         DeploymentPriFile,
55         SymbianSvgIconFile,
56         MaemoPngIconFile,
57         DesktopFile,
58         ExtendedFile
59     };
60
61     AbstractGeneratedFileInfo();
62
63     int fileType;
64     QFileInfo fileInfo;
65     int currentVersion; // Current version of the template file in Creator
66     int version; // The version in the file header
67     quint16 dataChecksum; // The calculated checksum
68     quint16 statedChecksum; // The checksum in the file header
69 };
70
71 typedef QPair<QString, QString> DeploymentFolder; // QPair<.source, .target>
72
73 /// \internal
74 class QT4PROJECTMANAGER_EXPORT AbstractMobileApp : public QObject
75 {
76     Q_OBJECT
77
78 public:
79     enum ScreenOrientation {
80         ScreenOrientationLockLandscape,
81         ScreenOrientationLockPortrait,
82         ScreenOrientationAuto
83     };
84
85     enum FileType {
86         MainCpp,
87         MainCppOrigin,
88         AppPro,
89         AppProOrigin,
90         AppProPath,
91         Desktop,
92         DesktopOrigin,
93         DeploymentPri,
94         DeploymentPriOrigin,
95         SymbianSvgIcon,
96         SymbianSvgIconOrigin,
97         MaemoPngIcon,
98         MaemoPngIconOrigin,
99         ExtendedFile
100     };
101
102     virtual ~AbstractMobileApp();
103
104     void setOrientation(ScreenOrientation orientation);
105     ScreenOrientation orientation() const;
106     void setProjectName(const QString &name);
107     QString projectName() const;
108     void setProjectPath(const QString &path);
109     void setSymbianSvgIcon(const QString &icon);
110     QString symbianSvgIcon() const;
111     void setMaemoPngIcon(const QString &icon);
112     QString maemoPngIcon() const;
113     void setSymbianTargetUid(const QString &uid);
114     QString symbianTargetUid() const;
115     void setNetworkEnabled(bool enabled);
116     bool networkEnabled() const;
117     QString path(int fileType) const;
118     QString error() const;
119
120 #ifndef CREATORLESSTEST
121     virtual Core::GeneratedFiles generateFiles(QString *errorMessage) const;
122 #else
123     bool generateFiles(QString *errorMessage) const;
124 #endif // CREATORLESSTEST
125
126     static QString symbianUidForPath(const QString &path);
127     static int makeStubVersion(int minor);
128     QList<AbstractGeneratedFileInfo> fileUpdates(const QString &mainProFile) const;
129     bool updateFiles(const QList<AbstractGeneratedFileInfo> &list, QString &error) const;
130
131     static const QString DeploymentPriFileName;
132 protected:
133     AbstractMobileApp();
134
135     static QString templatesRoot();
136     static void insertParameter(QString &line, const QString &parameter);
137
138     QByteArray readBlob(const QString &filePath, QString *errorMsg) const;
139     QByteArray generateFile(int fileType, QString *errorMessage) const;
140     QString outputPathBase() const;
141
142 #ifndef CREATORLESSTEST
143     static Core::GeneratedFile file(const QByteArray &data,
144         const QString &targetFile);
145 #endif // CREATORLESSTEST
146
147     static const QString CFileComment;
148     static const QString ProFileComment;
149     static const QString FileChecksum;
150     static const QString FileStubVersion;
151     static const int StubVersion;
152
153     QString m_error;
154 private:
155     QByteArray generateDesktopFile(QString *errorMessage) const;
156     QByteArray generateMainCpp(QString *errorMessage) const;
157     QByteArray generateProFile(QString *errorMessage) const;
158
159     virtual QByteArray generateFileExtended(int fileType,
160         bool *versionAndCheckSum, QString *comment, QString *errorMessage) const=0;
161     virtual QString pathExtended(int fileType) const=0;
162     virtual QString originsRoot() const=0;
163     virtual QString mainWindowClassName() const=0;
164     virtual int stubVersionMinor() const=0;
165     virtual bool adaptCurrentMainCppTemplateLine(QString &line) const=0;
166     virtual void handleCurrentProFileTemplateLine(const QString &line,
167         QTextStream &proFileTemplate, QTextStream &proFile,
168         bool &commentOutNextLine) const = 0;
169     virtual QList<AbstractGeneratedFileInfo> updateableFiles(const QString &mainProFile) const = 0;
170     virtual QList<DeploymentFolder> deploymentFolders() const = 0;
171
172     QString m_projectName;
173     QFileInfo m_projectPath;
174     QString m_symbianSvgIcon;
175     QString m_maemoPngIcon;
176     QString m_symbianTargetUid;
177     ScreenOrientation m_orientation;
178     bool m_networkEnabled;
179 };
180
181 } // namespace Qt4ProjectManager
182
183 #endif // ABSTRACTMOBILEAPP_H