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