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