267 |
262 |
268 t << languageRules.join("\n") << endl; |
263 t << languageRules.join("\n") << endl; |
269 tw << languageRules.join("\n") << endl; |
264 tw << languageRules.join("\n") << endl; |
270 ts << languageRules.join("\n") << endl; |
265 ts << languageRules.join("\n") << endl; |
271 |
266 |
272 // name of application, UID and version |
267 // Determine application version. If version has missing component values, |
273 QString applicationVersion = project->first("VERSION").isEmpty() ? "1,0,0" : project->first("VERSION").replace('.', ','); |
268 // those will default to zero. |
|
269 // If VERSION is missing altogether or is invalid, use "1,0,0" |
|
270 QStringList verNumList = project->first("VERSION").split('.'); |
|
271 uint major = 0; |
|
272 uint minor = 0; |
|
273 uint patch = 0; |
|
274 bool success = false; |
|
275 |
|
276 if (verNumList.size() > 0) { |
|
277 major = verNumList[0].toUInt(&success); |
|
278 if (success && verNumList.size() > 1) { |
|
279 minor = verNumList[1].toUInt(&success); |
|
280 if (success && verNumList.size() > 2) { |
|
281 patch = verNumList[2].toUInt(&success); |
|
282 } |
|
283 } |
|
284 } |
|
285 |
|
286 QString applicationVersion("1,0,0"); |
|
287 if (success) |
|
288 applicationVersion = QString("%1,%2,%3").arg(major).arg(minor).arg(patch); |
|
289 |
|
290 // Append package build version number if it is set |
|
291 QString pkgBuildVersion = project->first("DEPLOYMENT.pkg_build_version"); |
|
292 if (!pkgBuildVersion.isEmpty()) { |
|
293 success = false; |
|
294 uint build = pkgBuildVersion.toUInt(&success); |
|
295 if (success && build < 100) { |
|
296 if (pkgBuildVersion.size() == 1) |
|
297 pkgBuildVersion.prepend(QLatin1Char('0')); |
|
298 applicationVersion.append(pkgBuildVersion); |
|
299 } else { |
|
300 fprintf(stderr, "Warning: Invalid DEPLOYMENT.pkg_build_version (%s), must be a number between 0 - 99\n", qPrintable(pkgBuildVersion)); |
|
301 } |
|
302 } |
|
303 |
|
304 // Package header |
274 QString sisHeader = "; SIS header: name, uid, version\n#{\"%1\"},(%2),%3\n\n"; |
305 QString sisHeader = "; SIS header: name, uid, version\n#{\"%1\"},(%2),%3\n\n"; |
275 QString visualTarget = generator->escapeFilePath(project->first("TARGET")); |
306 QString visualTarget = generator->escapeFilePath(project->first("TARGET")); |
276 |
307 |
277 visualTarget = removePathSeparators(visualTarget); |
308 visualTarget = removePathSeparators(visualTarget); |
278 QString wrapperTarget = visualTarget + " installer"; |
309 QString wrapperTarget = visualTarget + " installer"; |
772 |
803 |
773 //QTP: loc changes start |
804 //QTP: loc changes start |
774 |
805 |
775 void SymbianCommonGenerator::writeSymbianLocFile(QStringList &symbianLangCodes) |
806 void SymbianCommonGenerator::writeSymbianLocFile(QStringList &symbianLangCodes) |
776 { |
807 { |
777 QMakeProject *project = generator->project; |
808 QMakeProject *project = generator->project; |
778 QString filename(translationFileName); |
809 // Loop through all the languages and generate language specific loc files. |
779 foreach(QString lang, symbianLangCodes) { |
810 foreach(QString lang, symbianLangCodes) { |
780 |
811 QString locFilename(translationFileName); //Use first entry from pro files TRANSLATIONS field as the name of the loc file. |
781 QString tsFilename(filename); |
812 locFilename.append("_"+lang+".loc"); |
782 QString language = qt2S60LangMapTable.key(lang, QString("en")); |
813 if (!project->first("SYMBIANLOCFILESDIR").isEmpty()) { |
783 tsFilename.append("_"+language+".ts"); |
814 locFilename.insert(0, lang+"/"); |
784 |
815 locFilename.insert(0, project->first("SYMBIANLOCFILESDIR")); |
785 tsFilename.insert(0, project->first("SYMBIANTRANSLATIONSRCDIR")); |
816 } else { |
786 |
817 locFilename.insert(0, "/epoc32/include/platform/mw/loc/"+lang+"/"); |
787 QString locFilename(filename); |
818 } |
788 locFilename.append("_"+lang+".loc"); |
819 QString shortCaption; |
789 if (!project->first("SYMBIANLOCFILESDIR").isEmpty()) { |
820 QString longCaption; |
790 locFilename.insert(0, lang+"/"); |
821 |
791 locFilename.insert(0, project->first("SYMBIANLOCFILESDIR")); |
822 QStringList translationFilenames = project->values("TRANSLATIONS"); |
792 } else { |
823 // Read captions from all the ts files that exist on pro file. Use the caption that is found first. Print warning notes from duplicates. |
793 locFilename.insert(0, "/epoc32/include/platform/mw/loc/"+lang+"/"); |
824 foreach (QString tsFilename, translationFilenames) { |
794 } |
825 // add the path and current language identification to ts name and search if txt_short_caption_ or txt_long_caption_ is present |
795 |
826 //QString tsFilename(tempfilename); |
796 QString shortCaption; |
827 if (!tsFilename.isEmpty()) { |
797 QString longCaption; |
828 tsFilename = generator->fileInfo(tsFilename).completeBaseName(); |
798 |
829 tsFilename = generator->unescapeFilePath(tsFilename); |
799 // get captions from ts file |
830 tsFilename = removePathSeparators(tsFilename); |
800 QFile tsFile(tsFilename); |
831 } |
801 if (tsFile.exists()) { |
832 QString language = qt2S60LangMapTable.key(lang, QString("en")); |
802 if (tsFile.open(QIODevice::ReadOnly)) { |
833 tsFilename.append("_"+language+".ts"); |
803 QString shortCaptionId = QLatin1String("txt_short_caption_"); |
834 tsFilename.insert(0, project->first("SYMBIANTRANSLATIONSRCDIR")); |
804 QString longCaptionId = QLatin1String("txt_long_caption_"); |
835 QFile tsFile(tsFilename); |
805 QXmlStreamReader xml(&tsFile); |
836 if (tsFile.exists()) { |
806 while (!xml.atEnd()) { |
837 if (tsFile.open(QIODevice::ReadOnly)) { |
807 xml.readNext(); |
838 QString shortCaptionId = QLatin1String("txt_short_caption_"); |
808 if (xml.isStartElement() && xml.name() == "context") { |
839 QString longCaptionId = QLatin1String("txt_long_caption_"); |
809 while (!(xml.isEndElement() && xml.name() == "context") && !xml.atEnd()) { |
840 QXmlStreamReader xml(&tsFile); |
810 xml.readNext(); |
841 while (!xml.atEnd()) { |
811 if (xml.isStartElement() && xml.name() == "message" |
842 xml.readNext(); |
812 && xml.attributes().value("numerus") == "no" |
843 if (xml.isStartElement() && xml.name() == "context") { |
813 && xml.attributes().value("id").toString().left(shortCaptionId.length()) == shortCaptionId) { |
844 while (!(xml.isEndElement() && xml.name() == "context") && !xml.atEnd()) { |
814 while (!(xml.isEndElement() && xml.name() == "message") && !xml.atEnd()) { |
845 xml.readNext(); |
815 xml.readNext(); |
846 if (xml.isStartElement() && xml.name() == "message" |
816 if (xml.isStartElement() && xml.name() == "translation") { |
847 && xml.attributes().value("numerus") == "no" |
817 shortCaption = xml.readElementText(); |
848 && xml.attributes().value("id").toString().left(shortCaptionId.length()) == shortCaptionId) { |
818 } |
849 while (!(xml.isEndElement() && xml.name() == "message") && !xml.atEnd()) { |
819 } |
850 xml.readNext(); |
820 } |
851 if (xml.isStartElement() && xml.name() == "translation") { |
821 if (xml.isStartElement() && xml.name() == "message" |
852 if (shortCaption.isEmpty()){ |
822 && xml.attributes().value("numerus") == "no" |
853 shortCaption = xml.readElementText(); |
823 && xml.attributes().value("id").toString().left(longCaptionId.length()) == longCaptionId) { |
854 } else { |
824 while (!(xml.isEndElement() && xml.name() == "message") && !xml.atEnd()) { |
855 fprintf(stderr, "Duplicate short caption field found from: '%s'.\n", qPrintable(tsFilename)); |
825 xml.readNext(); |
856 } |
826 if (xml.isStartElement() && xml.name() == "translation") { |
857 } |
827 longCaption = xml.readElementText(); |
858 } |
828 } |
859 } |
829 } |
860 if (xml.isStartElement() && xml.name() == "message" |
830 } |
861 && xml.attributes().value("numerus") == "no" |
831 } |
862 && xml.attributes().value("id").toString().left(longCaptionId.length()) == longCaptionId) { |
832 } |
863 while (!(xml.isEndElement() && xml.name() == "message") && !xml.atEnd()) { |
|
864 xml.readNext(); |
|
865 if (xml.isStartElement() && xml.name() == "translation" ) { |
|
866 if (longCaption.isEmpty()){ |
|
867 longCaption = xml.readElementText(); |
|
868 } else { |
|
869 fprintf(stderr, "Duplicate long caption field found from: '%s'.\n", qPrintable(tsFilename)); |
|
870 } |
|
871 } |
833 } |
872 } |
834 if (shortCaption.isEmpty()) { |
873 } |
835 fprintf(stderr, "Short caption generated from target name '#%s'.\n", qPrintable(fixedTarget)); |
874 } |
836 } |
875 } |
837 if (longCaption.isEmpty()) { |
876 } |
838 fprintf(stderr, "Warning: STRING_r_caption not generated from file '%s'.\n", qPrintable(tsFilename)); |
877 if (shortCaption.isEmpty()) { |
839 fprintf(stderr, " : caption generated from target name '#%s'.\n", qPrintable(fixedTarget)); |
878 fprintf(stderr, "Short caption generated from target name '#%s'.\n", qPrintable(fixedTarget)); |
840 } |
879 } |
841 if (xml.hasError()) |
880 if (longCaption.isEmpty()) { |
842 fprintf(stderr, "ERROR: \"%s\" when parsing ts file\n", qPrintable(xml.errorString())); |
881 fprintf(stderr, "Warning: STRING_r_caption not generated from file '%s'.\n", qPrintable(tsFilename)); |
843 } else { |
882 fprintf(stderr, " : caption generated from target name '#%s'.\n", qPrintable(fixedTarget)); |
844 fprintf(stderr, "Could not open ts file (%s)\n", qPrintable(tsFilename)); |
883 } |
845 } |
884 if (xml.hasError()) |
|
885 fprintf(stderr, "ERROR: \"%s\" when parsing ts file\n", qPrintable(xml.errorString())); |
|
886 } else { |
|
887 fprintf(stderr, "Could not open ts file (%s)\n", qPrintable(tsFilename)); |
|
888 } |
|
889 } else { |
|
890 fprintf(stderr, "Warning: ts file does not exist: (%s)\n", qPrintable(tsFilename)); |
|
891 fprintf(stderr, " : short and long caption generated from target name '#%s'.\n", qPrintable(fixedTarget)); |
|
892 } |
|
893 } |
|
894 // generate language specific caption loc file |
|
895 QFile ft(locFilename); |
|
896 if (ft.open(QIODevice::WriteOnly)) { |
|
897 generatedFiles << ft.fileName(); |
|
898 QTextStream t(&ft); |
|
899 t << "// ============================================================================" << endl; |
|
900 t << "// * Generated by qmake (" << qmake_version() << ") (Qt " << QT_VERSION_STR << ") on: "; |
|
901 t << QDateTime::currentDateTime().toString(Qt::ISODate) << endl; |
|
902 t << "// * This file is generated by qmake and should not be modified by the" << endl; |
|
903 t << "// * user." << endl; |
|
904 t << "// ============================================================================" << endl; |
|
905 t << endl; |
|
906 t <<"CHARACTER_SET UTF8"<<endl; |
|
907 if (!shortCaption.isEmpty()) { |
|
908 t << "#define STRING_r_short_caption \"" << shortCaption << "\"" << endl; |
846 } else { |
909 } else { |
847 fprintf(stderr, "Warning: ts file does not exist: (%s)\n", qPrintable(tsFilename)); |
910 t << "#define STRING_r_short_caption \"" "#"<< fixedTarget << "\"" << endl; |
848 fprintf(stderr, " : short and long caption generated from target name '#%s'.\n", qPrintable(fixedTarget)); |
911 } |
849 } |
912 if (!longCaption.isEmpty()) { |
850 |
913 t << "#define STRING_r_caption \"" << longCaption << "\"" << endl; |
851 // generate language specific caption loc file |
914 } else { |
852 QFile ft(locFilename); |
915 t << "#define STRING_r_caption \"" "#"<< fixedTarget << "\"" << endl; |
853 if (ft.open(QIODevice::WriteOnly)) { |
916 } |
854 generatedFiles << ft.fileName(); |
917 ft.close(); |
855 QTextStream t(&ft); |
918 } else { |
856 t << "// ============================================================================" << endl; |
919 PRINT_FILE_CREATE_ERROR(locFilename); |
857 t << "// * Generated by qmake (" << qmake_version() << ") (Qt " << QT_VERSION_STR << ") on: "; |
920 } |
858 t << QDateTime::currentDateTime().toString(Qt::ISODate) << endl; |
921 } |
859 t << "// * This file is generated by qmake and should not be modified by the" << endl; |
|
860 t << "// * user." << endl; |
|
861 t << "// ============================================================================" << endl; |
|
862 t << endl; |
|
863 if (!shortCaption.isEmpty()) { |
|
864 t << "#define STRING_r_short_caption \"" << shortCaption << "\"" << endl; |
|
865 } else { |
|
866 t << "#define STRING_r_short_caption \"" "#"<< fixedTarget << "\"" << endl; |
|
867 } |
|
868 if (!longCaption.isEmpty()) { |
|
869 t << "#define STRING_r_caption \"" << longCaption << "\"" << endl; |
|
870 } else { |
|
871 t << "#define STRING_r_caption \"" "#"<< fixedTarget << "\"" << endl; |
|
872 } |
|
873 ft.close(); |
|
874 } else { |
|
875 PRINT_FILE_CREATE_ERROR(locFilename); |
|
876 } |
|
877 } |
|
878 } |
922 } |
879 //QTP: loc change ends |
923 //QTP: loc change ends |
880 |
924 |
881 void SymbianCommonGenerator::readRssRules(QString &numberOfIcons, |
925 void SymbianCommonGenerator::readRssRules(QString &numberOfIcons, |
882 QString &iconFile, QMap<QString, |
926 QString &iconFile, QMap<QString, |