|
1 // Copyright (c) 2006-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 "pbapserver.h" |
|
17 #include "pbapchview.h" |
|
18 |
|
19 #include "btaccesshostlog.h" |
|
20 |
|
21 // |
|
22 // CPbapChView |
|
23 // |
|
24 /*static*/ CPbapChView* CPbapChView::NewL(CPbapLogWrapper& aLogClient, |
|
25 CFolderNodeCallHistory::THistoryType aHistoryType, |
|
26 MPbapChViewObserver& aObserver, |
|
27 TLogFlags aFlags) |
|
28 { |
|
29 LOG_STATIC_FUNC |
|
30 CPbapChView* self = new(ELeave) CPbapChView(aLogClient, aObserver); |
|
31 CleanupStack::PushL(self); |
|
32 self->ConstructL(aHistoryType, aFlags); |
|
33 CleanupStack::Pop(self); |
|
34 return self; |
|
35 } |
|
36 |
|
37 CPbapChView::CPbapChView(CPbapLogWrapper& aLogClient, MPbapChViewObserver& aObserver) |
|
38 : CActive(EPriorityStandard), iLogClient(aLogClient), iObserver(aObserver) |
|
39 { |
|
40 LOG_FUNC |
|
41 CActiveScheduler::Add(this); |
|
42 } |
|
43 |
|
44 void CPbapChView::ConstructL(CFolderNodeCallHistory::THistoryType aHistoryType, |
|
45 TLogFlags aFlags) |
|
46 { |
|
47 LOG_FUNC |
|
48 |
|
49 // create log view |
|
50 iLogView = CPbapLogViewEvent::NewL(iLogClient, *this); |
|
51 |
|
52 // create filter |
|
53 iLogFilterList = new(ELeave) CLogFilterList; |
|
54 CLogFilter* filter; |
|
55 |
|
56 if (aHistoryType == CFolderNodeCallHistory::ECombined) |
|
57 { |
|
58 // add all directions to filter list |
|
59 filter = CreateDirectionFilterLC(CFolderNodeCallHistory::EIncoming, aFlags); |
|
60 iLogFilterList->AppendL(filter); |
|
61 CleanupStack::Pop(filter); // ownership passed |
|
62 |
|
63 filter = CreateDirectionFilterLC(CFolderNodeCallHistory::EOutgoing, aFlags); |
|
64 iLogFilterList->AppendL(filter); |
|
65 CleanupStack::Pop(filter); // ownership passed |
|
66 |
|
67 filter = CreateDirectionFilterLC(CFolderNodeCallHistory::EMissed, aFlags); |
|
68 iLogFilterList->AppendL(filter); |
|
69 CleanupStack::Pop(filter); // ownership passed |
|
70 } |
|
71 else |
|
72 { |
|
73 // add direction to filter list |
|
74 filter = CreateDirectionFilterLC(aHistoryType, aFlags); |
|
75 iLogFilterList->AppendL(filter); |
|
76 CleanupStack::Pop(filter); // ownership passed |
|
77 } |
|
78 |
|
79 // filter the view asynchronously |
|
80 if (!iLogView->SetFilterL(*iLogFilterList, iStatus)) |
|
81 { |
|
82 // no events in view so async request was not issued, just complete |
|
83 // ourselves instead |
|
84 TRequestStatus* status=&iStatus; |
|
85 User::RequestComplete(status, KErrNone); |
|
86 |
|
87 // if no events then the view is not completely initialised, e.g. if |
|
88 // a new event is added to the view it is not included in the view |
|
89 // until SetFilterL is called again and completes asynchronously |
|
90 iRefreshView = ETrue; |
|
91 } |
|
92 |
|
93 SetActive(); |
|
94 } |
|
95 |
|
96 CPbapChView::~CPbapChView() |
|
97 { |
|
98 LOG_FUNC |
|
99 |
|
100 Cancel(); |
|
101 |
|
102 if (iLogFilterList) |
|
103 { |
|
104 iLogFilterList->ResetAndDestroy(); |
|
105 } |
|
106 delete iLogFilterList; |
|
107 delete iLogView; |
|
108 } |
|
109 |
|
110 void CPbapChView::RunL() |
|
111 { |
|
112 LOG_FUNC |
|
113 |
|
114 // Call History view is now ready |
|
115 iObserver.CallHistoryViewReady(iStatus.Int()); |
|
116 } |
|
117 |
|
118 void CPbapChView::DoCancel() |
|
119 { |
|
120 LOG_FUNC |
|
121 |
|
122 iLogView->Cancel(); |
|
123 } |
|
124 |
|
125 CLogFilter* CPbapChView::CreateDirectionFilterLC(CFolderNodeCallHistory::THistoryType aHistoryType, TLogFlags aFlags) |
|
126 { |
|
127 LOG_FUNC |
|
128 |
|
129 TLogString direction; |
|
130 switch (aHistoryType) |
|
131 { |
|
132 case CFolderNodeCallHistory::EIncoming: |
|
133 User::LeaveIfError(iLogClient.GetString(direction, R_LOG_DIR_IN)); |
|
134 break; |
|
135 case CFolderNodeCallHistory::EOutgoing: |
|
136 User::LeaveIfError(iLogClient.GetString(direction, R_LOG_DIR_OUT)); |
|
137 break; |
|
138 case CFolderNodeCallHistory::EMissed: |
|
139 User::LeaveIfError(iLogClient.GetString(direction, R_LOG_DIR_MISSED)); |
|
140 break; |
|
141 default: |
|
142 break; |
|
143 } |
|
144 |
|
145 CLogFilter* filter = CLogFilter::NewL(); |
|
146 CleanupStack::PushL(filter); |
|
147 filter->SetEventType(KLogCallEventTypeUid); |
|
148 filter->SetDirection(direction); |
|
149 |
|
150 if (aFlags != KLogNullFlags) |
|
151 { |
|
152 filter->SetFlags(aFlags); |
|
153 } |
|
154 return filter; // ownership transferred |
|
155 } |
|
156 |
|
157 CPbapLogViewEvent* CPbapChView::LogView() |
|
158 { |
|
159 LOG_FUNC |
|
160 return iLogView; |
|
161 } |
|
162 |
|
163 // from MPbapLogEngViewObserver |
|
164 void CPbapChView::PbapLogEngViewChangeEventAddedL(TLogId, TInt, TInt, TInt) |
|
165 { |
|
166 LOG_FUNC |
|
167 |
|
168 // inform our observer that a change has been made to Call History db. |
|
169 // if we need to refresh the view then the view is not ready to use. |
|
170 iObserver.CallHistoryChangeNotification(!iRefreshView); |
|
171 |
|
172 // refresh view if required |
|
173 if (iRefreshView) |
|
174 { |
|
175 // filter the view asynchronously |
|
176 if (!iLogView->SetFilterL(*iLogFilterList, iStatus)) |
|
177 { |
|
178 // this should not happen, indicates no events in view but we have just been |
|
179 // given notification that a new event has been added. Complete view with |
|
180 // error and then observer should delete this object and try to create it |
|
181 // again later |
|
182 __ASSERT_DEBUG(EFalse, Panic(EPbapChViewInconsistency)); |
|
183 |
|
184 TRequestStatus* status=&iStatus; |
|
185 User::RequestComplete(status, KErrCorrupt); |
|
186 } |
|
187 |
|
188 iRefreshView = EFalse; |
|
189 SetActive(); |
|
190 } |
|
191 } |
|
192 |
|
193 void CPbapChView::PbapLogEngViewChangeEventChangedL(TLogId, TInt, TInt, TInt) |
|
194 { |
|
195 LOG_FUNC |
|
196 |
|
197 // if a change is made to an event then this will not change the corresponding |
|
198 // handle and therefore we do not need to notify the observer of a change |
|
199 } |
|
200 |
|
201 void CPbapChView::PbapLogEngViewChangeEventDeletedL(TLogId, TInt, TInt, TInt) |
|
202 { |
|
203 LOG_FUNC |
|
204 |
|
205 // inform our observer that a change has been made to Call History db |
|
206 iObserver.CallHistoryChangeNotification(); |
|
207 } |
|
208 |
|
209 void CPbapChView::PbapLogEngViewChangeEventL(TUid, TInt, TInt, TInt) |
|
210 { |
|
211 LOG_FUNC |
|
212 |
|
213 // inform our observer that a change has been made to Call History db |
|
214 iObserver.CallHistoryChangeNotification(); |
|
215 } |