|
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 * This class communicates with the log db. This also handles all the |
|
16 * filtering options and registers Mce to LogEng to get notidied about |
|
17 * changes in log DB. |
|
18 * |
|
19 */ |
|
20 |
|
21 |
|
22 |
|
23 // INCLUDE FILES |
|
24 #include <e32base.h> |
|
25 |
|
26 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
27 #include "logeng.h" // for Event Type enumerations |
|
28 #else |
|
29 #include "logeng.h" // for event type enumerations |
|
30 #include "logsmspdudata.h" // for event type enumerations |
|
31 #endif |
|
32 #include "MceLogEngine.h" |
|
33 #include "MceLogEngineReader.h" |
|
34 #include "MceLogPbkMatcher.h" |
|
35 #include "MMceLogEngObserver.h" |
|
36 |
|
37 // LOCAL CONSTANTS AND MACROS |
|
38 _LIT( KPrivateNumber, "Private"); |
|
39 |
|
40 // LOCAL FUNCTIONS |
|
41 |
|
42 |
|
43 // ================= MEMBER FUNCTIONS ======================= |
|
44 |
|
45 CMceLogEngine::CMceLogEngine() : |
|
46 iForeground( ETrue ), // at foreground |
|
47 iDbDirty( EFalse ) // db is "clean" |
|
48 { |
|
49 } |
|
50 |
|
51 EXPORT_C CMceLogEngine* CMceLogEngine::NewL() |
|
52 { |
|
53 CMceLogEngine* self = new(ELeave) CMceLogEngine(); |
|
54 CleanupStack::PushL(self); |
|
55 self->ConstructL(); |
|
56 CleanupStack::Pop(); |
|
57 return self; |
|
58 } |
|
59 |
|
60 CMceLogEngine::~CMceLogEngine() |
|
61 { |
|
62 if (iEventArray) |
|
63 { |
|
64 iEventArray->ResetAndDestroy(); |
|
65 delete iEventArray; |
|
66 } |
|
67 delete iEngineReader; |
|
68 delete iLogClient; |
|
69 delete iPbkMatcher; |
|
70 iFsSession.Close(); |
|
71 } |
|
72 |
|
73 |
|
74 void CMceLogEngine::ConstructL() |
|
75 { |
|
76 User::LeaveIfError(iFsSession.Connect()); |
|
77 iEventArray = new (ELeave) CArrayPtrFlat<CLogEvent>(1); |
|
78 iLogClient = CLogClient::NewL(iFsSession); |
|
79 } |
|
80 |
|
81 EXPORT_C const CLogEvent* CMceLogEngine::Event( TInt aIndex ) |
|
82 { |
|
83 return iEventArray->At(aIndex); |
|
84 } |
|
85 |
|
86 EXPORT_C TInt CMceLogEngine::Count() const |
|
87 { |
|
88 return iEventArray->Count(); |
|
89 } |
|
90 |
|
91 void CMceLogEngine::ReadEventsCompletedL( TBool aStatus ) |
|
92 { |
|
93 if ( ! aStatus ) |
|
94 { |
|
95 ResetArray(); |
|
96 } |
|
97 |
|
98 if( iContainerObserver ) |
|
99 { |
|
100 iContainerObserver->MceLogEngineListBoxStateHasChangedL(); |
|
101 } |
|
102 } |
|
103 |
|
104 void CMceLogEngine::ResetArray() |
|
105 { |
|
106 if( iEventArray ) |
|
107 { |
|
108 iEventArray->ResetAndDestroy(); |
|
109 } |
|
110 } |
|
111 |
|
112 void CMceLogEngine::UpdateEventsL() |
|
113 { |
|
114 if (iEngineReader) |
|
115 { |
|
116 iEngineReader->Cancel(); |
|
117 } |
|
118 else |
|
119 { |
|
120 iEngineReader = CMceLogEngineReader::NewL(this); |
|
121 } |
|
122 |
|
123 iEngineReader->StartReadingL(); |
|
124 } |
|
125 |
|
126 void CMceLogEngine::AddEventToListL( CLogEvent* aEvent ) |
|
127 { |
|
128 iEventArray->AppendL( aEvent ); |
|
129 } |
|
130 |
|
131 |
|
132 EXPORT_C void CMceLogEngine::SetContainerObserver( MMceLogEngObserver* aContainerObserver ) |
|
133 { |
|
134 iContainerObserver = aContainerObserver; |
|
135 } |
|
136 |
|
137 |
|
138 EXPORT_C void CMceLogEngine::RemoveContainerObserver() |
|
139 { |
|
140 iContainerObserver = NULL; |
|
141 } |
|
142 |
|
143 |
|
144 EXPORT_C TInt CMceLogEngine::PurgeData( const CLogEvent* aEvent, CArrayFixFlat<TInt>* aData ) |
|
145 { |
|
146 TPckgBuf<TLogSmsPduData> packedData; |
|
147 TInt sMsTotal( 0 ); |
|
148 TInt sMsPending( 0 ); |
|
149 |
|
150 if( aEvent->EventType() == ( KLogsEngMmsEventTypeUid )) |
|
151 { |
|
152 return sMsTotal; |
|
153 } |
|
154 |
|
155 packedData.Copy( aEvent->Data().Ptr(), sizeof( TLogSmsPduData ) ); |
|
156 if( aEvent->Data().Length() > 0 ) |
|
157 { |
|
158 sMsTotal = packedData().iTotal; |
|
159 sMsPending = sMsTotal |
|
160 - packedData().iDelivered |
|
161 - packedData().iFailed; |
|
162 aData->At( 0 ) = sMsPending; |
|
163 aData->At( 1 ) = sMsTotal; |
|
164 } |
|
165 |
|
166 return sMsTotal; |
|
167 } |
|
168 |
|
169 EXPORT_C void CMceLogEngine::GetStandardStrings( TDes& aFailed, TDes& aPending ) |
|
170 { |
|
171 iLogClient->GetString( aPending, R_LOG_DEL_PENDING ); |
|
172 iLogClient->GetString( aFailed, R_LOG_DEL_FAILED ); |
|
173 } |
|
174 |
|
175 EXPORT_C TBool CMceLogEngine::IsNumberAvailable( TInt aIndex ) |
|
176 { |
|
177 if( Count() == 0 ) |
|
178 { |
|
179 return EFalse; |
|
180 } |
|
181 |
|
182 if( Event( aIndex )->Number().Size() == 0 ) |
|
183 { |
|
184 return EFalse; |
|
185 } |
|
186 |
|
187 if( Event( aIndex )->RemoteParty() == KPrivateNumber ) |
|
188 { |
|
189 return EFalse; |
|
190 } |
|
191 |
|
192 return ETrue; |
|
193 } |
|
194 |
|
195 |
|
196 EXPORT_C void CMceLogEngine::ForegroundGainedL() |
|
197 { |
|
198 UpdateEventsL(); |
|
199 if( !iPbkMatcher ) |
|
200 { |
|
201 iPbkMatcher = CMceLogPbkMatcher::NewL( iFsSession, this ); |
|
202 } |
|
203 iPbkMatcher->StartL(); |
|
204 } |
|
205 |
|
206 |
|
207 EXPORT_C void CMceLogEngine::ForegroundLost() |
|
208 { |
|
209 } |
|
210 |
|
211 void CMceLogEngine::PbkMatchingDoneL() |
|
212 { |
|
213 } |
|
214 |
|
215 EXPORT_C void CMceLogEngine::ClearDrListL() |
|
216 { |
|
217 ResetArray(); |
|
218 |
|
219 if( !iEngineReader ) |
|
220 { |
|
221 iEngineReader = CMceLogEngineReader::NewL(this); |
|
222 } |
|
223 iEngineReader->ClearDrListL(); |
|
224 |
|
225 if( iContainerObserver ) |
|
226 { |
|
227 iContainerObserver->MceLogEngineListBoxStateHasChangedL(); |
|
228 } |
|
229 } |
|
230 |
|
231 // End of file |