|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * Log configuration setter / getter |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CLogsConfig.h" |
|
22 #include "MLogsObserver.h" |
|
23 #include "LogsUID.h" |
|
24 |
|
25 #include "LogsDebug.h" |
|
26 #include "LogsTraces.h" |
|
27 |
|
28 // CONSTANTS |
|
29 const TInt KBytesToRequest ( 64 * 1024 ); |
|
30 |
|
31 // ---------------------------------------------------------------------------- |
|
32 // CLogsConfig::NewL |
|
33 // ---------------------------------------------------------------------------- |
|
34 // |
|
35 CLogsConfig* CLogsConfig::NewL( |
|
36 RFs& aFsSession, |
|
37 MLogsObserver* aObserver ) |
|
38 { |
|
39 TRACE_ENTRY_POINT; |
|
40 CLogsConfig* self = new (ELeave) CLogsConfig( aFsSession, aObserver ); |
|
41 CleanupStack::PushL( self ); |
|
42 self->ConstructL(); |
|
43 CleanupStack::Pop(); |
|
44 |
|
45 TRACE_EXIT_POINT; |
|
46 return self; |
|
47 } |
|
48 |
|
49 // ---------------------------------------------------------------------------- |
|
50 // CLogsConfig::CLogsConfig |
|
51 // ---------------------------------------------------------------------------- |
|
52 // |
|
53 CLogsConfig::CLogsConfig( |
|
54 RFs& aFsSession, |
|
55 MLogsObserver* aObserver ) : |
|
56 CActive( EPriorityStandard ), |
|
57 iFsSession( aFsSession ), |
|
58 iObserver( aObserver ), |
|
59 iState( EStateUndefined ) |
|
60 { |
|
61 TRACE_ENTRY_POINT; |
|
62 TRACE_EXIT_POINT; |
|
63 } |
|
64 |
|
65 // ---------------------------------------------------------------------------- |
|
66 // CLogsConfig::~CLogsConfig |
|
67 // ---------------------------------------------------------------------------- |
|
68 // |
|
69 CLogsConfig::~CLogsConfig() |
|
70 { |
|
71 TRACE_ENTRY_POINT; |
|
72 Cancel(); |
|
73 delete iLogClient; |
|
74 TRACE_EXIT_POINT; |
|
75 } |
|
76 |
|
77 // ---------------------------------------------------------------------------- |
|
78 // CLogsConfig::DoCancel |
|
79 // ---------------------------------------------------------------------------- |
|
80 // |
|
81 void CLogsConfig::DoCancel() |
|
82 { |
|
83 TRACE_ENTRY_POINT; |
|
84 iFsSession.ReleaseReserveAccess( EDriveC ); |
|
85 iLogClient->Cancel(); |
|
86 TRACE_EXIT_POINT; |
|
87 } |
|
88 |
|
89 // ---------------------------------------------------------------------------- |
|
90 // CLogsConfig::ConstructL |
|
91 // ---------------------------------------------------------------------------- |
|
92 // |
|
93 void CLogsConfig::ConstructL() |
|
94 { |
|
95 TRACE_ENTRY_POINT; |
|
96 iLogClient = CLogClient::NewL( iFsSession ); |
|
97 CActiveScheduler::Add( this ); |
|
98 TRACE_EXIT_POINT; |
|
99 } |
|
100 |
|
101 // ---------------------------------------------------------------------------- |
|
102 // CLogsConfig::RunL |
|
103 // ---------------------------------------------------------------------------- |
|
104 // |
|
105 void CLogsConfig::RunL() |
|
106 { |
|
107 TRACE_ENTRY_POINT; |
|
108 iFsSession.ReleaseReserveAccess( EDriveC ); |
|
109 |
|
110 if( iObserver ) |
|
111 { |
|
112 iState = EStateFinished; |
|
113 iObserver->StateChangedL( this ); |
|
114 } |
|
115 TRACE_EXIT_POINT; |
|
116 } |
|
117 |
|
118 // ---------------------------------------------------------------------------- |
|
119 // CLogsConfig::RunError |
|
120 // ---------------------------------------------------------------------------- |
|
121 // |
|
122 TInt CLogsConfig::RunError(TInt aError) |
|
123 { |
|
124 TRACE_ENTRY_POINT; |
|
125 if( aError == KErrAccessDenied ) |
|
126 { |
|
127 TRACE_EXIT_POINT; |
|
128 return KErrNone; |
|
129 } |
|
130 else |
|
131 { |
|
132 TRACE_EXIT_POINT; |
|
133 return aError; |
|
134 } |
|
135 } |
|
136 |
|
137 // ---------------------------------------------------------------------------- |
|
138 // CLogsConfig::SetConfig |
|
139 // ---------------------------------------------------------------------------- |
|
140 // |
|
141 void CLogsConfig::SetConfig( const TLogConfig& aConfig ) |
|
142 { |
|
143 TRACE_ENTRY_POINT; |
|
144 if (!IsActive()) |
|
145 { |
|
146 iFsSession.ReserveDriveSpace( EDriveC, KBytesToRequest ); |
|
147 iFsSession.GetReserveAccess( EDriveC ); |
|
148 |
|
149 iLogClient->ChangeConfig( aConfig, iStatus ); |
|
150 SetActive(); |
|
151 } |
|
152 TRACE_EXIT_POINT; |
|
153 } |
|
154 |
|
155 // ---------------------------------------------------------------------------- |
|
156 // CLogsConfig::GetConfig |
|
157 // ---------------------------------------------------------------------------- |
|
158 // |
|
159 void CLogsConfig::GetConfig( TLogConfig& aConfig ) |
|
160 { |
|
161 TRACE_ENTRY_POINT; |
|
162 if (!IsActive()) |
|
163 { |
|
164 iState = EStateInitializing; |
|
165 iLogClient->GetConfig( aConfig, iStatus ); |
|
166 SetActive(); |
|
167 } |
|
168 TRACE_EXIT_POINT; |
|
169 } |
|
170 |
|
171 // ---------------------------------------------------------------------------- |
|
172 // CLogsConfig::SetObserver |
|
173 // ---------------------------------------------------------------------------- |
|
174 // |
|
175 void CLogsConfig::SetObserver( MLogsObserver* aObserver ) |
|
176 { |
|
177 TRACE_ENTRY_POINT; |
|
178 iObserver = aObserver; |
|
179 TRACE_EXIT_POINT; |
|
180 } |
|
181 |
|
182 // ---------------------------------------------------------------------------- |
|
183 // CLogsConfig::State |
|
184 // ---------------------------------------------------------------------------- |
|
185 // |
|
186 TLogsState CLogsConfig::State() const |
|
187 { |
|
188 TRACE_ENTRY_POINT; |
|
189 TRACE_EXIT_POINT; |
|
190 return iState; |
|
191 } |