loggingservices/filelogger/SSVR/FLOGTHRD.CPP
changeset 0 08ec8eefde2f
equal deleted inserted replaced
-1:000000000000 0:08ec8eefde2f
       
     1 // Copyright (c) 1997-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 //
       
    15 
       
    16 /**
       
    17  @file
       
    18 */
       
    19 
       
    20 #include <flogger.h>
       
    21 #include "FLOGSTD.H"
       
    22 
       
    23 
       
    24 
       
    25 #ifdef __WINS__
       
    26 /**
       
    27 stack for file logger
       
    28 
       
    29 @internalComponent
       
    30 */
       
    31 const TUint KFLoggerStackSize=0x3000;
       
    32 
       
    33 /**
       
    34 min heap size for file logger
       
    35 
       
    36 @internalComponent
       
    37 */
       
    38 const TUint KFLoggerMinHeapSize=0x1000;
       
    39 
       
    40 /** 
       
    41 define _FLOGGER_LARGE_HEAP if flogger is 
       
    42 running out of memory (KErrNoMemory)
       
    43 */
       
    44 #ifdef _FLOGGER_LARGE_HEAP
       
    45 
       
    46 	/**
       
    47 	Max heap size for file logger
       
    48 
       
    49 	@internalComponent
       
    50 	*/
       
    51 	const TUint KFLoggerMaxHeapSize=0x100000;	/// 1M
       
    52 
       
    53 #else
       
    54 
       
    55 	/**
       
    56 	Max heap size for file logger
       
    57 
       
    58 	@internalComponent
       
    59 	*/
       
    60 	const TUint KFLoggerMaxHeapSize=0x40000;	/// 256K
       
    61 
       
    62 #endif // _FLOGGER_LARGE_HEAP
       
    63 #endif  //__WINS__
       
    64 
       
    65 /** 
       
    66 Uid for the Flogger server
       
    67 
       
    68 @internalComponent
       
    69 */
       
    70 const TInt KFLoggerServerUid=0x10004ee0;
       
    71 
       
    72 /**
       
    73 Literal which contains FLOGSVR
       
    74 
       
    75 @internalComponent
       
    76 */
       
    77 _LIT(KFLoggerServerExecutable,"FLOGSVR");
       
    78 
       
    79 /**
       
    80 FLogger class definition
       
    81 */
       
    82 
       
    83 TInt FLogger::Start()
       
    84 /**
       
    85 Start the FLOGGER server.
       
    86 
       
    87 @return KErrNone if successful 
       
    88 */
       
    89 	{
       
    90 
       
    91 	TRequestStatus stat;
       
    92 	RProcess server;
       
    93 	TInt ret=server.Create(KFLoggerServerExecutable,KNullDesC,TUidType(KNullUid,KNullUid,TUid::Uid(KFLoggerServerUid)),EOwnerThread);
       
    94 	if (ret!=KErrNone)
       
    95 		return ret;
       
    96 	server.Rendezvous(stat);
       
    97 	server.Resume();
       
    98 	server.Close();
       
    99 	User::WaitForRequest(stat);
       
   100 	return stat.Int();
       
   101 	}
       
   102 
       
   103 EXPORT_C TInt FLogger::Run(FLogger::TSignal& /*aSignal*/)
       
   104 /**
       
   105 Instantiates Active scheduler for the asynchronous request.
       
   106 
       
   107 @param aSignal signal info
       
   108 @return KErrNone if successful else KErrNoMemory
       
   109 */
       
   110 	{
       
   111 
       
   112 	__UHEAP_MARK;
       
   113 	
       
   114 	TInt ret = KErrNone;
       
   115 	CTrapCleanup* cleanup=CTrapCleanup::New();
       
   116 	if (cleanup==NULL)
       
   117 		ret=KErrNoMemory;
       
   118 
       
   119 	if (ret==KErrNone)
       
   120 		ret=Init();
       
   121 
       
   122 	RProcess::Rendezvous(ret);
       
   123 	if (ret==KErrNone)
       
   124 		CActiveScheduler::Start();
       
   125 
       
   126 	delete CActiveScheduler::Current();
       
   127 	delete cleanup;
       
   128 	
       
   129 	__UHEAP_MARKEND;
       
   130 
       
   131 	return ret;
       
   132 	}
       
   133 
       
   134 TInt FLogger::Init()
       
   135 /**
       
   136 Initialises CFLoggerScheduler
       
   137 
       
   138 @return KErrNone if successful
       
   139 */
       
   140 	{
       
   141 
       
   142 	TRAPD(ret,CFLoggerScheduler::NewL());
       
   143 	return ret;
       
   144 	}
       
   145 
       
   146 /**
       
   147 CFLoggerScheduler class definitions
       
   148 */
       
   149 
       
   150 void CFLoggerScheduler::NewL()
       
   151 /**
       
   152 Installs CActiveScheduler
       
   153 */
       
   154 	{
       
   155 
       
   156 #ifdef __WINS__
       
   157 // ensure the server thread has a handle on FLOGGER.DLL
       
   158 	_LIT(KFLoggerLibraryName,"FLOGGER");
       
   159 	RLibrary l;
       
   160 	User::LeaveIfError(l.Load(KFLoggerLibraryName,KNullDesC));
       
   161 #endif
       
   162 
       
   163 	User::LeaveIfError(RThread::RenameMe(KFLoggerServerName));
       
   164 //
       
   165 	CFLoggerScheduler* self=new(ELeave) CFLoggerScheduler;
       
   166 	CActiveScheduler::Install(self);
       
   167 	self->iServer=CFileLoggerServer::NewL();
       
   168 	}
       
   169 
       
   170 CFLoggerScheduler::~CFLoggerScheduler()
       
   171 /**
       
   172 Destructor
       
   173 */
       
   174 	{
       
   175 
       
   176 	delete iServer;
       
   177 	}
       
   178 
       
   179 void CFLoggerScheduler::Error(TInt aError) const
       
   180 /**
       
   181 Message servicing failed
       
   182 
       
   183 @param aError error value for failed message
       
   184 */
       
   185 	{
       
   186 	iServer->Error(aError);
       
   187 	}
       
   188