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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
|
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the qmake application of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, 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.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "symbiancommon.h"
#include <qdebug.h>
// Included from tools/shared
#include <symbian/epocroot.h>
#define RESOURCE_DIRECTORY_RESOURCE "\\\\resource\\\\apps\\\\"
#define RSS_RULES "RSS_RULES"
#define RSS_RULES_BASE "RSS_RULES."
#define RSS_TAG_NBROFICONS "number_of_icons"
#define RSS_TAG_ICONFILE "icon_file"
#define MANUFACTURER_NOTE_FILE "manufacturer_note.txt"
#define DEFAULT_MANUFACTURER_NOTE \
"The package is not supported for devices from this manufacturer. Please try the selfsigned " \
"version of the package instead."
SymbianCommonGenerator::SymbianCommonGenerator(MakefileGenerator *generator)
: generator(generator)
{
}
void SymbianCommonGenerator::init()
{
QMakeProject *project = generator->project;
fixedTarget = generator->escapeFilePath(project->first("TARGET"));
fixedTarget = removePathSeparators(fixedTarget);
removeSpecialCharacters(fixedTarget);
// This should not be empty since the mkspecs are supposed to set it if missing.
uid3 = project->first("TARGET.UID3").trimmed();
if ((project->values("TEMPLATE")).contains("app"))
targetType = TypeExe;
else if ((project->values("TEMPLATE")).contains("lib")) {
// Check CONFIG to see if we are to build staticlib or dll
if (project->isActiveConfig("staticlib") || project->isActiveConfig("static"))
targetType = TypeLib;
else if (project->isActiveConfig("plugin"))
targetType = TypePlugin;
else
targetType = TypeDll;
} else {
targetType = TypeSubdirs;
}
// UID is valid as either hex or decimal, so just convert it to number and back to hex
// to get proper string for private dir
bool conversionOk = false;
uint uidNum = uid3.toUInt(&conversionOk, 0);
if (!conversionOk) {
fprintf(stderr, "Error: Invalid UID \"%s\".\n", uid3.toUtf8().constData());
} else {
privateDirUid.setNum(uidNum, 16);
while (privateDirUid.length() < 8)
privateDirUid.insert(0, QLatin1Char('0'));
}
}
bool SymbianCommonGenerator::containsStartWithItem(const QChar &c, const QStringList& src)
{
bool result = false;
foreach(QString str, src) {
if (str.startsWith(c)) {
result = true;
break;
}
}
return result;
}
void SymbianCommonGenerator::removeSpecialCharacters(QString& str)
{
// When modifying this method check also application_icon.prf
str.replace(QString("/"), QString("_"));
str.replace(QString("\\"), QString("_"));
str.replace(QString("-"), QString("_"));
str.replace(QString(":"), QString("_"));
str.replace(QString("."), QString("_"));
str.replace(QString(" "), QString("_"));
}
void SymbianCommonGenerator::generatePkgFile(const QString &iconFile, DeploymentList &depList, bool epocBuild)
{
QMakeProject *project = generator->project;
QString pkgFilename = QString("%1_template.%2").arg(fixedTarget).arg("pkg");
if (!Option::output_dir.isEmpty())
pkgFilename = Option::output_dir + '/' + pkgFilename;
QFile pkgFile(pkgFilename);
if (!pkgFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
PRINT_FILE_CREATE_ERROR(pkgFilename);
return;
}
generatedFiles << pkgFile.fileName();
QTextStream t(&pkgFile);
QString installerSisHeader = project->values("DEPLOYMENT.installer_header").join("\n");
QString wrapperStreamBuffer;
QTextStream tw(&wrapperStreamBuffer);
QString dateStr = QDateTime::currentDateTime().toString(Qt::ISODate);
// Header info
QString wrapperPkgFilename = QString("%1_installer.%2")
.arg(fixedTarget)
.arg("pkg");
QString headerComment = "; %1 generated by qmake at %2\n"
"; This file is generated by qmake and should not be modified by the user\n"
";\n\n";
t << headerComment.arg(pkgFilename).arg(dateStr);
tw << headerComment.arg(wrapperPkgFilename).arg(dateStr);
// Construct QStringList from pkg_prerules since we need search it before printed to file
QStringList rawPkgPreRules;
foreach(QString deploymentItem, project->values("DEPLOYMENT")) {
foreach(QString pkgrulesItem, project->values(deploymentItem + ".pkg_prerules")) {
QStringList pkgrulesValue = project->values(pkgrulesItem);
// If there is no stringlist defined for a rule, use rule name directly
// This is convenience for defining single line mmp statements
if (pkgrulesValue.isEmpty()) {
rawPkgPreRules << pkgrulesItem;
} else {
foreach(QString pkgrule, pkgrulesValue) {
rawPkgPreRules << pkgrule;
}
}
}
}
// Apply some defaults if specific data does not exist in PKG pre-rules
if (!containsStartWithItem('&', rawPkgPreRules)) {
// language, (*** hardcoded to english atm, should be parsed from TRANSLATIONS)
QString languageCode = "; Language\n&EN\n\n";
t << languageCode;
tw << languageCode;
} else {
// In case user defines langs, he must take care also about SIS header
if (!containsStartWithItem('#', rawPkgPreRules))
fprintf(stderr, "Warning: If language is defined with DEPLOYMENT pkg_prerules, also the SIS header must be defined\n");
}
// name of application, UID and version
QString applicationVersion = project->first("VERSION").isEmpty() ? "1,0,0" : project->first("VERSION").replace('.', ',');
QString sisHeader = "; SIS header: name, uid, version\n#{\"%1\"},(%2),%3\n\n";
QString visualTarget = generator->escapeFilePath(generator->fileFixify(project->first("TARGET")));
visualTarget = removePathSeparators(visualTarget);
QString wrapperTarget = visualTarget + " installer";
if (installerSisHeader.startsWith("0x", Qt::CaseInsensitive)) {
tw << sisHeader.arg(wrapperTarget).arg(installerSisHeader).arg(applicationVersion);
} else {
tw << installerSisHeader << endl;
}
if (!containsStartWithItem('#', rawPkgPreRules)) {
t << sisHeader.arg(visualTarget).arg(uid3).arg(applicationVersion);
}
// Localized vendor name
QString vendorName;
if (!containsStartWithItem('%', rawPkgPreRules)) {
vendorName += "; Localised Vendor name\n%{\"Vendor\"}\n\n";
}
// Unique vendor name
if (!containsStartWithItem(':', rawPkgPreRules)) {
vendorName += "; Unique Vendor name\n:\"Vendor\"\n\n";
}
t << vendorName;
tw << vendorName;
// PKG pre-rules - these are added before actual file installations i.e. SIS package body
if (rawPkgPreRules.size()) {
QString comment = "\n; Manual PKG pre-rules from PRO files\n";
t << comment;
tw << comment;
foreach(QString item, rawPkgPreRules) {
// Only regular pkg file should have package dependencies or pkg header if that is
// defined using prerules.
if (!item.startsWith("(") && !item.startsWith("#")) {
tw << item << endl;
}
t << item << endl;
}
t << endl;
tw << endl;
}
// Begin Manufacturer block
if (!project->values("DEPLOYMENT.manufacturers").isEmpty()) {
QString manufacturerStr("IF ");
foreach(QString manufacturer, project->values("DEPLOYMENT.manufacturers")) {
manufacturerStr.append(QString("(MANUFACTURER)=(%1) OR \n ").arg(manufacturer));
}
// Remove the final OR
manufacturerStr.chop(8);
t << manufacturerStr << endl;
}
// Install paths on the phone *** should be dynamic at some point
QString installPathBin = "!:\\sys\\bin";
QString installPathResource = "!:\\resource\\apps";
QString installPathRegResource = "!:\\private\\10003a3f\\import\\apps";
// Find location of builds
QString destDirBin;
QString destDirResource;
QString destDirRegResource;
if (epocBuild) {
destDirBin = QString("%1epoc32/release/$(PLATFORM)/$(TARGET)").arg(epocRoot());
destDirResource = QString("%1epoc32/data/z/resource/apps").arg(epocRoot());
destDirRegResource = QString("%1epoc32/data/z/private/10003a3f/import/apps").arg(epocRoot());
} else {
destDirBin = project->first("DESTDIR");
if (destDirBin.isEmpty())
destDirBin = ".";
else if (destDirBin.endsWith('/') || destDirBin.endsWith('\\'))
destDirBin.chop(1);
destDirResource = destDirBin;
destDirRegResource = destDirBin;
}
if (targetType == TypeExe) {
// deploy .exe file
t << "; Executable and default resource files" << endl;
QString exeFile = fixedTarget + ".exe";
t << QString("\"%1/%2\" - \"%3\\%4\"")
.arg(destDirBin)
.arg(exeFile)
.arg(installPathBin)
.arg(exeFile) << endl;
// deploy rsc & reg_rsc file
if (!project->isActiveConfig("no_icon")) {
t << QString("\"%1/%2\" - \"%3\\%4\"")
.arg(destDirResource)
.arg(fixedTarget + ".rsc")
.arg(installPathResource)
.arg(fixedTarget + ".rsc") << endl;
t << QString("\"%1/%2\" - \"%3\\%4\"")
.arg(destDirRegResource)
.arg(fixedTarget + "_reg.rsc")
.arg(installPathRegResource)
.arg(fixedTarget + "_reg.rsc") << endl;
if (!iconFile.isEmpty()) {
if (epocBuild) {
t << QString("\"%1epoc32/data/z%2\" - \"!:%3\"")
.arg(epocRoot())
.arg(iconFile)
.arg(QDir::toNativeSeparators(iconFile)) << endl << endl;
} else {
QDir mifIconDir(project->first("DESTDIR"));
QFileInfo mifIcon(mifIconDir.relativeFilePath(project->first("TARGET")));
QString mifIconFileName = mifIcon.fileName();
mifIconFileName.replace(QRegExp("[-: .]"), "_");
mifIconFileName.append(".mif");
t << QString("\"%1/%2\" - \"!:%3\"")
.arg(mifIcon.path())
.arg(mifIconFileName)
.arg(QDir::toNativeSeparators(iconFile)) << endl << endl;
}
}
}
}
// deploy any additional DEPLOYMENT files
QString remoteTestPath;
remoteTestPath = QString("!:\\private\\%1").arg(privateDirUid);
initProjectDeploySymbian(project, depList, remoteTestPath, true, epocBuild, "$(PLATFORM)", "$(TARGET)", generatedDirs, generatedFiles);
if (depList.size())
t << "; DEPLOYMENT" << endl;
for (int i = 0; i < depList.size(); ++i) {
t << QString("\"%1\" - \"%2\"")
.arg(depList.at(i).from)
.arg(depList.at(i).to) << endl;
}
t << endl;
// PKG post-rules - these are added after actual file installations i.e. SIS package body
t << "; Manual PKG post-rules from PRO files" << endl;
foreach(QString deploymentItem, project->values("DEPLOYMENT")) {
foreach(QString pkgrulesItem, project->values(deploymentItem + ".pkg_postrules")) {
QStringList pkgrulesValue = project->values(pkgrulesItem);
// If there is no stringlist defined for a rule, use rule name directly
// This is convenience for defining single line statements
if (pkgrulesValue.isEmpty()) {
t << pkgrulesItem << endl;
} else {
foreach(QString pkgrule, pkgrulesValue) {
t << pkgrule << endl;
}
}
t << endl;
}
}
// Close Manufacturer block
if (!project->values("DEPLOYMENT.manufacturers").isEmpty()) {
QString manufacturerFailNoteFile;
if (project->values("DEPLOYMENT.manufacturers.fail_note").isEmpty()) {
manufacturerFailNoteFile = QString("%1_" MANUFACTURER_NOTE_FILE).arg(uid3);
QFile ft(manufacturerFailNoteFile);
if (ft.open(QIODevice::WriteOnly)) {
generatedFiles << ft.fileName();
QTextStream t2(&ft);
t2 << QString(DEFAULT_MANUFACTURER_NOTE) << endl;
} else {
PRINT_FILE_CREATE_ERROR(manufacturerFailNoteFile)
}
} else {
manufacturerFailNoteFile = project->values("DEPLOYMENT.manufacturers.fail_note").join("");
}
t << "ELSEIF NOT(0) ; MANUFACTURER" << endl
<< "\"" << generator->fileInfo(manufacturerFailNoteFile).absoluteFilePath() << "\""
<< " - \"\", FILETEXT, TEXTEXIT" << endl
<< "ENDIF ; MANUFACTURER" << endl;
}
// Write wrapper pkg
if (!installerSisHeader.isEmpty()) {
QFile wrapperPkgFile(wrapperPkgFilename);
if (!wrapperPkgFile.open(QIODevice::WriteOnly | QIODevice::Text)) {
PRINT_FILE_CREATE_ERROR(wrapperPkgFilename);
return;
}
generatedFiles << wrapperPkgFile.fileName();
QTextStream twf(&wrapperPkgFile);
twf << wrapperStreamBuffer << endl;
// Wrapped files deployment
QString currentPath = qmake_getpwd();
QString sisName = QString("%1.sis").arg(fixedTarget);
twf << "\"" << currentPath << "/" << sisName << "\" - \"c:\\adm\\" << sisName << "\"" << endl;
QString bootStrapPath = QLibraryInfo::location(QLibraryInfo::PrefixPath);
bootStrapPath.append("/bootstrap.sis");
QFileInfo fi(generator->fileInfo(bootStrapPath));
twf << "@\"" << fi.absoluteFilePath() << "\",(0x2002CCCD)" << endl;
}
}
QString SymbianCommonGenerator::removePathSeparators(QString &file)
{
QString ret = file;
while (ret.indexOf(QDir::separator()) > 0) {
ret.remove(0, ret.indexOf(QDir::separator()) + 1);
}
return ret;
}
void SymbianCommonGenerator::writeRegRssFile(QStringList &userItems)
{
QString filename(fixedTarget);
filename.append("_reg.rss");
if (!Option::output_dir.isEmpty())
filename = Option::output_dir + '/' + filename;
QFile ft(filename);
if (ft.open(QIODevice::WriteOnly)) {
generatedFiles << ft.fileName();
QTextStream t(&ft);
t << "// ============================================================================" << endl;
t << "// * Generated by qmake (" << qmake_version() << ") (Qt " QT_VERSION_STR ") on: ";
t << QDateTime::currentDateTime().toString(Qt::ISODate) << endl;
t << "// * This file is generated by qmake and should not be modified by the" << endl;
t << "// * user." << endl;
t << "// ============================================================================" << endl;
t << endl;
t << "#include <" << fixedTarget << ".rsg>" << endl;
t << "#include <appinfo.rh>" << endl;
t << endl;
t << "UID2 KUidAppRegistrationResourceFile" << endl;
t << "UID3 " << uid3 << endl << endl;
t << "RESOURCE APP_REGISTRATION_INFO" << endl;
t << "\t{" << endl;
t << "\tapp_file=\"" << fixedTarget << "\";" << endl;
t << "\tlocalisable_resource_file=\"" RESOURCE_DIRECTORY_RESOURCE << fixedTarget << "\";" << endl;
t << endl;
foreach(QString item, userItems)
t << "\t" << item << endl;
t << "\t}" << endl;
} else {
PRINT_FILE_CREATE_ERROR(filename)
}
}
void SymbianCommonGenerator::writeRssFile(QString &numberOfIcons, QString &iconFile)
{
QString filename(fixedTarget);
if (!Option::output_dir.isEmpty())
filename = Option::output_dir + '/' + filename;
filename.append(".rss");
QFile ft(filename);
if (ft.open(QIODevice::WriteOnly)) {
generatedFiles << ft.fileName();
QTextStream t(&ft);
t << "// ============================================================================" << endl;
t << "// * Generated by qmake (" << qmake_version() << ") (Qt " QT_VERSION_STR ") on: ";
t << QDateTime::currentDateTime().toString(Qt::ISODate) << endl;
t << "// * This file is generated by qmake and should not be modified by the" << endl;
t << "// * user." << endl;
t << "// ============================================================================" << endl;
t << endl;
t << "#include <appinfo.rh>" << endl;
t << "#include \"" << fixedTarget << ".loc\"" << endl;
t << endl;
t << "RESOURCE LOCALISABLE_APP_INFO r_localisable_app_info" << endl;
t << "\t{" << endl;
t << "\tshort_caption = STRING_r_short_caption;" << endl;
t << "\tcaption_and_icon =" << endl;
t << "\tCAPTION_AND_ICON_INFO" << endl;
t << "\t\t{" << endl;
t << "\t\tcaption = STRING_r_caption;" << endl;
QString rssIconFile = iconFile;
rssIconFile = rssIconFile.replace("/", "\\\\");
if (numberOfIcons.isEmpty() || rssIconFile.isEmpty()) {
// There can be maximum one item in this tag, validated when parsed
t << "\t\tnumber_of_icons = 0;" << endl;
t << "\t\ticon_file = \"\";" << endl;
} else {
// There can be maximum one item in this tag, validated when parsed
t << "\t\tnumber_of_icons = " << numberOfIcons << ";" << endl;
t << "\t\ticon_file = \"" << rssIconFile << "\";" << endl;
}
t << "\t\t};" << endl;
t << "\t}" << endl;
t << endl;
} else {
PRINT_FILE_CREATE_ERROR(filename);
}
}
void SymbianCommonGenerator::writeLocFile(QStringList &symbianLangCodes)
{
QString filename(fixedTarget);
if (!Option::output_dir.isEmpty())
filename = Option::output_dir + '/' + filename;
filename.append(".loc");
QFile ft(filename);
if (ft.open(QIODevice::WriteOnly)) {
generatedFiles << ft.fileName();
QTextStream t(&ft);
t << "// ============================================================================" << endl;
t << "// * Generated by qmake (" << qmake_version() << ") (Qt " QT_VERSION_STR ") on: ";
t << QDateTime::currentDateTime().toString(Qt::ISODate) << endl;
t << "// * This file is generated by qmake and should not be modified by the" << endl;
t << "// * user." << endl;
t << "// ============================================================================" << endl;
t << endl;
t << "#ifdef LANGUAGE_SC" << endl;
t << "#define STRING_r_short_caption \"" << fixedTarget << "\"" << endl;
t << "#define STRING_r_caption \"" << fixedTarget << "\"" << endl;
foreach(QString lang, symbianLangCodes) {
t << "#elif defined LANGUAGE_" << lang << endl;
t << "#define STRING_r_short_caption \"" << fixedTarget << "\"" << endl;
t << "#define STRING_r_caption \"" << fixedTarget << "\"" << endl;
}
t << "#else" << endl;
t << "#define STRING_r_short_caption \"" << fixedTarget << "\"" << endl;
t << "#define STRING_r_caption \"" << fixedTarget << "\"" << endl;
t << "#endif" << endl;
} else {
PRINT_FILE_CREATE_ERROR(filename);
}
}
void SymbianCommonGenerator::readRssRules(QString &numberOfIcons, QString &iconFile, QStringList &userRssRules)
{
QMakeProject *project = generator->project;
for (QMap<QString, QStringList>::iterator it = project->variables().begin(); it != project->variables().end(); ++it) {
if (it.key().startsWith(RSS_RULES_BASE)) {
QString newKey = it.key().mid(sizeof(RSS_RULES_BASE) - 1);
if (newKey.isEmpty()) {
fprintf(stderr, "Warning: Empty RSS_RULES_BASE key encountered\n");
continue;
}
QStringList newValues;
QStringList values = it.value();
foreach(QString item, values) {
// If there is no stringlist defined for a rule, use rule name directly
// This is convenience for defining single line statements
if (project->values(item).isEmpty()) {
newValues << item;
} else {
foreach(QString itemRow, project->values(item)) {
newValues << itemRow;
}
}
}
// Verify thet there is exactly one value in RSS_TAG_NBROFICONS
if (newKey == RSS_TAG_NBROFICONS) {
if (newValues.count() == 1) {
numberOfIcons = newValues[0];
} else {
fprintf(stderr, "Warning: There must be exactly one value in '%s%s'\n",
RSS_RULES_BASE, RSS_TAG_NBROFICONS);
continue;
}
// Verify thet there is exactly one value in RSS_TAG_ICONFILE
} else if (newKey == RSS_TAG_ICONFILE) {
if (newValues.count() == 1) {
iconFile = newValues[0];
} else {
fprintf(stderr, "Warning: There must be exactly one value in '%s%s'\n",
RSS_RULES_BASE, RSS_TAG_ICONFILE);
continue;
}
} else {
fprintf(stderr, "Warning: Unsupported key:'%s%s'\n",
RSS_RULES_BASE, newKey.toLatin1().constData());
continue;
}
}
}
foreach(QString item, project->values(RSS_RULES)) {
// If there is no stringlist defined for a rule, use rule name directly
// This is convenience for defining single line mmp statements
if (project->values(item).isEmpty()) {
userRssRules << item;
} else {
userRssRules << project->values(item);
}
}
// Validate that either both RSS_TAG_NBROFICONS and RSS_TAG_ICONFILE keys exist
// or neither of them exist
if (!((numberOfIcons.isEmpty() && iconFile.isEmpty()) ||
(!numberOfIcons.isEmpty() && !iconFile.isEmpty()))) {
numberOfIcons.clear();
iconFile.clear();
fprintf(stderr, "Warning: Both or neither of '%s%s' and '%s%s' keys must exist.\n",
RSS_RULES_BASE, RSS_TAG_NBROFICONS, RSS_RULES_BASE, RSS_TAG_ICONFILE);
}
// Validate that RSS_TAG_NBROFICONS contains only numbers
if (!numberOfIcons.isEmpty()) {
bool ok;
numberOfIcons = numberOfIcons.simplified();
numberOfIcons.toInt(&ok);
if (!ok) {
numberOfIcons.clear();
iconFile.clear();
fprintf(stderr, "Warning: '%s%s' must be integer in decimal format.\n",
RSS_RULES_BASE, RSS_TAG_NBROFICONS);
}
}
}
QStringList SymbianCommonGenerator::symbianLangCodesFromTsFiles()
{
QStringList tsfiles;
QStringList symbianLangCodes;
tsfiles << generator->project->values("TRANSLATIONS");
fillQt2S60LangMapTable();
foreach(QString file, tsfiles) {
int extIndex = file.lastIndexOf(".");
int langIndex = file.lastIndexOf("_", (extIndex - file.length()));
langIndex += 1;
QString qtlang = file.mid(langIndex, extIndex - langIndex);
QString s60lang = qt2S60LangMapTable.value(qtlang, QString("SC"));
if (!symbianLangCodes.contains(s60lang) && s60lang != "SC")
symbianLangCodes += s60lang;
}
return symbianLangCodes;
}
void SymbianCommonGenerator::fillQt2S60LangMapTable()
{
qt2S60LangMapTable.reserve(170); // 165 items at time of writing.
qt2S60LangMapTable.insert("ab", "SC"); //Abkhazian //
qt2S60LangMapTable.insert("om", "SC"); //Afan //
qt2S60LangMapTable.insert("aa", "SC"); //Afar //
qt2S60LangMapTable.insert("af", "34"); //Afrikaans //Afrikaans
qt2S60LangMapTable.insert("sq", "35"); //Albanian //Albanian
qt2S60LangMapTable.insert("am", "36"); //Amharic //Amharic
qt2S60LangMapTable.insert("ar", "37"); //Arabic //Arabic
qt2S60LangMapTable.insert("hy", "38"); //Armenian //Armenian
qt2S60LangMapTable.insert("as", "SC"); //Assamese //
qt2S60LangMapTable.insert("ay", "SC"); //Aymara //
qt2S60LangMapTable.insert("az", "SC"); //Azerbaijani //
qt2S60LangMapTable.insert("ba", "SC"); //Bashkir //
qt2S60LangMapTable.insert("eu", "SC"); //Basque //
qt2S60LangMapTable.insert("bn", "41"); //Bengali //Bengali
qt2S60LangMapTable.insert("dz", "SC"); //Bhutani //
qt2S60LangMapTable.insert("bh", "SC"); //Bihari //
qt2S60LangMapTable.insert("bi", "SC"); //Bislama //
qt2S60LangMapTable.insert("br", "SC"); //Breton //
qt2S60LangMapTable.insert("bg", "42"); //Bulgarian //Bulgarian
qt2S60LangMapTable.insert("my", "43"); //Burmese //Burmese
qt2S60LangMapTable.insert("be", "40"); //Byelorussian //Belarussian
qt2S60LangMapTable.insert("km", "SC"); //Cambodian //
qt2S60LangMapTable.insert("ca", "44"); //Catalan //Catalan
qt2S60LangMapTable.insert("zh", "SC"); //Chinese //
qt2S60LangMapTable.insert("co", "SC"); //Corsican //
qt2S60LangMapTable.insert("hr", "45"); //Croatian //Croatian
qt2S60LangMapTable.insert("cs", "25"); //Czech //Czech
qt2S60LangMapTable.insert("da", "07"); //Danish //Danish
qt2S60LangMapTable.insert("nl", "18"); //Dutch //Dutch
qt2S60LangMapTable.insert("en", "01"); //English //English(UK)
qt2S60LangMapTable.insert("eo", "SC"); //Esperanto //
qt2S60LangMapTable.insert("et", "49"); //Estonian //Estonian
qt2S60LangMapTable.insert("fo", "SC"); //Faroese //
qt2S60LangMapTable.insert("fj", "SC"); //Fiji //
qt2S60LangMapTable.insert("fi", "09"); //Finnish //Finnish
qt2S60LangMapTable.insert("fr", "02"); //French //French
qt2S60LangMapTable.insert("fy", "SC"); //Frisian //
qt2S60LangMapTable.insert("gd", "52"); //Gaelic //Gaelic
qt2S60LangMapTable.insert("gl", "SC"); //Galician //
qt2S60LangMapTable.insert("ka", "53"); //Georgian //Georgian
qt2S60LangMapTable.insert("de", "03"); //German //German
qt2S60LangMapTable.insert("el", "54"); //Greek //Greek
qt2S60LangMapTable.insert("kl", "SC"); //Greenlandic //
qt2S60LangMapTable.insert("gn", "SC"); //Guarani //
qt2S60LangMapTable.insert("gu", "56"); //Gujarati //Gujarati
qt2S60LangMapTable.insert("ha", "SC"); //Hausa //
qt2S60LangMapTable.insert("he", "57"); //Hebrew //Hebrew
qt2S60LangMapTable.insert("hi", "58"); //Hindi //Hindi
qt2S60LangMapTable.insert("hu", "17"); //Hungarian //Hungarian
qt2S60LangMapTable.insert("is", "15"); //Icelandic //Icelandic
qt2S60LangMapTable.insert("id", "59"); //Indonesian //Indonesian
qt2S60LangMapTable.insert("ia", "SC"); //Interlingua //
qt2S60LangMapTable.insert("ie", "SC"); //Interlingue //
qt2S60LangMapTable.insert("iu", "SC"); //Inuktitut //
qt2S60LangMapTable.insert("ik", "SC"); //Inupiak //
qt2S60LangMapTable.insert("ga", "60"); //Irish //Irish
qt2S60LangMapTable.insert("it", "05"); //Italian //Italian
qt2S60LangMapTable.insert("ja", "32"); //Japanese //Japanese
qt2S60LangMapTable.insert("jv", "SC"); //Javanese //
qt2S60LangMapTable.insert("kn", "62"); //Kannada //Kannada
qt2S60LangMapTable.insert("ks", "SC"); //Kashmiri //
qt2S60LangMapTable.insert("kk", "63"); //Kazakh //Kazakh
qt2S60LangMapTable.insert("rw", "SC"); //Kinyarwanda //
qt2S60LangMapTable.insert("ky", "SC"); //Kirghiz //
qt2S60LangMapTable.insert("ko", "65"); //Korean //Korean
qt2S60LangMapTable.insert("ku", "SC"); //Kurdish //
qt2S60LangMapTable.insert("rn", "SC"); //Kurundi //
qt2S60LangMapTable.insert("lo", "66"); //Laothian //Laothian
qt2S60LangMapTable.insert("la", "SC"); //Latin //
qt2S60LangMapTable.insert("lv", "67"); //Latvian //Latvian
qt2S60LangMapTable.insert("ln", "SC"); //Lingala //
qt2S60LangMapTable.insert("lt", "68"); //Lithuanian //Lithuanian
qt2S60LangMapTable.insert("mk", "69"); //Macedonian //Macedonian
qt2S60LangMapTable.insert("mg", "SC"); //Malagasy //
qt2S60LangMapTable.insert("ms", "70"); //Malay //Malay
qt2S60LangMapTable.insert("ml", "71"); //Malayalam //Malayalam
qt2S60LangMapTable.insert("mt", "SC"); //Maltese //
qt2S60LangMapTable.insert("mi", "SC"); //Maori //
qt2S60LangMapTable.insert("mr", "72"); //Marathi //Marathi
qt2S60LangMapTable.insert("mo", "73"); //Moldavian //Moldovian
qt2S60LangMapTable.insert("mn", "74"); //Mongolian //Mongolian
qt2S60LangMapTable.insert("na", "SC"); //Nauru //
qt2S60LangMapTable.insert("ne", "SC"); //Nepali //
qt2S60LangMapTable.insert("nb", "08"); //Norwegian //Norwegian
qt2S60LangMapTable.insert("oc", "SC"); //Occitan //
qt2S60LangMapTable.insert("or", "SC"); //Oriya //
qt2S60LangMapTable.insert("ps", "SC"); //Pashto //
qt2S60LangMapTable.insert("fa", "SC"); //Persian //
qt2S60LangMapTable.insert("pl", "27"); //Polish //Polish
qt2S60LangMapTable.insert("pt", "13"); //Portuguese //Portuguese
qt2S60LangMapTable.insert("pa", "77"); //Punjabi //Punjabi
qt2S60LangMapTable.insert("qu", "SC"); //Quechua //
qt2S60LangMapTable.insert("rm", "SC"); //RhaetoRomance //
qt2S60LangMapTable.insert("ro", "78"); //Romanian //Romanian
qt2S60LangMapTable.insert("ru", "16"); //Russian //Russian
qt2S60LangMapTable.insert("sm", "SC"); //Samoan //
qt2S60LangMapTable.insert("sg", "SC"); //Sangho //
qt2S60LangMapTable.insert("sa", "SC"); //Sanskrit //
qt2S60LangMapTable.insert("sr", "79"); //Serbian //Serbian
qt2S60LangMapTable.insert("sh", "SC"); //SerboCroatian //
qt2S60LangMapTable.insert("st", "SC"); //Sesotho //
qt2S60LangMapTable.insert("tn", "SC"); //Setswana //
qt2S60LangMapTable.insert("sn", "SC"); //Shona //
qt2S60LangMapTable.insert("sd", "SC"); //Sindhi //
qt2S60LangMapTable.insert("si", "80"); //Singhalese //Sinhalese
qt2S60LangMapTable.insert("ss", "SC"); //Siswati //
qt2S60LangMapTable.insert("sk", "26"); //Slovak //Slovak
qt2S60LangMapTable.insert("sl", "28"); //Slovenian //Slovenian
qt2S60LangMapTable.insert("so", "81"); //Somali //Somali
qt2S60LangMapTable.insert("es", "04"); //Spanish //Spanish
qt2S60LangMapTable.insert("su", "SC"); //Sundanese //
qt2S60LangMapTable.insert("sw", "84"); //Swahili //Swahili
qt2S60LangMapTable.insert("sv", "06"); //Swedish //Swedish
qt2S60LangMapTable.insert("tl", "39"); //Tagalog //Tagalog
qt2S60LangMapTable.insert("tg", "SC"); //Tajik //
qt2S60LangMapTable.insert("ta", "87"); //Tamil //Tamil
qt2S60LangMapTable.insert("tt", "SC"); //Tatar //
qt2S60LangMapTable.insert("te", "88"); //Telugu //Telugu
qt2S60LangMapTable.insert("th", "33"); //Thai //Thai
qt2S60LangMapTable.insert("bo", "89"); //Tibetan //Tibetan
qt2S60LangMapTable.insert("ti", "90"); //Tigrinya //Tigrinya
qt2S60LangMapTable.insert("to", "SC"); //Tonga //
qt2S60LangMapTable.insert("ts", "SC"); //Tsonga //
qt2S60LangMapTable.insert("tr", "14"); //Turkish //Turkish
qt2S60LangMapTable.insert("tk", "92"); //Turkmen //Turkmen
qt2S60LangMapTable.insert("tw", "SC"); //Twi //
qt2S60LangMapTable.insert("ug", "SC"); //Uigur //
qt2S60LangMapTable.insert("uk", "93"); //Ukrainian //Ukrainian
qt2S60LangMapTable.insert("ur", "94"); //Urdu //Urdu
qt2S60LangMapTable.insert("uz", "SC"); //Uzbek //
qt2S60LangMapTable.insert("vi", "96"); //Vietnamese //Vietnamese
qt2S60LangMapTable.insert("vo", "SC"); //Volapuk //
qt2S60LangMapTable.insert("cy", "97"); //Welsh //Welsh
qt2S60LangMapTable.insert("wo", "SC"); //Wolof //
qt2S60LangMapTable.insert("xh", "SC"); //Xhosa //
qt2S60LangMapTable.insert("yi", "SC"); //Yiddish //
qt2S60LangMapTable.insert("yo", "SC"); //Yoruba //
qt2S60LangMapTable.insert("za", "SC"); //Zhuang //
qt2S60LangMapTable.insert("zu", "98"); //Zulu //Zulu
qt2S60LangMapTable.insert("nn", "75"); //Nynorsk //NorwegianNynorsk
qt2S60LangMapTable.insert("bs", "SC"); //Bosnian //
qt2S60LangMapTable.insert("dv", "SC"); //Divehi //
qt2S60LangMapTable.insert("gv", "SC"); //Manx //
qt2S60LangMapTable.insert("kw", "SC"); //Cornish //
qt2S60LangMapTable.insert("ak", "SC"); //Akan //
qt2S60LangMapTable.insert("kok", "SC"); //Konkani //
qt2S60LangMapTable.insert("gaa", "SC"); //Ga //
qt2S60LangMapTable.insert("ig", "SC"); //Igbo //
qt2S60LangMapTable.insert("kam", "SC"); //Kamba //
qt2S60LangMapTable.insert("syr", "SC"); //Syriac //
qt2S60LangMapTable.insert("byn", "SC"); //Blin //
qt2S60LangMapTable.insert("gez", "SC"); //Geez //
qt2S60LangMapTable.insert("kfo", "SC"); //Koro //
qt2S60LangMapTable.insert("sid", "SC"); //Sidamo //
qt2S60LangMapTable.insert("cch", "SC"); //Atsam //
qt2S60LangMapTable.insert("tig", "SC"); //Tigre //
qt2S60LangMapTable.insert("kaj", "SC"); //Jju //
qt2S60LangMapTable.insert("fur", "SC"); //Friulian //
qt2S60LangMapTable.insert("ve", "SC"); //Venda //
qt2S60LangMapTable.insert("ee", "SC"); //Ewe //
qt2S60LangMapTable.insert("wa", "SC"); //Walamo //
qt2S60LangMapTable.insert("haw", "SC"); //Hawaiian //
qt2S60LangMapTable.insert("kcg", "SC"); //Tyap //
qt2S60LangMapTable.insert("ny", "SC"); //Chewa //
}
|