sl@0: // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). sl@0: // All rights reserved. sl@0: // This component and the accompanying materials are made available sl@0: // under the terms of "Eclipse Public License v1.0" sl@0: // which accompanies this distribution, and is available sl@0: // at the URL "http://www.eclipse.org/legal/epl-v10.html". sl@0: // sl@0: // Initial Contributors: sl@0: // Nokia Corporation - initial contribution. sl@0: // sl@0: // Contributors: sl@0: // sl@0: // Description: sl@0: // E32Main(), DoMainL() implementations sl@0: // sl@0: // sl@0: sl@0: #include sl@0: #include sl@0: #include "CentRepConvTool.h" sl@0: #include "srvres.h" sl@0: sl@0: // sl@0: // DoMainL() get command line args and pass them to CCentRepConv. sl@0: // sl@0: static void DoMainL() sl@0: { sl@0: TInt nPushed = 0; sl@0: sl@0: // create and install the active scheduler so that sl@0: // CacheManager can add itself to the scheduler. sl@0: // *** but do not CActiveScheduler::Start() *** sl@0: CActiveScheduler* s=new(ELeave) CActiveScheduler; sl@0: CleanupStack::PushL(s); sl@0: nPushed++; sl@0: CActiveScheduler::Install(s); sl@0: sl@0: TServerResources::InitialiseL(); // CentRep server static data sl@0: CleanupStack::PushL(TCleanupItem(TCleanupOperation(&TServerResources::Close), NULL)); sl@0: nPushed++; sl@0: sl@0: HBufC* cmdLine = HBufC::NewL(User::CommandLineLength()); sl@0: CleanupStack::PushL(cmdLine); sl@0: nPushed++; sl@0: sl@0: TPtr cmdLinePtr(cmdLine->Des()); sl@0: User::CommandLine(cmdLinePtr); sl@0: sl@0: CCentRepConvTool* convTool = CCentRepConvTool::NewL(*cmdLine, sl@0: TServerResources::iFs, ETrue); sl@0: CleanupStack::PushL(convTool); sl@0: nPushed++; sl@0: sl@0: convTool->ProcessCmdL(); sl@0: sl@0: CleanupStack::PopAndDestroy(nPushed); sl@0: } sl@0: sl@0: // sl@0: // The main function of CentRepConv tool which converts repository files sl@0: // from text format to binary and vice versa. sl@0: // Repositories in binary format load faster. CentRep clients are sl@0: // strongly encouraged to convert their text init files to binary sl@0: // to speed up access to their settings. sl@0: // sl@0: TInt E32Main() sl@0: { sl@0: __UHEAP_MARK; sl@0: sl@0: CTrapCleanup* trapCleanup = CTrapCleanup::New(); sl@0: __ASSERT_ALWAYS(trapCleanup != NULL, User::Invariant()); sl@0: sl@0: TRAPD(err, ::DoMainL()); sl@0: sl@0: if (err != KErrNone) sl@0: { sl@0: _LIT(KText, "CentRepConv tool failed. Error code = %d"); sl@0: RDebug::Print(KText, err); sl@0: } sl@0: sl@0: delete trapCleanup; sl@0: sl@0: __UHEAP_MARKEND; sl@0: sl@0: return err; sl@0: }