--- a/dependencies/mifconv/group/mifconv.mmp Sat Mar 27 01:00:02 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
-* Copyright (c) 2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: project definition file
-*
-*/
-
-#include <platform_paths.hrh>
-
-TARGET mifconv.exe
-TARGETTYPE exe
-
-USERINCLUDE ../inc
-MW_LAYER_SYSTEMINCLUDE
-SOURCEPATH ../src
-
-SOURCE mifconv.cpp
-SOURCE mifconv_argument.cpp
-SOURCE mifconv_argumentmanager.cpp
-SOURCE mifconv_bitmapconverter.cpp
-SOURCE mifconv_bitmapheaderconverter.cpp
-SOURCE mifconv_convertermanager.cpp
-SOURCE mifconv_exception.cpp
-SOURCE mifconv_iconbinaryconverter.cpp
-SOURCE mifconv_mifconverter.cpp
-SOURCE mifconv_sourcefile.cpp
-SOURCE mifconv_util.cpp
-
--- a/dependencies/mifconv/src/mifconv.cpp Sat Mar 27 01:00:02 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,78 +0,0 @@
-/*
-* Copyright (c) 2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Mifconv main.
-*
-*/
-
-
-#include "mifconv.h"
-#include "mifconv_exception.h"
-#include "mifconv_argumentmanager.h"
-#include "mifconv_convertermanager.h"
-#include "mifconv_util.h"
-
-int main( int argc, char *argv[] )
-{
- cout << endl << "Mifconv v" << MifConvVersion << " - " << MifConvDate << endl;
- // Instantiate the argument manager and mif creator:
- MifConvArgumentManager* argMgr = MifConvArgumentManager::Instance();
- MifConvConverterManager* converterMgr = MifConvConverterManager::Instance();
-
- try {
- // Read arguments to string vector:
- MifConvStringList strList;
- for( int i = 1; i < argc; ++i )
- {
- strList.push_back(MifConvString(argv[i]));
- }
-
- // Initialize arguments:
- argMgr->Init(strList);
-
- // Initialize converters:
- converterMgr->Init();
-
- // Run converters for source files:
- converterMgr->ProcessIcons();
-
- // Cleanup temp files etc:
- converterMgr->Cleanup();
- }
- catch( MifConvException& e ) {
- // In case of error, print exception to stderr, cleanup temp files and exit:
- std::stringstream strForInt;
- strForInt << e.Line();
-
- MifConvUtil::DebugLog(e.File() + MifConvString(":") + strForInt.str() + MifConvString(":") + e.String());
- cerr << e.String() << endl;
- converterMgr->Cleanup(true);
- converterMgr->Reset();
- argMgr->Reset();
- exit(MIFCONV_ERROR);
- }
- catch(...)
- {
- // Unknown error:
- MifConvUtil::DebugLog("MifConv: Unknown error");
- cerr << "MifConv: Unknown error" << endl;
- converterMgr->Cleanup(true);
- converterMgr->Reset();
- argMgr->Reset();
- exit(MIFCONV_ERROR);
- }
-
- converterMgr->Reset();
- argMgr->Reset();
- return MIFCONV_NO_ERROR;
-}
--- a/dependencies/mifconv/src/mifconv_argument.cpp Sat Mar 27 01:00:02 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,20 +0,0 @@
-/*
-* Copyright (c) 2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Mifconv tool argument definitions.
-*
-*/
-
-
-#include "mifconv.h"
-#include "mifconv_argument.h"
--- a/dependencies/mifconv/src/mifconv_argumentmanager.cpp Sat Mar 27 01:00:02 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,991 +0,0 @@
-/*
-* Copyright (c) 2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Mifconv argument manager class.
-*
-*/
-
-
-#include "mifconv.h"
-#include "mifconv_argumentmanager.h"
-#include "mifconv_exception.h"
-#include "mifconv_util.h"
-
-// Static singleton initialization
-MifConvArgumentManager* MifConvArgumentManager::iInstance = 0;
-
-/**
- * Returns pointer to the singleton object
- */
-MifConvArgumentManager* MifConvArgumentManager::Instance()
-{
- if( iInstance == 0 )
- {
- iInstance = new MifConvArgumentManager();
- }
- return iInstance;
-}
-
-/**
- * Free the allocated memory
- */
-void MifConvArgumentManager::Reset()
-{
- delete iInstance;
- iInstance = 0;
-}
-
-/**
- *
- */
-inline void MifConvArgumentManager::THROW_USAGE_EXCEPTION() const
-{
- MifConvString usageStr;
- SetUsageString(usageStr);
- throw MifConvException(usageStr, MifConvString(__FILE__), __LINE__);
-}
-
-inline void MifConvArgumentManager::THROW_ERROR( const MifConvString& errorMsg, const MifConvString& file, int line ) const
-{
- throw MifConvException( MifConvString("ERROR: " + errorMsg + "\nType mifconv -? for help\n"), file, line);
-}
-
-/**
- *
- */
-MifConvArgumentManager::MifConvArgumentManager()
-:
-iEpocRoot(DEFAULT_EPOCROOT)
-{
- GetMifEnv();
-}
-
-/**
- *
- */
-MifConvArgumentManager::~MifConvArgumentManager()
-{}
-
-/**
- * This function checks if the given argument is boolean type of argument.
- * Boolean type arguments are listed in a <code>MifConvBooleanArguments</code> table
- * and this function checks if the given string matches any of those. Returns the length
- * of the argument name if found, zero otherwise.
- */
-size_t MifConvArgumentManager::IsBooleanArgument( const MifConvString& argName ) const
-{
- if( IsArgument(argName) )
- {
- try {
- int tblSize = sizeof(MifConvBooleanArguments) / sizeof(MifConvString);
- for( int i = 0; i < tblSize; ++i )
- {
- size_t tmpLen = MifConvBooleanArguments[i].length();
- if( argName.length() > tmpLen )
- {
- if( MifConvUtil::CompareIgnoreCase(MifConvString(argName.begin()+1, argName.begin() + 1 + tmpLen), MifConvBooleanArguments[i]) == 0 )
- {
- return tmpLen;
- }
- }
- }
- }
- catch(...)
- {
- THROW_USAGE_EXCEPTION();
- }
- }
- return 0;
-}
-
-/**
- * This function checks if the given argument is a help argument.
- * Help arguments are listed in a <code>MifConvHelpArguments</code> table
- * and this function checks if the given string matches any of those. Returns the length
- * of the argument name if found, zero otherwise.
- */
-size_t MifConvArgumentManager::IsHelpArgument( const MifConvString& argName ) const
-{
- if( IsArgument(argName) )
- {
- try {
- int tblSize = sizeof(MifConvHelpArguments) / sizeof(MifConvString);
- for( int i = 0; i < tblSize; ++i )
- {
- size_t tmpLen = MifConvHelpArguments[i].length();
-
- // Following check separates -H from -Hheadername.mbg parameter:
- if( argName.length() == tmpLen+1 )
- {
- if( MifConvUtil::CompareIgnoreCase(MifConvString(argName.begin()+1, argName.begin() + 1 + tmpLen), MifConvHelpArguments[i]) == 0 )
- {
- return tmpLen;
- }
- }
- }
- }
- catch(...)
- {
- THROW_USAGE_EXCEPTION();
- }
- }
- return 0;
-}
-
-/**
- * This function checks if the given argument is string type of argument.
- * String type arguments are listed in a <code>MifConvStringArguments</code> table
- * and this function checks if the given string matches any of those. Returns the length
- * of the argument name if found, zero otherwise.
- */
-size_t MifConvArgumentManager::IsStringArgument( const MifConvString& argName ) const
-{
- if( IsArgument(argName) )
- {
- try {
- int tblSize = sizeof(MifConvStringArguments) / sizeof(MifConvString);
- for( int i = 0; i < tblSize; ++i )
- {
- size_t tmpLen = MifConvStringArguments[i].length();
- if( argName.length() > tmpLen )
- {
- if( MifConvUtil::CompareIgnoreCase(MifConvString(argName.begin()+1, argName.begin()+1+tmpLen), MifConvStringArguments[i]) == 0 )
- {
- return tmpLen;
- }
- }
- }
- }
- catch(...)
- {
- THROW_USAGE_EXCEPTION();
- }
- }
- return 0;
-}
-
-/**
- * This function checks if the given argument is string list type of argument.
- * String list type arguments are listed in a <code>MifConvStringListArguments</code> table
- * and this function checks if the given string matches any of those. Returns the length
- * of the argument name if found, zero otherwise.
- */
-size_t MifConvArgumentManager::IsStringListArgument( const MifConvString& argName ) const
-{
- if( IsArgument(argName) )
- {
- try {
- int tblSize = sizeof(MifConvStringListArguments) / sizeof(MifConvString);
- for( int i = 0; i < tblSize; ++i )
- {
- size_t tmpLen = MifConvStringListArguments[i].length();
- if( argName.length() > tmpLen )
- {
- if( MifConvUtil::CompareIgnoreCase(MifConvString(argName.begin()+1, argName.begin()+1+tmpLen), MifConvStringListArguments[i]) == 0 )
- {
- return tmpLen;
- }
- }
- }
- }
- catch(...)
- {
- THROW_USAGE_EXCEPTION();
- }
- }
- return 0;
-}
-
-/**
- *
- */
-bool MifConvArgumentManager::IsDepthArgument( const MifConvString& argName ) const
-{
- if( IsArgument(argName) )
- {
- try {
- int tblSize = sizeof(MifConvDepthArguments) / sizeof(MifConvString);
- for( int i = 0; i < tblSize; ++i )
- {
- size_t tmpLen = MifConvDepthArguments[i].length();
- if( argName.length() > tmpLen )
- {
- MifConvString trimmedArgument(argName.begin()+1, argName.begin() + 1 + tmpLen);
- if( MifConvUtil::CompareIgnoreCase(trimmedArgument, MifConvDepthArguments[i]) == 0 )
- {
- return true;
- }
- }
- }
- }
- catch(...)
- {
- THROW_USAGE_EXCEPTION();
- }
- }
- return false;
-}
-
-/**
- *
- */
-bool MifConvArgumentManager::IsAnimatedFlag( const MifConvString& argName ) const
-{
- return IsArgument( argName ) && argName.length() > MifConvAnimatedIconArg.length() &&
- MifConvUtil::CompareIgnoreCase(MifConvString(argName.begin()+1, argName.end() ), MifConvAnimatedIconArg ) == 0;
-}
-
-/**
- *
- */
-void MifConvArgumentManager::SetTargetFile( const MifConvString& arg )
-{
- iTargetFile = arg;
-}
-
-/**
- *
- */
-const MifConvString& MifConvArgumentManager::TargetFile() const
-{
- return iTargetFile;
-}
-
-/**
- *
- */
-IconDisplayMode MifConvArgumentManager::ConvertToDisplayMode(IconDepth depth) const
-{
- MifConvIconDisplayModeMap::const_iterator i = iDisplayModeMap.find(depth);
- if( i != iDisplayModeMap.end() )
- return i->second;
-
- return DisplayMode_None;
-}
-
-/**
- *
- */
-IconDisplayMode MifConvArgumentManager::ConvertToMaskDisplayMode(IconMaskDepth depth) const
-{
- MifConvMaskIconDisplayModeMap::const_iterator i = iMaskDisplayModeMap.find(depth);
- if( i != iMaskDisplayModeMap.end() )
- return i->second;
-
- return DisplayMode_None;
-}
-
-/**
- *
- */
-IconDepth MifConvArgumentManager::ConvertToDepth( const MifConvString& depthStr ) const
-{
- MifConvIconDepthMap::const_iterator i = iDepthMap.find(depthStr);
- if( i != iDepthMap.end() )
- return i->second;
-
- return IconDepth_Undefined;
-}
-/**
- *
- */
-IconMaskDepth MifConvArgumentManager::ConvertToMaskDepth( const MifConvString depthStr ) const
-{
- MifConvIconMaskDepthMap::const_iterator i = iMaskDepthMap.find(depthStr);
- if( i != iMaskDepthMap.end() )
- return i->second;
-
- return IconMaskDepth_Undefined;
-}
-
-/**
- *
- */
-void MifConvArgumentManager::Init( const MifConvStringList& argList )
-{
- // Build maps for mapping depth, mask and displaymode constants:
- PopulateDepthAndMaskMaps();
- // Allocate search paths where to search source files:
- MifConvString epocRoot(EpocRoot());
-
- // Global icons folder can contain only .svg files:
- iSearchRules.push_back(MifConvSourceSearchRule(MifConvString(epocRoot + S60_ICONS_PATH), vector<MifConvString>(1, SVG_FILE_EXTENSION)));
- // Global bitmaps folder can contain only .bmp files:
- iSearchRules.push_back(MifConvSourceSearchRule(MifConvString(epocRoot + S60_BITMAPS_PATH), vector<MifConvString>(1, BMP_FILE_EXTENSION)));
- // EPOCROOT, if given in environment variables:
- if( epocRoot.length() > 0 )
- {
- iSearchRules.push_back(MifConvSourceSearchRule(epocRoot+EPOC32_PATH, vector<MifConvString>(1, MIFCONV_WILDCARD)));
- }
-
- AddArguments(argList);
-
- // check if the parameter file is given:
- const MifConvString& paramFilename = StringValue(MifConvParameterFileArg);
- if( paramFilename.length() > 0 )
- {
- // Add arguments from the parameter file:
- MifConvStringList paramListFromFile;
- ReadParameterFile( paramFilename, paramListFromFile );
- if( paramListFromFile.size() > 0 )
- {
- AddArguments(paramListFromFile, true);
- }
- }
- // Resolve file type extensions using given flags and investigating the existing files:
- FinalizeArguments();
-}
-
-/**
- * Read string argument value:
- */
-MifConvString MifConvArgumentManager::ReadStringArgument(const MifConvStringList& argList, MifConvStringList::const_iterator& i, unsigned int argNameLen)
-{
- // Take the actual argument value, for example /TmyTempDir --> myTempDir
- MifConvString argValue((*i).begin() + argNameLen, (*i).end());
- if( argValue.length() > 0 )
- {
- // String arguments can have spaces when they are enclosed with " marks (For example directory names).
- if( argValue[0] == '\"' )
- {
- MifConvString quotedArgValue(argValue);
- // Check if the last char is also ":
- if( quotedArgValue[ quotedArgValue.length()-1 ] == '\"' )
- {
- return quotedArgValue;
- }
-
- // See if the next string ends with \" mark, for example "My Folder" is presented with following argument list:
- // argList[0] = "My
- // argList[1] = Folder"
- while(++i != argList.end())
- {
- MifConvString nextString((*i).begin(), (*i).end());
- quotedArgValue += " " + nextString;
- if( nextString[ nextString.length()-1 ] == '\"' )
- {
- return "\"" + quotedArgValue + "\"";
- }
- }
- }
- }
- return argValue;
-}
-
-/**
- * Read string argument value:
- */
-void MifConvArgumentManager::ReadStringListArgument(MifConvStringList::const_iterator& i, unsigned int argNameLen, MifConvStringList& StringValueList)
-{
- // Take the actual argument value, for example /imyInputDir;myTempDir --> myTempDir
- MifConvString argValue((*i).begin() + argNameLen, (*i).end());
- MifConvUtil::SplitString( argValue, STRING_LIST_ARGUMENT_SEPARATOR, StringValueList );
-}
-
-/**
- *
- */
-void MifConvArgumentManager::AddArguments( const MifConvStringList& argList, bool paramsFromFile )
-{
- MifConvStringList::const_iterator i = argList.begin();
-
- if( i == argList.end() )
- {
- THROW_ERROR("No arguments", MifConvString(__FILE__), __LINE__);
- }
-
- // Check if help is needed:
- while( i != argList.end() )
- {
- if( IsHelpArgument(*i) )
- {
- THROW_USAGE_EXCEPTION();
- }
- ++i;
- }
-
- i = argList.begin();
-
- while( i != argList.end() )
- {
- unsigned int argLen = 0;
- if( i == argList.begin() && paramsFromFile == false )
- {
- // First command line argument must be the target file.
- // If the given list (argList) is read from the file, then
- // the first one is not target file.
- if( !IsArgument(*i) )
- {
- MifConvString targetFile(ReadStringArgument( argList, i, 0 ));
- // Make sure that the file extension is .mif:
- targetFile = MifConvUtil::FilenameWithoutExtension(targetFile);
- targetFile += MifConvString(FILE_EXTENSION_SEPARATOR) + MifConvString(MIF_FILE_EXTENSION);
- SetTargetFile(targetFile);
- }
- else
- {
- THROW_ERROR( "Target file must be given as first argument.", MifConvString(__FILE__), __LINE__ );
- }
- ++i;
- if( i == argList.end() )
- {
- THROW_ERROR("Missing arguments", MifConvString(__FILE__), __LINE__);
- }
- }
- else if( IsBooleanArgument(*i) )
- {
- // Insert boolean type argument to the boolean arguments list:
- MifConvString argName((*i).begin()+1, (*i).end());
- MifConvUtil::ToLower(argName); // Lower the cases to make comparison easier later
- std::pair<BooleanArgMap::iterator, bool> res = iBooleanArguments.insert(std::make_pair<MifConvString, MifConvBooleanArgument>(
- argName, MifConvBooleanArgument( argName, true )));
- if( res.second == false )
- {
- // parameter already exists in the map, update the value:
- res.first->second = MifConvBooleanArgument( argName, true );
- }
- ++i;
- }
- else if( (argLen = (unsigned int) IsStringArgument(*i) ) > 0 )
- {
- MifConvString argName((*i).begin()+1, (*i).begin() + 1 + argLen);
- MifConvUtil::ToLower(argName); // Lower the cases to make comparison easier later
- MifConvString argValue(ReadStringArgument( argList, i, argLen+1 ));
- if( argValue.length() == 0 )
- {
- // Do not accept string arguments with zero length (E.g. "/H")
- THROW_ERROR( "Missing argument value for " + *i, MifConvString(__FILE__), __LINE__ );
- }
- // Insert string type argument to the string arguments list:
- std::pair<StringArgMap::iterator, bool> res = iStringArguments.insert(std::make_pair<MifConvString, MifConvStringArgument>(
- argName, MifConvStringArgument( argName, argValue )));
- if( res.second == false )
- {
- // parameter already exists in the map, update the value:
- res.first->second = MifConvStringArgument( argName, argValue );
- }
- ++i;
- }
- else if( (argLen = (unsigned int) IsStringListArgument(*i)) > 0 )
- {
- MifConvString argName((*i).begin()+1, (*i).begin() + 1 + argLen);
- MifConvUtil::ToLower(argName); // Lower the cases to make comparison easier later
- MifConvStringList argValue;
- ReadStringListArgument( i, argLen+1, argValue );
-
- if( argValue.size() == 0 )
- {
- // Do not accept string arguments with zero length (E.g. "/H")
- THROW_ERROR( "Missing argument value for " + *i, MifConvString(__FILE__), __LINE__ );
- }
- // Insert string list type argument to the string arguments list:
- std::pair<StringListArgMap::iterator, bool> res = iStringListArguments.insert(std::make_pair<MifConvString, MifConvStringListArgument>(
- argName, MifConvStringListArgument( argName, argValue )));
- if( res.second == false )
- {
- // parameter already exists in the map, update the value:
- res.first->second = MifConvStringListArgument( argName, argValue );
- }
- ++i;
- }
- else if( IsDepthArgument(*i) )
- {
- // Let's build source file argument...
- // ... first is depth and mask:
- MifConvString depthAndMask(*i);
- MifConvUtil::ToLower(depthAndMask); // Lower the cases to make comparison easier later
- ++i;
- // Check that there is still an argument:
- if( i == argList.end() )
- {
- THROW_ERROR( "Missing source file argument.", MifConvString(__FILE__), __LINE__ );
- }
-
- // Then we check if animated flag is given next:
- bool isAnimated = IsAnimatedFlag(*i);
-
- if( isAnimated )
- {
- // This was an animated flag, so next must be filename:
- ++i;
- // Check that there is still an argument:
- if( i == argList.end() )
- {
- THROW_ERROR( "Missing source file argument.", MifConvString(__FILE__), __LINE__ );
- //THROW_USAGE_EXCEPTION();
- }
- }
-
- // One more check... Check that the next string is not an argument (starting with '-' or '/')
- // It should be a filename for the source icon.
- if( IsArgument(*i) )
- {
- THROW_ERROR( "Missing source file argument.", MifConvString(__FILE__), __LINE__ );
- }
-
- MifConvSourceFile srcFile;
- srcFile.SetDepthAndMask(depthAndMask);
- srcFile.SetDisplayMode(ConvertToDisplayMode(srcFile.Depth()));
- srcFile.SetMaskDisplayMode(ConvertToMaskDisplayMode(srcFile.MaskDepth()));
- srcFile.SetFilename(ReadStringArgument( argList, i, 0 ));
- srcFile.SetAnimated(isAnimated);
- iSourceFiles.push_back(srcFile);
- ++i;
- }
- else if( IsAnimatedFlag(*i) )
- {
- // Icon animated flag found
- // Let's see if the next is depth argument:
- ++i;
- MifConvString depthAndMask;
- if( IsDepthArgument(*i) )
- {
- depthAndMask = *i;
- MifConvUtil::ToLower(depthAndMask);
- ++i;
- }
-
- // One more check... Check that the next string is not an argument (starting with '-' or '/')
- if( IsArgument(*i) )
- {
- THROW_ERROR( "Missing source file argument.", MifConvString(__FILE__), __LINE__ );
- }
-
- MifConvSourceFile srcFile;
- srcFile.SetDepthAndMask(depthAndMask);
- srcFile.SetDisplayMode(ConvertToDisplayMode(srcFile.Depth()));
- srcFile.SetMaskDisplayMode(ConvertToMaskDisplayMode(srcFile.MaskDepth()));
- srcFile.SetFilename(*i);
- srcFile.SetAnimated(true);
- iSourceFiles.push_back(srcFile);
- ++i;
- }
- else
- {
- THROW_ERROR( "Invalid argument: " + *i, MifConvString(__FILE__), __LINE__ );
- }
- }
-}
-
-/**
- * Resolves correct type for the source file. Sets also mask filenames for bmp-files:
- */
-void MifConvArgumentManager::ResolveSourceFileTypes()
-{
- bool extensionFlag = BooleanValue(MifConvUseExtensionArg);
-
- // check if the input directory is given:
- const MifConvStringList& inputDirList = StringListValue(MifConvIconSourceDirectory);
-
- // Add user-defined input directory to search directory list, put MIFCONV_WILDCARD
- // as filetype rule, because user defined directory can contain all supported filetypes:
- int indexcounter = 0;
- for( MifConvStringList::const_iterator iDir = inputDirList.begin(); iDir != inputDirList.end(); ++iDir )
- {
- MifConvSourceSearchRule customRule(*iDir, MifConvStringList(1, MIFCONV_WILDCARD));
- MifConvUtil::ReplaceChar(customRule.SearchPath(), INCORRECT_DIR_SEPARATOR2, DIR_SEPARATOR2);
- MifConvUtil::RemoveDuplicateDirSeparators(customRule.SearchPath());
- iSearchRules.insert(iSearchRules.begin()+indexcounter, customRule);
-
- ++indexcounter;
- }
-
- for( MifConvSourceFileList::iterator src = iSourceFiles.begin(); src != iSourceFiles.end(); ++ src )
- {
- if( extensionFlag )
- {
- MifConvString extension = MifConvUtil::FileExtension(src->Filename());
- if( !FindAndSetPathAndType( *src, extension ) )
- {
- THROW_ERROR_COMMON("File not found " + src->Filename(), MifConvString(__FILE__), __LINE__ );
- }
- }
- else
- {
- // "Use extension" -flag not given, so resolve extensions for source files
- if( !FindAndSetPathAndType( *src, SVGB_BINARY_FILE_EXTENSION ) )
- {
- if( !FindAndSetPathAndType( *src, SVG_FILE_EXTENSION ) )
- {
- if( !FindAndSetPathAndType( *src, BMP_FILE_EXTENSION ) )
- {
- THROW_ERROR_COMMON("File not found " + src->Filename(), MifConvString(__FILE__), __LINE__ );
- }
- }
- }
- }
- }
-}
-
-/**
- *
- */
-void MifConvArgumentManager::GetMifEnv()
-{
- // Read EPOCROOT environment variable
- char* tmpPtr = 0;
- tmpPtr = getenv(EPOCROOT_ENV.c_str());
- if( tmpPtr )
- {
- iEpocRoot = MifConvString(tmpPtr);
- MifConvUtil::ReplaceChar(iEpocRoot, INCORRECT_DIR_SEPARATOR2, DIR_SEPARATOR2);
- // Make sure that the last char is directory separator
- if( iEpocRoot.length() > 0 && iEpocRoot.at( iEpocRoot.length()-1) != DIR_SEPARATOR2 )
- {
- iEpocRoot += DIR_SEPARATOR;
- }
- }
-}
-
-/**
- *
- */
-const MifConvString& MifConvArgumentManager::EpocRoot() const
-{
- return iEpocRoot;
-}
-
-/**
- *
- */
-bool MifConvArgumentManager::FindAndSetPathAndType( MifConvSourceFile& srcFile, const MifConvString& extension )
-{
- // Search the filename first "as is":
- MifConvString tmp( MifConvUtil::FilenameWithoutExtension( srcFile.Filename() ) + MifConvString(FILE_EXTENSION_SEPARATOR) + extension );
- if( MifConvUtil::FileExists(tmp) )
- {
- srcFile.SetFilename(tmp);
- MifConvUtil::FindAndSetBitmapMaskFile(srcFile);
- return true;
- }
-
- // If the absolute path was given, return false, because the file was not found with given path and filename.
- // Otherwise continue searching.
- if( //(srcFile.Filename().length() > 0 && srcFile.Filename().at(0) == DIR_SEPARATOR2) ||
- (srcFile.Filename().length() > 1 && srcFile.Filename().at(1) == ':') )
- {
- return false;
- }
-
- // Search from the pre-defined locations:
- for( SearchRules::iterator i = iSearchRules.begin(); i != iSearchRules.end(); ++i )
- {
- bool validPath = false;
- const MifConvStringList& allowedTypes = i->AllowedFileTypes();
-
- // See if the file with given extension is allowed to locate in search path.
- // For example, epoc32\s60\icons folder can contain only .svg files and epoc32\s60\bitmaps
- // can contain only .bmp files:
- for( MifConvStringList::const_iterator typeIter = allowedTypes.begin(); typeIter != allowedTypes.end(); ++typeIter )
- {
- if( *typeIter == MIFCONV_WILDCARD || *typeIter == extension )
- {
- validPath = true;
- break;
- }
- }
-
- if( validPath )
- {
- MifConvString searchPath(i->SearchPath());
-
- // Make sure that the last char is directory separator
- if( searchPath.length() > 0 && searchPath.at( searchPath.length()-1) != DIR_SEPARATOR2 )
- {
- searchPath += DIR_SEPARATOR;
- }
-
- searchPath += MifConvUtil::FilenameWithoutExtension( srcFile.Filename() ) + MifConvString(FILE_EXTENSION_SEPARATOR) + extension;
-
- MifConvUtil::RemoveDuplicateDirSeparators(searchPath);
-
- if( MifConvUtil::FileExists( searchPath ) )
- {
- srcFile.SetFilename(searchPath);
- MifConvUtil::FindAndSetBitmapMaskFile(srcFile);
- return true;
- }
- }
- }
- return false;
-}
-
-/**
- *
- */
-void MifConvArgumentManager::ProcessArgumentPaths()
-{
- // Fix directory separators first:
- for( StringArgMap::iterator i = iStringArguments.begin(); i != iStringArguments.end(); ++i )
- {
- MifConvString tmp = i->second.Value();
- MifConvUtil::ReplaceChar(tmp, INCORRECT_DIR_SEPARATOR2, DIR_SEPARATOR2);
- MifConvUtil::RemoveDuplicateDirSeparators(tmp);
- i->second.SetValue(tmp);
- }
-
- // Fix directory separators in source filenames also:
- for( MifConvSourceFileList::iterator j = iSourceFiles.begin(); j != iSourceFiles.end(); ++j )
- {
- MifConvString tmp = j->Filename();
- MifConvUtil::ReplaceChar(tmp, INCORRECT_DIR_SEPARATOR2, DIR_SEPARATOR2);
- MifConvUtil::RemoveDuplicateDirSeparators(tmp);
- j->SetFilename(tmp);
- }
-
- // Fix directory separators in search rule directories also:
- for( SearchRules::iterator k = iSearchRules.begin(); k != iSearchRules.end(); ++k )
- {
- MifConvString& tmp = k->SearchPath();
- MifConvUtil::ReplaceChar(tmp, INCORRECT_DIR_SEPARATOR2, DIR_SEPARATOR2);
- MifConvUtil::RemoveDuplicateDirSeparators(tmp);
- }
-
- // Fix target file also:
- MifConvUtil::ReplaceChar(iTargetFile, INCORRECT_DIR_SEPARATOR2, DIR_SEPARATOR2);
- MifConvUtil::RemoveDuplicateDirSeparators(iTargetFile);
-}
-
-/**
- *
- */
-void MifConvArgumentManager::FinalizeArguments()
-{
- ProcessArgumentPaths();
- ResolveSourceFileTypes();
-}
-
-/**
- *
- */
-void MifConvArgumentManager::SetUsageString( MifConvString& usageStr ) const
-{
- usageStr = "";
-
- usageStr += "Copyright (c) " + MifConvYears + " Nokia Corporation and/or its subsidiary(-ies). All rights reserved.\n";
- usageStr += "\n";
- usageStr += "Usage: mifconv <MIFFILE> [-F<file>] <options> <sources>]\n";
- usageStr += "\n";
- usageStr += "Where:\n";
- usageStr += " MIFFILE Specifies the target MIF file to be created\n";
- usageStr += " -F<file> Specifies a parameter file, which can contain any of the options\n";
- usageStr += " and sources separated by spaces or newlines\n";
- usageStr += "\n";
- usageStr += "Options:\n";
- usageStr += " -H<file> Specifies a name of the MIF header file (default extension MBG)\n";
- usageStr += " -I<dir;dir;...> Specifies a set of custom source directories where source files\n";
- usageStr += " will be searched. As a fallback, global source directories are\n";
- usageStr += " used\n";
- usageStr += " -E Specifies that source icons are only loaded with given file\n";
- usageStr += " extensions. By default, Mifconv prefers source icons with\n";
- usageStr += " extension .SVG over .BMP, regardless of which is given as\n";
- usageStr += " a parameter\n";
- usageStr += " -X Disables SVG compression. If this flag is set, SVG icons are\n";
- usageStr += " added to MIF file without compressing them first\n";
- usageStr += " -P<file> Specifies a path to custom palette file for bitmap files\n";
- usageStr += " -T<dir> Specifies a path where temporary files are created\n";
- usageStr += " -B<file> Specifies a path for non-default BMConv utility\n";
- usageStr += " -S<file> Specifies a path for non-default SVGTBinenCode utility\n";
- usageStr += " -V<string> Specifies a non-platform default format version of SVGT binary\n";
- usageStr += " conversion. It can be any of the following value:\n";
- usageStr += " 1 BGR / float encoding\n";
- usageStr += " 2 BGR / fixed point encoding\n";
- usageStr += " 3 RGB / fixed point encoding\n";
- usageStr += " 4 RGB / float encoding\n";
- usageStr += "Sources:\n";
- usageStr += " [-A] <DEPTH[,MASK]> <FILE> [ [-A] <DEPTH[,MASK]> <FILE> ... ]\n";
- usageStr += " [-A] Specifies animated flag for the icon\n";
- usageStr += " [DEPTH] Specifies icon depth, it can be any of these values\n";
- usageStr += " -1,-2,-4,-8,-c4,-c8,-c12,-c16,-c24,-c32\n";
- usageStr += " [MASK] Specifies icon mask depth, it can be any of these values\n";
- usageStr += " 1,8\n";
- usageStr += " [FILE] Specifies path to the input file, supported file extensions are\n";
- usageStr += " SVG, SVGB, BMP\n";
- usageStr += "\n";
- usageStr += "Other info:\n";
-#ifdef WIN32
- usageStr += " * '-' or '/' can be used as parameter switch prefix\n";
-#endif
- usageStr += " * Value of icon mask and depth is meaningful only for bitmap files, but the mask\n";
- usageStr += " value defines if mask entry will be available or not in the header file\n";
- usageStr += " * If mask parameter is defined for a BMP file, Mifconv automatically pics\n";
- usageStr += " a file ending _mask_soft for value 8 and _mask for value 1 of mask\n";
- usageStr += "\n";
- usageStr += "Examples:\n";
- usageStr += " mifconv mybuttons.mif -Hmybuttons.mbg -c8,8 button1 -c8,8 button2\n";
-}
-
-/**
- *
- */
-const MifConvString& MifConvArgumentManager::StringValue( const MifConvString& argName ) const
-{
- StringArgMap::const_iterator i = iStringArguments.find(argName);
- if( i != iStringArguments.end() )
- {
- return i->second.Value();
- }
-
- return iDummyString;
-}
-
-/**
- *
- */
-const MifConvStringList& MifConvArgumentManager::StringListValue( const MifConvString& argName ) const
-{
- StringListArgMap::const_iterator i = iStringListArguments.find(argName);
- if( i != iStringListArguments.end() )
- {
- return i->second.Value();
- }
-
- return iDummyStringList;
-}
-
-/**
- *
- */
-bool MifConvArgumentManager::BooleanValue( const MifConvString& argName ) const
-{
- BooleanArgMap::const_iterator i = iBooleanArguments.find(argName);
- if( i != iBooleanArguments.end() )
- {
- return i->second.Value();
- }
-
- return false;
-}
-
-/**
- *
- */
-const MifConvSourceFileList& MifConvArgumentManager::SourceFiles() const
-{
- return iSourceFiles;
-}
-
-/**
- *
- */
-bool MifConvArgumentManager::IsArgument( const MifConvString& str ) const
-{
- try {
- return str.at(0) == OPTION_PREFIX1_CHAR || str.at(0) == OPTION_PREFIX2_CHAR;
- }
- catch(...)
- {
- THROW_ERROR("Zero or corrupted string in MifConvArgumentManager::IsArgument()\n", MifConvString(__FILE__), __LINE__);
- }
- return false;
-}
-
-/**
- *
- */
-void MifConvArgumentManager::PopulateDepthAndMaskMaps()
-{
- // Insert value-string pairs for the icon depths:
- iDepthMap.insert(std::make_pair(MifConvDepth_1, IconDepth_1));
- iDepthMap.insert(std::make_pair(MifConvDepth_2, IconDepth_2));
- iDepthMap.insert(std::make_pair(MifConvDepth_4, IconDepth_4));
- iDepthMap.insert(std::make_pair(MifConvDepth_8, IconDepth_8));
- iDepthMap.insert(std::make_pair(MifConvDepth_c4, IconDepth_c4));
- iDepthMap.insert(std::make_pair(MifConvDepth_c8, IconDepth_c8));
- iDepthMap.insert(std::make_pair(MifConvDepth_c12, IconDepth_c12));
- iDepthMap.insert(std::make_pair(MifConvDepth_c16, IconDepth_c16));
- iDepthMap.insert(std::make_pair(MifConvDepth_c24, IconDepth_c24));
- iDepthMap.insert(std::make_pair(MifConvDepth_c32, IconDepth_c32));
-
- // Insert value-string pairs for the icon masks:
- iMaskDepthMap.insert(std::make_pair(MifConvMaskDepth_1, IconMaskDepth_1));
- iMaskDepthMap.insert(std::make_pair(MifConvMaskDepth_8, IconMaskDepth_8));
-
- // Insert value-pairs for display modes:
- iDisplayModeMap.insert(std::make_pair(IconDepth_1, DisplayMode_Gray2));
- iDisplayModeMap.insert(std::make_pair(IconDepth_2, DisplayMode_Gray4));
- iDisplayModeMap.insert(std::make_pair(IconDepth_4, DisplayMode_Gray16));
- iDisplayModeMap.insert(std::make_pair(IconDepth_8, DisplayMode_Gray256));
- iDisplayModeMap.insert(std::make_pair(IconDepth_c4, DisplayMode_Color16));
- iDisplayModeMap.insert(std::make_pair(IconDepth_c8, DisplayMode_Color256));
- iDisplayModeMap.insert(std::make_pair(IconDepth_c12, DisplayMode_Color4K));
- iDisplayModeMap.insert(std::make_pair(IconDepth_c16, DisplayMode_Color64K));
- iDisplayModeMap.insert(std::make_pair(IconDepth_c24, DisplayMode_Color16M));
- iDisplayModeMap.insert(std::make_pair(IconDepth_c32, DisplayMode_Color16MU));
-
- iMaskDisplayModeMap.insert(std::make_pair(IconMaskDepth_1, DisplayMode_Gray2));
- iMaskDisplayModeMap.insert(std::make_pair(IconMaskDepth_8, DisplayMode_Gray256));
-}
-
-/**
- *
- */
-void MifConvArgumentManager::ReadParameterFile(const MifConvString& paramFilename, MifConvStringList& paramList)
-{
- // Check if the file exists:
- if( MifConvUtil::FileExists(paramFilename) == false )
- {
- THROW_ERROR_COMMON("Unable to open file for reading! " + paramFilename, MifConvString(__FILE__), __LINE__ );
- }
-
- MifConvFileData paramFileData = MifConvUtil::FileContents(paramFilename);
-
- MifConvString tmpString;
- for(size_t i = 0; i < paramFileData.second; ++i )
- {
- if( MifConvUtil::IsWhiteSpace(paramFileData.first[i]) == false )
- {
- tmpString += paramFileData.first[i];
- }
- else if( tmpString.length() > 0 )
- {
- paramList.push_back( tmpString );
- tmpString = MifConvString();
- }
- }
-
- if( tmpString.length() > 0 )
- {
- paramList.push_back( tmpString );
- tmpString = MifConvString();
- }
- delete[] paramFileData.first;
-}
-
-/**
- * Helper class for source search rules
- */
-
-MifConvSourceSearchRule::MifConvSourceSearchRule(const MifConvString& path, const MifConvStringList& types)
-:
-iSearchPath(path),
-iAllowedFileTypes(types)
-{}
-
-MifConvSourceSearchRule::~MifConvSourceSearchRule()
-{}
-
-const MifConvString& MifConvSourceSearchRule::SearchPath() const
-{
- return iSearchPath;
-}
-
-MifConvString& MifConvSourceSearchRule::SearchPath()
-{
- return iSearchPath;
-}
-
-const MifConvStringList& MifConvSourceSearchRule::AllowedFileTypes() const
-{
- return iAllowedFileTypes;
-}
--- a/dependencies/mifconv/src/mifconv_bitmapconverter.cpp Sat Mar 27 01:00:02 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,277 +0,0 @@
-/*
-* Copyright (c) 2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Mifconv bitmap converters class.
-*
-*/
-
-
-#include "mifconv.h"
-#include "mifconv_bitmapconverter.h"
-#include "mifconv_util.h"
-#include "mifconv_exception.h"
-#include "mifconv_argumentmanager.h"
-#include <stdio.h>
-
-const MifConvString BMCONV_DEFAULT_PATH(EPOC_TOOLS_PATH);
-
-/**
- *
- */
-MifConvBitmapConverter::MifConvBitmapConverter()
-{
- MifConvArgumentManager* argMgr = MifConvArgumentManager::Instance();
- // Output file:
- iTargetFilename = MifConvUtil::FilenameWithoutExtension(argMgr->TargetFile()) + "." + MifConvString(MBM_FILE_EXTENSION);
-}
-
-/**
- *
- */
-MifConvBitmapConverter::~MifConvBitmapConverter()
-{
-}
-
-/**
- *
- */
-void MifConvBitmapConverter::Init()
-{
- CleanupTargetFiles();
-}
-
-/**
- *
- */
-void MifConvBitmapConverter::CleanupTargetFiles()
-{
- if( MifConvUtil::FileExists(iTargetFilename) )
- {
- // Try to remove file MIFCONV_MAX_REMOVE_TRIES times, no exception in case of failure:
- MifConvUtil::RemoveFile(iTargetFilename, MIFCONV_MAX_REMOVE_TRIES, true);
- }
-}
-
-/**
- *
- */
-void MifConvBitmapConverter::AppendFile( const MifConvSourceFile& sourcefile )
-{
- if( MifConvUtil::FileExtension( sourcefile.Filename() ) == BMP_FILE_EXTENSION )
- {
- iSourceFiles.push_back( sourcefile );
- }
-}
-
-/**
- *
- */
-void MifConvBitmapConverter::Convert()
-{
- if( iSourceFiles.size() > 0 )
- {
- ConvertToMbm();
- }
-}
-
-/**
- *
- */
-void MifConvBitmapConverter::Cleanup(bool err)
-{
- CleanupTempFiles();
- if( err )
- {
- CleanupTargetFiles();
- }
-}
-
-/**
- *
- */
-void MifConvBitmapConverter::ConvertToMbm()
-{
- RunBmconv();
-}
-
-/**
- *
- */
-void MifConvBitmapConverter::InitTempFile()
-{
- MifConvArgumentManager* argMgr = MifConvArgumentManager::Instance();
- // Construct temp file name
- iTempDir = MifConvUtil::DefaultTempDirectory();
- const MifConvString& tempDirArg = argMgr->StringValue(MifConvTempPathArg);
- if( tempDirArg.length() > 0 )
- {
- iTempDir = tempDirArg;
- }
-
- if( iTempDir.length() > 0 && iTempDir.at(iTempDir.length()-1) != DIR_SEPARATOR2 )
- {
- iTempDir.append(DIR_SEPARATOR);
- }
-
- // Generate new temp-filename:
- iTempDir.append(MifConvUtil::TemporaryFilename());
-
- // append tmp at as postfix
- // this is needed because the generated name can contain a single period '.'
- // character as the last character which is eaten away when the directory created.
- iTempDir.append(MifConvString("tmp"));
-
- MifConvUtil::EnsurePathExists(iTempDir);
-
- iTempDir.append(DIR_SEPARATOR);
-
- iTempFilename = iTempDir + MifConvUtil::FilenameWithoutExtension(MifConvUtil::FilenameWithoutPath(argMgr->TargetFile()));
- iTempFilename += BMCONV_TEMP_FILE_POSTFIX;
-
- // Create temp file
- fstream tempFile(iTempFilename.c_str(), ios::out|ios::binary|ios::trunc);
- if (!tempFile.is_open())
- {
- throw MifConvException(MifConvString("Unable to create tmp file! ") + iTempFilename);
- }
-
- try {
- // quiet mode
- tempFile << BMCONV_OPTION_PREFIX << BMCONV_QUIET_PARAMETER << " ";
- // Palette argument
- const MifConvString& paletteArg = argMgr->StringValue(MifConvPaletteFileArg);
- if( paletteArg.length() > 0 )
- {
- tempFile << BMCONV_OPTION_PREFIX << BMCONV_PALETTE_PARAMETER;
- tempFile << MifConvString(paletteArg + " ");
- }
-
- tempFile << iTargetFilename << " ";
- // Add filenames to the temp file
- for( MifConvSourceFileList::iterator i = iSourceFiles.begin(); i != iSourceFiles.end(); ++i )
- {
- AppendBmpToTempFile(tempFile, *i);
- }
- }
- catch(...) {
- tempFile.close();
- throw;
- }
-
- tempFile.close();
-}
-
-/**
- *
- */
-void MifConvBitmapConverter::RunBmconv()
-{
- MifConvArgumentManager* argMgr = MifConvArgumentManager::Instance();
- // Create and initialize the temp file:
- InitTempFile();
-
- // Build bmconv command
- MifConvString bmconvCommand("\""); // Open " mark
-
- const MifConvString& bmconvPath = argMgr->StringValue(MifConvBmconvPathArg);
- const MifConvString& defaultBmconvPath = GetDefaultBmConvPath();
- if( bmconvPath.length() > 0 )
- {
- bmconvCommand += bmconvPath; // If the path is given, use it.
- }
- else
- {
- bmconvCommand += defaultBmconvPath; // Use default path
- }
-
- // Ensure that the last char of the path is dir-separator:
- if( bmconvCommand.length() > 1 && bmconvCommand.at(bmconvCommand.length()-1) != DIR_SEPARATOR2 )
- bmconvCommand += DIR_SEPARATOR;
-
- // Then add bmconv executable call and close the " mark
- bmconvCommand += BMCONV_EXECUTABLE_NAME + MifConvString("\" ");
- bmconvCommand += "\"" + iTempFilename + "\"";
-
- MifConvUtil::EnsurePathExists(iTargetFilename, true);
-
- cout << "Writing mbm: " << iTargetFilename << endl;
- int err = 0;
-
-#ifdef __linux__
- if ((err = system (MifConvString(bmconvCommand).c_str())) != 0) // Returns 0 if success
-#else
- if ((err = system (MifConvString("\""+bmconvCommand+"\"").c_str())) != 0) // Returns 0 if success
-#endif
- {
- THROW_ERROR_COMMON("Executing BMCONV failed", MifConvString(__FILE__), __LINE__);
- }
-}
-
-/**
- *
- */
-void MifConvBitmapConverter::CleanupTempFiles()
-{
- if( iTempFilename.length() > 0 && remove( iTempFilename.c_str() ) != 0 )
- {
- perror( "Error deleting temporary file (bitmap conversion)" );
- }
-
- if( iTempDir.length() > 0 && MifConvUtil::RemoveDirectory( iTempDir ) != 0 )
- {
- perror( "Error deleting temporary directory (bitmap conversion)" );
- }
-}
-
-/**
- *
- */
-const MifConvString& MifConvBitmapConverter::GetDefaultBmConvPath()
-{
- if( iDefaultBmConvPath.length() == 0 )
- {
- // Check if the EPOCROOT is given
- MifConvString epocRoot(MifConvArgumentManager::Instance()->EpocRoot());
- if( epocRoot.length() > 0 )
- {
- // EPOCROOT environment variable defined.
- iDefaultBmConvPath = epocRoot + BMCONV_DEFAULT_PATH;
- }
- }
-
- return iDefaultBmConvPath;
-}
-
-/**
- *
- */
-void MifConvBitmapConverter::AppendBmpToTempFile(fstream& aStream, const MifConvSourceFile& bmpFile)
- {
- cout << "Loading file: " << bmpFile.Filename() << endl;
-
- aStream << BMCONV_OPTION_PREFIX;
- aStream << bmpFile.DepthString();
- aStream << bmpFile.Filename();
- aStream << " ";
-
- // Prepare also for the case that mask is not used at all.
- const MifConvString& maskName = bmpFile.BmpMaskFilename();
- if (maskName.length() > 0 )
- {
- cout << "Loading file: " << maskName << endl;
- aStream << BMCONV_OPTION_PREFIX;
- aStream << bmpFile.MaskDepthString();
- aStream << maskName;
- }
- aStream << " ";
- }
--- a/dependencies/mifconv/src/mifconv_bitmapheaderconverter.cpp Sat Mar 27 01:00:02 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,166 +0,0 @@
-/*
-* Copyright (c) 2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Mifconv bitmap header converter class.
-*
-*/
-
-
-#include "mifconv.h"
-#include "mifconv_bitmapheaderconverter.h"
-#include "mifconv_argumentmanager.h"
-#include "mifconv_util.h"
-#include "mifconv_exception.h"
-
-const int MIF_ID_FIRST = 16384;
-
-/**
- *
- */
-MifConvBitmapHeaderConverter::MifConvBitmapHeaderConverter()
-:
-iCurrentSourceId(MIF_ID_FIRST)
-{
- MifConvArgumentManager* argMgr = MifConvArgumentManager::Instance();
- iHeaderFilename = argMgr->StringValue(MifConvHeaderArg);
-}
-
-/**
- *
- */
-MifConvBitmapHeaderConverter::~MifConvBitmapHeaderConverter()
-{
-}
-
-/**
- *
- */
-void MifConvBitmapHeaderConverter::Init()
-{
- CleanupTargetFiles();
-}
-
-/**
- *
- */
-void MifConvBitmapHeaderConverter::CleanupTargetFiles()
-{
- if( MifConvUtil::FileExists(iHeaderFilename) )
- {
- // Try to remove file MIFCONV_MAX_REMOVE_TRIES times, no exception in case of failure:
- MifConvUtil::RemoveFile(iHeaderFilename, MIFCONV_MAX_REMOVE_TRIES, true);
- }
-}
-
-/**
- *
- */
-void MifConvBitmapHeaderConverter::AppendFile( const MifConvSourceFile& sourcefile )
-{
- iSourceFiles.push_back( sourcefile );
-}
-
-/**
- *
- */
-void MifConvBitmapHeaderConverter::Convert()
-{
- // Check if the headerfile name is given. Return if not:
- if( iHeaderFilename.length() > 0 )
- {
- cout << "Writing mbg: " << iHeaderFilename << endl;
- MifConvUtil::EnsurePathExists(iHeaderFilename, true);
- }
- else
- {
- return;
- }
-
- // Create / open the header file:
- fstream headerFile(iHeaderFilename.c_str(), ios::out|ios::trunc);
-
- // If file creation/opening was not successful, give warning and return:
- if( !headerFile.is_open() )
- {
- MifConvString debugStr("WARNING: Headerfile " + iHeaderFilename + " cannot be opened for writing.");
- cout << debugStr << endl;
- MifConvUtil::DebugLog(debugStr);
- return;
- }
- iDestFile = &headerFile; // Save the pointer to the file stream
- (*iDestFile) << endl;
- // Write the beginning of the header file:
- WriteStart();
-
- // Add source file items to enumerator:
- for( MifConvSourceFileList::iterator i = iSourceFiles.begin(); i != iSourceFiles.end(); ++i )
- {
- WriteItemToHeader(*i);
- }
-
- // Write the end of the file...
- WriteEnd();
-
- // ...and close the file:
- iDestFile->close();
-}
-
-/**
- *
- */
-void MifConvBitmapHeaderConverter::WriteStart()
-{
- (*iDestFile) << "/* This file has been generated, DO NOT MODIFY. */" << endl;
- (*iDestFile) << "enum TMif" << MifConvUtil::UnadornedFilename(iHeaderFilename) << "\n\t{" << endl;
-}
-
-/**
- *
- */
-void MifConvBitmapHeaderConverter::WriteItemToHeader( const MifConvSourceFile& source )
-{
- MifConvString unadornedHeaderFile(MifConvUtil::UnadornedFilename(iHeaderFilename));
-
- (*iDestFile) << "\tEMbm" << unadornedHeaderFile << MifConvUtil::UnadornedFilename(source.Filename()) << " = " << iCurrentSourceId++ << "," << endl;
-
- // Write mask also, if any:
- if( source.MaskDepth() != IconMaskDepth_Undefined )
- {
- (*iDestFile) << "\tEMbm" << unadornedHeaderFile << MifConvUtil::UnadornedFilename(source.Filename()) << "_mask = " << iCurrentSourceId++ << "," << endl;
- }
- else
- {
- // Skip mask ID if mask not present so that adding a mask later does not change IDs.
- iCurrentSourceId++;
- }
-}
-
-/**
- *
- */
-void MifConvBitmapHeaderConverter::WriteEnd()
-{
- (*iDestFile) << "\tEMbm" << MifConvUtil::UnadornedFilename(iHeaderFilename) << "LastElement" << endl;
- (*iDestFile) << "\t};" << endl;
-}
-
-/**
- *
- */
-void MifConvBitmapHeaderConverter::Cleanup(bool err)
-{
- if( err )
- {
- CleanupTargetFiles();
- }
-}
--- a/dependencies/mifconv/src/mifconv_convertermanager.cpp Sat Mar 27 01:00:02 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,190 +0,0 @@
-/*
-* Copyright (c) 2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Mifconv converter manager class.
-*
-*/
-
-
-#include "mifconv.h"
-#include "mifconv_convertermanager.h"
-#include "mifconv_argumentmanager.h"
-#include "mifconv_util.h"
-#include "mifconv_bitmapconverter.h"
-#include "mifconv_bitmapheaderconverter.h"
-#include "mifconv_iconbinaryconverter.h"
-#include "mifconv_mifconverter.h"
-
-// Static singleton initialization
-MifConvConverterManager* MifConvConverterManager::iInstance = 0;
-
-/**
- * Returns pointer to the singleton object
- */
-MifConvConverterManager* MifConvConverterManager::Instance()
-{
- if( iInstance == 0 )
- {
- iInstance = new MifConvConverterManager();
- }
- return iInstance;
-}
-
-/**
- * Free the allocated memory
- */
-void MifConvConverterManager::Reset()
-{
- delete iInstance;
- iInstance = 0;
-}
-
-/**
- * Constructor
- */
-MifConvConverterManager::MifConvConverterManager()
-{
-
-}
-
-/**
- *
- */
-void MifConvConverterManager::Init()
-{
- // Add bmp --> mbm converter:
- MifConvBitmapConverter* bitmapConverter = new MifConvBitmapConverter();
- iAllConverters.push_back(bitmapConverter);
-
- // Add headerfile (mbg) converter:
- MifConvBitmapHeaderConverter* headerConverter = new MifConvBitmapHeaderConverter();
- iAllConverters.push_back(headerConverter);
-
- // Add svg --> svgb converter:
- MifConvIconBinaryConverter* svgConverter = new MifConvIconBinaryConverter();
- iAllConverters.push_back(svgConverter);
-
- // Add mif converter:
- MifConvMifConverter* mifConverter = new MifConvMifConverter();
- iAllConverters.push_back(mifConverter);
-
- // Add file converters for .BMP files:
- MifConvFileConverterList bmpConverters;
- bmpConverters.push_back(bitmapConverter);
- bmpConverters.push_back(headerConverter);
- bmpConverters.push_back(mifConverter);
- iFileConverters.insert(std::make_pair(MifConvString(BMP_FILE_EXTENSION), bmpConverters));
-
- // Add file converters for .SVG files:
- MifConvFileConverterList svgConverters;
- svgConverters.push_back(headerConverter);
- svgConverters.push_back(svgConverter);
- if( MifConvArgumentManager::Instance()->BooleanValue(MifConvDisableSvgCompression) )
- {
- // SVG files will be added to mif-file without compression (i.e. don't use svgtbinencode for them).
- svgConverters.push_back(mifConverter);
- }
- iFileConverters.insert(std::make_pair(MifConvString(SVG_FILE_EXTENSION), svgConverters));
-
- // Add file converters for .SVGB files:
- MifConvFileConverterList svgbConverters;
- svgbConverters.push_back(headerConverter);
- if( !MifConvArgumentManager::Instance()->BooleanValue(MifConvDisableSvgCompression) )
- {
- // SVG files will be compressed first.
- svgbConverters.push_back(mifConverter);
- }
- iFileConverters.insert(std::make_pair(MifConvString(SVGB_BINARY_FILE_EXTENSION), svgbConverters));
-
- // Initialize converters
- for( MifConvFileConverterList::iterator i = iAllConverters.begin(); i != iAllConverters.end(); ++i )
- {
- (*i)->Init();
- }
-}
-
-/**
- * Destructor
- */
-MifConvConverterManager::~MifConvConverterManager()
-{
- for( MifConvFileConverterList::iterator conv = iAllConverters.begin(); conv != iAllConverters.end(); ++conv )
- {
- delete *conv;
- }
-}
-
-/**
- * Adds source files to converters and converts them
- */
-void MifConvConverterManager::ProcessIcons()
-{
- MifConvArgumentManager* argMgr = MifConvArgumentManager::Instance();
- // Loop all the source files and append them to correct converters:
- const MifConvSourceFileList& sourcefiles = argMgr->SourceFiles();
- for( MifConvSourceFileList::const_iterator i = sourcefiles.begin(); i != sourcefiles.end(); ++i )
- {
- MifConvFileConverterList& converters = GetConverters(*i);
- for( MifConvFileConverterList::iterator converter = converters.begin(); converter != converters.end(); ++converter )
- {
- (*converter)->AppendFile(*i);
- }
- }
-
- // Run all the converters:
- for( MifConvFileConverterList::iterator conv = iAllConverters.begin(); conv != iAllConverters.end(); ++conv )
- {
- (*conv)->Convert();
- }
-}
-
-/**
- *
- */
-void MifConvConverterManager::Cleanup(bool error)
-{
- for( MifConvFileConverterList::iterator conv = iAllConverters.begin(); conv != iAllConverters.end(); ++conv )
- {
- try {
- (*conv)->Cleanup(error);
- }
- catch(...) {
- // Exception should not be thrown if cleaning after error situation
- if( !error )
- throw;
- }
- }
-}
-
-/**
- *
- */
-MifConvFileConverterList& MifConvConverterManager::GetConverters(const MifConvSourceFile& source)
-{
- return GetConverters(source.Filename());
-}
-
-/**
- *
- */
-MifConvFileConverterList& MifConvConverterManager::GetConverters(const MifConvString& filename)
-{
- MifConvString extension(MifConvUtil::FileExtension(filename));
- FileConverterMap::iterator i = iFileConverters.find(extension);
- if( i != iFileConverters.end() )
- {
- return i->second;
- }
-
- return iDummyConverterList;
-}
--- a/dependencies/mifconv/src/mifconv_exception.cpp Sat Mar 27 01:00:02 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,76 +0,0 @@
-/*
-* Copyright (c) 2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Mifconv exception class.
-*
-*/
-
-
-#include "mifconv.h"
-#include "mifconv_exception.h"
-
-MifConvException::MifConvException()
-:
-iLine(0)
-{}
-
-MifConvException::MifConvException(const MifConvString& str, const MifConvString& file, int line)
-:
-iString(str),
-iFile(file),
-iLine(line)
-{}
-
-MifConvException::MifConvException(const MifConvException& rhs)
-:
-iString(rhs.iString),
-iFile(rhs.iFile),
-iLine(rhs.iLine)
-{}
-
-MifConvException::~MifConvException()
-{}
-
-void MifConvException::SetString(const MifConvString& str)
-{
- iString = str;
-}
-const MifConvString& MifConvException::String() const
-{
- return iString;
-}
-
-MifConvString& MifConvException::String()
-{
- return iString;
-}
-
-void MifConvException::SetFile(const MifConvString& file)
-{
- iFile = file;
-}
-
-const MifConvString& MifConvException::File() const
-{
- return iFile;
-}
-
-void MifConvException::SetLine(int line)
-{
- iLine = line;
-}
-
-int MifConvException::Line() const
-{
- return iLine;
-}
--- a/dependencies/mifconv/src/mifconv_iconbinaryconverter.cpp Sat Mar 27 01:00:02 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,302 +0,0 @@
-/*
-* Copyright (c) 2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Mifconv icon binary converters class.
-*
-*/
-
-
-#include "mifconv.h"
-#include "mifconv_iconbinaryconverter.h"
-#include "mifconv_util.h"
-#include "mifconv_exception.h"
-#include "mifconv_convertermanager.h"
-#include "mifconv_argumentmanager.h"
-#include <errno.h>
-#include <algorithm>
-
-const MifConvString SVGTBINENCODE_DEFAULT_PATH(EPOC_TOOLS_PATH);
-
-/**
- *
- */
-MifConvIconBinaryConverter::MifConvIconBinaryConverter()
-{
-}
-
-/**
- *
- */
-MifConvIconBinaryConverter::~MifConvIconBinaryConverter()
-{
-}
-
-/**
- *
- */
-void MifConvIconBinaryConverter::Init()
-{
-}
-
-/**
- *
- */
-void MifConvIconBinaryConverter::CleanupTargetFiles()
-{
-}
-
-/**
- *
- */
-void MifConvIconBinaryConverter::AppendFile( const MifConvSourceFile& sourcefile )
-{
- if( MifConvUtil::FileExtension( sourcefile.Filename() ) == SVG_FILE_EXTENSION &&
- MifConvArgumentManager::Instance()->BooleanValue(MifConvDisableSvgCompression) == false)
- {
- iSourceFiles.push_back( sourcefile );
-
- // Create temp directory:
- if( iTempDir.length() == 0 )
- {
- InitTempFile();
- }
-
- // External SVGTBINENCODE converts .svg files to .svgb files. However, .svgb files
- // shall be given to mif-converter to get them in mif-file:
-
- // Create new string for .svgb file name:
- MifConvString tmpFile(sourcefile.Filename());
- ConvertToBinaryFilename(tmpFile);
- MifConvString tempBinFilename(iTempDir + MifConvUtil::FilenameWithoutExtension(tmpFile) + "." + SVGB_BINARY_FILE_EXTENSION);
-
- // Get converters for .svgb files:
- MifConvFileConverterList& additionalConverters = MifConvConverterManager::Instance()->GetConverters(tempBinFilename);
-
- // Converters for .svg files:
- MifConvFileConverterList& thisFilesConverters = MifConvConverterManager::Instance()->GetConverters( sourcefile.Filename() );
-
- // Save temporary binary filename for later deleting:
- iTempFilenames.push_back(tempBinFilename);
-
- // Add temporary file to converters:
- for( MifConvFileConverterList::iterator c = additionalConverters.begin(); c != additionalConverters.end(); ++c )
- {
- // We have to make sure that we don't add same file twice to same converter. So, let's take first a list of
- // .svg file converters and compare them to the .svgb file converters. Don't add temporary file to converters
- // that are found from both of the lists.
- MifConvFileConverterList::iterator c2 = std::find(thisFilesConverters.begin(), thisFilesConverters.end(), *c );
- if( c2 == thisFilesConverters.end() )
- {
- // .svgb converter not found from .svg converters -> add temporary file to .svgb converter:
- MifConvSourceFile svgbFile(sourcefile);
- svgbFile.SetFilename(tempBinFilename);
- (*c)->AppendFile(svgbFile);
- }
- }
- }
-}
-
-/**
- *
- */
-void MifConvIconBinaryConverter::Convert()
-{
- if( iSourceFiles.size() > 0 && MifConvArgumentManager::Instance()->BooleanValue(MifConvDisableSvgCompression) == false )
- {
- ConvertToSvgb();
- }
-}
-
-/**
- *
- */
-void MifConvIconBinaryConverter::Cleanup(bool err)
-{
- CleanupTempFiles();
- if( err )
- {
- CleanupTargetFiles();
- }
-}
-
-/**
- *
- */
-void MifConvIconBinaryConverter::ConvertToSvgb()
-{
- RunExtConverter();
-}
-
-/**
- *
- */
-void MifConvIconBinaryConverter::InitTempFile()
-{
- MifConvArgumentManager* argMgr = MifConvArgumentManager::Instance();
- // Construct temp file name
- // If temp directory is given in command line arguments, use it:
- iTempDir = MifConvUtil::DefaultTempDirectory();
- const MifConvString& tempDirArg = argMgr->StringValue(MifConvTempPathArg);
- if( tempDirArg.length() > 0 )
- {
- iTempDir = tempDirArg;
- }
-
- if( iTempDir.length() > 0 && iTempDir.at(iTempDir.length()-1) != DIR_SEPARATOR2 )
- {
- iTempDir.append(DIR_SEPARATOR);
- }
-
- // Generate new temp-filename:
- iTempDir.append(MifConvUtil::TemporaryFilename());
-
- // append tmp at as postfix
- // this is needed because the generated name can contain a single period '.'
- // character as the last character which is eaten away when the directory created.
- iTempDir.append(MifConvString("tmp"));
-
- MifConvUtil::EnsurePathExists(iTempDir);
-
- iTempDir.append(DIR_SEPARATOR);
-}
-
-/**
- *
- */
-void MifConvIconBinaryConverter::ConvertToBinaryFilename( MifConvString& input )
-{
- MifConvUtil::ReplaceChar(input, DIR_SEPARATOR2, '_');
- MifConvUtil::ReplaceChar(input, INCORRECT_DIR_SEPARATOR2, '_');
- MifConvUtil::ReplaceChar(input, ':', '_');
- MifConvUtil::ReplaceChar(input, ' ', '_');
-}
-
-/**
- *
- */
-void MifConvIconBinaryConverter::RunExtConverter()
-{
- MifConvArgumentManager* argMgr = MifConvArgumentManager::Instance();
-
- // Build svgtbinencode command
- MifConvString extConverterCommand("\""); // Open the " mark
- MifConvString versionArgument;
- MifConvString sourceArgument;
-
- const MifConvString& extConverterPath = argMgr->StringValue(MifConvSvgencodePathArg);
- const MifConvString& defaultExtConverterPath = GetDefaultExtConverterPath();
- if( extConverterPath.length() > 0 )
- {
- extConverterCommand += extConverterPath; // If the path is given, use it.
- }
- else
- {
- extConverterCommand += defaultExtConverterPath; // Use default path
- }
-
- // Ensure that the last char of the path is dir-separator:
- if( extConverterCommand.length() > 1 && extConverterCommand.at(extConverterCommand.length()-1) != DIR_SEPARATOR2 )
- extConverterCommand += DIR_SEPARATOR;
-
- // Then add SVGTBINENCODE executable call and close the " mark
- extConverterCommand += SVGTBINENCODE_EXECUTABLE_NAME + MifConvString("\" ");
-
- // If SVGTBINENCODE version is given, use it also:
- const MifConvString& extConverterVersion = argMgr->StringValue(MifConvSvgtVersionArg);
- if( extConverterVersion.length() > 0 )
- {
- versionArgument = SVGTBINENCODE_OPTION_PREFIX +
- MifConvString(SVGTBINENCODE_VERSION_PARAMETER) + " " + extConverterVersion;
- extConverterCommand += versionArgument + " ";
- }
-
- // Run converter for each of the source files:
- for( MifConvSourceFileList::iterator i = iSourceFiles.begin(); i != iSourceFiles.end(); ++i )
- {
- // Build temp filename by replacing dir separator and ':' chars with '_':
- MifConvString tmpFileName(i->Filename());
- ConvertToBinaryFilename(tmpFileName);
-
- // Copy source file to temp directory:
- MifConvString to(iTempDir + tmpFileName);
- if( MifConvUtil::CopyFile(i->Filename(), to) == false )
- {
- THROW_ERROR_COMMON("File copy failed: " + to, MifConvString(__FILE__), __LINE__ );
- }
- iTempFilenames.push_back(to);
- // It seems that system() function does not work if the command consists of two separate parts
- // enclosed with quotation marks. If the whole string is enclosed with quotation marks then it works...
- // For example: command '"\epoc32\tools\bmconv" "somefile"' does not work while command
- // '""\epoc32\tools\bmconv" "somefile""' does.
- if( system(MifConvString("\""+extConverterCommand+"\""+to+"\"\"").c_str()) < 0 )
- {
- int ernro = errno; // The error number must check straight away before any next system command
-
- MifConvString errStr("Executing SVGTBINENCODE failed");
- if( ernro )
- {
- errStr += ", system error = " + MifConvUtil::ToString(ernro); // Possible system error.
- }
- THROW_ERROR_COMMON(errStr, MifConvString(__FILE__), __LINE__ );
- }
- }
-}
-
-/**
- *
- */
-void MifConvIconBinaryConverter::CleanupTempFiles()
-{
- for( MifConvStringList::iterator i = iTempFilenames.begin(); i != iTempFilenames.end(); ++i )
- {
- if( remove( i->c_str() ) != 0 )
- {
- perror( "Error deleting file (svg conversion)" );
- }
- }
- if( iTempDir.length() > 0 && MifConvUtil::RemoveDirectory( iTempDir ) != 0 )
- {
- perror( "Error deleting temporary directory (svg conversion)" );
- }
-}
-
-/**
- *
- */
-const MifConvString& MifConvIconBinaryConverter::GetDefaultExtConverterPath()
-{
- if( iDefaultExtConverterPath.length() == 0 )
- {
- // Check if the EPOCROOT is given
- MifConvString epocRoot(MifConvArgumentManager::Instance()->EpocRoot());
- if( epocRoot.length() > 0 )
- {
- iDefaultExtConverterPath += epocRoot;
- }
-
- // Ensure that the last char of the path is dir-separator:
- if( iDefaultExtConverterPath.length() > 0 )
- {
- if( iDefaultExtConverterPath.at(iDefaultExtConverterPath.length()-1) != DIR_SEPARATOR2 )
- {
- iDefaultExtConverterPath += DIR_SEPARATOR;
- }
- iDefaultExtConverterPath += SVGTBINENCODE_DEFAULT_PATH;
- }
- }
-
- return iDefaultExtConverterPath;
-}
-
-
-
--- a/dependencies/mifconv/src/mifconv_mifconverter.cpp Sat Mar 27 01:00:02 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,295 +0,0 @@
-/*
-* Copyright (c) 2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Mifconv MIF converters class.
-*
-*/
-
-
-#include "mifconv.h"
-#include "mifconv_mifconverter.h"
-#include "mifconv_util.h"
-#include "mifconv_exception.h"
-#include "mifconv_argumentmanager.h"
-
-// File versions:
-// V1 - first version.
-// V2 - stores information if icon location (MIF/MBM) inside the MIF file (bitmap offsets array).
-// This way, icon IDs in MBG header can be always the same regardless of which icons are in MIF
-// file and which in MBM file.
-static const int KFileVersion(2);
-static const int KIconVersion(1);
-
-static const int FileHeaderSizeInBytes = 4*4;
-static const int IconHeaderSizeInBytes = 4*8;
-static const int KUidAvkonMultiIconFile(0x034232342);
-static const int KUidAvkonMultiIcon(0x034232343);
-
-//static const int IconFormatType_BMP(0);
-//static const int IconFormatType_SVG(1);
-
-static const unsigned int svgbSignatureLow (0x03FA56CC); //66737868
-static const unsigned int svgbSignatureHigh(0x03FA56CF); //66737871
-
-static const unsigned int nvgSignatureLow (0x0067766E); //('n'+'v'+'g'+0)
-static const unsigned int nvgSignatureHigh(0xFF67766E); //('n'+'v'+'g'+255)
-
-/**
- *
- */
-MifConvMifConverter::MifConvMifConverter()
-{
- MifConvArgumentManager* argMgr = MifConvArgumentManager::Instance();
- iTargetFilename = argMgr->TargetFile();
-}
-
-/**
- *
- */
-MifConvMifConverter::~MifConvMifConverter()
-{
- // Delete file contents
- for( StringPtrVector::iterator i = iContentPointers.begin(); i != iContentPointers.end(); ++i )
- {
- delete[] *i;
- }
-}
-
-/**
- *
- */
-void MifConvMifConverter::Init()
-{
- CleanupTargetFiles();
-}
-
-/**
- *
- */
-void MifConvMifConverter::CleanupTargetFiles()
-{
- if( MifConvUtil::FileExists(iTargetFilename) )
- {
- // Try to remove file MIFCONV_MAX_REMOVE_TRIES times, no exception in case of failure:
- MifConvUtil::RemoveFile(iTargetFilename, MIFCONV_MAX_REMOVE_TRIES, true);
- }
-}
-
-/**
- *
- */
-void MifConvMifConverter::AppendFile( const MifConvSourceFile& sourcefile )
-{
- if( MifConvUtil::FileExtension( sourcefile.Filename() ) == BMP_FILE_EXTENSION ||
- MifConvUtil::FileExtension( sourcefile.Filename() ) == SVG_FILE_EXTENSION ||
- MifConvUtil::FileExtension( sourcefile.Filename() ) == SVGB_BINARY_FILE_EXTENSION )
- {
- iSourceFiles.push_back( sourcefile );
- }
-}
-
-void MifConvMifConverter::Convert()
-{
- ReadFileContents();
- cout << "Writing mif: " << MifConvArgumentManager::Instance()->TargetFile() << endl;
- ConvertToMif();
-}
-
-void MifConvMifConverter::ReadFileContents()
-{
- for( MifConvSourceFileList::iterator i = iSourceFiles.begin(); i != iSourceFiles.end(); ++i )
- {
- // Just read the contents of the .svgb files
- if( MifConvUtil::FileExtension( i->Filename() ) != BMP_FILE_EXTENSION )
- {
- if( MifConvUtil::FileExists(i->Filename()) == false )
- {
- THROW_ERROR_COMMON("Unable to open file for reading! " + i->Filename(), MifConvString(__FILE__), __LINE__ );
- }
- cout << "Loading file: " << i->Filename() << endl;
- MifConvFileData retVal = MifConvUtil::FileContents(i->Filename());
- iContentPointers.push_back(retVal.first); // Save pointer for deleting it later
- i->SetContent(retVal.first, retVal.second);
- }
- }
-}
-
-
-void MifConvMifConverter::Cleanup(bool err)
-{
- CleanupTempFiles();
- if( err )
- {
- CleanupTargetFiles();
- }
-}
-
-void MifConvMifConverter::ConvertToMif()
-{
- try {
- OpenTargetFile();
- }
- catch( MifConvException& e )
- {
- // If file creation/opening was not successful, give warning and return:
- MifConvString debugStr("WARNING: Target file " + iTargetFilename + " cannot be opened for writing.");
- cout << debugStr << endl;
- MifConvUtil::DebugLog(debugStr);
- return;
- }
- WriteTargetHeader();
- WriteIconArray();
- WriteIcons();
-}
-
-void MifConvMifConverter::OpenTargetFile()
-{
- iTargetFile.open( iTargetFilename.c_str(), ios::out|ios::binary );
-
- if (!iTargetFile.is_open())
- {
- // Create path if it does not exist.
- MifConvUtil::EnsurePathExists(iTargetFilename, true);
- iTargetFile.clear();
- iTargetFile.open( iTargetFilename.c_str(), ios::out|ios::binary );
- }
- if (!iTargetFile.is_open())
- {
- THROW_ERROR_COMMON("Cannot write to file! " + iTargetFilename, MifConvString(__FILE__), __LINE__);
- }
-}
-
-void MifConvMifConverter::WriteTargetHeader()
- {
- size_t arraySize = iSourceFiles.size() * 2;
- int offset = FileHeaderSizeInBytes;
- iTargetFile.write( (char*) &KUidAvkonMultiIconFile, 4 );
- iTargetFile.write( (char*) &KFileVersion, 4 );
- iTargetFile.write( (char*) &offset, 4 );
- iTargetFile.write( (char*) &arraySize, 4 );
- }
-
-void MifConvMifConverter::CleanupTempFiles()
-{
-}
-
-void MifConvMifConverter::WriteIcons()
-{
- for( MifConvSourceFileList::iterator i = iSourceFiles.begin(); i != iSourceFiles.end(); ++i )
- {
- if( i->ContentLength() > 0 )
- {
- WriteIconHeader(*i);
- WriteIconData(*i);
- }
- }
-}
-
-MifConvDefs::IconFormatType MifConvMifConverter::ReadIconBinaryType(const MifConvSourceFile& src)
-{
- MifConvDefs::IconFormatType ret = MifConvDefs::IconFormatType_SVG;
-
- if( src.ContentLength() >= 4 )
- {
- const char* iconData = src.Content();
-
- if( iconData[0] == 'n' &&
- iconData[1] == 'v' &&
- iconData[2] == 'g' )
- {
- ret = MifConvDefs::IconFormatType_NVG;
- }
- }
-
- return ret;
-}
-
-void MifConvMifConverter::WriteIconHeader(const MifConvSourceFile& src)
-{
- int type = 0;
- if( MifConvUtil::FileExtension(src.Filename()) == BMP_FILE_EXTENSION )
- type = MifConvDefs::IconFormatType_BMP;
- else
- type = ReadIconBinaryType(src);
- //type = IconFormatType_SVG;
-
- int animated = (int) src.IsAnimated();
- int dataLen = src.ContentLength();
- int depth = src.DisplayMode();
- int mask = src.MaskDisplayMode();
- int dataoffset = IconHeaderSizeInBytes; // 8 = number of writes in this method.
-
- iTargetFile.write((char*)&KUidAvkonMultiIcon, 4); // 1
- iTargetFile.write((char*)&KIconVersion, 4); // 2
- iTargetFile.write((char*)&dataoffset, 4); // 3
- iTargetFile.write((char*)&dataLen, 4); // 4
- iTargetFile.write((char*)&type, 4); // 5
- iTargetFile.write((char*)&depth, 4); // 6
- iTargetFile.write((char*)&animated, 4); // 7
- iTargetFile.write((char*)&mask, 4); // 8
-}
-
-void MifConvMifConverter::WriteIconData(const MifConvSourceFile& src)
-{
- if( src.Content() )
- {
- iTargetFile.write(src.Content(), src.ContentLength());
- }
-}
-
-/**
-*
-*/
-void MifConvMifConverter::WriteIconArray()
-{
- int offset = (int) FileHeaderSizeInBytes + (int)iSourceFiles.size()*4*2*2;
- MifConvSourceFileList::iterator i = iSourceFiles.begin();
-
- int mbmIndex = 0;
- int zero = 0;
-
- for( ; i != iSourceFiles.end(); ++i )
- {
- // MIF icon
- if( MifConvUtil::FileExtension(i->Filename()) != BMP_FILE_EXTENSION )
- {
- int length = i->ContentLength() + IconHeaderSizeInBytes;
- iTargetFile.write( (char*) &offset, 4 );
- iTargetFile.write( (char*) &length, 4 );
- // same information for the mask...
- iTargetFile.write( (char*) &offset, 4 );
- iTargetFile.write( (char*) &length, 4 );
-
- offset += length;
- }
- // MBM icon
- else
- {
- iTargetFile.write( (char*) &mbmIndex, 4 );
- iTargetFile.write( (char*) &zero, 4 );
-
- // Masked MBM icon -> There is own MBM index for the mask.
- if(i->MaskDepth() != IconMaskDepth_Undefined )
- {
- mbmIndex--;
- }
-
- iTargetFile.write( (char*) &mbmIndex, 4 );
- iTargetFile.write( (char*) &zero, 4 );
-
- // MBM incides are coded as negative in the 'offset' field,
- // so that they can be easily separated from the actual MIF offsets.
- mbmIndex--;
- }
- }
-}
--- a/dependencies/mifconv/src/mifconv_sourcefile.cpp Sat Mar 27 01:00:02 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,179 +0,0 @@
-/*
-* Copyright (c) 2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Mifconv source file class.
-*
-*/
-
-
-#include "mifconv.h"
-#include "mifconv_sourcefile.h"
-#include "mifconv_util.h"
-#include "mifconv_exception.h"
-#include "mifconv_argument.h"
-#include "mifconv_argumentmanager.h"
-
-MifConvSourceFile::MifConvSourceFile()
-:
-iDepth(IconDepth_Undefined),
-iMaskDepth(IconMaskDepth_Undefined),
-iDisplayMode(DisplayMode_None),
-iMaskDisplayMode(DisplayMode_None),
-iAnimated(false),
-iContent(0),
-iContentLen(0)
-{
-}
-
-MifConvSourceFile::MifConvSourceFile( const MifConvSourceFile& src )
-:
-iFilename( src.Filename() ),
-iDepthString( src.DepthString() ),
-iMaskDepthString( src.MaskDepthString() ),
-iDepth(src.iDepth),
-iMaskDepth(src.iMaskDepth),
-iDisplayMode(src.iDisplayMode),
-iMaskDisplayMode(src.iMaskDisplayMode),
-iAnimated( src.IsAnimated() ),
-iMaskFilename( src.iMaskFilename ),
-iContent(src.iContent),
-iContentLen(src.iContentLen)
-{
-}
-
-MifConvSourceFile::~MifConvSourceFile()
-{}
-
-char* MifConvSourceFile::Content() const
-{
- return iContent;
-}
-
-int MifConvSourceFile::ContentLength() const
-{
- return iContentLen;
-}
-
-void MifConvSourceFile::SetContent(char* content, unsigned int len)
-{
- iContent = content;
- iContentLen = len;
-}
-
-const MifConvString& MifConvSourceFile::Filename() const
-{
- return iFilename;
-}
-
-void MifConvSourceFile::SetAnimated( bool isAnimated )
-{
- iAnimated = isAnimated;
-}
-
-void MifConvSourceFile::SetFilename( const MifConvString& filename )
-{
- iFilename = filename;
-}
-
-void MifConvSourceFile::SetDisplayMode( IconDisplayMode mode)
-{
- iDisplayMode = mode;
-}
-
-IconDisplayMode MifConvSourceFile::DisplayMode() const
-{
- return iDisplayMode;
-}
-
-void MifConvSourceFile::SetMaskDisplayMode( IconDisplayMode mode)
-{
- iMaskDisplayMode = mode;
-}
-
-IconDisplayMode MifConvSourceFile::MaskDisplayMode() const
-{
- return iMaskDisplayMode;
-}
-
-IconDepth MifConvSourceFile::Depth() const
-{
- return iDepth;
-}
-
-void MifConvSourceFile::SetDepth(IconDepth depth)
-{
- iDepth = depth;
-}
-
-const MifConvString& MifConvSourceFile::DepthString() const
-{
- return iDepthString;
-}
-
-IconMaskDepth MifConvSourceFile::MaskDepth() const
-{
- return iMaskDepth;
-}
-
-void MifConvSourceFile::SetMaskDepth(IconMaskDepth depth)
-{
- iMaskDepth = depth;
-}
-
-const MifConvString& MifConvSourceFile::MaskDepthString() const
-{
- return iMaskDepthString;
-}
-
-bool MifConvSourceFile::IsAnimated() const
-{
- return iAnimated;
-}
-
-const MifConvString& MifConvSourceFile::BmpMaskFilename() const
-{
- return iMaskFilename;
-}
-
-void MifConvSourceFile::SetBmpMaskFilename( const MifConvString& maskFilename )
-{
- iMaskFilename = maskFilename;
-}
-
-void MifConvSourceFile::SetDepthString( const MifConvString& depth )
-{
- iDepthString = depth;
-}
-
-void MifConvSourceFile::SetMaskDepthString( const MifConvString& mask )
-{
- iMaskDepthString = mask;
-}
-
-void MifConvSourceFile::SetDepthAndMask( const MifConvString& depthAndMask )
-{
- size_t separatorIndex = depthAndMask.find(",");
-
- if( separatorIndex != MifConvString::npos )
- {
- iDepthString = MifConvString(depthAndMask.begin()+1, depthAndMask.begin()+separatorIndex);
- iMaskDepthString = MifConvString(depthAndMask.begin()+separatorIndex+1, depthAndMask.end());
- iMaskDepth = MifConvArgumentManager::Instance()->ConvertToMaskDepth(iMaskDepthString);
- }
- else
- {
- iDepthString = MifConvString(depthAndMask.begin()+1, depthAndMask.end());
- }
- iDepth = MifConvArgumentManager::Instance()->ConvertToDepth(iDepthString);
-}
-
--- a/dependencies/mifconv/src/mifconv_util.cpp Sat Mar 27 01:00:02 2010 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,593 +0,0 @@
-/*
-* Copyright (c) 2009 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description: Mifconv utilities.
-*
-*/
-
-
-#include "mifconv.h"
-#include "mifconv_util.h"
-#include "mifconv_exception.h"
-#include "mifconv_argumentmanager.h"
-#include <sys/stat.h> // for stat
-#ifdef WIN32
- #include <direct.h> // for _getcwd, _chdir, _mkdir
-#else
- #include <unistd.h>
-#endif
-#include <stdlib.h> // for _MAX_PATH
-#include <stdio.h>
-
-#ifndef _MAX_PATH
-#define _MAX_PATH (260)
-#endif
-
-MifConvUtil::MifConvDebugMode MifConvUtil::iDebugMode = DebugMode_Unknown;
-MifConvString MifConvUtil::iDebugFile = "";
-MifConvString MifConvUtil::iTempDirectory = "";
-
-/**
- *
- */
-MifConvString MifConvUtil::FileExtension( const MifConvString& fileName )
-{
- size_t indexOfDot; // index of '.' character in the given string
-
- // Find last occurence of the '.' character
- if( ( indexOfDot = fileName.find_last_of('.') ) == MifConvString::npos )
- {
- // Not found, return empty string
- return MifConvString("");
- }
-
- // Return the substring starting after the '.' character
- return MifConvString( fileName.begin()+indexOfDot+1, fileName.end() );
-}
-
-/**
- *
- */
-MifConvString MifConvUtil::FilenameWithoutExtension( const MifConvString& fileName )
-{
- size_t indexOfDot; // index of '.' character in the given string
-
- // Find last occurence of the '.' character
- if( ( indexOfDot = fileName.find_last_of('.') ) == MifConvString::npos )
- {
- // Not found, return the whole name
- return fileName;
- }
-
- // Return the substring preceding the last '.' character
- return MifConvString( fileName.begin(), fileName.begin() + indexOfDot );
-}
-
-/**
- *
- */
-MifConvString MifConvUtil::FilenameWithoutPath( const MifConvString& fileName )
-{
- size_t indexOfDirSeparator; // index of directory separator in the given string
-
- // Find last occurence of the '.' character
- if( ( indexOfDirSeparator = fileName.find_last_of(DIR_SEPARATOR2) ) == MifConvString::npos )
- {
- // Not found, return the whole name
- return fileName;
- }
-
- // Return the substring beginnig after the last directory separator
- return MifConvString( fileName.begin()+indexOfDirSeparator+1, fileName.end() );
-}
-
-/**
- *
- */
-bool MifConvUtil::FileExists( const MifConvString& fileName )
-{
- struct stat fileInfo;
- int retVal = 0;
-
- // Try to get file attributes to see if the file exists or not:
- retVal = stat( fileName.c_str(), &fileInfo);
- return retVal == 0;
-}
-
-/**
- *
- */
-size_t MifConvUtil::FileSize( const MifConvString& fileName )
-{
- struct stat fileInfo;
- int retVal = 0;
-
- // Try to get file attributes to see if the file exists or not:
- retVal = stat( fileName.c_str(), &fileInfo);
- if( retVal != 0 )
- {
- THROW_ERROR_COMMON("File not found: " + fileName, MifConvString(__FILE__), __LINE__);
- }
-
- return fileInfo.st_size;
-}
-
-/**
- *
- */
-MifConvFileData MifConvUtil::FileContents( const MifConvString& fileName )
-{
- unsigned int fileLen = (unsigned int) (MifConvUtil::FileSize(fileName)/sizeof(char));
-
- ifstream fs( fileName.c_str(), FILE_IN_BINARY_NOCREATE_FLAGS );
- if (!fs.is_open())
- {
- THROW_ERROR_COMMON("Unable to open file for reading! " + fileName, MifConvString(__FILE__), __LINE__);
- }
- char* buffer = new char[fileLen];
- fs.read(buffer, fileLen);
- return MifConvFileData(buffer, fileLen);
-}
-
-/**
- *
- */
-void MifConvUtil::ReplaceChar( MifConvString& str, char replaceFrom, char replaceTo)
-{
- if( str.length() > 0 )
- {
- MifConvString::size_type index = 0;
- while( (index = str.find(replaceFrom, index)) != MifConvString::npos )
- {
- str.replace(index,1,1,replaceTo);
- }
- }
-}
-
-/**
- *
- */
-void MifConvUtil::SplitPath( const MifConvString& sourcePath, MifConvString& drive, MifConvString& path)
- {
- if( sourcePath.length() > 0 )
- {
- size_t driveSeparatorPos = sourcePath.find(':');
- if( driveSeparatorPos != MifConvString::npos )
- {
- drive = MifConvString(sourcePath.begin(), sourcePath.begin() + driveSeparatorPos );
- path = MifConvString(sourcePath.begin() + driveSeparatorPos + 1, sourcePath.end() );
- }
- else
- {
- path = sourcePath;
- }
- }
- else
- {
- drive = MifConvString("");
- path = MifConvString("");
- }
-}
-
-/**
- *
- */
-MifConvString MifConvUtil::CurrentPath()
-{
- char temp[_MAX_PATH];
-#ifdef WIN32
- _getcwd(temp, _MAX_PATH);
-#else
- getcwd(temp, _MAX_PATH);
-#endif
- return MifConvString(temp);
-}
-
-/**
- *
- */
-int MifConvUtil::CompareIgnoreCase( const MifConvString& lhs, const MifConvString& rhs )
-{
- MifConvString lhsCopy(lhs);
- MifConvString rhsCopy(rhs);
-
- return ToLower(lhsCopy).compare(ToLower(rhsCopy));
-}
-
-/**
- *
- */
-MifConvString& MifConvUtil::ToLower( MifConvString& str )
-{
- MifConvString::iterator it(str.begin());
- for(; it != str.end(); ++it)
- {
- *it = (char) tolower((unsigned char)*it);
- }
- return str;
-}
-
-/**
- *
- */
-void MifConvUtil::EnsurePathExists( const MifConvString& destFileName, bool ignoreLast )
- {
- MifConvString currentPath;
- MifConvString tmpDrive;
- MifConvString tmpPath;
-
- // Parse a drive of a destination path; if any
- SplitPath( destFileName, tmpDrive, tmpPath );
-
- // Save current directory
- currentPath = CurrentPath();
-
- // Change drive if needed:
- if( tmpDrive.length() > 0 )
- {
- tmpDrive += ":";
- tmpDrive += DIR_SEPARATOR;
- ChangeDirectory(tmpDrive);
- }
-
- // Split desination path to separate directories:
- MifConvStringList destDirList;
-
- // Check if the root is given first and add it to dir list:
- if( tmpPath.length() > 0 && tmpPath.at(0) == DIR_SEPARATOR2 )
- {
- destDirList.push_back(DIR_SEPARATOR);
- }
-
- // Add other directories to destination dir list:
- SplitString( tmpPath, DIR_SEPARATOR, destDirList );
-
- // Remove last component from the list if it should be ignored:
- if( ignoreLast )
- {
- destDirList.pop_back();
- }
-
- unsigned int i = 0;
- while( i < destDirList.size() )
- {
- const MifConvString& dir = destDirList[i++];
- if( !FileExists(dir) )
- {
- if( !CreateDirectory( dir ) )
- {
- // Change back to original directory:
- ChangeDirectory( currentPath );
- THROW_ERROR_COMMON("Directory " + tmpPath + " cannot be created", MifConvString(__FILE__), __LINE__);
- }
- }
- ChangeDirectory( dir );
- }
-
- // Change back to original directory:
- ChangeDirectory( currentPath );
-}
-
-/**
- *
- */
-void MifConvUtil::RemoveDuplicateDirSeparators( MifConvString& str )
-{
- MifConvString searchString(DIR_SEPARATOR);
- searchString += DIR_SEPARATOR;
- size_t pos = str.find(searchString);
-
- while(pos != MifConvString::npos)
- {
- str.erase(pos, 1);
- pos = str.find(searchString);
- }
-}
-
-/**
- *
- */
-bool MifConvUtil::CreateDirectory( const MifConvString& path )
-{
-#ifdef WIN32
- return _mkdir( path.c_str() ) == 0;
-#else
- return mkdir( path.c_str(), 0777 ) == 0;
-#endif
-}
-
-/**
- *
- */
-void MifConvUtil::SplitString( const MifConvString& str, const MifConvString& separator, MifConvStringList& components )
-{
- size_t beginPos = 0;
- size_t endPos = 0;
-
- while( (endPos = str.find(separator, beginPos)) != MifConvString::npos )
- {
- if( endPos - beginPos > 0 )
- {
- components.push_back( MifConvString( str.begin()+beginPos, str.begin()+endPos ) );
- }
- beginPos = endPos+1;
- }
- if( str.begin()+beginPos != str.end() )
- {
- components.push_back( MifConvString(str.begin()+beginPos, str.end()) );
- }
-}
-
-/**
- *
- */
-MifConvString MifConvUtil::UnadornedFilename( const MifConvString& filename )
-{
- MifConvStringList splitted;
- SplitString(filename, DIR_SEPARATOR, splitted);
-
- MifConvString tmp(splitted.back());
- splitted.clear();
- SplitString(tmp, INCORRECT_DIR_SEPARATOR, splitted);
-
- tmp = splitted.back();
- splitted.clear();
- SplitString(tmp, FILE_EXTENSION_SEPARATOR, splitted);
-
- MifConvString fixedname;
-
- if( splitted.size() > 0 )
- {
- fixedname = ToLower(splitted[0]);
- if( fixedname.length() > 0 )
- {
- fixedname[0] = (char) toupper( fixedname[0] );
- }
- }
- return fixedname;
-}
-
-/**
- *
- */
-void MifConvUtil::FindAndSetBitmapMaskFile( MifConvSourceFile& srcFile )
-{
- if( srcFile.MaskDepth() == IconMaskDepth_Undefined )
- {
- return; // No mask file
- }
- MifConvString fileExtension(FileExtension( srcFile.Filename() ));
-
- if( CompareIgnoreCase(fileExtension, BMP_FILE_EXTENSION) != 0 )
- {
- return;
- }
-
- MifConvString maskFilename(FilenameWithoutExtension(srcFile.Filename()));
-
- if( srcFile.MaskDepth() == IconMaskDepth_1 )
- {
- maskFilename += "_mask.bmp";
- }
- else if( srcFile.MaskDepth() == IconMaskDepth_8 )
- {
- maskFilename += "_mask_soft.bmp";
- }
- else
- {
- THROW_ERROR_COMMON("Invalid mask depth\n", MifConvString(__FILE__), __LINE__);
- }
-
- if( !FileExists(maskFilename) )
- {
- cerr << endl << "*** WARNING! Missing bitmap: " << maskFilename << endl;
- }
-
- srcFile.SetBmpMaskFilename( maskFilename );
-}
-
-/**
- *
- */
-MifConvString MifConvUtil::TemporaryFilename()
-{
- MifConvString tmp(tmpnam(NULL));
- MifConvString::iterator i = tmp.begin();
-
- if( *i == '.' )
- {
- ++i;
- }
-
- if( *i == DIR_SEPARATOR2 || *i == INCORRECT_DIR_SEPARATOR2 )
- {
- ++i;
- }
-
- return MifConvString(i, tmp.end());
-}
-
-/**
- *
- */
-bool MifConvUtil::CopyFile(const MifConvString& from, const MifConvString& to)
-{
- bool retval = false;
- ifstream in(from.c_str(), ios::binary);
- if( in )
- {
- ofstream out(to.c_str(), ios::binary);
- if( out )
- {
- out << in.rdbuf();
- retval = out.good();
- out.close();
- }
- in.close();
- }
- return retval;
-}
-
-/**
- *
- */
-bool MifConvUtil::IsWhiteSpace(char c)
-{
- return c == ' ' || c == '\n' || c == '\r' || c == '\t';
-}
-
-/**
- *
- */
-void MifConvUtil::ChangeDirectory( const MifConvString& dirName )
-{
-#ifdef WIN32
- _chdir( dirName.c_str() );
-#else
- chdir( dirName.c_str() );
-#endif
-}
-
-/**
- *
- */
-int MifConvUtil::RemoveDirectory( const MifConvString& dirName )
-{
-#ifdef WIN32
- return _rmdir( dirName.c_str() );
-#else
- return rmdir( dirName.c_str() );
-#endif
-}
-
-/**
- *
- */
-void MifConvUtil::RemoveFile( const MifConvString& fileName, int maxTries, bool noException )
-{
- for( int i = 0; i < maxTries; ++i )
- {
-#ifdef WIN32
- int ret = _unlink(fileName.c_str());
-#else
- int ret = unlink(fileName.c_str());
-#endif
-
- if( ret == 0 )
- {
- // Delete was successful
- return;
- }
-
- // Delete was not successful
- if( i >= maxTries-1 )
- {
- // Max amount of tries exceeded -> print warning or throw an exception
- if( noException )
- {
- MifConvString debugStr("WARNING: Cannot remove file " + fileName);
- DebugLog(debugStr);
- }
- else
- {
- THROW_ERROR_COMMON("Cannot remove file " + fileName, MifConvString(__FILE__), __LINE__);
- }
- }
- }
-}
-
-/**
- *
- */
-MifConvString MifConvUtil::DebugFile()
-{
- char* tmpPtr = getenv(MIFCONV_DEBUG_FILE_ENV.c_str());
- if( tmpPtr )
- {
- return MifConvString(tmpPtr);
- }
- return MifConvString();
-}
-
-/**
- *
- */
-void MifConvUtil::DebugLog(const MifConvString& debugStr)
-{
- if( iDebugMode == DebugMode_Unknown )
- {
- iDebugFile = MifConvUtil::DebugFile();
- if( iDebugFile.length() > 0 )
- {
- iDebugMode = DebugMode_Debug;
- }
- else
- {
- iDebugMode = DebugMode_NoDebug;
- }
- }
-
- if( iDebugMode == DebugMode_Debug )
- {
- ios_base::openmode file_flags;
- if( MifConvUtil::FileExists(iDebugFile) )
- {
- file_flags = ios::out|ios::app;
- }
- else
- {
- file_flags = ios::out|ios::trunc;
- }
- fstream debugLog(iDebugFile.c_str(), file_flags);
- if(debugLog.is_open())
- {
- debugLog << debugStr << endl;
- debugLog.close();
- }
- }
-}
-
-/**
- *
- */
-const MifConvString& MifConvUtil::DefaultTempDirectory()
- {
- if( iTempDirectory.length() == 0 )
- {
- char* tmpPtr = getenv(SBS_BUILD_DIR_ENV.c_str());
- if( tmpPtr && MifConvString(tmpPtr).length() > 0 )
- {
- iTempDirectory = MifConvString(tmpPtr);
-
- if( iTempDirectory.at(iTempDirectory.length()-1) != DIR_SEPARATOR2 )
- {
- iTempDirectory += DIR_SEPARATOR;
- }
-
- iTempDirectory += EPOC_ICON_BUILD_PATH_POSTFIX +
- MifConvString(DIR_SEPARATOR) +
- MifConvString("temp");
- }
- else
- {
- iTempDirectory = MifConvArgumentManager::Instance()->EpocRoot() +
- EPOC_BUILD_PATH +
- MifConvString(DIR_SEPARATOR) +
- EPOC_ICON_BUILD_PATH_POSTFIX +
- MifConvString(DIR_SEPARATOR) +
- MifConvString("temp");
- }
- }
- return iTempDirectory;
- }
-