sl@0: // Copyright (c) 1997-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: // sl@0: sl@0: /** sl@0: @file sl@0: */ sl@0: sl@0: #include sl@0: #include "FLOGSTD.H" sl@0: sl@0: sl@0: sl@0: #ifdef __WINS__ sl@0: /** sl@0: stack for file logger sl@0: sl@0: @internalComponent sl@0: */ sl@0: const TUint KFLoggerStackSize=0x3000; sl@0: sl@0: /** sl@0: min heap size for file logger sl@0: sl@0: @internalComponent sl@0: */ sl@0: const TUint KFLoggerMinHeapSize=0x1000; sl@0: sl@0: /** sl@0: define _FLOGGER_LARGE_HEAP if flogger is sl@0: running out of memory (KErrNoMemory) sl@0: */ sl@0: #ifdef _FLOGGER_LARGE_HEAP sl@0: sl@0: /** sl@0: Max heap size for file logger sl@0: sl@0: @internalComponent sl@0: */ sl@0: const TUint KFLoggerMaxHeapSize=0x100000; /// 1M sl@0: sl@0: #else sl@0: sl@0: /** sl@0: Max heap size for file logger sl@0: sl@0: @internalComponent sl@0: */ sl@0: const TUint KFLoggerMaxHeapSize=0x40000; /// 256K sl@0: sl@0: #endif // _FLOGGER_LARGE_HEAP sl@0: #endif //__WINS__ sl@0: sl@0: /** sl@0: Uid for the Flogger server sl@0: sl@0: @internalComponent sl@0: */ sl@0: const TInt KFLoggerServerUid=0x10004ee0; sl@0: sl@0: /** sl@0: Literal which contains FLOGSVR sl@0: sl@0: @internalComponent sl@0: */ sl@0: _LIT(KFLoggerServerExecutable,"FLOGSVR"); sl@0: sl@0: /** sl@0: FLogger class definition sl@0: */ sl@0: sl@0: TInt FLogger::Start() sl@0: /** sl@0: Start the FLOGGER server. sl@0: sl@0: @return KErrNone if successful sl@0: */ sl@0: { sl@0: sl@0: TRequestStatus stat; sl@0: RProcess server; sl@0: TInt ret=server.Create(KFLoggerServerExecutable,KNullDesC,TUidType(KNullUid,KNullUid,TUid::Uid(KFLoggerServerUid)),EOwnerThread); sl@0: if (ret!=KErrNone) sl@0: return ret; sl@0: server.Rendezvous(stat); sl@0: server.Resume(); sl@0: server.Close(); sl@0: User::WaitForRequest(stat); sl@0: return stat.Int(); sl@0: } sl@0: sl@0: EXPORT_C TInt FLogger::Run(FLogger::TSignal& /*aSignal*/) sl@0: /** sl@0: Instantiates Active scheduler for the asynchronous request. sl@0: sl@0: @param aSignal signal info sl@0: @return KErrNone if successful else KErrNoMemory sl@0: */ sl@0: { sl@0: sl@0: __UHEAP_MARK; sl@0: sl@0: TInt ret = KErrNone; sl@0: CTrapCleanup* cleanup=CTrapCleanup::New(); sl@0: if (cleanup==NULL) sl@0: ret=KErrNoMemory; sl@0: sl@0: if (ret==KErrNone) sl@0: ret=Init(); sl@0: sl@0: RProcess::Rendezvous(ret); sl@0: if (ret==KErrNone) sl@0: CActiveScheduler::Start(); sl@0: sl@0: delete CActiveScheduler::Current(); sl@0: delete cleanup; sl@0: sl@0: __UHEAP_MARKEND; sl@0: sl@0: return ret; sl@0: } sl@0: sl@0: TInt FLogger::Init() sl@0: /** sl@0: Initialises CFLoggerScheduler sl@0: sl@0: @return KErrNone if successful sl@0: */ sl@0: { sl@0: sl@0: TRAPD(ret,CFLoggerScheduler::NewL()); sl@0: return ret; sl@0: } sl@0: sl@0: /** sl@0: CFLoggerScheduler class definitions sl@0: */ sl@0: sl@0: void CFLoggerScheduler::NewL() sl@0: /** sl@0: Installs CActiveScheduler sl@0: */ sl@0: { sl@0: sl@0: #ifdef __WINS__ sl@0: // ensure the server thread has a handle on FLOGGER.DLL sl@0: _LIT(KFLoggerLibraryName,"FLOGGER"); sl@0: RLibrary l; sl@0: User::LeaveIfError(l.Load(KFLoggerLibraryName,KNullDesC)); sl@0: #endif sl@0: sl@0: User::LeaveIfError(RThread::RenameMe(KFLoggerServerName)); sl@0: // sl@0: CFLoggerScheduler* self=new(ELeave) CFLoggerScheduler; sl@0: CActiveScheduler::Install(self); sl@0: self->iServer=CFileLoggerServer::NewL(); sl@0: } sl@0: sl@0: CFLoggerScheduler::~CFLoggerScheduler() sl@0: /** sl@0: Destructor sl@0: */ sl@0: { sl@0: sl@0: delete iServer; sl@0: } sl@0: sl@0: void CFLoggerScheduler::Error(TInt aError) const sl@0: /** sl@0: Message servicing failed sl@0: sl@0: @param aError error value for failed message sl@0: */ sl@0: { sl@0: iServer->Error(aError); sl@0: } sl@0: