|
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 * Updates SMS events contact name to match one in contact model |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
22 #include <logengevents.h> |
|
23 #endif |
|
24 #include <logview.h> |
|
25 #include <logcli.h> |
|
26 #include "CLogsSMSEventUpdater.h" |
|
27 #include "MLogsObserver.h" |
|
28 |
|
29 // EXTERNAL DATA STRUCTURES |
|
30 |
|
31 // EXTERNAL FUNCTION PROTOTYPES |
|
32 |
|
33 // CONSTANTS |
|
34 const TInt KFieldId = 5; |
|
35 |
|
36 // MACROS |
|
37 |
|
38 // LOCAL CONSTANTS AND MACROS |
|
39 |
|
40 // MODULE DATA STRUCTURES |
|
41 |
|
42 // LOCAL FUNCTION PROTOTYPES |
|
43 |
|
44 // ==================== LOCAL FUNCTIONS ==================== |
|
45 |
|
46 // ================= MEMBER FUNCTIONS ======================= |
|
47 |
|
48 |
|
49 // ---------------------------------------------------------------------------- |
|
50 // CLogsSMSEventUpdater:: |
|
51 // ---------------------------------------------------------------------------- |
|
52 // |
|
53 CLogsSMSEventUpdater::CLogsSMSEventUpdater( |
|
54 RFs& aFsSession, |
|
55 MLogsObserver* aObserver ) : |
|
56 CLogsBaseUpdater( aFsSession, aObserver ) |
|
57 { |
|
58 } |
|
59 |
|
60 // ---------------------------------------------------------------------------- |
|
61 // CLogsSMSEventUpdater:: |
|
62 // ---------------------------------------------------------------------------- |
|
63 // |
|
64 CLogsSMSEventUpdater* CLogsSMSEventUpdater::NewL( |
|
65 RFs& aFsSession, |
|
66 MLogsObserver* aObserver, |
|
67 CVPbkPhoneNumberMatchStrategy::TVPbkPhoneNumberMatchFlags aMatchFlags ) |
|
68 { |
|
69 CLogsSMSEventUpdater* self = new ( ELeave ) CLogsSMSEventUpdater( aFsSession, aObserver ); |
|
70 CleanupStack::PushL( self ); |
|
71 self->ConstructL( aMatchFlags ); |
|
72 CleanupStack::Pop(); |
|
73 return self; |
|
74 } |
|
75 |
|
76 // ---------------------------------------------------------------------------- |
|
77 // CLogsSMSEventUpdater::ConstructL |
|
78 // ---------------------------------------------------------------------------- |
|
79 // |
|
80 void CLogsSMSEventUpdater::ConstructL( CVPbkPhoneNumberMatchStrategy::TVPbkPhoneNumberMatchFlags aMatchFlags ) |
|
81 { |
|
82 BaseConstructL( aMatchFlags ); |
|
83 iLogViewEvent = CLogViewEvent::NewL( *iLogClient, *this ); |
|
84 iFilter->SetEventType( KLogShortMessageEventTypeUid ); |
|
85 iFilter->SetFlags( KLogEventContactSearched ); |
|
86 iFilter->SetNullFields( ELogFlagsField ); |
|
87 CActiveScheduler::Add( this ); |
|
88 } |
|
89 |
|
90 // ---------------------------------------------------------------------------- |
|
91 // CLogsSMSEventUpdater::~CLogsSMSEventUpdater |
|
92 // ---------------------------------------------------------------------------- |
|
93 // |
|
94 CLogsSMSEventUpdater::~CLogsSMSEventUpdater() |
|
95 { |
|
96 } |
|
97 |
|
98 |
|
99 // ---------------------------------------------------------------------------- |
|
100 // CLogsSMSEventUpdater::StartRunningL |
|
101 // ---------------------------------------------------------------------------- |
|
102 // |
|
103 void CLogsSMSEventUpdater::StartRunningL() |
|
104 { |
|
105 Cancel(); |
|
106 |
|
107 if( iLogViewEvent->SetFilterL( *iFilter, iStatus ) ) //returns true, if found log events |
|
108 { |
|
109 iState = EStateActive; |
|
110 iPhase = EFilter; |
|
111 SetActive(); |
|
112 } |
|
113 else if( iObserver ) |
|
114 { |
|
115 iState = EStateSMSUpdaterFinished; |
|
116 iObserver->StateChangedL( this ); |
|
117 } |
|
118 } |
|
119 |
|
120 // ---------------------------------------------------------------------------- |
|
121 // CLogsSMSEventUpdater::ContinueRunningL |
|
122 // ---------------------------------------------------------------------------- |
|
123 // |
|
124 void CLogsSMSEventUpdater::ContinueRunningL( TInt aFieldId ) |
|
125 { |
|
126 if( aFieldId != KErrNotFound ) //Set remote party etc only if a contact was found |
|
127 { |
|
128 TBuf<KFieldId> fieldText; |
|
129 fieldText.Append( aFieldId ); |
|
130 iEvent->SetRemoteParty( *iName ); //iName set in the base class |
|
131 |
|
132 // iEvent->SetSubject( fieldText ); |
|
133 } |
|
134 |
|
135 //We set ContactSearched flag on, so next time we'll skip this entry and do not |
|
136 //attempt again update remote party (even if we did not find remote party for it). |
|
137 //Also, KLogEventContactSearched events only are accepted to |
|
138 //EventListView (CLogsMainReader::SetOneFilterLC). |
|
139 iEvent->SetFlags( KLogEventContactSearched ); |
|
140 iLogClient->ChangeEvent( *iEvent, iStatus ); |
|
141 SetActive(); |
|
142 } |
|
143 |
|
144 |
|
145 // ---------------------------------------------------------------------------- |
|
146 // CLogsSMSEventUpdater::RunL |
|
147 // ---------------------------------------------------------------------------- |
|
148 // |
|
149 void CLogsSMSEventUpdater::RunL() |
|
150 { |
|
151 if( iStatus == KErrNone ) |
|
152 { |
|
153 switch( iPhase ) |
|
154 { |
|
155 case EFilter: |
|
156 if( iLogViewEvent->FirstL( iStatus ) ) //If there's at least one entry in view, let's process it |
|
157 { |
|
158 iState = EStateActive; |
|
159 iPhase = ERead; |
|
160 SetActive(); |
|
161 } |
|
162 else |
|
163 { |
|
164 iState = EStateFinished; |
|
165 } |
|
166 break; |
|
167 |
|
168 case ERead: |
|
169 { |
|
170 |
|
171 iEvent->CopyL( iLogViewEvent->Event() ); |
|
172 iPhase = EUpdate; |
|
173 |
|
174 // SAT sms events are not updated since they do not have number |
|
175 SearchRemotePartyL( iEvent->Number() ); |
|
176 |
|
177 //SetActive() is called when base class has got the contact and calls ContinueRunningL |
|
178 } |
|
179 break; |
|
180 |
|
181 case EUpdate: |
|
182 if( iLogViewEvent->FirstL( iStatus ) ) //If there's still at least one entry in view, let's continue |
|
183 { //processing it (this assumes that the event updated above has |
|
184 iPhase = ERead; //has already disappeared from view and the "next" shows now as "first" |
|
185 SetActive(); //in view). |
|
186 } |
|
187 else |
|
188 { |
|
189 iState = EStateFinished; |
|
190 } |
|
191 break; |
|
192 |
|
193 default: |
|
194 break; |
|
195 } |
|
196 } |
|
197 |
|
198 if( iObserver ) //( <--not waiting here iState = EStateFinished!) |
|
199 { |
|
200 iObserver->StateChangedL( this ); //Inform for each change the observer that there's change in db (Maybe it's |
|
201 } //worthwhile to do it immediately (as here) instead of waiting iState to reach EStateFinished. |
|
202 //This way more rereads are started but we get speedier update of list too. |
|
203 //Note that change of db (above) also invokes call of HandleLogViewChangeEventAddedL (below) too. |
|
204 } |
|
205 |
|
206 |
|
207 // ---------------------------------------------------------------------------- |
|
208 // CLogsSMSEventUpdater::HandleLogViewChangeEventAddedL |
|
209 // |
|
210 // When new event added to db, we need to start checking it in case the new event |
|
211 // is messaging event (it is not shown before we update it by KLogEventContactSearched) |
|
212 // ---------------------------------------------------------------------------- |
|
213 // |
|
214 void CLogsSMSEventUpdater::HandleLogViewChangeEventAddedL( |
|
215 TLogId /*aId*/, |
|
216 TInt /*aViewIndex*/, |
|
217 TInt /*aChangeIndex*/, |
|
218 TInt aTotalChangeCount ) |
|
219 { |
|
220 if( aTotalChangeCount > 0 ) |
|
221 { |
|
222 StartL(); |
|
223 } |
|
224 } |
|
225 |
|
226 // ---------------------------------------------------------------------------- |
|
227 // CLogsSMSEventUpdater::HandleLogViewChangeEventChangedL |
|
228 // |
|
229 // is this needed (as we don't know for sure if a messaging event is eventually |
|
230 // constructed by changing the db, we cannot only trust to HandleLogViewChangeEventAddedL |
|
231 // to take care of it, so let's keep the below too just in case... |
|
232 // ---------------------------------------------------------------------------- |
|
233 // |
|
234 void CLogsSMSEventUpdater::HandleLogViewChangeEventChangedL( |
|
235 TLogId /*aId*/, |
|
236 TInt /*aViewIndex*/, |
|
237 TInt /*aChangeIndex*/, |
|
238 TInt aTotalChangeCount ) |
|
239 { |
|
240 if( aTotalChangeCount > 0 ) |
|
241 { |
|
242 StartL(); |
|
243 } |
|
244 } |
|
245 |
|
246 // ---------------------------------------------------------------------------- |
|
247 // CLogsSMSEventUpdater::HandleLogViewChangeEventDeletedL |
|
248 // |
|
249 // No need to do anything when delete notification received. |
|
250 // ---------------------------------------------------------------------------- |
|
251 // |
|
252 void CLogsSMSEventUpdater::HandleLogViewChangeEventDeletedL( |
|
253 TLogId /*aId*/, |
|
254 TInt /*aViewIndex*/, |
|
255 TInt /*aChangeIndex*/, |
|
256 TInt /*aTotalChangeCount*/ ) |
|
257 { |
|
258 } |
|
259 |
|
260 |
|
261 // End of File |