# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1282201369 -10800 # Node ID 5cc91383ab1e23f17d78e5882ebab04a0475c9b5 # Parent cd189dac02f7fb23e4a16717cfb9c1ddf46f2930 Revision: 201031 Kit: 201033 diff -r cd189dac02f7 -r 5cc91383ab1e appinstaller/AppMngr2/GSSettingsPlugin/data/appmngr2gssettingspluginrsc.rss --- a/appinstaller/AppMngr2/GSSettingsPlugin/data/appmngr2gssettingspluginrsc.rss Thu Jul 15 18:47:04 2010 +0300 +++ b/appinstaller/AppMngr2/GSSettingsPlugin/data/appmngr2gssettingspluginrsc.rss Thu Aug 19 10:02:49 2010 +0300 @@ -231,6 +231,6 @@ RESOURCE TBUF r_am_set_ocsp_none { - buf = qtn_selec_sett_val_field_none; + buf = qtn_am_set_ocsp_url_none; } diff -r cd189dac02f7 -r 5cc91383ab1e appinstaller/AppMngr2/help/data/xhtml.zip Binary file appinstaller/AppMngr2/help/data/xhtml.zip has changed diff -r cd189dac02f7 -r 5cc91383ab1e appinstaller/AppMngr2/loc/appmngr2.loc --- a/appinstaller/AppMngr2/loc/appmngr2.loc Thu Jul 15 18:47:04 2010 +0300 +++ b/appinstaller/AppMngr2/loc/appmngr2.loc Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2003-2008 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -237,3 +237,8 @@ // r: 5.1 #define qtn_swins_lsh2_untrusted "Untrusted" +// d: Setting field value for OCSP URL when there is no data. +// l: set_value_pane_t1 +// r: 9.2 +#define qtn_am_set_ocsp_url_none "None" + diff -r cd189dac02f7 -r 5cc91383ab1e appinstaller/AppinstUi/Plugin/SisxUI/Src/SisxUIHandler.cpp --- a/appinstaller/AppinstUi/Plugin/SisxUI/Src/SisxUIHandler.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/appinstaller/AppinstUi/Plugin/SisxUI/Src/SisxUIHandler.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2002-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -478,7 +478,9 @@ // than the currently installed old version (i.e. when downgrading). See // also User::QueryVersionSupported() although it has bit different meaning. TBool downgrading = ( newVersion.iMajor < oldVersion.iMajor || - ( newVersion.iMajor == oldVersion.iMajor && newVersion.iMinor < oldVersion.iMinor ) ); + ( newVersion.iMajor == oldVersion.iMajor && newVersion.iMinor < oldVersion.iMinor ) || + ( newVersion.iMajor == oldVersion.iMajor && newVersion.iMinor == oldVersion.iMinor && + newVersion.iBuild < oldVersion.iBuild ) ); if( !downgrading ) { iShowingDialog = EFalse; diff -r cd189dac02f7 -r 5cc91383ab1e installationservices/swi/inc/switextshell.iby --- a/installationservices/swi/inc/switextshell.iby Thu Jul 15 18:47:04 2010 +0300 +++ b/installationservices/swi/inc/switextshell.iby Thu Aug 19 10:02:49 2010 +0300 @@ -19,7 +19,7 @@ #ifndef SWITEXTSHELL #define SWITEXTSHELL -define ROMDRIVE \epoc32\data\Z +define ROMDRIVE EPOCROOT##epoc32\data\Z // SWI configuration - already in textshell ROM #include diff -r cd189dac02f7 -r 5cc91383ab1e installationservices/swi/inc/tswitextshell.iby --- a/installationservices/swi/inc/tswitextshell.iby Thu Jul 15 18:47:04 2010 +0300 +++ b/installationservices/swi/inc/tswitextshell.iby Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -45,7 +45,7 @@ #include "ezlib.iby" #include "openenv.iby" -define ZDRIVE \epoc32\winscw\c +define ZDRIVE EPOCROOT##epoc32\winscw\c // This the file which used to redirect the request from cam-ocsptest01 to ban-ocsptest01 data = ZDRIVE\autohardware\hosts \hosts diff -r cd189dac02f7 -r 5cc91383ab1e installationservices/swi/source/sisfile/siscompressed.cpp --- a/installationservices/swi/source/sisfile/siscompressed.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/installationservices/swi/source/sisfile/siscompressed.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -53,12 +53,21 @@ void CCompressed::ConstructL(TInt64& aBytesRead, TReadTypeBehaviour aTypeReadBehaviour) { CField::ConstructL(iDataProvider, EFieldTypeCompressed, aBytesRead, aTypeReadBehaviour); + // Get the current offset User::LeaveIfError(iDataProvider.Seek(ESeekCurrent, iOffset)); + TInt64 fieldOffset = 0; + +#ifdef SIS_CRC_CHECK_ENABLED // Calculate CRC of header and field data - TInt64 fieldOffset = iOffset - HeaderSize(); + fieldOffset = iOffset - HeaderSize(); User::LeaveIfError(iDataProvider.Seek(ESeekStart, fieldOffset)); CField::CalculateCrcL(iDataProvider, HeaderSize() + Length() + PaddingSize(), iCrc ); +#else + fieldOffset = iOffset + Length() + PaddingSize(); + User::LeaveIfError(iDataProvider.Seek(ESeekStart, fieldOffset)); +#endif + aBytesRead += Length() + PaddingSize(); } diff -r cd189dac02f7 -r 5cc91383ab1e installationservices/swi/source/sisfile/sisdata.cpp --- a/installationservices/swi/source/sisfile/sisdata.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/installationservices/swi/source/sisfile/sisdata.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -62,10 +62,16 @@ User::LeaveIfError(iDataProvider.Seek(ESeekCurrent, iOffset)); ReadMemberArrayL(iDataProvider, iDataUnits, EFieldTypeDataUnit, arrayBytes, EReadType); + TInt64 fieldOffset = 0; +#ifdef SIS_CRC_CHECK_ENABLED // Calculate CRC of header and field data by reading the entire header and field - TInt64 fieldOffset = iOffset - HeaderSize(); + fieldOffset = iOffset - HeaderSize(); User::LeaveIfError(iDataProvider.Seek(ESeekStart, fieldOffset)); CField::CalculateCrcL(iDataProvider, HeaderSize() + Length() + PaddingSize(), iCrc ); +#else + fieldOffset = iOffset + Length() + PaddingSize(); + User::LeaveIfError(iDataProvider.Seek(ESeekStart, fieldOffset)); +#endif aBytesRead += Length() + PaddingSize(); } diff -r cd189dac02f7 -r 5cc91383ab1e installationservices/swi/source/sisregistry/server_legacy/sisregistrycache.cpp --- a/installationservices/swi/source/sisregistry/server_legacy/sisregistrycache.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/installationservices/swi/source/sisregistry/server_legacy/sisregistrycache.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -82,20 +82,23 @@ // General note: trap the error because this is not a leaving function // and generating an error will not help - // store the backup file out - TRAP(res, StoreBackupL()); - if (res != KErrNone) - { - DEBUG_PRINTF2(_L8("Sis Registry Server - Failed to store backup (failure code: %d.)"), res); - } + if (iIntegrityService) + { + // store the backup file out + TRAP(res, StoreBackupL()); + if (res != KErrNone) + { + DEBUG_PRINTF2(_L8("Sis Registry Server - Failed to store backup (failure code: %d.)"), res); + } - // integrity service operation committing point - TRAP(res, iIntegrityService->CommitL()); - if (res != KErrNone) - { - DEBUG_PRINTF2(_L8("Sis Registry Server - Failed to commit integrity services changes (failure code %d.)"), res); - } - + // integrity service operation committing point + TRAP(res, iIntegrityService->CommitL()); + if (res != KErrNone) + { + DEBUG_PRINTF2(_L8("Sis Registry Server - Failed to commit integrity services changes (failure code %d.)"), res); + } + } + delete iBackupFile; delete iIntegrityService; @@ -446,7 +449,7 @@ User::Leave(KErrCorrupt); } - iTokens.Append(token); + iTokens.AppendL(token); CleanupStack::Pop(token); CleanupStack::PopAndDestroy(&fileStream); @@ -1417,7 +1420,7 @@ CleanupClosePushL(aDriveList); aDriveList.Reset(); // a copy of the controller is always kept on drive C - aDriveList.Append(iSystemDrive); + aDriveList.AppendL(iSystemDrive); // only controllers will be written to removable media and // we have now to check for those diff -r cd189dac02f7 -r 5cc91383ab1e installationservices/swi/source/sisregistry/server_legacy/sisregistryserversession.cpp --- a/installationservices/swi/source/sisregistry/server_legacy/sisregistryserversession.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/installationservices/swi/source/sisregistry/server_legacy/sisregistryserversession.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1856,6 +1856,7 @@ { // Destroys object so we continue to next iteration. CleanupStack::PopAndDestroy(sidObject); + sidObject = NULL; } } // End for loop. diff -r cd189dac02f7 -r 5cc91383ab1e installationservices/swi/test/tsisfile/steps/basestep.cpp --- a/installationservices/swi/test/tsisfile/steps/basestep.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/installationservices/swi/test/tsisfile/steps/basestep.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -141,6 +141,7 @@ SetTestStepResult(err); User::Leave(err); } +#ifdef SIS_CRC_CHECK_ENABLED TRAP(err, contents->CheckCrcL()); if (err == KErrCorrupt) { @@ -148,10 +149,11 @@ SetTestStepResult(err); User::Leave(err); } +#endif CleanupStack::Pop(contents); - return contents; - } + return contents; + } CController* CParserTestStep::GetControllerL(CContents& contents, TBool aUseInPlaceParse) { TRAPD(err, iControllerData = contents.ReadControllerL()); diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swianalysistoolkit/source/common/symbiantypes.h --- a/secureswitools/swianalysistoolkit/source/common/symbiantypes.h Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swianalysistoolkit/source/common/symbiantypes.h Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -47,14 +47,18 @@ typedef long int TInt32; typedef unsigned long int TUint32; -typedef short int TInt16; +typedef short int TInt16; typedef signed char TInt8; -typedef unsigned short int TUint16; +typedef unsigned short int TUint16; typedef unsigned char TUint8; typedef bool TBool; -typedef TUint16 TCRC; -typedef int TInt; +typedef TUint16 TCRC; +typedef int TInt; +typedef unsigned int TUint; +typedef void TAny; +typedef unsigned short int TText16; +typedef unsigned char TText8; #endif /* __SYMBIAN_TYPES_H__ */ @@ -63,3 +67,6 @@ #else #define STRING std::string #endif // _UNICODE + +#define ETrue true; +#define EFalse false; diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swianalysistoolkit/source/common/utf8/utf8.h --- a/secureswitools/swianalysistoolkit/source/common/utf8/utf8.h Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swianalysistoolkit/source/common/utf8/utf8.h Thu Aug 19 10:02:49 2010 +0300 @@ -79,6 +79,9 @@ ------------------------------------------------------------------------ */ +#ifndef __UTF_H__ +#define __UTF_H__ + /* --------------------------------------------------------------------- The following 4 definitions are compiler-specific. The C standard does not guarantee that wchar_t has at least @@ -165,4 +168,6 @@ } #endif +#endif //__UTF_H__ + /* --------------------------------------------------------------------- */ diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/group/dumpsislib.mmp --- a/secureswitools/swisistools/group/dumpsislib.mmp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/group/dumpsislib.mmp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -23,6 +23,7 @@ USERINCLUDE ../source/dumpsislib USERINCLUDE ../source/sisxlibrary USERINCLUDE ../../swianalysistoolkit/source/common +USERINCLUDE ../../swianalysistoolkit/source/common/utf8 MW_LAYER_SYSTEMINCLUDE_SYMBIAN diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/group/interpretsis.mmp --- a/secureswitools/swisistools/group/interpretsis.mmp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/group/interpretsis.mmp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -26,6 +26,7 @@ USERINCLUDE ../source/sisxlibrary USERINCLUDE ../source/common USERINCLUDE ../../swianalysistoolkit/source/common +USERINCLUDE ../../swianalysistoolkit/source/common/utf8 MW_LAYER_SYSTEMINCLUDE_SYMBIAN SYSTEMINCLUDE ../../openssllib/import/inc/openssl @@ -56,5 +57,8 @@ OPTION GCC -w OPTION GCC -fno-stack-check OPTION GCC -fpermissive +#ifdef TOOLS2_LINUX +OPTION GCC -rdynamic +#endif // TOOLS2_LINUX MACRO _UNICODE _CONSOLE _STLP_THREADS UNICODE __GNUG__ diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/group/interpretsislib.mmp --- a/secureswitools/swisistools/group/interpretsislib.mmp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/group/interpretsislib.mmp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -23,6 +23,8 @@ USERINCLUDE ../source/interpretsislib USERINCLUDE ../source/sisxlibrary USERINCLUDE ../../swianalysistoolkit/source/common +USERINCLUDE ../../swianalysistoolkit/source/common/utf8 +USERINCLUDE ../source/common #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK USERINCLUDE ../source/xmlparser @@ -77,6 +79,8 @@ SOURCE util.cpp #endif +SOURCEPATH ../../swianalysistoolkit/source/common/utf8 +SOURCE utf8.cpp #ifndef TOOLS2_LINUX MACRO _UNICODE _CONSOLE _STLP_THREADS _WIN32 UNICODE __GNUG__ XML_LIBRARY diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/group/scrtool.mmp --- a/secureswitools/swisistools/group/scrtool.mmp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/group/scrtool.mmp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -27,6 +27,7 @@ USERINCLUDE ../source/xmlparser USERINCLUDE ../source/dbmanager USERINCLUDE ../source/dbmanager/sqlite +USERINCLUDE ../source/sisxlibrary SYSTEMINCLUDE ../source/xmlparser/xerces/include MW_LAYER_SYSTEMINCLUDE_SYMBIAN @@ -46,7 +47,14 @@ SOURCE logs.cpp exception.cpp util.cpp -STATICLIBRARY eay32 xerces +STATICLIBRARY xerces +STATICLIBRARY sisx +#ifndef TOOLS2_LINUX +STATICLIBRARY eay32 +#else +STATICLIBRARY crypto dl c +#endif + #ifndef TOOLS2_LINUX MACRO _UNICODE _CONSOLE _STLP_THREADS _WIN32 UNICODE __GNUG__ XML_LIBRARY @@ -60,5 +68,8 @@ OPTION GCC -w OPTION GCC -fno-stack-check OPTION GCC -fpermissive +#ifdef TOOLS2_LINUX +OPTION GCC -rdynamic +#endif //OPTION GCC -masm=intel SMPSAFE diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/common/util.cpp --- a/secureswitools/swisistools/source/common/util.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/common/util.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -24,7 +24,6 @@ #include "util.h" #include "symbiantypes.h" -#include #include #include #include @@ -32,6 +31,10 @@ #include #include #include +#ifdef _WIN32 +#include +#endif // _WIN32 +#include "utf8.h" static const TUint32 CrcTab32[256] = { @@ -100,38 +103,94 @@ 0xb3667a2e, 0xc4614ab8, 0x5d681b02, 0x2a6f2b94, 0xb40bbe37, 0xc30c8ea1, 0x5a05df1b, 0x2d02ef8d }; + +namespace Util +{ +/** + * Converts wide char (unicode) string to multibyte string + * This interface is provided so that we can have different implementation + * in windows and linux machine. + * @param aSource string to be converted + * @param aSourceLen Source len. If this is -1 then it will calculate the length of the source. + * @param aTarget target location. + * @param aTargetLen Space in the target location. + * @param aCodePage Code page number (currently supported in windows only) + * @return Number of bytes that make up the converted part of multibyte sequence. + * If aTarget is NULL then the function will return the size needed to store + * the complete conversion of the source string. + */ +int ConvertWideCharToMultiByte(const wchar_t* aSource, int aSourceLen, char* aTarget, int aTargetLen, TUint32 aCodePage = 0); +/** + * Converts multibyte string to wide char (unicode) + * This interface is provided so that we can have different implementation + * in windows and linux machine. + * @param aSource string to be converted + * @param aSourceLen Source len. If this is -1 then it will calculate the length of the source. + * @param aTarget target location. + * @param aTargetLen Space in the target location. + * @param aCodePage Code page number (currently supported in windows only) + * @return Number of bytes that make up the converted part of widechar sequence. + * If aTarget is NULL then the function will return the size needed to store + * the complete conversion of the source string. + */ +int ConvertMultiByteToWideChar(const char* aSource, int aSourceLen, wchar_t* aTarget, int aTargetLen, TUint32 aCodePage = 0); +}; // namespace Util -DllExport std::string Util::wstring2string (const std::wstring& aWide) +#ifdef __linux__ +int Util::ConvertWideCharToMultiByte(const wchar_t* aSource, int /*aSourceLen*/, char* aTarget, int aTargetLen, TUint32 /*aCodePage*/) { - int max = WideCharToMultiByte(CP_OEMCP,0,aWide.c_str(),aWide.length(),0,0,0,0); - std::string reply; - if (max > 0 ) + int retValue = wcstombs(aTarget, aSource, aTargetLen); + if (-1 == retValue) { - char* buffer = new char [max]; - try - { - WideCharToMultiByte(CP_OEMCP,0,aWide.c_str(),aWide.length(),buffer,max,0,0); - reply = std::string (buffer, max); - } - catch (...) - { - } - delete [] buffer; + return 0; } - return reply; + return retValue; + } + +int Util::ConvertMultiByteToWideChar(const char* aSource, int /*aSourceLen*/, wchar_t* aTarget, int aTargetLen, TUint32 /*aCodePage*/) + { + int retValue = mbstowcs(aTarget, aSource, aTargetLen); + if (-1 == retValue) + { + return 0; + } + return retValue; } -std::wstring Util::string2wstring (const std::string& aNarrow) +#else + +int Util::ConvertWideCharToMultiByte(const wchar_t* aSource, int aSourceLen, char* aTarget, int aTargetLen, TUint32 aCodePage) + { + if(0 == aCodePage) + { + aCodePage = CP_OEMCP; + } + return WideCharToMultiByte( aCodePage, 0, aSource, aSourceLen, aTarget, aTargetLen, NULL, NULL); + } + +int Util::ConvertMultiByteToWideChar(const char* aSource, int aSourceLen, wchar_t* aTarget, int aTargetLen, TUint32 aCodePage) { - int max = MultiByteToWideChar(CP_OEMCP,0,aNarrow.c_str(),aNarrow.length(),0,0); + if(0 == aCodePage) + { + aCodePage = CP_OEMCP; + } + return MultiByteToWideChar( aCodePage, 0, aSource, aSourceLen, aTarget, aTargetLen); + } + +#endif // __linux__ + +std::wstring Util::string2wstring (const char* aNarrow) + { + std::string narrowStr(aNarrow); + int max = ConvertMultiByteToWideChar(aNarrow, strlen(aNarrow),0,0); std::wstring reply; if (max > 0 ) { wchar_t* buffer = new wchar_t [max]; try { - MultiByteToWideChar(CP_OEMCP,0,aNarrow.c_str(),aNarrow.length(),buffer,max); + ConvertMultiByteToWideChar(aNarrow, strlen(aNarrow),buffer,max); reply = std::wstring (buffer, max); } catch (...) @@ -142,26 +201,6 @@ return reply; } -std::wstring Util::string2wstring (const char* aNarrow) - { - std::string narrowStr(aNarrow); - int max = MultiByteToWideChar(CP_OEMCP,0,narrowStr.c_str(),narrowStr.length(),0,0); - std::wstring reply; - if (max > 0 ) - { - wchar_t* buffer = new wchar_t [max]; - try - { - MultiByteToWideChar(CP_OEMCP,0,narrowStr.c_str(),narrowStr.length(),buffer,max); - reply = std::wstring (buffer, max); - } - catch (...) - { - } - delete [] buffer; - } - return reply; - } DllExport int Util::WideCharToInteger(const wchar_t* aWideChar) { @@ -173,7 +212,7 @@ TInt64 Util::WideCharToInt64(const wchar_t* aWideChar) { - __int64 i64 = 0; + TInt64 i64 = 0; swscanf(aWideChar, L"%I64d", &i64); return i64; } @@ -230,4 +269,3 @@ crc = (crc >> 8) ^ CrcTab32[(crc ^ *p++) & 0xff]; return crc; } - \ No newline at end of file diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/dumpsis/main.cpp --- a/secureswitools/swisistools/source/dumpsis/main.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/dumpsis/main.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -64,7 +64,7 @@ } else { - std::wcout << L":" << str; + std::wcout << L":" << str.c_str(); std::vector capList; fdesc->GetCapabilityList(capList); std::wcout << std::endl; diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/dumpsis/options.cpp --- a/secureswitools/swisistools/source/dumpsis/options.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/dumpsis/options.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -84,7 +84,7 @@ { std::cout << "\nDUMPSIS Version " << MajorVersion << '.' << MinorVersion << std::endl; std::cout << "A utility for decompiling Software Installation (SIS) files" << std::endl; - std::cout <<"Copyright (c) Symbian Software Limited 2004-2008. All rights reserved.\n\n" << std::flush; + std::cout <<"Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.\n\n" << std::flush; } Options::Options (int argc, wchar_t** argv) @@ -99,7 +99,21 @@ while (--argc) { argv++; - if ((**argv == '-') || (**argv == '/')) + // WINDOWS ENVIRONMENT : If the underlying platform is WINDOWS then, + // cope up with multiple arguments following the '-' or '/'. + // + // LINUX ENVIRONMENT : If the underlying platform is LINUX then, cope + // up with multiple arguments following only the '-'. This restriction + // of not dealing with arguments following '/' is due to the fact that, + // the absolute paths in case of LINUX start with a '/'. So, this could + // be mistaken as an option if we treat anything prefixed by a '/' as + // an option. Hence, this facility is being removed once for all and + // only '-' can(should) be used for specifying an option. + if ( (**argv == '-') +#ifndef __TOOLS2_LINUX__ + || (**argv == '/') +#endif + ) { const wchar_t* optPtr = *argv; diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/dumpsis/options.h --- a/secureswitools/swisistools/source/dumpsis/options.h Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/dumpsis/options.h Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -30,7 +30,7 @@ using std::ostream; int const MajorVersion=1; -int const MinorVersion=2; +int const MinorVersion=3; int const BuildVersion=0; /** Exceptions raised while processing the command line diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/dumpsislib/dumpsis.cpp --- a/secureswitools/swisistools/source/dumpsislib/dumpsis.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/dumpsislib/dumpsis.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -28,10 +28,10 @@ #include #include - #include "dumpsis.h" #include "siscontroller.h" #include "exception.h" +#include "utf8.h" CDumpSis::CDumpSis(const std::wstring& aSISFileName, bool aVerbose) : iController(NULL), @@ -68,6 +68,7 @@ std::wostream outStream (inStream.rdbuf ()); outStream << wchar_t(0xfeff); + if(iIsStub) { iController->AddPackageEntry (outStream, iVerbose); @@ -78,7 +79,27 @@ } std::wstring str = inStream.str(); +#ifndef __TOOLS2_LINUX__ WriteToFile(aPkgFileName, reinterpret_cast(str.c_str()), str.length()*2); +#else + TUint32 size = str.size(); + const wchar_t * source = str.c_str(); + + unsigned short int* buffer = new unsigned short int[size*2]; + + // Using a temp variable in place of buffer as ConvertUTF32toUTF16 modifies the source pointer passed. + unsigned short int* temp = buffer; + + //Converting to UTF-16 because makesis do not support UTF-32. + ConvertUTF32toUTF16(&source, source + size, &temp, temp + (size*2), lenientConversion); + + TUint32 buflen = temp-buffer; + // Appending NULL to the converted buffer. + *temp = NULL; + + WriteToFile(aPkgFileName, reinterpret_cast(buffer), buflen*2); + delete[] buffer; +#endif } void CDumpSis::CreatePackage(const CSISController& aSisController, const std::wstring& aPkgFileName) @@ -89,7 +110,27 @@ outStream << wchar_t(0xfeff); aSisController.AddPackageEntry (outStream, iVerbose); std::wstring str = inStream.str(); +#ifndef __TOOLS2_LINUX__ WriteToFile(aPkgFileName, reinterpret_cast(str.c_str()), str.length()*2); +#else + TUint32 size = str.size(); + const wchar_t * source = str.c_str(); + + unsigned short int* buffer = new unsigned short int[size*2]; + + // Using a temp variable in place of buffer as ConvertUTF32toUTF16 modifies the source pointer passed. + unsigned short int* temp = buffer; + + //Converting to UTF-16 because makesis do not support UTF-32. + ConvertUTF32toUTF16(&source, source + size, &temp, temp + (size*2), lenientConversion); + + TUint32 buflen = temp-buffer; + // Appending NULL to the converted buffer. + *temp = NULL; + + WriteToFile(aPkgFileName, reinterpret_cast(buffer), buflen*2); + delete[] buffer; +#endif } void CDumpSis::ExtractFiles(const std::wstring& aTargetDir, TExtractionLevel aLevel) diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/interpretsis/commandparser.cpp --- a/secureswitools/swisistools/source/interpretsis/commandparser.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/interpretsis/commandparser.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -170,8 +170,8 @@ void CCommandParser::DisplayVersion() { - std::cout << "\nINTERPRETSIS " << " Version 2.1.3 ." << std::endl; - std::cout << "Copyright (c) 2009 Symbian Software Ltd. All rights reserved.\n " << std::endl; + std::cout << "\nINTERPRETSIS " << " Version 2.2.0 ." << std::endl; + std::cout << "Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved.\n " << std::endl; } @@ -386,7 +386,7 @@ } default: { - LERROR(Utf8ToUcs2(std::string(optPtr))); + LERROR(string2wstring(std::string(optPtr))); throw CCommandParser::ECmdLineUnknownOption; } } @@ -447,8 +447,7 @@ while (currentPos != end) { currentPos = std::find(it, end, ','); - std::wstring x; - Utf8ToUcs2(std::string(it,(currentPos-it)), x); + std::wstring x = string2wstring(std::string(it,(currentPos-it))); //aOptionsList.push_back(x); (aParamList.*aFilePtr)(x); @@ -475,8 +474,7 @@ while (currentPos != end) { currentPos = std::find(it, end, ','); - std::wstring x; - Utf8ToUcs2(std::string(it,(currentPos-it)), x); + std::wstring x = string2wstring(std::string(it,(currentPos-it))); InstallSISFile sisFileName(x, '$', false); aParamList.AddSISFile(sisFileName); @@ -494,8 +492,7 @@ // As the sisfile attributes are predetermined input, therefore we can just // parse according to the predetermined inputs. - std::wstring fileName; - Utf8ToUcs2(sisFileOption, fileName); + std::wstring fileName = string2wstring(sisFileOption); InstallSISFile sisFileName(fileName, '$', false); diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/interpretsis/main.cpp --- a/secureswitools/swisistools/source/interpretsis/main.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/interpretsis/main.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -29,6 +29,22 @@ #include "logger.h" #include "../common/exception.h" + +#ifndef _WIN32 +#include + +//__ctype_b was removed from glibc. This is a workaround to fix the linking problem +extern "C" + { + const unsigned short int** __ctype_b() + { + return __ctype_b_loc(); + } + } + +#endif // _WIN32 + + int main(int argc, const char* argv[]) { bool pauseWhenDone = false; @@ -48,7 +64,7 @@ if (options.LogFile().size() > 0) { - logFile = new std::wofstream(Ucs2ToUtf8(options.LogFile()).c_str(), std::ios::app); + logFile = new std::wofstream(wstring2string(options.LogFile()).c_str(), std::ios::app); Logger::SetStream(*logFile); } else @@ -90,7 +106,7 @@ } catch (InterpretSisError& e) { - LERROR(L"\t" << Utf8ToUcs2(e.what())); + LERROR(L"\t" << string2wstring(e.what())); result = e.GetErrorCode(); } catch (CSISException e) @@ -109,7 +125,7 @@ #endif catch (std::exception &err) { - std::wstring emessage = Utf8ToUcs2( err.what() ); + std::wstring emessage = string2wstring( err.what() ); LERROR( L"Error: " << emessage); result = STD_EXCEPTION; } diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/interpretsislib/adornedutilities.cpp --- a/secureswitools/swisistools/source/interpretsislib/adornedutilities.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/interpretsislib/adornedutilities.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -56,7 +56,11 @@ } } +#ifndef __TOOLS2_LINUX__ bool IsAdornedVariationOf(const std::wstring& aFileName1, const std::wstring& aFileName2) +#else +bool IsAdornedVariationOf(const std::wstring& aFileName1, const std::wstring& aFileName2, const std::wstring& aDrivePath) +#endif { std::wstring unadornedFileName1; GetUnadornedFileName(aFileName1,unadornedFileName1); @@ -64,6 +68,11 @@ std::wstring unadornedFileName2; GetUnadornedFileName(aFileName2,unadornedFileName2); + #ifdef __TOOLS2_LINUX__ + ConvertToLocalPath( unadornedFileName1, aDrivePath ); + ConvertToLocalPath( unadornedFileName2, aDrivePath ); + #endif + // Check whether filename2 is a variant of filename1 // e.g: d:\sys\bin\DummyDll{000A0001}.dll is considered a variant of c:\sys\bin\DummyDll.dll // because they both break down to \sys\bin\DummyDll.dll @@ -73,7 +82,7 @@ std::wstring fileName2Path(StringUtils::Path(unadornedFileName2)); std::wstring fileName2NameAndExt(StringUtils::NameAndExt(unadornedFileName2)); - return ((fileName1Path == fileName2Path) && (fileName1NameAndExt == fileName2NameAndExt)); + return ( !wcscmp(fileName1Path.c_str(), fileName2Path.c_str()) && !wcscmp(fileName1NameAndExt.c_str(), fileName2NameAndExt.c_str()) ); } void FindAllAdornedVariants(const std::wstring& aSearchNameWild, const std::wstring& aSearchPath, std::list& aAdornedFileNamesFound, const DrivesMap& aDriveMap) diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/interpretsislib/adornedutilities.h --- a/secureswitools/swisistools/source/interpretsislib/adornedutilities.h Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/interpretsislib/adornedutilities.h Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -45,7 +45,11 @@ @param aFileName1 first name to compare (full path and name) @param aFileName2 second name to compare (full path and name) */ +#ifndef __TOOLS2_LINUX__ bool IsAdornedVariationOf(const std::wstring& aFileName1, const std::wstring& aFileName2); +#else +bool IsAdornedVariationOf(const std::wstring& aFileName1, const std::wstring& aFileName2, const std::wstring& aDrivePath); +#endif /** Searches through the file system looking for all variants of searchNameWild @param aSearchNameWild represents the filename pattern that is to be searched for (i.e: afile{????????}.ext) diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/interpretsislib/configmanager.cpp --- a/secureswitools/swisistools/source/interpretsislib/configmanager.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/interpretsislib/configmanager.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -123,7 +123,7 @@ if ( FileExists( fileName ) ) { std::string fName; - fName = Ucs2ToUtf8( fileName ); + fName = wstring2string( fileName ); // std::ifstream stream; stream.open( fName.c_str(), std::ios::binary ); @@ -382,7 +382,7 @@ std::ostringstream stream; stream << "Unsupported keyword at line " << aLineNumber << " of ini file [" << aKey << " = " << aValue << "] "; stream << std::endl; - std::wstring finalMessage = Utf8ToUcs2( stream.str() ); + std::wstring finalMessage = string2wstring( stream.str() ); LWARN( finalMessage ); } } @@ -398,7 +398,7 @@ if ( KConfigAttributes[i].iId == aId ) { std::wstring entry( KConfigAttributes[i].iName ); - ret = Ucs2ToUtf8( entry ); + ret = wstring2string( entry ); } } // @@ -411,7 +411,7 @@ std::string upperCased( aName ); upperCased = StringUtils::ToUpper( upperCased ); std::wstring searchFor; - searchFor = Utf8ToUcs2( upperCased ); + searchFor = string2wstring( upperCased ); // const int attributeCount = sizeof( KConfigAttributes ) / sizeof( ConfigAttribute ); const ConfigAttribute* ret = NULL; @@ -512,7 +512,7 @@ } // Set the drive representation location - Utf8ToUcs2(std::string(it, (currentPos-it)), aDrive->iDir); + aDrive->iDir = string2wstring(std::string(it, (currentPos-it))); temp = StringUtils::TrimWhiteSpace( std::string(currentPos, end) ); @@ -614,7 +614,7 @@ char drive = aDrive; std::stringstream warn; warn << "Redefining drive: " << drive; - std::wstring finalMessage = Utf8ToUcs2( warn.str() ); + std::wstring finalMessage = string2wstring( warn.str() ); LWARN( finalMessage + L" to " + aDir); delete it->second; @@ -687,7 +687,7 @@ stream << "\'" << iValue << "\'" << " directory is not found"; break; case ETypeDriveError: - LERROR( Utf8ToUcs2( iValue ) ); + LERROR( string2wstring( iValue ) ); return; default: @@ -696,7 +696,7 @@ } // stream << std::endl; - std::wstring finalMessage = Utf8ToUcs2( stream.str() ); + std::wstring finalMessage = string2wstring( stream.str() ); // LERROR( finalMessage ); } diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/interpretsislib/deserialiser.h --- a/secureswitools/swisistools/source/interpretsislib/deserialiser.h Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/interpretsislib/deserialiser.h Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -26,6 +26,8 @@ #include "serialisable.h" #include "cardinality.h" #include "ucmp.h" +#include "utf8.h" +#include "is_utils.h" #pragma warning (disable: 4800) @@ -137,6 +139,50 @@ return *this; } +#ifdef __TOOLS2_LINUX__ + + Deserialiser& operator>>(std::wstring& val) + { + Cardinality card; + *this >> card; + TUint32 size = card; + + TUint32 sizebackup = size; + + unsigned short int* buff = 0; + + if (size & 0x01) + { + throw std::runtime_error("Decoding 8bit text into std::wstring"); + } + else + { + size = size >> 1; + buff = new unsigned short int[(int)size]; + TUnicodeExpander exp; + TMemoryUnicodeSink sink((TUint16*)buff); + exp.ExpandL(sink, *this ,size); + unsigned short int* source = buff; + wchar_t buffer[size]; + // Using a temp variable in place of buffer as ConvertUTF16toUTF32 modifies the source pointer passed. + wchar_t* temp = buffer; + + ConvertUTF16toUTF32(&source, source + sizebackup, &temp, temp + size, lenientConversion); + + // Appending NUL to the converted buffer. + *temp = 0; + val.assign(buffer, size); + + } + + ConvertToForwardSlash(val); + + delete buff; + return *this; + } + +#else + Deserialiser& operator>>(std::wstring& val) { @@ -161,6 +207,7 @@ delete buff; return *this; } +#endif void read(TUint8* aDst, TUint32 aCount) { diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/interpretsislib/errors.h --- a/secureswitools/swisistools/source/interpretsislib/errors.h Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/interpretsislib/errors.h Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -85,7 +85,7 @@ } inline InterpretSisError( const std::wstring& aError, ErrorCodes aCode ) - : std::runtime_error( Ucs2ToUtf8(aError) ), iCode( aCode ) + : std::runtime_error( wstring2string(aError) ), iCode( aCode ) { } diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/interpretsislib/expressionevaluator.cpp --- a/secureswitools/swisistools/source/interpretsislib/expressionevaluator.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/interpretsislib/expressionevaluator.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -108,9 +108,9 @@ { iExpressionDepth=0; std::string error = "SIS File expression too complex\n"; - std::string x; + std::string x = wstring2string(iExpEnv.GetPackageName()); // - throw InvalidSis(Ucs2ToUtf8(iExpEnv.GetPackageName(),x), error, SIS_NOT_SUPPORTED); + throw InvalidSis(x, error, SIS_NOT_SUPPORTED); } switch (aExpression.Operator()) @@ -248,9 +248,9 @@ { iExpressionDepth=0; std::string error = "SIS File contains user options\n"; - std::string x; + std::string x = wstring2string(iExpEnv.GetPackageName()); // - throw InvalidSis(Ucs2ToUtf8(iExpEnv.GetPackageName(),x), error, SIS_NOT_SUPPORTED); + throw InvalidSis(x, error, SIS_NOT_SUPPORTED); } case CSISExpression::EPrimTypeNumber: @@ -261,9 +261,9 @@ { iExpressionDepth=0; std::string error = "SIS File contains unknown expression\n"; - std::string x; + std::string x = wstring2string(iExpEnv.GetPackageName()); // - throw InvalidSis(Ucs2ToUtf8(iExpEnv.GetPackageName(),x), error, SIS_NOT_SUPPORTED); + throw InvalidSis(x, error, SIS_NOT_SUPPORTED); } } @@ -316,8 +316,7 @@ } // Require for invalid file exception (also helps with debugging) - std::string narrowFileName; - narrowFileName = Ucs2ToUtf8( fileName, narrowFileName ); + std::string narrowFileName = wstring2string( fileName ); // Now continue with file, assuming we've fixed up the path or then // have enough characters to process @@ -345,8 +344,7 @@ ConvertToLocalPath( fileName, iCDrive ); // For debugging - narrowFileName = Ucs2ToUtf8( fileName, narrowFileName ); - + narrowFileName = wstring2string( fileName ); fileExists = FileExists( fileName ); break; } @@ -363,7 +361,7 @@ std::ostringstream stream; stream << "\tIF EXISTS(\'" << narrowFileName << "\') => " << fileExists; std::string msg = stream.str(); - std::wstring finalMessage = Utf8ToUcs2( msg ); + std::wstring finalMessage = string2wstring( msg ); LINFO( finalMessage ); } // @@ -428,7 +426,7 @@ std::ostringstream stream; stream << "Input language " << result << " is not supported by SIS file. Using first language " <IsEmulatorExecutable()) - LWARN(iTargetFile << L" is an emulator binary!"); + LWARN(iTargetFile.c_str() << L" is an emulator binary!"); } // PA SIS files @@ -64,6 +69,11 @@ iTargetFile(aFdes.Target().GetString()), iLocalTargetFile(aFdes.Target().GetString()) { + // Transforming the file path into lower case to maintain consistency + // between Windows and Linux as Linux path is case-sensitive. + std::transform(iTargetFile.begin(), iTargetFile.end(), iTargetFile.begin(), tolower); + std::transform(iLocalTargetFile.begin(), iLocalTargetFile.end(), iLocalTargetFile.begin(), tolower); + // Update the installing file with the actual target drive letter ChangeTargetDrive(aDrivePath, aInstallingDrive); @@ -86,7 +96,7 @@ iSid = info.iSecureId; if(fileType & EFileEmulatorExe) - LWARN(iTargetFile << L" is an emulator binary!"); + LWARN(iTargetFile.c_str() << L" is an emulator binary!"); } else if (fileType & EFileDll) { @@ -111,6 +121,9 @@ { // get the local path ConvertToLocalPath(iLocalTargetFile,aDrivePath); +#ifdef __TOOLS2_LINUX__ + ConvertToForwardSlash(iTargetFile); +#endif // change the drive letter if (StringUtils::StartsWithDrive(iTargetFile)) diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/interpretsislib/installer.cpp --- a/secureswitools/swisistools/source/interpretsislib/installer.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/interpretsislib/installer.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -21,7 +21,9 @@ #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK #include "dbhelper.h" - +#ifndef __TOOLS2_LINUX__ +#include +#endif #endif //SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK #include #include @@ -54,7 +56,11 @@ // Constants const char KRomDriveLetter = 'z'; const TUint32 KSwiDaemonUid = 0x10202DCE; +#ifndef __TOOLS2_LINUX__ const std::wstring KSysBinPath = L"\\sys\\bin\\"; +#else +const std::wstring KSysBinPath = L"/sys/bin/"; +#endif TInt CheckWildCard(TInt aVal, TInt aReplace) { @@ -111,7 +117,11 @@ // Ensure formatting is correct if ( StringUtils::IsLastCharacter( shortName, KDirectorySeparator[ 0 ] ) || + #ifndef __TOOLS2_LINUX__ StringUtils::IsLastCharacter( shortName, L'/' ) ) + #else + StringUtils::IsLastCharacter( shortName, L'\\' ) ) + #endif { shortName.erase(shortName.length()-1,1); } @@ -198,7 +208,7 @@ catch (InterpretSisError& e) { LERROR(L"Failed installing " << (curr->iFileName)); - LERROR(L"\t" << Utf8ToUcs2(e.what())); + LERROR(L"\t" << string2wstring(e.what())); curr = sisFiles.erase(curr); if (result == 0) @@ -465,7 +475,7 @@ if (installType == CSISInfo::EInstAugmentation) { // Clean up the installed files from the specified SP package and the SisRegistry Entry - iRegistry.RemoveEntry(uid, aSis.GetPackageName(), aSis.GetVendorName()); + iRegistry.RemoveEntry(uid, aSis.GetPackageName().c_str(), aSis.GetVendorName().c_str()); } // Regenerate the ROM stub registry entries for eclipsing check later. @@ -731,8 +741,8 @@ else { // Unicode characters can not be displayed on DOS prompt - std::string temporary = Ucs2ToUtf8(target); - std::wstring targetDisplay = Utf8ToUcs2( temporary ); + std::string temporary = wstring2string(target); + std::wstring targetDisplay = string2wstring( temporary ); LINFO(L"Installing file: " << targetDisplay); std::wstring targetDirectory = localTarget.substr( 0, localTarget.rfind( KDirectorySeparator ) ); @@ -783,8 +793,15 @@ { // register the hash std::wstring basename = localTarget.substr( localTarget.rfind( KDirectorySeparator ) + 1 ); - std::wstring hashdir = iSystemDrivePath + L"\\sys\\hash\\"; + #ifndef __TOOLS2_LINUX__ + // Remove the null character at the end and. + std::wstring tempStr = iSystemDrivePath.c_str(); + std::wstring hashdir = tempStr + L"\\sys\\hash\\"; std::wstring reghashdir = L"$:\\sys\\hash\\"; + #else + std::wstring hashdir = iSystemDrivePath + L"/sys/hash/"; + std::wstring reghashdir = L"$:/sys/hash/"; + #endif if ( !MakeDir( hashdir ) ) { @@ -795,8 +812,7 @@ // hash file is always created on the system drive reghashdir[0] = iSystemDrive; - LINFO(L"\tCreating hash: " << reghashdir << basename); - + LINFO(L"\tCreating hash: " << reghashdir << basename.c_str()); std::wstring hash = hashdir + basename; HANDLE hFile = MakeSISOpenFile(hash.c_str(), GENERIC_WRITE, CREATE_ALWAYS); if( INVALID_HANDLE_VALUE == hFile ) @@ -870,7 +886,11 @@ // find all adorned variants in the ROM/ROFS logs if (iParamList.IsFlagSet(CParameterList::EFlagsRomRofsLogFilesSet)) { + #ifndef __TOOLS2_LINUX__ std::wstring romSearchNameWild = L"z:\\sys\\bin\\"; + #else + std::wstring romSearchNameWild = L"z:/sys/bin/"; + #endif romSearchNameWild.append(searchNameWild); iRomManager.FindAllAdornedVariants(romSearchNameWild, aAdornedFileNamesFound); } @@ -983,7 +1003,11 @@ { // we are eclipsing a ROM file, check if this is authorised: // see implementation of IsEclipsable() + #ifndef __TOOLS2_LINUX__ if (!IsEclipsable(searchNameUnadorned, aSUFlag)) + #else + if (!IsEclipsable(searchNameUnadorned, aSUFlag, localDir)) + #endif { result = false; break; @@ -998,7 +1022,7 @@ // this drive should be added to iEclipsableOverwriteFiles. if (processEclipsingSuspectsFoundOnThisDrive && unadornedFound) { - iEclipsableOverwriteFiles.push_back(searchNameUnadorned); + iEclipsableOverwriteFiles.push_back(searchNameUnadorned.c_str()); } if (processEclipsingSuspectsFoundOnThisDrive && adornedFound) @@ -1014,7 +1038,7 @@ int drive = tolower(adornedFile[0]); if (drive == disk) { - iEclipsableOverwriteFiles.push_back(adornedFile); + iEclipsableOverwriteFiles.push_back(adornedFile.c_str()); } } } @@ -1087,7 +1111,11 @@ @param aRomFile fully qualified filename in ROM that is to be checked for eclipising (i.e: z:\sys\bin\some.dll) @param aSUFlag specifies if the installing SIS file has been signed by a SU certificate */ +#ifndef __TOOLS2_LINUX__ bool Installer::IsEclipsable(std::wstring& aRomFile, bool aSUFlag) +#else +bool Installer::IsEclipsable(std::wstring& aRomFile, bool aSUFlag, const std::wstring& aDrivePath) +#endif { // SA/SP/PU sis + RU flag + signed by SU root cert is allowed if (aSUFlag) @@ -1111,7 +1139,11 @@ } else if (goesToSysBin) // case 2 { + #ifndef __TOOLS2_LINUX__ if (IsAdornedVariationOf(eclipsableRomFile,aRomFile)) + #else + if (IsAdornedVariationOf(eclipsableRomFile,aRomFile,aDrivePath)) + #endif { isEclipsable = true; break; @@ -1145,8 +1177,8 @@ // do not display a warning if the installing file is a PA. The user // needs to copy the installing files to the installing directory // prior to installing the SIS file. - std::string tempTarget = Ucs2ToUtf8(aTarget); - std::wstring targetDisplay = Utf8ToUcs2( tempTarget ); + std::string tempTarget = wstring2string(aTarget); + std::wstring targetDisplay = string2wstring( tempTarget ); if (aFile.GetInstallType() == CSISInfo::EInstPreInstalledApp) { LINFO(targetDisplay << L" found for PA installation"); @@ -1162,7 +1194,7 @@ if (isSp) { std::wostringstream os; - os << aTarget << L" overwrites file from base package 0x" << std::hex << owningUid << L" \"" << owningObj->GetPackageName() << L"\"" << std::endl; + os << aTarget.c_str() << L" overwrites file from base package 0x" << std::hex << owningUid << L" \"" << owningObj->GetPackageName() << L"\"" << std::endl; iProblemFiles.append(os.str()); iError = ECLIPSING_VIOLATION; } @@ -1175,13 +1207,13 @@ if (isSp || (!aSUFlag && (isPu || isSa))) { std::wostringstream os; - os << aTarget << L" overwrites file from base package 0x" << std::hex << owningUid << L" \"" << owningObj->GetPackageName() << L"\"" << std::endl; + os << aTarget.c_str() << L" overwrites file from base package 0x" << std::hex << owningUid << L" \"" << owningObj->GetPackageName() << L"\"" << std::endl; iProblemFiles.append(os.str()); iError = ECLIPSING_VIOLATION; } else { - LWARN(aTarget << L" overwrites file from base package 0x" << std::hex << owningUid << L" \"" << owningObj->GetPackageName() << L"\""); + LWARN(aTarget.c_str() << L" overwrites file from base package 0x" << std::hex << owningUid << L" \"" << owningObj->GetPackageName() << L"\""); } } } @@ -1201,19 +1233,19 @@ std::wstring eclipseFile(*curr); TUint32 owningUid = 0; - const SisRegistryObject* owningObj = iRegistry.OwningPackage(eclipseFile, owningUid); + const SisRegistryObject* owningObj = iRegistry.OwningPackage(eclipseFile.c_str(), owningUid); // always allow orphaned file overwriting if (owningUid == 0) { - LWARN(eclipseFile << L" eclipses orphaned file."); + LWARN(eclipseFile.c_str() << L" eclipses orphaned file."); } else { // SP/PU can not overwrite a file belonging to a different base pkg or // SP/PU can not eclipse a base package which is not in the ROM. std::wostringstream os; - os << eclipseFile << L" eclipses file from package 0x" << std::hex << owningUid << L" \"" << owningObj->GetPackageName() << L"\"" << std::endl; + os << eclipseFile.c_str() << L" eclipses file from package 0x" << std::hex << owningUid << L" \"" << owningObj->GetPackageName().c_str() << L"\""<< std::endl; iProblemFiles.append(os.str()); iError = ECLIPSING_VIOLATION; continue; @@ -1235,10 +1267,17 @@ Sids sids; GetSidsFromInstallable(aFiles, sids); + #ifndef __TOOLS2_LINUX__ const std::wstring privatePath = L":\\private\\"; const std::wstring sysPath = L":\\sys\\"; const std::wstring sysBinPath = L":\\sys\\bin\\"; const std::wstring resourcePath = L":\\resource\\"; + #else + const std::wstring privatePath = L":/private/"; + const std::wstring sysPath = L":/sys/"; + const std::wstring sysBinPath = L":/sys/bin/"; + const std::wstring resourcePath = L":/resource/"; + #endif const std::wstring exeType = L".exe"; int num_of_files = aFiles.size(); @@ -1265,7 +1304,7 @@ const CSISFileDescription* sisDescription = file->FileDescription(); // file to be installed - std::wstring target( file->GetTarget() ); + std::wstring target( file->GetTarget().c_str() ); if (sisDescription->Operation() == CSISFileDescription::EOpText) break; @@ -1276,7 +1315,7 @@ { // eclipsing problem std::wostringstream os; - os << L"FN file \"" << target << L"\" can not remove a file from \\sys or \\resource" << std::endl; + os << L"FN file \"" << target.c_str() << L"\" can not remove a file from \\sys or \\resource" << std::endl; iProblemFiles.append(os.str()); iError = DATA_CAGE_VIOLATION; continue; @@ -1284,7 +1323,7 @@ } else { - std::wstring realTarget(file->GetLocalTarget()); + std::wstring realTarget(file->GetLocalTarget().c_str()); std::wstring romTarget(target); romTarget[0] = KRomDriveLetter; @@ -1296,7 +1335,7 @@ { // eclipsing problem std::wostringstream os; - os << target << L" eclipses file from ROM" << std::endl; + os << target.c_str() << L" eclipses file from ROM" << std::endl; iProblemFiles.append(os.str()); iError = ECLIPSING_VIOLATION; continue; @@ -1348,14 +1387,17 @@ const int KUidStringLength = 8; std::wstring importPath = privatePath; - + #ifndef __TOOLS2_LINUX__ importPath.append( uidStr.str() + L"\\import" ); + #else + importPath.append( uidStr.str() + L"/import" ); + #endif if ((target.find(importPath,0) == std::wstring::npos) && !suFlag) { // only SA with RU + SU and PU with RU + SU flag can override other private directory std::wostringstream os; - os << target << L" cannot be written to a private directory which " + os << target.c_str() << L" cannot be written to a private directory which " << L"does not belong to any exe in this package" << std::endl; iProblemFiles.append(os.str()); iError = DATA_CAGE_VIOLATION; @@ -1425,8 +1467,8 @@ { std::wostringstream os; - os << L"The existing file " << owningSidFile << L" already has the SID 0x" << std::hex << sid - << std::dec << L", cannot install " << target << std::endl; + os << L"The existing file " << owningSidFile.c_str() << L" already has the SID 0x" << std::hex << sid + << std::dec << L", cannot install " << target.c_str() << std::endl; iProblemFiles.append(os.str()); iError = DUPLICATE_SID; continue; @@ -1450,7 +1492,7 @@ { const CSISFileDescription* fD = *iter; - std::wstring romStubTarget(fD->Target().GetString()); + std::wstring romStubTarget(fD->Target().GetString().c_str()); if (StringUtils::WildcardCompare(romStubTarget,romFileWithDuplicateSid)) { @@ -1471,7 +1513,7 @@ std::wostringstream os; os << L"A ROM file already has the SID 0x" << std::hex << file->Sid() - << std::dec << L", cannot install " << target << std::endl; + << std::dec << L", cannot install " << target.c_str() << std::endl; iProblemFiles.append(os.str()); iError = DUPLICATE_SID; continue; @@ -1481,7 +1523,7 @@ else if (realTarget.find(sysBinPath) != std::wstring::npos) { std::wostringstream os; - os << target << L" cannot be installed to a data caged area" << std::endl; + os << target.c_str() << L" cannot be installed to a data caged area" << std::endl; iProblemFiles.append(os.str()); iError = DATA_CAGE_VIOLATION; continue; @@ -1497,8 +1539,8 @@ if (!iProblemFiles.empty()) { - std::string x; - throw InvalidSis("", Ucs2ToUtf8(iProblemFiles,x), iError); + std::string x = wstring2string(iProblemFiles); + throw InvalidSis("", x, iError); } } @@ -1536,8 +1578,11 @@ { int targetDrive = aInstallSISFile.iTargetDrive; std::wstring drivePath = iConfigManager.GetLocalDrivePath(targetDrive); - + #ifndef __TOOLS2_LINUX__ drivePath.append(L"\\private\\"); + #else + drivePath.append(L"/private/"); + #endif // build SwiDaemon Pathname std::wstring ctrl = StringUtils::MakePathFromSID(drivePath, KSwiDaemonUid); @@ -1552,7 +1597,6 @@ ctrl.append(s.str()); - switch(aSis.GetInstallType()) { case CSISInfo::EInstInstallation: diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/interpretsislib/installer.h --- a/secureswitools/swisistools/source/interpretsislib/installer.h Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/interpretsislib/installer.h Thu Aug 19 10:02:49 2010 +0300 @@ -111,7 +111,11 @@ bool IsValidEclipsingUpgrade(const SisFile& aSis, const SisRegistryObject& registryEntry); bool ValidEclipse(const SisFile& aFile, const std::wstring& target, const InstallableFile& aInstallableFile, bool aSUFlag); void HandleFileOverwriting(const SisFile& aFile, const std::wstring& target, bool aSUFlag); + #ifndef __TOOLS2_LINUX__ bool IsEclipsable(std::wstring& aRomFile, bool aSUFlag); + #else + bool IsEclipsable(std::wstring& aRomFile, bool aSUFlag, const std::wstring& aDrivePath); + #endif void FilterNonBlockingFilesOfFilename(const SisFile& aFile, const std::wstring& target); void WarnEclipseOverWrite(const SisFile& aFile); diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/interpretsislib/interpretsis.cpp --- a/secureswitools/swisistools/source/interpretsislib/interpretsis.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/interpretsislib/interpretsis.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -114,4 +114,8 @@ } } +const SisRegistry* CInterpretSIS::GetSisRegistry() const + { + return iSisRegistry; + } // End of File diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/interpretsislib/interpretsis.h --- a/secureswitools/swisistools/source/interpretsislib/interpretsis.h Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/interpretsislib/interpretsis.h Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -62,6 +62,8 @@ * Un-install installed applications specified while creating this class. */ void Uninstall(); + + const SisRegistry* GetSisRegistry() const; private: void ConstructL(); diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/interpretsislib/is_utils.cpp --- a/secureswitools/swisistools/source/interpretsislib/is_utils.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/interpretsislib/is_utils.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -75,20 +75,63 @@ } +void ConvertToPlatformSpecificPath( TUint16* aIn, TUint32 len ) +{ + while( len-- > 0 ) + { + if( *aIn == '\\' ) + { + *aIn = '/'; + } + aIn++; + } +} + +#ifdef __TOOLS2_LINUX__ +void ConvertToForwardSlash( std::wstring& aIn) +{ + std::wstring::size_type idx = 0; + + while( (idx = aIn.find(L"\\", idx)) != std::wstring::npos) + { + aIn.replace( idx, 1, KDirectorySeparator ); + } +} +#endif + + void ConvertToLocalPath( std::wstring& aIn, const std::wstring& aDrivePath ) { std::wstring::size_type idx = 0; - while( (idx = aIn.find(L"\\\\", idx)) != std::wstring::npos) + + #ifndef __TOOLS2_LINUX__ + while( (idx = aIn.find(L"//", idx)) != std::wstring::npos) { - aIn.replace( idx, 4, KDirectorySeparator ); + aIn.replace( idx, 2, KDoubleSlashPathPrefix ); } - // + idx = 0; + while( (idx = aIn.find(L"/", idx)) != std::wstring::npos) { aIn.replace( idx, 1, KDirectorySeparator ); } - + #else + + idx = 0; + + while( (idx = aIn.find(L"\\\\", idx)) != std::wstring::npos) + { + aIn.replace( idx, 2, KDoubleSlashPathPrefix ); + } + + idx = 0; + + while( (idx = aIn.find(L"\\", idx)) != std::wstring::npos) + { + aIn.replace( idx, 1, KDirectorySeparator ); + } + #endif // If the first two characters represent a drive specification // then replace them entirely with the value from the // PC's path ('aDrivePath'). @@ -98,15 +141,14 @@ const bool startsWithDrive = StringUtils::StartsWithDrive( aIn ); if ( startsWithDrive ) { - aIn.replace(aIn.begin(), aIn.begin()+2, aDrivePath); + aIn.replace(aIn.begin(), aIn.begin()+2, aDrivePath.c_str()); } else { - aIn.insert( 0, aDrivePath ); + aIn.insert( 0, aDrivePath.c_str() ); } } - struct TPair { TUint16 first; TUint16 second; @@ -1008,10 +1050,22 @@ } int FoldedCompare(const std::wstring& aLeft, const std::wstring& aRight) { - std::wstring::const_iterator l = aLeft.begin(); - std::wstring::const_iterator r = aRight.begin(); - std::wstring::const_iterator le = aLeft.end(); - std::wstring::const_iterator re = aRight.end(); + std::wstring iLeft=aLeft.c_str(); + std::wstring iRight=aRight.c_str(); + +#ifdef __TOOLS2_LINUX__ + std::wstring::size_type idx = 0; + + while( (idx = iLeft.find(L"\\", idx)) != std::wstring::npos) + { + iLeft.replace( idx, 1, KDirectorySeparator ); + } +#endif + + std::wstring::const_iterator l = iLeft.begin(); + std::wstring::const_iterator r = iRight.begin(); + std::wstring::const_iterator le = iLeft.end(); + std::wstring::const_iterator re = iRight.end(); while (l != le && r != re) { @@ -1025,7 +1079,7 @@ ++r; } - return aLeft.size() - aRight.size(); + return iLeft.size() - iRight.size(); } int ReadSecurityInfo( SBinarySecurityInfo& aInfo, const std::wstring aFileName ) @@ -1045,7 +1099,12 @@ throw "Failed in redirection operation"; } +#ifndef __LINUX__ nulStdErr = fopen("NUL:" , "w"); +#else + nulStdErr = fopen("/dev/null", "w"); +#endif + if (!nulStdErr) { throw "Failed in redirection operation"; @@ -1087,3 +1146,25 @@ } // end for i } +const std::wstring Utils::IntegerToWideString(int aInt) + { + std::wstringstream wstream; + wstream << aInt; + return wstream.str(); + } + +std::wstring Utils::Int64ToWideString(TInt64 aInt) + { + std::wstringstream strInt64; + strInt64 << aInt; + return strInt64.str(); + } + +int Utils::WideStringToInteger(const std::wstring& aWideString) + { + unsigned long int value=0; + std::wstringstream str(aWideString); + str >> value; + return value; + } + diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/interpretsislib/is_utils.h --- a/secureswitools/swisistools/source/interpretsislib/is_utils.h Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/interpretsislib/is_utils.h Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -75,6 +75,10 @@ int GetStat(const std::wstring& aFile, struct stat*); + void ConvertToPlatformSpecificPath( TUint16* aIn, TUint32 len ); + #ifdef __TOOLS2_LINUX__ + void ConvertToForwardSlash( std::wstring& aIn); + #endif void ConvertToLocalPath( std::wstring& aIn, const std::wstring& aDrivePath); @@ -140,9 +144,6 @@ dp38, dp39, dp40, dp41, dp42, dp43, dp44, dp45}; void GetEquivalentLanguageList(CSISLanguage::TLanguage aLang, TLanguagePath& aEquivalents); - std::string wstring2string (const std::wstring& aWide); - - std::wstring string2wstring (const std::string& aNarrow); const std::wstring IntegerToWideString(int aInt); diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/interpretsislib/rommanager.cpp --- a/secureswitools/swisistools/source/interpretsislib/rommanager.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/interpretsislib/rommanager.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -29,8 +29,13 @@ #include "is_utils.h" // String constants +#ifndef __TOOLS2_LINUX__ const std::wstring KRomManagerSysBinPath = L"z:\\sys\\bin\\"; const std::string KRomManagerRomDrive = "Z:\\"; +#else +const std::wstring KRomManagerSysBinPath = L"z:/sys/bin/"; +const std::string KRomManagerRomDrive = "Z:/"; +#endif const std::string KRomManagerRomLogProcessingFile = "Processing file "; const std::string KRomManagerRomLogReadingResource = "Reading resource "; const std::string KRomManagerRomLogReadingResource2 = " to rom linear address"; @@ -146,7 +151,7 @@ { for( std::list::const_iterator it = aLogFileNames.begin() ; it != aLogFileNames.end(); it++ ) { - std::string narrowLogFileName = Ucs2ToUtf8( *it ); + std::string narrowLogFileName = wstring2string( *it ); std::string narrowUpperCaseLogFileName = StringUtils::ToUpper( narrowLogFileName ); // Get the base name @@ -188,7 +193,7 @@ // Get filename & convert it to uppercase, since our map key is // also in upper case form. - std::string narrowFileName = Ucs2ToUtf8( aFileName ); + std::string narrowFileName = wstring2string( aFileName ); narrowFileName = StringUtils::ToUpper( narrowFileName ); // Do we have a corresponding entry? @@ -210,7 +215,7 @@ for ( ; curr != end ; ++curr) { - std::wstring romFile = Utf8ToUcs2(curr->first); + std::wstring romFile = string2wstring(curr->first); if (StringUtils::WildcardCompare(searchNameWild,romFile)) { aAdornedFileNamesFound.push_back(romFile); @@ -233,7 +238,7 @@ TUint32 romSid = romEntry->SecurityInfo().iSecureId; if (romSid != 0 && romSid == aSid) { - aFile = Utf8ToUcs2(romEntry->RomFileName()); + aFile = string2wstring(romEntry->RomFileName()); return true; } } @@ -248,7 +253,7 @@ // Get filename & convert it to uppercase, since our map key is // also in upper case form. - std::string narrowFileName = Ucs2ToUtf8( aFileName ); + std::string narrowFileName = wstring2string( aFileName ); narrowFileName = StringUtils::ToUpper( narrowFileName ); // Do we have a corresponding entry? @@ -269,7 +274,7 @@ void RomManagerLogFiles::ReadObyFile( const std::string& aFileName ) { - std::wstring fileName = Utf8ToUcs2( aFileName ); + std::wstring fileName = string2wstring( aFileName ); if ( FileExists( fileName ) ) { std::ifstream stream; @@ -570,7 +575,7 @@ } // stream << std::endl; - std::wstring finalMessage = Utf8ToUcs2( stream.str() ); + std::wstring finalMessage = string2wstring( stream.str() ); // LERROR( finalMessage ); } diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/interpretsislib/serialiser.h --- a/secureswitools/swisistools/source/interpretsislib/serialiser.h Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/interpretsislib/serialiser.h Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -26,6 +26,7 @@ #include "serialisable.h" #include "ucmp.h" #include "cardinality.h" +#include "utf8.h" /** * @file SERIALISER.H @@ -81,15 +82,49 @@ Serialiser& operator<<(std::wstring& val) { + + std::wstring tempval = val.c_str(); + +#ifdef __TOOLS2_LINUX__ + std::wstring::size_type idx = 0; + while( (idx = tempval.find(L"/", idx)) != std::wstring::npos) + { + tempval.replace( idx, 1, L"\\" ); + } +#endif + Cardinality card; - TUint32 size = val.size() << 1; + TUint32 size = tempval.size() << 1; + +#ifdef __TOOLS2_LINUX__ + const wchar_t * source = tempval.c_str(); + unsigned short int* buffer = new unsigned short int[size]; + + // Using a temp variable in place of buffer as ConvertUTF32toUTF16 modifies the source pointer passed. + unsigned short int* temp = buffer; + + ConvertUTF32toUTF16(&source, tempval.c_str() + tempval.size(), &temp, temp + size, lenientConversion); + + // Appending NULL to the converted buffer. + *temp = NULL; +#endif + card.SetSize(size); *this << card; TUnicodeCompressor comp; - TMemoryUnicodeSource src((TUint16*)val.c_str()); + +#ifdef __TOOLS2_LINUX__ + TMemoryUnicodeSource src((TUint16*)buffer); +#else + TMemoryUnicodeSource src((TUint16*)tempval.c_str()); +#endif + //The compressed unicode output could end up larger than the input, thus restricting the output to KMaxTInt. - comp.CompressL(*this, src, KMaxTInt, val.size()); + comp.CompressL(*this, src, KMaxTInt, tempval.size()); +#ifdef __TOOLS2_LINUX__ + delete[] buffer; +#endif return *this; } diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/interpretsislib/sisfile.cpp --- a/secureswitools/swisistools/source/interpretsislib/sisfile.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/interpretsislib/sisfile.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -204,9 +204,8 @@ if (failed) { - std::string x; - throw InvalidSis(Ucs2ToUtf8(this->GetPackageName(),x), - error, SIS_NOT_SUPPORTED); + std::string x = wstring2string(this->GetPackageName()); + throw InvalidSis(x, error, SIS_NOT_SUPPORTED); } } @@ -263,6 +262,7 @@ success = true; break; case CSISFileDescription::EOpNull: + case CSISFileDescription::EOpNone: success = true; break; default: @@ -276,6 +276,7 @@ break; } } + return success; } @@ -421,9 +422,9 @@ if (ifBlock.WasteOfSpace()) { - std::string x; std::string error = "corrupt SIS file"; - throw InvalidSis(Ucs2ToUtf8(this->GetPackageName(),x), error, INVALID_SIS); + std::string x = wstring2string(this->GetPackageName()); + throw InvalidSis(x, error, INVALID_SIS); } // Main expression diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/interpretsislib/sisregistry.cpp --- a/secureswitools/swisistools/source/interpretsislib/sisregistry.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/interpretsislib/sisregistry.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -51,6 +51,7 @@ // SisX Library Includes #include "sisfiledescription.h" #include "sisstring.h" +#include "utility.h" // User Includes #include "sisregistry.h" @@ -64,9 +65,15 @@ #include "configmanager.h" // Constants +#ifndef __TOOLS2_LINUX__ const std::wstring SisRegistry::KPathToRegistry(L"\\sys\\install\\sisregistry/"); const std::wstring SisRegistry::KPathToRomStubs(L"\\system\\install\\"); const std::wstring SisRegistry::KPathToRegistryVersionMarker(L"\\system\\data\\"); +#else +const std::wstring SisRegistry::KPathToRegistry(L"/sys/install/sisregistry/"); +const std::wstring SisRegistry::KPathToRomStubs(L"/system/install/"); +const std::wstring SisRegistry::KPathToRegistryVersionMarker(L"/system/data/"); +#endif const std::wstring KRegistryEntry(L"00000000.reg"); const std::wstring KControllerEntry(L"00000000_0000.ctl"); const std::wstring KBackupLst(L"backup.lst"); @@ -81,9 +88,13 @@ const std::wstring SisRegistry::KRegistryV52(L"sisregistry_5.2.txt"); const std::wstring SisRegistry::KRegistryV53(L"sisregistry_5.3.txt"); const std::wstring SisRegistry::KRegistryV54(L"sisregistry_5.4.txt"); +#ifndef __TOOLS2_LINUX__ const std::wstring SisRegistry::KRomStubDir(L"z:\\system\\install\\"); const std::wstring SisRegistry::KRomRegistryVersionMarker(L"z:\\system\\data\\"); - +#else +const std::wstring SisRegistry::KRomStubDir(L"z:/system/install/"); +const std::wstring SisRegistry::KRomRegistryVersionMarker(L"z:/system/data/"); +#endif const std::string SisRegistry::KRegistryV40string("4.0"); const std::string SisRegistry::KRegistryV50string("5.0"); const std::string SisRegistry::KRegistryV51string("5.1"); @@ -545,9 +556,7 @@ while(it != iEntries.end()) { - if (aUid == it->first && - aPackageName == it->second->GetPackageName() && - aVendorName == it->second->GetVendorName()) + if (aUid == it->first && !wcscmp(aPackageName.c_str(), it->second->GetPackageName().c_str()) && aVendorName == it->second->GetVendorName() ) { LINFO(L"Removing package \"" << it->second->GetPackageName() << L"\" prior to re-installation"); @@ -948,7 +957,11 @@ { return (aFileName.find(L'?') != std::wstring::npos || aFileName.find(L'*') != std::wstring::npos || + #ifndef __TOOLS2_LINUX__ aFileName[aFileName.length() - 1] == L'\\'); + #else + aFileName[aFileName.length() - 1] == L'/'); + #endif } @@ -1030,7 +1043,11 @@ continue; std::fstream input; + #ifndef __TOOLS2_LINUX__ std::wstring filename(aPath + L"\\" + *c); + #else + std::wstring filename(aPath + L"/" + *c); + #endif OpenFile(filename.c_str(), input, std::fstream::in | std::fstream::binary); @@ -1041,7 +1058,7 @@ if (!obj) { - throw std::runtime_error("Cannot create SisRegistryObject for " + Ucs2ToUtf8(filename)); + throw std::runtime_error("Cannot create SisRegistryObject for " + wstring2string(filename)); } Deserialiser des(input); @@ -1241,7 +1258,7 @@ msg.append(L" does not have any SisRegistry file"); - throw std::runtime_error( Ucs2ToUtf8(msg) ); + throw std::runtime_error( wstring2string(msg) ); } aObj.SetIndex( index ); @@ -1253,7 +1270,7 @@ msg.append(L" directory NOT found"); - throw std::runtime_error( Ucs2ToUtf8(msg) ); + throw std::runtime_error( wstring2string(msg) ); } } } @@ -1276,7 +1293,7 @@ msg.append(L" directory NOT found"); - throw std::runtime_error( Ucs2ToUtf8(msg) ); + throw std::runtime_error( wstring2string(msg) ); } } } @@ -1329,7 +1346,7 @@ msg.append(L" does not have any Sis Controller file"); - throw std::runtime_error( Ucs2ToUtf8(msg) ); + throw std::runtime_error( wstring2string(msg) ); } } @@ -1447,32 +1464,34 @@ void SisRegistry::UpdateInstallationInformation(XmlDetails::TScrPreProvisionDetail aScrPreProvisionDetail) { - CXmlGenerator xmlgenerator; - char* tmpFileName = tmpnam(NULL); + CXmlGenerator xmlGenerator; + char* tmpFileName = tmpnam(NULL); std::wstring filename(string2wstring(tmpFileName)); - - xmlgenerator.WritePreProvisionDetails(filename , aScrPreProvisionDetail); - + + int isRomApplication = 0; + xmlGenerator.WritePreProvisionDetails(filename , aScrPreProvisionDetail, isRomApplication); + + #ifdef __LINUX__ + std::string executable = "scrtool"; + #else std::string executable = "scrtool.exe"; + #endif + std::string command; command = executable + " -d " + GetDbPath() + " -p " + tmpFileName; - + int error = system(command.c_str()); - + + int err = remove(tmpFileName); + if(err != 0) + LERROR(L"Temporary file removal failed."); + if(error != 0) { std::string err = "Scrtool failed to upload the database registry entry."; LERROR(L"Scrtool failed to upload the database registry entry."); throw InterpretSisError(err, DATABASE_UPDATE_FAILED); } - - error = remove(tmpFileName); - - if(error != 0) - { - LERROR(L"Temporary file removal failed."); - } - } std::string SisRegistry::GetDbPath() @@ -1482,10 +1501,17 @@ iParamList.IsFlagSet(CParameterList::EFlagsDisableZDriveChecksSet) ) { + #ifndef __TOOLS2_LINUX__ return wstring2string(iParamList.SystemDrivePath()) + "\\sys\\install\\scr\\scr.db"; + #else + return wstring2string(iParamList.SystemDrivePath()) + "/sys/install/scr/scr.db"; + #endif } - + #ifndef __TOOLS2_LINUX__ return wstring2string(iParamList.RomDrivePath()) + "\\sys\\install\\scr\\provisioned\\scr.db"; + #else + return wstring2string(iParamList.RomDrivePath()) + "/sys/install/scr/provisioned/scr.db"; + #endif } @@ -1819,8 +1845,8 @@ // The property is a concatenation of the algorithm id and the hash data const std::string hashData = aHashContainer.GetData(); - std::string encodedHashData = Util::Base64Encode(hashData); - std::wstring wideHashData = Utils::string2wstring(encodedHashData); + std::string encodedHashData = Util::Base64Encode(hashData); + std::wstring wideHashData = string2wstring(encodedHashData); AddComponentProperty( aComponent, DbConstants::CompControllerHashData, wideHashData, aCount, true); } @@ -2014,7 +2040,7 @@ if(!aFileDescription->GetHash().GetData().empty()) { std::string binHashData = Util::Base64Encode(aFileDescription->GetHash().GetData()); - std::wstring hashData = Utils::string2wstring(binHashData); + std::wstring hashData = string2wstring(binHashData); AddFileProperty( aComponentFile, DbConstants::FileHashData, hashData, true); } } diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/interpretsislib/sisregistry.h --- a/secureswitools/swisistools/source/interpretsislib/sisregistry.h Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/interpretsislib/sisregistry.h Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -90,6 +90,7 @@ static const std::string KRegistryV52string; static const std::string KRegistryV53string; static const std::string KRegistryV54string; + typedef std::multimap EntryMap; private: // Internal methods void ReadStubs( const std::wstring& aDirectory ); @@ -109,6 +110,7 @@ TUint32 GetUid(TUint32 aSid) const; TUint32 GetUid(const std::wstring& aSidFile) const; bool GetInRom(TUint32 aUid) const; + std::string GetDbPath(); #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK const DbHelper* GetDbHelper() const; #endif @@ -123,9 +125,6 @@ private: // Friends friend struct Contains; -private: // Type definitions - typedef std::multimap EntryMap; - private: // Constants static const std::wstring KPathToRegistry; static const std::wstring KPathToRomStubs; @@ -260,8 +259,6 @@ void GenerateDbRegistryEntry(const SisRegistryObject& aSisRegistryObject, bool aOriginVerified); - std::string GetDbPath(); - std::wstring GetGlobalId( TUint32 aUid , TInt aInstallType, std::wstring aPackageName); void SetOriginVerification(XmlDetails::TScrPreProvisionDetail::TComponent& aComponent, bool aOriginVerified); diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/interpretsislib/sisregistryobject.cpp --- a/secureswitools/swisistools/source/interpretsislib/sisregistryobject.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/interpretsislib/sisregistryobject.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -146,7 +146,7 @@ iProperties.push_back(p); } - const const CSISArray& deps = + const CSISArray& deps = aSis.GetDependencies()->DependencyList(); for(i = 0; i < deps.size(); ++i) @@ -401,9 +401,9 @@ } else { - std::string x; std::string error = "can not retrieve localized vendor name"; - throw InvalidSis(Ucs2ToUtf8((std::wstring)packageName,x), error, INVALID_SIS); + std::string x = wstring2string((std::wstring)packageName); + throw InvalidSis(x, error, INVALID_SIS); } // Signed by SU cert diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/interpretsislib/stringutils.cpp --- a/secureswitools/swisistools/source/interpretsislib/stringutils.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/interpretsislib/stringutils.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -30,6 +30,7 @@ #include "is_utils.h" #include "logger.h" #include "utility_interface.h" +#include "util.h" // Constants const int KInterpretSISExpectedSIDLength = 8; @@ -51,14 +52,29 @@ // then the function will return 0 int ret = 0; int pos = 0; - if((pos = aPath.find(L"/", aIndex)) != std::wstring::npos) + #ifndef __TOOLS2_LINUX__ + if((pos = aPath.find(L"//", aIndex)) != std::wstring::npos) + { + ret = 2; + } + #else + if((pos = aPath.find(L"\\\\", aIndex)) != std::wstring::npos) + { + ret = 2; + } + #endif + + #ifndef __TOOLS2_LINUX__ + else if((pos = aPath.find(L"/", aIndex)) != std::wstring::npos) { ret = 1; } - else if((pos = aPath.find(L"\\\\", aIndex)) != std::wstring::npos) + #else + else if((pos = aPath.find(L"\\", aIndex)) != std::wstring::npos) { - ret = 2; + ret = 1; } + #endif aIndex = pos; return ret; } @@ -73,7 +89,9 @@ int len = ConvertMultiByteToWideChar(src, -1, NULL, 0); buf = new wchar_t[len+1]; len = ConvertMultiByteToWideChar(src, -1, buf, len); - ret = std::wstring( buf ); + + ret = std::wstring( buf ,len); + delete[] buf; // std::wstring::size_type idx = 0; @@ -82,7 +100,7 @@ ret.replace(idx, len, KDirectorySeparator); } // - return ret; + return ret.c_str(); } @@ -144,6 +162,14 @@ return ret; } +std::wstring StringUtils::ToLower( const std::wstring& aString ) + { + std::wstring ret( aString ); + std::transform( ret.begin(), ret.end(), ret.begin(), tolower ); + + return ret; + } + bool StringUtils::IsLastCharacter( const std::wstring& aString, wchar_t aChar ) { bool isLast = false; @@ -164,13 +190,17 @@ // if ( aText.length() >= 3 ) { - const std::string prefix = ToUpper( Ucs2ToUtf8( aText.substr( 0, 3 ) ) ); + const std::string prefix = ToUpper( wstring2string( aText.substr( 0, 3 ) ) ); // const char drive = prefix[ 0 ]; const char colon = prefix[ 1 ]; const char backslash = prefix[ 2 ]; // + #ifndef __TOOLS2_LINUX__ if ( colon == ':' && backslash == '\\' ) + #else + if ( colon == ':' && (backslash == '/' || backslash == '\\')) + #endif { startsWithDrive = ( drive >= 'A' && drive <= 'Z' ) || (drive == '!') ; } @@ -270,6 +300,29 @@ */ bool StringUtils::WildcardCompare(const std::wstring& aWildCardFileName, const std::wstring& aFileName) { + #ifdef __TOOLS2_LINUX__ + // In case the incoming data is a DB entry then it will be having windows + // specific paths due to the consistency of DB contents across WINDOWS + // and LINUX. So, we need to convert them to LINUX paths and then compare. + + std::wstring::size_type idx = 0; + + while( (idx = aWildCardFileName.find(L"\\", idx)) != std::wstring::npos) + { + aWildCardFileName.replace( idx, 1, L"/" ); + } + + idx = 0; + + while( (idx = aFileName.find(L"\\", idx)) != std::wstring::npos) + { + aFileName.replace( idx, 1, L"/" ); + } + #endif + + aWildCardFileName = StringUtils::ToLower(aWildCardFileName); + aFileName = StringUtils::ToLower(aFileName); + std::wstring::const_iterator wildCurr = aWildCardFileName.begin(); std::wstring::const_iterator wildEnd = aWildCardFileName.end(); @@ -357,7 +410,19 @@ */ std::wstring StringUtils::NameAndExt( const std::wstring& aFile ) { +#ifndef __TOOLS2_LINUX__ int pos = aFile.find_last_of(L"\\"); +#else + // We should also check for backward slash since the caller could be + // passing a string containing a windows-specific paths within LINUX. + // + // One instance being - an SCR database entry under LINUX, which has + // the windows specific paths of the installed files to maintain + // consistency across WINDOWS and LINUX platforms. + + int pos = aFile.find_last_of(L"/"); + pos = pos == std::wstring::npos ? aFile.find_last_of(L"\\") : pos; +#endif if (pos == std::wstring::npos) { return L""; @@ -382,7 +447,11 @@ */ std::wstring StringUtils::DriveAndPath( const std::wstring& aFile ) { - int pos = aFile.find_last_of(L"\\"); +#ifndef __TOOLS2_LINUX__ + int pos = aFile.find_last_of(L"\\"); +#else + int pos = aFile.find_last_of(L"/"); +#endif if (pos == std::wstring::npos) { return L""; @@ -405,8 +474,13 @@ */ std::wstring StringUtils::Path( const std::wstring& aFile ) { - int firstPos = aFile.find_first_of(L"\\"); - int lastPos = aFile.find_last_of(L"\\"); +#ifndef __TOOLS2_LINUX__ + int firstPos = aFile.find_first_of(L"\\"); + int lastPos = aFile.find_last_of(L"\\"); +#else + int firstPos = aFile.find_first_of(L"/"); + int lastPos = aFile.find_last_of(L"/"); +#endif if (lastPos >= firstPos) { @@ -428,7 +502,12 @@ */ std::wstring StringUtils::Name( const std::wstring& aFile ) { +#ifndef __TOOLS2_LINUX__ int startPos = aFile.find_last_of(L"\\"); +#else + int startPos = aFile.find_last_of(L"/"); +#endif + int endPos = aFile.find_last_of(L"."); if (endPos > startPos) diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/interpretsislib/stringutils.h --- a/secureswitools/swisistools/source/interpretsislib/stringutils.h Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/interpretsislib/stringutils.h Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -35,7 +35,17 @@ #include "symbiantypes.h" // Constants +#ifndef __TOOLS2_LINUX__ const std::wstring KDirectorySeparator( L"\\" ); +const std::wstring KDoubleSlashPathPrefix( L"\\\\" ); +const std::string KDirectorySeparatorString( "\\" ); +const std::string KDoubleSlashPathPrefixString( "\\\\" ); +#else +const std::wstring KDirectorySeparator( L"/" ); +const std::wstring KDoubleSlashPathPrefix( L"//" ); +const std::string KDirectorySeparatorString( "/" ); +const std::string KDoubleSlashPathPrefixString( "//" ); +#endif class StringUtils { @@ -47,6 +57,7 @@ static std::string ToUpper( const std::string& aString ); static std::wstring ToUpper( const std::wstring& aString ); static std::string ToLower( const std::string& aString ); + static std::wstring ToLower( const std::wstring& aString ); static bool IsLastCharacter( const std::wstring& aString, wchar_t aChar ); static bool StartsWithDrive( const std::wstring& aText ); static std::wstring MakePathFromSID( const std::wstring& aBasePath, TUint32 aSID ); diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/interpretsislib/utils_posix.cpp --- a/secureswitools/swisistools/source/interpretsislib/utils_posix.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/interpretsislib/utils_posix.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -22,14 +22,17 @@ #include #include"utility_interface.h" +#include"util.h" bool FileExists(const std::wstring& aFile) { - return true; + struct stat x; + int err = GetStat(aFile,&x ); + return err == 0; } bool RemoveFile(const std::wstring& aFile) { - return true; + return _wunlink(aFile.c_str()) == 0; } bool CreateFile(const std::wstring& aFile) { @@ -38,16 +41,16 @@ int GetStat(const std::wstring& aFile, struct stat* s) { - std::string str; - return stat(Ucs2ToUtf8(aFile, str).c_str(), s); + std::string str = wstring2string(aFile); + return stat(str.c_str(), s); } void GetDirContents(const std::wstring& path, std::list& contents) { - std::string utfString; - DIR* currDir = opendir(Ucs2ToUtf8(path, utfString).c_str()); + std::string utfString = wstring2string(path); + DIR* currDir = opendir(utfString.c_str()); while (currDir) { @@ -59,8 +62,8 @@ } else { - std::wstring ucsString; - contents.push_back(Utf8ToUcs2(currElem->d_name, ucsString)); + std::wstring ucsString = string2wstring(currElem->d_name); + contents.push_back(ucsString); } } } @@ -111,14 +114,22 @@ } else {// Skip creation of root directory + #ifndef __TOOLS2_LINUX__ index = aDir.find(L'\\', index); + #else + index = aDir.find(L'/', index); + #endif } do { index += 1; // Try to make each directory in the path. If ERR_ALREADY_EXISTS is returned // then this is okay. Other errors are fatal. + #ifndef __TOOLS2_LINUX__ index = aDir.find(L'\\', index); + #else + index = aDir.find(L'/', index); + #endif std::wstring dir = aDir.substr( 0, index ); if(dir == L".") { @@ -140,8 +151,8 @@ bool OpenFile(const std::wstring& aFile, std::fstream& aStream, std::ios_base::open_mode aMode) { - std::string s; - aStream.open(Ucs2ToUtf8(aFile, s).c_str(), aMode); + std::string s = wstring2string(aFile); + aStream.open(s.c_str(), aMode); return aStream.good(); } @@ -176,15 +187,27 @@ void RemoveHashForFile(const std::wstring& aFile, const int aDriveLetter, const std::wstring& aPath) { + #ifndef __TOOLS2_LINUX__ std::wstring hashdir = L"$:\\sys\\hash\\"; + #else + std::wstring hashdir = L"$:/sys/hash/"; + #endif std::wstring basename = aFile.substr( aFile.rfind( KDirectorySeparator ) + 1) ; if (basename.size() == 0) { + #ifndef __TOOLS2_LINUX__ basename = aFile.substr(aFile.rfind(L"\\")); + #else + basename = aFile.substr(aFile.rfind(L"/")); + #endif } hashdir[0] = aDriveLetter; + #ifndef __TOOLS2_LINUX__ std::wstring hashFile = aPath + L"\\sys\\hash\\" + basename; + #else + std::wstring hashFile = aPath + L"/sys/hash/" + basename; + #endif if (FileExists(hashFile)) { RemoveFile(hashFile); diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/interpretsislib/utils_win32.cpp --- a/secureswitools/swisistools/source/interpretsislib/utils_win32.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/interpretsislib/utils_win32.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -273,71 +273,3 @@ return 0; } -std::string Utils::wstring2string (const std::wstring& aWide) - { - int max = WideCharToMultiByte(CP_OEMCP,0,aWide.c_str(),aWide.length(),0,0,0,0); - std::string reply; - if (max > 0 ) - { - char* buffer = new char [max]; - try - { - WideCharToMultiByte(CP_OEMCP,0,aWide.c_str(),aWide.length(),buffer,max,0,0); - reply = std::string (buffer, max); - } - catch (...) - { - } - delete [] buffer; - } - return reply; - } - -std::wstring Utils::string2wstring (const std::string& aNarrow) - { - int max = MultiByteToWideChar(CP_OEMCP,0,aNarrow.c_str(),aNarrow.length(),0,0); - std::wstring reply; - if (max > 0 ) - { - wchar_t* buffer = new wchar_t [max]; - try - { - MultiByteToWideChar(CP_OEMCP,0,aNarrow.c_str(),aNarrow.length(),buffer,max); - reply = std::wstring (buffer, max); - } - catch (...) - { - } - delete [] buffer; - } - return reply; - } - -const std::wstring Utils::IntegerToWideString(int aInt) - { - std::wstringstream wstream; - wstream << aInt; - return wstream.str(); - } - -std::wstring Utils::Int64ToWideString(TInt64 aInt) - { - wchar_t wint[20]; - -#ifdef _MSC_VER - swprintf(wint, L"%I64u", aInt); -#else - swprintf(wint, 20, L"%I64u", aInt); -#endif // _MSC_VER - - std::wstring strInt64(wint); - return strInt64; - } - -int Utils::WideStringToInteger(const std::wstring& aWideString) - { - unsigned long int value=0; - std::wstringstream str(aWideString); - str >> value; - return value; - } diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/makesis/makesis.cpp --- a/secureswitools/swisistools/source/makesis/makesis.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/makesis/makesis.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,4 +1,4 @@ -// Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +// Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). // All rights reserved. // This component and the accompanying materials are made available // under the terms of the License "Eclipse Public License v1.0" @@ -498,7 +498,7 @@ iVerbose(false) {} -int CMakeSIS::Run(int argc, wchar_t* argv[]) +int CMakeSIS::RunL(int argc, wchar_t* argv[]) // Inputs : argc, argv, envp - The command line passed to the process { int err=1; @@ -542,7 +542,7 @@ bool isStubFile= (iCmdOptions.Flags() & CParseCmd::EOptMakeStub) != 0; - pkgParser.MakeSis(iCmdOptions.SourceFile(), iCmdOptions.TargetFile(), isStubFile, iCmdOptions.InterpretSisReport()); + pkgParser.MakeSisL(iCmdOptions.SourceFile(), iCmdOptions.TargetFile(), isStubFile, iCmdOptions.InterpretSisReport()); err = 0; if (iCmdOptions.InterpretSisReport()) @@ -599,7 +599,7 @@ */ wchar_t **argv1 = CommandLineArgs(argc,argv); CMakeSIS app; - int reply = app.Run(argc, argv1); + int reply = app.RunL(argc, argv1); cleanup(argc,argv1); return reply; } diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/makesis/makesis.h --- a/secureswitools/swisistools/source/makesis/makesis.h Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/makesis/makesis.h Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -51,7 +51,7 @@ public: CMakeSIS(); - int Run(int argc, wchar_t* argv[]); + int RunL(int argc, wchar_t* argv[]); bool ParseSource(); bool WriteTarget(); diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/makesislib/packageparser.cpp --- a/secureswitools/swisistools/source/makesislib/packageparser.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/makesislib/packageparser.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -175,7 +175,7 @@ } -void CPackageParser::MakeSis(const wchar_t* aPkgFileName, const wchar_t* aSisFileName, bool aMakeStub, bool aReportInterpretSisError) +void CPackageParser::MakeSisL(const wchar_t* aPkgFileName, const wchar_t* aSisFileName, bool aMakeStub, bool aReportInterpretSisError) { iMakeStub = aMakeStub; iReportInterpretSisError = aReportInterpretSisError; diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/makesislib/packageparser.h --- a/secureswitools/swisistools/source/makesislib/packageparser.h Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/makesislib/packageparser.h Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 1997-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -194,7 +194,7 @@ * @param aMakeStub boolean which tells whether to create stub or not. * @param aReportInterpretSisError whether to report interpretsis failure or not. */ - void MakeSis(const wchar_t* aPkgFileName, const wchar_t* aSisFileName, bool aMakeStub, bool aReportInterpretSisError); + void MakeSisL(const wchar_t* aPkgFileName, const wchar_t* aSisFileName, bool aMakeStub, bool aReportInterpretSisError); /** * This function will parse the package file. In case of any error it will diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/signsis/parameter.cpp --- a/secureswitools/swisistools/source/signsis/parameter.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/signsis/parameter.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -58,10 +58,22 @@ for (int index = 1; index < argc; index++) { - if ( (argv [index][0] == '-') || - (argv [index][0] == '/')) + // WINDOWS ENVIRONMENT : If the underlying platform is WINDOWS then, + // cope up with multiple arguments following the '-' or '/'. + // + // LINUX ENVIRONMENT : If the underlying platform is LINUX then, cope + // up with multiple arguments following only the '-'. This restriction + // of not dealing with arguments following '/' is due to the fact that, + // the absolute paths in case of LINUX start with a '/'. So, this could + // be mistaken as an option if we treat anything prefixed by a '/' as + // an option. Hence, this facility is being removed once for all and + // only '-' can(should) be used for specifying an option. + if ( (argv [index][0] == '-') +#ifndef __LINUX__ + || (argv [index][0] == '/') +#endif + ) { - // cope with multiple arguments following the '-' or '/' int wCharacter = 1; while (argv[index][wCharacter] !='\0') { @@ -379,7 +391,7 @@ { std::cout << std::endl << "SIGNSIS " << " Version 5.1" << std::endl; std::cout << "A utility for signing Software Installation (SIS) files." << std::endl; - std::cout << "Copyright (c) 2007 Symbian Software Ltd. All rights reserved. " << std::endl; + std::cout << "Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). All rights reserved." << std::endl; #ifdef _DEBUG std::cout << std::endl << "Development Version" << std::endl; #endif diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/signsislib/sissignature.cpp --- a/secureswitools/swisistools/source/signsislib/sissignature.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/signsislib/sissignature.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -427,6 +427,7 @@ std::cout << ERR_error_string (ERR_get_error (), NULL); } BIO_free(mem); + mem = NULL; RSA_free (rsa); } else @@ -451,6 +452,7 @@ { std::cout << ERR_error_string (ERR_get_error (), NULL); BIO_free(mem); + mem = NULL; DSA_free (dsa); } else diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/sisxlibrary/siscapabilities.cpp --- a/secureswitools/swisistools/source/sisxlibrary/siscapabilities.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/sisxlibrary/siscapabilities.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2005-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -78,7 +78,7 @@ CSISException::ThrowIf(oldStderr == -1, CSISException::EFileProblem, "Failed in redirection operation"); #ifdef __TOOLS2_LINUX__ - nulStderr = fopen("NULL", "w"); + nulStderr = fopen("/dev/null", "w"); #else nulStderr = fopen("NUL:", "w"); #endif diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/sisxlibrary/siscontents.cpp --- a/secureswitools/swisistools/source/sisxlibrary/siscontents.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/sisxlibrary/siscontents.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -67,7 +67,11 @@ bool CSISContents::IsSisFile(const std::wstring& aFileName) { TSISStream input; + #ifdef __TOOLS2_LINUX__ std::wstring fileName = FixPathDelimiters(aFileName); + #else + std::wstring fileName = aFileName; + #endif HANDLE file = ::MakeSISOpenFile(fileName.c_str(),GENERIC_READ,OPEN_EXISTING); CSISException::ThrowIf ((INVALID_HANDLE_VALUE == file), CSISException::EFileProblem, std::wstring (L"cannot open ") + fileName); @@ -99,7 +103,11 @@ void CSISContents::Load (const std::wstring& aFileName, TUint64* size) { TSISStream input; + #ifdef __TOOLS2_LINUX__ std::wstring fileName = FixPathDelimiters(aFileName); + #else + std::wstring fileName = aFileName; + #endif HANDLE file = ::MakeSISOpenFile(fileName.c_str(),GENERIC_READ,OPEN_EXISTING); if (INVALID_HANDLE_VALUE == file) { diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/sisxlibrary/sisexpression.cpp --- a/secureswitools/swisistools/source/sisxlibrary/sisexpression.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/sisxlibrary/sisexpression.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -584,7 +584,7 @@ return false; } - std::wistringstream wStrStream(aString); + std::wistringstream wStrStream(aString.c_str()); if((wStrStream >> std::dec >> aDecimalValue) && wStrStream.eof()) { diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/sisxlibrary/sisinfo.cpp --- a/secureswitools/swisistools/source/sisxlibrary/sisinfo.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/sisxlibrary/sisinfo.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -178,6 +178,10 @@ { aStream << L", SH"; } + if (iInstallFlags & EInstFlagNonRemovable) + { + aStream << L", NR"; + } #ifdef SYMBIAN_UNIVERSAL_INSTALL_FRAMEWORK if (iInstallFlags & EInstFlagHide) { diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/sisxlibrary/sisstring.h --- a/secureswitools/swisistools/source/sisxlibrary/sisstring.h Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/sisxlibrary/sisstring.h Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -261,7 +261,7 @@ { return true; } - return iData.compare (aString) != 0; + return wcscmp(iData.c_str(), aString) != 0; } @@ -278,7 +278,7 @@ inline void CSISString::AddPackageEntry(std::wostream& aStream, bool aVerbose) const { (void)aVerbose; - aStream << iData; + aStream << iData.c_str(); } #endif // __SISSTRING_H__ diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/sisxlibrary/utility.cpp --- a/secureswitools/swisistools/source/sisxlibrary/utility.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/sisxlibrary/utility.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -48,7 +48,7 @@ } -std::string wstring2string (const std::wstring& aWide) +DllExport std::string wstring2string (const std::wstring& aWide) { int max = ConvertWideCharToMultiByte(aWide.c_str(),aWide.length(),0,0); std::string reply; @@ -84,8 +84,8 @@ { } delete [] buffer; - } - return reply; + } + return reply.c_str(); } void EnsureExtended (std::wstring& aName, const std::wstring& aDefaultExtension) @@ -374,15 +374,22 @@ std::wstring FixPathDelimiters( const std::wstring& aString ) { + std::wstring ret = aString; - std::wstring::size_type idx = 0; int len = 0; while(len = FirstInvalidDirSeparatorSize(ret, idx)) { - ret.replace( idx, len, KSisDirectorySeparator ); + if(idx == 0 && len == 2) + { + ret.replace( idx, len, KSisInitialNetworkPathSlashes ); + } + else + { + ret.replace( idx, len, KSisDirectorySeparator ); + } } - return ret; + return ret.c_str(); } int GetFileType(std::wstring& aFileName) diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/sisxlibrary/utility.h --- a/secureswitools/swisistools/source/sisxlibrary/utility.h Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/sisxlibrary/utility.h Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -32,11 +32,13 @@ #include #include "basetype.h" #include "fieldroot.h" +#include "../common/toolsconf.h" #define FreeMemory(x) {if((x) != NULL) {free(x); (x)=NULL;}} // Constants const std::wstring KSisDirectorySeparator( L"/" ); +const std::wstring KSisInitialNetworkPathSlashes( L"//" ); typedef struct { wchar_t* iName; @@ -62,7 +64,7 @@ int SearchSortedUCTable (const SIdentifierTable aTable [], const std::wstring& aIdentifier); TUint32 IdentifyUCKeyword (const SKeyword aKeyword [], std::wstring aIdentifier, const std::wstring& aContext); -std::string wstring2string (const std::wstring& aWide); +DllExport std::string wstring2string (const std::wstring& aWide); std::wstring string2wstring (const std::string& aNarrow); bool ValidateFileName (std::wstring& aName, const bool aMustExist); bool ValidateFileName (std::wstring& aName, const bool aMustExist, const std::wstring& aDefaultExtension); diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/sisxlibrary/utility_interface.h --- a/secureswitools/swisistools/source/sisxlibrary/utility_interface.h Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/sisxlibrary/utility_interface.h Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -99,6 +99,33 @@ */ int ConvertMultiByteToWideChar(const char* aSource, int aSourceLen, wchar_t* aTarget, int aTargetLen, TUint32 aCodePage = 0); +/* +Copies an existing file to a new file. +@Parameters aSrc : The name of an existing file. +@Parameters aDest : The name of the new file. +@Parameters aFlag : (only for windows) If this parameter is TRUE and the new file specified by aDest already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds. + +Return Value +If the function succeeds, the return value is zero. +If the function fails, the return value is nonzero. +*/ + +int FileCopyA(const char* aSrc, const char* aDest, size_t aFlag); + + +/* +Moves an existing file or a directory, including its children +@Parameters aSrc : The current name of the file or directory on the local computer. +@Parameters aDest : The new name for the file or directory. The new name must not already exist. A new file may be on a different file system or drive. A new directory must be on the same drive. + +Return Value +If the function succeeds, the return value is zero. +If the function fails, the return value is nonzero. +*/ + +int FileMoveA(const char* aSrc, const char* aDest); + + // interface for only Linux #ifdef __TOOLS2_LINUX__ diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/sisxlibrary/utility_linux.cpp --- a/secureswitools/swisistools/source/sisxlibrary/utility_linux.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/sisxlibrary/utility_linux.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -175,18 +175,24 @@ int _wunlink(const wchar_t* wc) { int ret = 0; - int len = wcstombs(0,wc,-1); - char *tmp = new char[len]; + const int len = wcstombs(0,wc,-1); + + char* tmp = new char[len+1]; ret = wcstombs(tmp, wc, len); + if(ret == -1) { printf("wunlink: wcstombs error\n"); - delete[] tmp; + delete [] tmp; return ret; } + tmp[ret] = '\0'; ret = unlink(tmp); + if(ret != 0) printf("wunlink: %s: %s\n", tmp, strerror(ret)); + + delete [] tmp; return ret; } @@ -621,5 +627,35 @@ } +int FileCopyA(const char* aSrc, const char* aDest, size_t aFlag) + { + int err= 0; + const int len = 512; + // Overwrites the orphaned file(if any). + char cmd[ len ] = "cp -f "; + strcat(cmd, aSrc); + strcat(cmd, " "); + strcat(cmd, aDest); + strcat(cmd, " 2> /dev/null"); + err = system(cmd); + return err; + } + +int FileMoveA(const char* aSrc, const char* aDest) + { + int err= 0; + + // Overwrites the orphaned file(if any). + char cmd[ 512 ] = "mv -f "; + strcat(cmd, aSrc); + strcat(cmd, " "); + strcat(cmd, aDest); + strcat(cmd, " 2> /dev/null"); + + err = system(cmd); + + return err; + } + diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/source/sisxlibrary/utility_windows.cpp --- a/secureswitools/swisistools/source/sisxlibrary/utility_windows.cpp Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/source/sisxlibrary/utility_windows.cpp Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of the License "Eclipse Public License v1.0" @@ -185,3 +185,15 @@ return ::GetLastError(); } +int FileCopyA(const char* aSrc, const char* aDest, size_t aFlag) +{ + int err=CopyFileA(aSrc,aDest,aFlag); + return err; +} + +int FileMoveA(const char* aSrc, const char* aDest) +{ + int err=MoveFileA(aSrc,aDest); + return err; +} + diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/test/tdumpsis/testdumpsis.pl --- a/secureswitools/swisistools/test/tdumpsis/testdumpsis.pl Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/test/tdumpsis/testdumpsis.pl Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ # -# Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). +# Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies). # All rights reserved. # This component and the accompanying materials are made available # under the terms of the License "Eclipse Public License v1.0" @@ -345,6 +345,22 @@ %s ; "; + +# +# Template string to generate PKG file for TestNRFlag. +# +$PkgFileWithNRflag = " +; File to verify NR flag is dumped correctly. +; +;Languages +&EN +; +#{\"TestPacakge\"}, (0x80000077), 1, 0, 0, TYPE=SA, RU, NR +; +%{\"Vendor\"} +:\"Vendor\" +"; + # # Do test for each elements of TestItems array # @@ -535,6 +551,9 @@ SatisfyCoverage(); VerifyErroneousCommandLineArg(); + +TestNRFlag(); + # # Display the result # @@ -1481,3 +1500,53 @@ unlink $TestLogFile; } +sub TestNRFlag + { + $TestNRflagsis = "test_nr_flag.sis"; + $TestNRflagLog = "test_nr_flag.Log"; + $TestNRflagpkg = "test_nr_flag.pkg"; + $DumpsisGenPkgPath = "\/test_nr_flag"; + $ExpectedStringInDumpedPackage = "NR"; + WriteLog("Test if the NR flag, in the original package file, is present in the dumped package file \n"); + + CreateFile('test_nr_flag.pkg', $PkgFileWithNRflag); + # Create a sis file + my $result = system("/epoc32/tools/MAKESIS -v $TestNRflagpkg $TestNRflagsis > $TestNRflagLog "); + + # Execute DumpSIS on the created sis file. + my $result1 = system("/epoc32/tools/DUMPSIS $TestNRflagsis > $TestNRflagLog"); + + use Cwd; + $dir = cwd; + chdir $dir.$DumpsisGenPkgPath; + + open($pkgcontent,$TestNRflagpkg); + foreach (<$pkgcontent>) + { + $_ =~ tr/\000//d; + if ($_ =~ m/$ExpectedStringInDumpedPackage/) + { + $result2 = 1; + } + } + close($pkgcontent); + + chdir $dir; + $NumberOfTests++; + if ($result == 0 && $result1 == 0 && $result2 == 1) + { + $NumberOfPassed++; + WriteLog("Passed\n\n"); + } + else + { + $NumberOfFailed++; + WriteLog("Failed\n\n"); + } + + unlink $TestNRflagpkg; + unlink $TestNRflagsis; + unlink $TestNRflagLog; + use File::Path; + rmtree "$dir$DumpsisGenPkgPath"; + } \ No newline at end of file diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/test/tinterpretsisinteg/check.pl --- a/secureswitools/swisistools/test/tinterpretsisinteg/check.pl Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/test/tinterpretsisinteg/check.pl Thu Aug 19 10:02:49 2010 +0300 @@ -1,5 +1,5 @@ # -# Copyright (c) 2006-2009 Nokia Corporation and/or its subsidiary(-ies). +# Copyright (c) 2006-2010 Nokia Corporation and/or its subsidiary(-ies). # All rights reserved. # This component and the accompanying materials are made available # under the terms of the License "Eclipse Public License v1.0" @@ -172,7 +172,7 @@ $searchresult = 0; $filenotexist = 0; - $filename = trim($temp); + $filename = lc trim($temp); if($filename eq "") { # Blank line found - no file to check diff -r cd189dac02f7 -r 5cc91383ab1e secureswitools/swisistools/test/tinterpretsisinteg/testinterpretsis.bat --- a/secureswitools/swisistools/test/tinterpretsisinteg/testinterpretsis.bat Thu Jul 15 18:47:04 2010 +0300 +++ b/secureswitools/swisistools/test/tinterpretsisinteg/testinterpretsis.bat Thu Aug 19 10:02:49 2010 +0300 @@ -1890,7 +1890,7 @@ call copy \epoc32\winscw\c\tswi\tinterpretsisinteg\data\version_5_3.txt .\romdrive\system\data\sisregistry_5.3.txt > NUL call interpretsis -z .\romdrive -c .\cdrive -s \epoc32\winscw\c\tswi\tinterpretsisinteg\data\simple.sis -w info -l \epoc32\winscw\c\interpretsis_test_harness.txt > NUL if not %errorlevel%==0 GOTO LAST -call fc .\cdrive\sys\install\sisregistry\80000001\00000000.reg \epoc32\winscw\c\tswi\tinterpretsisinteg\data\80000001_53\00000000.reg | find "FC: no differences encountered" > NUL +call fc /c .\cdrive\sys\install\sisregistry\80000001\00000000.reg \epoc32\winscw\c\tswi\tinterpretsisinteg\data\80000001_53\00000000.reg | find "FC: no differences encountered" > NUL if not %errorlevel%==0 GOTO LAST ECHO ***ERRORCODE*** %errorlevel% PASS>>\epoc32\winscw\c\interpretsis_test_harness.txt GOTO PASS_CLEAN @@ -1904,7 +1904,7 @@ call copy \epoc32\winscw\c\tswi\tinterpretsisinteg\data\version_5_1.txt .\romdrive\system\data\sisregistry_5.1.txt > NUL call interpretsis -z .\romdrive -c .\cdrive -s \epoc32\winscw\c\tswi\tinterpretsisinteg\data\simple.sis -w info -l \epoc32\winscw\c\interpretsis_test_harness.txt > NUL if not %errorlevel%==0 GOTO LAST -call fc .\cdrive\sys\install\sisregistry\80000001\00000000.reg \epoc32\winscw\c\tswi\tinterpretsisinteg\data\80000001_51\00000000.reg | find "FC: no differences encountered" > NUL +call fc /c .\cdrive\sys\install\sisregistry\80000001\00000000.reg \epoc32\winscw\c\tswi\tinterpretsisinteg\data\80000001_51\00000000.reg | find "FC: no differences encountered" > NUL if not %errorlevel%==0 GOTO LAST ECHO ***ERRORCODE*** %errorlevel% PASS>>\epoc32\winscw\c\interpretsis_test_harness.txt GOTO PASS_CLEAN @@ -1918,7 +1918,7 @@ call copy \epoc32\winscw\c\tswi\tinterpretsisinteg\data\version_4_1.txt .\romdrive\system\data\sisregistry_4.0.txt > NUL call interpretsis -z .\romdrive -c .\cdrive -s \epoc32\winscw\c\tswi\tinterpretsisinteg\data\simple.sis -w info -l \epoc32\winscw\c\interpretsis_test_harness.txt > NUL if not %errorlevel%==0 GOTO LAST -call fc .\cdrive\sys\install\sisregistry\80000001\00000000.reg \epoc32\winscw\c\tswi\tinterpretsisinteg\data\80000001_40\00000000.reg | find "FC: no differences encountered" > NUL +call fc /c .\cdrive\sys\install\sisregistry\80000001\00000000.reg \epoc32\winscw\c\tswi\tinterpretsisinteg\data\80000001_40\00000000.reg | find "FC: no differences encountered" > NUL if not %errorlevel%==0 GOTO LAST ECHO ***ERRORCODE*** %errorlevel% PASS>>\epoc32\winscw\c\interpretsis_test_harness.txt GOTO PASS_CLEAN @@ -1928,7 +1928,7 @@ if not exist .\romdrive\system\install mkdir .\romdrive\system\install > NUL call interpretsis -z .\romdrive -c .\cdrive -s \epoc32\winscw\c\tswi\tinterpretsisinteg\data\simple.sis -k 5.3 -w info -l \epoc32\winscw\c\interpretsis_test_harness.txt > NUL if not %errorlevel%==0 GOTO LAST -call fc .\cdrive\sys\install\sisregistry\80000001\00000000.reg \epoc32\winscw\c\tswi\tinterpretsisinteg\data\80000001_53\00000000.reg | find "FC: no differences encountered" > NUL +call fc /c .\cdrive\sys\install\sisregistry\80000001\00000000.reg \epoc32\winscw\c\tswi\tinterpretsisinteg\data\80000001_53\00000000.reg | find "FC: no differences encountered" > NUL if not %errorlevel%==0 GOTO LAST ECHO ***ERRORCODE*** %errorlevel% PASS>>\epoc32\winscw\c\interpretsis_test_harness.txt GOTO PASS_CLEAN @@ -1940,7 +1940,7 @@ call copy \epoc32\winscw\c\tswi\tinterpretsisinteg\data\version_4_1.txt .\romdrive\system\data\sisregistry_4.0.txt > NUL call interpretsis -z .\romdrive -c .\cdrive -s \epoc32\winscw\c\tswi\tinterpretsisinteg\data\simple.sis -k 5.3 -w info -l \epoc32\winscw\c\interpretsis_test_harness.txt > NUL if not %errorlevel%==0 GOTO LAST -call fc .\cdrive\sys\install\sisregistry\80000001\00000000.reg \epoc32\winscw\c\tswi\tinterpretsisinteg\data\80000001_53\00000000.reg | find "FC: no differences encountered" > NUL +call fc /c .\cdrive\sys\install\sisregistry\80000001\00000000.reg \epoc32\winscw\c\tswi\tinterpretsisinteg\data\80000001_53\00000000.reg | find "FC: no differences encountered" > NUL if not %errorlevel%==0 GOTO LAST ECHO ***ERRORCODE*** %errorlevel% PASS>>\epoc32\winscw\c\interpretsis_test_harness.txt GOTO PASS_CLEAN @@ -1952,7 +1952,7 @@ call copy \epoc32\winscw\c\tswi\tinterpretsisinteg\data\version_5_3.txt .\romdrive\system\data\sisregistry_5.3.txt > NUL call interpretsis -z .\romdrive -c .\cdrive -s \epoc32\winscw\c\tswi\tinterpretsisinteg\data\simple.sis -w info -l \epoc32\winscw\c\interpretsis_test_harness.txt > NUL if not %errorlevel%==0 GOTO LAST -call fc .\cdrive\sys\install\sisregistry\80000001\00000000.reg \epoc32\winscw\c\tswi\tinterpretsisinteg\data\80000001_53\00000000.reg | find "FC: no differences encountered" > NUL +call fc /c .\cdrive\sys\install\sisregistry\80000001\00000000.reg \epoc32\winscw\c\tswi\tinterpretsisinteg\data\80000001_53\00000000.reg | find "FC: no differences encountered" > NUL if not %errorlevel%==0 GOTO LAST ECHO ***ERRORCODE*** %errorlevel% PASS>>\epoc32\winscw\c\interpretsis_test_harness.txt GOTO PASS_CLEAN @@ -1964,7 +1964,7 @@ call copy \epoc32\winscw\c\tswi\tinterpretsisinteg\data\version_5_1.txt .\romdrive\system\data\sisregistry_5.1.txt > NUL call interpretsis -z .\romdrive -c .\cdrive -s \epoc32\winscw\c\tswi\tinterpretsisinteg\data\simple.sis -w info -l \epoc32\winscw\c\interpretsis_test_harness.txt > NUL if not %errorlevel%==0 GOTO LAST -call fc .\cdrive\sys\install\sisregistry\80000001\00000000.reg \epoc32\winscw\c\tswi\tinterpretsisinteg\data\80000001_51\00000000.reg | find "FC: no differences encountered" > NUL +call fc /c .\cdrive\sys\install\sisregistry\80000001\00000000.reg \epoc32\winscw\c\tswi\tinterpretsisinteg\data\80000001_51\00000000.reg | find "FC: no differences encountered" > NUL if not %errorlevel%==0 GOTO LAST ECHO ***ERRORCODE*** %errorlevel% PASS>>\epoc32\winscw\c\interpretsis_test_harness.txt GOTO PASS_CLEAN @@ -1976,7 +1976,7 @@ call copy \epoc32\winscw\c\tswi\tinterpretsisinteg\data\version_5_3.txt .\romdrive\system\data\sisregistry_5.3.txt > NUL call interpretsis -z .\romdrive -c .\cdrive -s \epoc32\winscw\c\tswi\tinterpretsisinteg\data\simple.sis -w info -l \epoc32\winscw\c\interpretsis_test_harness.txt > NUL if not %errorlevel%==0 GOTO LAST -call fc .\cdrive\sys\install\sisregistry\80000001\00000000.reg \epoc32\winscw\c\tswi\tinterpretsisinteg\data\80000001_53\00000000.reg | find "FC: no differences encountered" > NUL +call fc /c .\cdrive\sys\install\sisregistry\80000001\00000000.reg \epoc32\winscw\c\tswi\tinterpretsisinteg\data\80000001_53\00000000.reg | find "FC: no differences encountered" > NUL if not %errorlevel%==0 GOTO LAST ECHO ***ERRORCODE*** %errorlevel% PASS>>\epoc32\winscw\c\interpretsis_test_harness.txt GOTO PASS_CLEAN @@ -2503,7 +2503,7 @@ if not %errorlevel%==0 GOTO LAST set exist_file=.\edrive\private\10202dce\802730A9_0.sis if not exist %exist_file% GOTO FAIL_NOT_FOUND -call fc .\edrive\private\10202dce\802730A9_0.sis \epoc32\winscw\c\tswi\tinterpretsisinteg\data\802730A9_0.sis | find "FC: no differences encountered" > NUL +call fc /c .\edrive\private\10202dce\802730A9_0.sis \epoc32\winscw\c\tswi\tinterpretsisinteg\data\802730A9_0.sis | find "FC: no differences encountered" > NUL if not %errorlevel%==0 GOTO LAST ECHO ***ERRORCODE*** %errorlevel% PASS>>\epoc32\winscw\c\interpretsis_test_harness.txt GOTO PASS_CLEAN