|
1 // Copyright (c) 2002-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 #include "LogViewWindowChangeObserver.h" |
|
17 |
|
18 // Constants |
|
19 const TInt KLogViewIgnoreStackGranularity = 3; |
|
20 |
|
21 |
|
22 ///////////////////////////////////////////////////////////////////////////////////////// |
|
23 // -----> CLogViewWindowChangeObserver (source) |
|
24 ///////////////////////////////////////////////////////////////////////////////////////// |
|
25 |
|
26 CLogViewWindowChangeObserver::CLogViewWindowChangeObserver(MLogViewChangeObserverInternal& aObserver) |
|
27 : iObserver(aObserver), iIgnoreStack(KLogViewIgnoreStackGranularity) |
|
28 { |
|
29 } |
|
30 |
|
31 CLogViewWindowChangeObserver::~CLogViewWindowChangeObserver() |
|
32 { |
|
33 iIgnoreStack.Close(); |
|
34 } |
|
35 |
|
36 ///////////////////////////////////////////////////////////////////////////////////////// |
|
37 ///////////////////////////////////////////////////////////////////////////////////////// |
|
38 ///////////////////////////////////////////////////////////////////////////////////////// |
|
39 |
|
40 void CLogViewWindowChangeObserver::IgnoreNextEventL(TLogId aId, TType aType) |
|
41 { |
|
42 TIgnoreEvent event(aId, aType); |
|
43 User::LeaveIfError(iIgnoreStack.Append(event)); |
|
44 } |
|
45 |
|
46 ///////////////////////////////////////////////////////////////////////////////////////// |
|
47 ///////////////////////////////////////////////////////////////////////////////////////// |
|
48 ///////////////////////////////////////////////////////////////////////////////////////// |
|
49 |
|
50 void CLogViewWindowChangeObserver::HandleLogViewChangeEventAddedL(TLogId aId, TInt aViewIndex, TInt aChangeIndex, TInt aTotalChangeCount) |
|
51 { |
|
52 const TInt index = Find(aId, ELogEventTypeAdd); |
|
53 if (index == KErrNotFound) |
|
54 iObserver.HandleLogViewChangeEventAddedL(aId, aViewIndex, aChangeIndex, aTotalChangeCount); |
|
55 else |
|
56 iIgnoreStack.Remove(index); |
|
57 } |
|
58 |
|
59 void CLogViewWindowChangeObserver::HandleLogViewChangeEventChangedL(TLogId aId, TInt aViewIndex, TInt aChangeIndex, TInt aTotalChangeCount) |
|
60 { |
|
61 const TInt index = Find(aId, ELogEventTypeChange); |
|
62 if (index == KErrNotFound) |
|
63 iObserver.HandleLogViewChangeEventChangedL(aId, aViewIndex, aChangeIndex, aTotalChangeCount); |
|
64 else |
|
65 iIgnoreStack.Remove(index); |
|
66 } |
|
67 |
|
68 void CLogViewWindowChangeObserver::HandleLogViewChangeEventDeletedL(TLogId aId, TInt aViewIndex, TInt aChangeIndex, TInt aTotalChangeCount) |
|
69 { |
|
70 const TInt index = Find(aId, ELogEventTypeDelete); |
|
71 if (index == KErrNotFound) |
|
72 iObserver.HandleLogViewChangeEventDeletedL(aId, aViewIndex, aChangeIndex, aTotalChangeCount); |
|
73 else |
|
74 iIgnoreStack.Remove(index); |
|
75 } |
|
76 |
|
77 ///////////////////////////////////////////////////////////////////////////////////////// |
|
78 ///////////////////////////////////////////////////////////////////////////////////////// |
|
79 ///////////////////////////////////////////////////////////////////////////////////////// |
|
80 |
|
81 void CLogViewWindowChangeObserver::HandleLogViewChangeEventLogClearedL() |
|
82 { |
|
83 iObserver.HandleLogViewChangeEventLogClearedL(); |
|
84 } |
|
85 |
|
86 ///////////////////////////////////////////////////////////////////////////////////////// |
|
87 ///////////////////////////////////////////////////////////////////////////////////////// |
|
88 ///////////////////////////////////////////////////////////////////////////////////////// |
|
89 |
|
90 TInt CLogViewWindowChangeObserver::Find(TLogId aId, TType aType) const |
|
91 { |
|
92 const TInt count = iIgnoreStack.Count(); |
|
93 for(TInt i=0; i<count; i++) |
|
94 { |
|
95 const TIgnoreEvent& event = iIgnoreStack[i]; |
|
96 if (event.iId == aId && event.iType == aType) |
|
97 return i; |
|
98 } |
|
99 return KErrNotFound; |
|
100 } |