persistentstorage/centralrepository/convtool/src/main.cpp
changeset 0 08ec8eefde2f
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // E32Main(), DoMainL() implementations
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <e32std.h>
       
    19 #include <e32debug.h>
       
    20 #include "CentRepConvTool.h"
       
    21 #include "srvres.h"
       
    22 
       
    23 //
       
    24 // DoMainL() get command line args and pass them to CCentRepConv.
       
    25 //
       
    26 static void DoMainL()
       
    27 	{
       
    28 	TInt nPushed = 0;
       
    29 
       
    30 	// create and install the active scheduler so that 
       
    31 	// CacheManager can add itself to the scheduler.
       
    32 	// *** but do not CActiveScheduler::Start() ***
       
    33 	CActiveScheduler* s=new(ELeave) CActiveScheduler;
       
    34 	CleanupStack::PushL(s);
       
    35 	nPushed++;
       
    36 	CActiveScheduler::Install(s);
       
    37 
       
    38 	TServerResources::InitialiseL(); // CentRep server static data
       
    39 	CleanupStack::PushL(TCleanupItem(TCleanupOperation(&TServerResources::Close), NULL));
       
    40 	nPushed++;
       
    41 
       
    42 	HBufC* cmdLine = HBufC::NewL(User::CommandLineLength());
       
    43 	CleanupStack::PushL(cmdLine);
       
    44 	nPushed++;
       
    45 
       
    46 	TPtr cmdLinePtr(cmdLine->Des());
       
    47 	User::CommandLine(cmdLinePtr);
       
    48 
       
    49 	CCentRepConvTool* convTool = CCentRepConvTool::NewL(*cmdLine,
       
    50 		TServerResources::iFs, ETrue);
       
    51 	CleanupStack::PushL(convTool);
       
    52 	nPushed++;
       
    53 
       
    54 	convTool->ProcessCmdL();
       
    55 
       
    56 	CleanupStack::PopAndDestroy(nPushed);
       
    57 	}
       
    58 
       
    59 //
       
    60 // The main function of CentRepConv tool which converts repository files
       
    61 // from text format to binary and vice versa.
       
    62 // Repositories in binary format load faster. CentRep clients are
       
    63 // strongly encouraged to convert their text init files to binary
       
    64 // to speed up access to their settings.
       
    65 //
       
    66 TInt E32Main()
       
    67 	{
       
    68 	__UHEAP_MARK;
       
    69 
       
    70 	CTrapCleanup* trapCleanup = CTrapCleanup::New();
       
    71 	__ASSERT_ALWAYS(trapCleanup != NULL, User::Invariant());
       
    72 	
       
    73 	TRAPD(err, ::DoMainL());
       
    74 
       
    75 	if (err != KErrNone)
       
    76 		{
       
    77 		_LIT(KText, "CentRepConv tool failed. Error code = %d");
       
    78 		RDebug::Print(KText, err);
       
    79 		}
       
    80 
       
    81 	delete trapCleanup;
       
    82 
       
    83 	__UHEAP_MARKEND;
       
    84 
       
    85 	return err;
       
    86     }