1 /**************************************************************************
3 ** This file is part of Qt Creator
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
10 ** GNU Lesser General Public License Usage
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.
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.
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.
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
31 **************************************************************************/
33 #ifndef ABSTRACTMOBILEAPP_H
34 #define ABSTRACTMOBILEAPP_H
36 #include "../qt4projectmanager_global.h"
37 #include <QtCore/QFileInfo>
38 #include <QtCore/QPair>
40 #ifndef CREATORLESSTEST
41 #include <coreplugin/basefilewizard.h>
42 #endif // CREATORLESSTEST
44 QT_FORWARD_DECLARE_CLASS(QTextStream)
46 namespace Qt4ProjectManager {
49 struct QT4PROJECTMANAGER_EXPORT AbstractGeneratedFileInfo
61 AbstractGeneratedFileInfo();
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
71 typedef QPair<QString, QString> DeploymentFolder; // QPair<.source, .target>
74 class QT4PROJECTMANAGER_EXPORT AbstractMobileApp : public QObject
79 enum ScreenOrientation {
80 ScreenOrientationLockLandscape,
81 ScreenOrientationLockPortrait,
102 virtual ~AbstractMobileApp();
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;
120 #ifndef CREATORLESSTEST
121 virtual Core::GeneratedFiles generateFiles(QString *errorMessage) const;
123 bool generateFiles(QString *errorMessage) const;
124 #endif // CREATORLESSTEST
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;
131 static const QString DeploymentPriFileName;
135 static QString templatesRoot();
136 static void insertParameter(QString &line, const QString ¶meter);
138 QByteArray readBlob(const QString &filePath, QString *errorMsg) const;
139 QByteArray generateFile(int fileType, QString *errorMessage) const;
140 QString outputPathBase() const;
142 #ifndef CREATORLESSTEST
143 static Core::GeneratedFile file(const QByteArray &data,
144 const QString &targetFile);
145 #endif // CREATORLESSTEST
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;
155 QByteArray generateDesktopFile(QString *errorMessage) const;
156 QByteArray generateMainCpp(QString *errorMessage) const;
157 QByteArray generateProFile(QString *errorMessage) const;
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;
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;
181 } // namespace Qt4ProjectManager
183 #endif // ABSTRACTMOBILEAPP_H