aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/qt4projectmanager/qt-s60/s60publishingsissettingspageovi.cpp
blob: 828b7fa01a0218e57d61c1cdb9f6aeccc39d1294 (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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
**
** Contact: Nokia Corporation (info@qt.nokia.com)
**
**
** 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.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**************************************************************************/

#include "s60publishingsissettingspageovi.h"
#include "ui_s60publishingsissettingspageovi.h"
#include "s60publisherovi.h"
#include "s60certificateinfo.h"

#include <QtGui/QAbstractButton>

using namespace ProjectExplorer;

namespace Qt4ProjectManager {
namespace Internal {

S60PublishingSisSettingsPageOvi::S60PublishingSisSettingsPageOvi(S60PublisherOvi *publisher, QWidget *parent) :
    QWizardPage(parent),
    ui(new Ui::S60PublishingSisSettingsPageOvi),
    m_publisher(publisher)
{
    ui->setupUi(this);

    //Setup labels which display icons about the state of the entry
    //error icons
    ui->capabilitiesErrorLabel->hide();
    ui->qtVersionErrorLabel->hide();
    ui->uid3ErrorLabel->hide();
    ui->globalVendorNameErrorLabel->hide();
    ui->localisedVendorNamesErrorLabel->hide();
    //ok icons
    ui->capabilitiesOkLabel->hide();
    ui->qtVersionOkLabel->hide();
    ui->uid3OkLabel->hide();
    ui->globalVendorNameOkLabel->hide();
    ui->localisedVendorNamesOkLabel->hide();
    //warning icons
    ui->globalVendorNameWarningLabel->hide();
    ui->localisedVendorNamesWarningLabel->hide();
    ui->qtVersionWarningLabel->hide();
    ui->uid3WarningLabel->hide();
}

void S60PublishingSisSettingsPageOvi::initializePage()
{
    //Finish creation of the publisher
    m_publisher->completeCreation();

    showWarningsForUnenforcableChecks();

    //Check Global Vendor Name
    ui->globalVendorNameLineEdit->setText(m_publisher->globalVendorName());
    globalVendorNameChanged();
    connect(ui->globalVendorNameLineEdit,SIGNAL(textChanged(QString)),SLOT(globalVendorNameChanged()));

    //Check Localised Vendor Names
    ui->localisedVendorNamesLineEdit->setText(m_publisher->localisedVendorNames());
    localisedVendorNamesChanged();
    connect(ui->localisedVendorNamesLineEdit,SIGNAL(textChanged(QString)),SLOT(localisedVendorNamesChanged()));

    //Check Qt Version Used in Builds
    ui->qtVersionDisplayLabel->setText(m_publisher->qtVersion());
    qtVersionChanged();

    //Check UID3
    ui->uid3LineEdit->setText(m_publisher->uid3());
    uid3Changed();
    connect(ui->uid3LineEdit,SIGNAL(textChanged(QString)),SLOT(uid3Changed()));

    //Check for capabilities which are not signed for
    ui->capabilitiesDisplayLabel->setText(m_publisher->capabilities());
    capabilitiesChanged();
}

void S60PublishingSisSettingsPageOvi::cleanupPage()
{
    m_publisher->cleanUp();
}

S60PublishingSisSettingsPageOvi::~S60PublishingSisSettingsPageOvi()
{
    delete ui;
}

void S60PublishingSisSettingsPageOvi::reflectSettingState(bool settingState, QLabel *okLabel, QLabel *errorLabel, QLabel *errorReasonLabel, const QString &errorReason)
{
    if (!settingState) {
        okLabel->hide();
        errorLabel->show();
        errorReasonLabel->setTextFormat(Qt::RichText);
        errorReasonLabel->setText(errorReason);
        errorReasonLabel->show();
    } else {
        okLabel->show();
        errorLabel->hide();
        errorReasonLabel->hide();
    }

    // This is a hack.
    // the labels change size, most likely increasing height but that doesn't change the wizard layout
    // It essentially forces QWizard to update its layout. (Until setTitleFormat checks whether the format changed at all...)
    // todo figure out whether the QWizard should be doing that automatically
    wizard()->setTitleFormat(wizard()->titleFormat());
}

void S60PublishingSisSettingsPageOvi::globalVendorNameChanged()
{
    reflectSettingState(m_publisher->isVendorNameValid(ui->globalVendorNameLineEdit->text()),
                        ui->globalVendorNameOkLabel,
                        ui->globalVendorNameErrorLabel,
                        ui->globalVendorNameErrorReasonLabel,
                        tr("%1 is a default vendor name used for testing and development. <br>"
                           "The Vendor_Name field cannot contain the name 'Nokia'. <br>"
                           "You are advised against using the default names 'Vendor' and 'Vendor-EN'. <br>"
                           "You should also not leave the entry blank. <br>"
                           "see <a href=\"http://www.forum.nokia.com/Distribute/Packaging_and_signing.xhtml\">Packaging and Signing</a> for guidelines.<br>")
                        .arg("\"" + ui->globalVendorNameLineEdit->text() + "\""));
    m_publisher->setVendorName(ui->globalVendorNameLineEdit->text());
}

void S60PublishingSisSettingsPageOvi::localisedVendorNamesChanged()
{
    QStringList localisedVendorNames = ui->localisedVendorNamesLineEdit->text().split(',');

    bool settingState = true;
    QStringList wrongVendorNames;

    foreach (const QString &localisedVendorName, localisedVendorNames) {
        if (!m_publisher->isVendorNameValid(localisedVendorName)) {
            wrongVendorNames.append(localisedVendorName);
            settingState = false;
        }
    }

    QString pluralOrSingular = tr("%1 is a default vendor name used for testing and development.").arg(wrongVendorNames.join(", "));
    if (wrongVendorNames.count() > 1)
        pluralOrSingular = tr("%1 are default vendor names used for testing and development.").arg(wrongVendorNames.join(", "));

    reflectSettingState(settingState,
                        ui->localisedVendorNamesOkLabel,
                        ui->localisedVendorNamesErrorLabel,
                        ui->localisedVendorNamesErrorReasonLabel,
                        tr("%1 <br>"
                           "The Vendor_Name field cannot contain the name 'Nokia'. <br>"
                           "You are advised against using the default names 'Vendor' and 'Vendor-EN'. <br>"
                           "You should also not leave the entry blank. <br>"
                           "See <a href=\"http://www.forum.nokia.com/Distribute/Packaging_and_signing.xhtml\">"
                           "Packaging and Signing</a> for guidelines.<br>").arg(pluralOrSingular));
    m_publisher->setLocalVendorNames(ui->localisedVendorNamesLineEdit->text());
}

void S60PublishingSisSettingsPageOvi::qtVersionChanged()
{
}

void S60PublishingSisSettingsPageOvi::uid3Changed()
{
    QString testUID3ErrorMsg = tr("The application UID %1 is only for testing and development.<br>"
                               "SIS packages built with it cannot be distributed via the Ovi Store.<br>");

    QString symbianSignedUID3ErrorMsg = tr("The application UID %1 is a symbiansigned.com UID. <br>"
                                        "Applications with this UID will be rejected by "
                                        "Application Signing Services for Ovi Store.<br>"
                                        "If you want to continue with a symbiansigned.com UID, "
                                        "sign your application on symbiansigned.com and upload the "
                                        "signed application to Publish to Ovi.<br>");

    QString errorMsg = tr("The application UID %1 is not an acceptable UID.<br>"
                          "SIS packages built with it cannot be signed by "
                          "Application Signing Services for Ovi Store.<br>");

    if (m_publisher->isTestUID3(ui->uid3LineEdit->text())) {
        errorMsg = testUID3ErrorMsg;
    } else if (m_publisher->isKnownSymbianSignedUID3(ui->uid3LineEdit->text())) {
        errorMsg = symbianSignedUID3ErrorMsg;
    }

    reflectSettingState(m_publisher->isUID3Valid(ui->uid3LineEdit->text()),
                        ui->uid3OkLabel,
                        ui->uid3ErrorLabel,
                        ui->uid3ErrorReasonLabel,
                        tr("The application UID is a global unique indentifier of the SIS package.<br>") +
                        errorMsg.arg(ui->uid3LineEdit->text()) +
                        tr("To get a unique application UID for your package file,<br>"
                           "please register at <a href=\"http://info.publish.ovi.com/\">publish.ovi.com</a>"));

    if (m_publisher->isUID3Valid(ui->uid3LineEdit->text())) {
        ui->uid3WarningLabel->show();
        ui->uid3WarningReasonLabel->setText("If this UID is from symbiansigned.com, It will be "
                                            "rejected by Application Signing Services for Ovi Store.<br>"
                                            "If you want to continue with a symbiansigned.com UID, "
                                            "sign your application on symbiansigned.com and upload "
                                            "the signed application to Publish to Ovi.<br>"
                                            "It is, however, recommended that you obtain a UID from "
                                            "<a href=\"http://info.publish.ovi.com/\">publish.ovi.com</a>");
        ui->uid3WarningReasonLabel->show();
    } else {
        ui->uid3WarningLabel->hide();
        ui->uid3WarningReasonLabel->hide();
    }

    m_publisher->setAppUid(ui->uid3LineEdit->text());
}

void S60PublishingSisSettingsPageOvi::capabilitiesChanged()
{
    QStringList capabilities = ui->capabilitiesDisplayLabel->text().split(',');
    QString errorMessage;

    //Check for certified Signed capabilities
    QStringList capabilitesNeedingCertifiedSigned;
    foreach (const QString &capability, capabilities) {
       if( m_publisher->isCapabilityOneOf(capability, S60PublisherOvi::CertifiedSigned)) {
            capabilitesNeedingCertifiedSigned.append(capability);
            capabilities.removeOne(capability);
        }
    }

    if (!capabilitesNeedingCertifiedSigned.isEmpty())
        errorMessage.append(tr("%1 need(s) to be certified signed. "
                               "Please go to <a href=\"symbiansigned.com\">symbiansigned.com</a> for guidance.")
                            .arg(capabilitesNeedingCertifiedSigned.join(", ")));

    //Check for capabilities needing manufacturer approval
    QStringList capabilitiesNeedingManufacturerApproved;

    foreach (const QString &capability, capabilities) {
       if( m_publisher->isCapabilityOneOf(capability, S60PublisherOvi::ManufacturerApproved))
            capabilitiesNeedingManufacturerApproved.append(capability);
    }

    if (!capabilitiesNeedingManufacturerApproved.isEmpty()) {
        errorMessage.append(tr("<br>%1 need(s) manufacturer approval.<br>").arg(capabilitiesNeedingManufacturerApproved.join(", ")));
    }

    errorMessage.prepend(tr("Some capabilities might require a special kind of signing or approval from the manufacturer.<br>"));

    reflectSettingState(capabilitesNeedingCertifiedSigned.isEmpty() && capabilitiesNeedingManufacturerApproved.isEmpty(),
                        ui->capabilitiesOkLabel,
                        ui->capabilitiesErrorLabel,
                        ui->capabilitiesErrorReasonLabel,
                        errorMessage);
}

void S60PublishingSisSettingsPageOvi::showWarningsForUnenforcableChecks()
{
    //Warn about use of unreleased Qt Versions
    //ui->qtVersionWarningLabel->show(); //looks better without...
    ui->qtVersionWarningReasonLabel->setText(tr("Please verify that you have a released version of Qt. <br>"
                                                "<a href=\"http://wiki.forum.nokia.com/index.php/Nokia_Smart_Installer_for_Symbian\">Qt Packages Distributed by Smart Installer</a> has a list of released Qt versions."));
}

} // namespace Internal
} // namespace Qt4ProjectManager