|
1 /* |
|
2 * Copyright (c) 2009 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 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <exception> |
|
20 #include <logview.h> |
|
21 #include "logsworker.h" |
|
22 #include "logsstatebase.h" |
|
23 #include "logslogger.h" |
|
24 |
|
25 // CONSTANTS |
|
26 |
|
27 // ---------------------------------------------------------------------------- |
|
28 // LogsWorker::LogsWorker |
|
29 // ---------------------------------------------------------------------------- |
|
30 // |
|
31 LogsWorker::LogsWorker(bool readAllEvents) |
|
32 : CActive( EPriorityStandard ), |
|
33 mReadAllEvents(readAllEvents), |
|
34 mLogClient(0), |
|
35 mLogViewRecent(0), |
|
36 mLogViewEvent(0), |
|
37 mDuplicatesView(0), |
|
38 mIndex(0), |
|
39 mCurrentStateIndex(0), |
|
40 mCurrentStateMachine(0), |
|
41 mCurrentEventId(-1) |
|
42 { |
|
43 LOGS_QDEBUG( "logs [ENG] -> LogsWorker::LogsWorker()" ) |
|
44 |
|
45 CActiveScheduler::Add( this ); |
|
46 |
|
47 LOGS_QDEBUG( "logs [ENG] <- LogsWorker::LogsWorker()" ) |
|
48 } |
|
49 |
|
50 // ---------------------------------------------------------------------------- |
|
51 // LogsWorker::~LogsWorker |
|
52 // ---------------------------------------------------------------------------- |
|
53 // |
|
54 LogsWorker::~LogsWorker() |
|
55 { |
|
56 LOGS_QDEBUG( "logs [ENG] -> LogsWorker::~LogsWorker()" ) |
|
57 |
|
58 Cancel(); |
|
59 |
|
60 LOGS_QDEBUG( "logs [ENG] <- LogsWorker::~LogsWorker()" ) |
|
61 } |
|
62 |
|
63 // ---------------------------------------------------------------------------- |
|
64 // LogsWorker::RunL |
|
65 // ---------------------------------------------------------------------------- |
|
66 // |
|
67 void LogsWorker::RunL() |
|
68 { |
|
69 LOGS_QDEBUG_3( "logs [ENG] -> LogsWorker::RunL(), (state, status):", |
|
70 mCurrentStateIndex, iStatus.Int() ) |
|
71 |
|
72 // Error handling in RunError |
|
73 __ASSERT_ALWAYS( iStatus.Int() == KErrNone, User::Leave( iStatus.Int() ) ); |
|
74 |
|
75 if ( currentState().continueL() ){ |
|
76 SetActive(); |
|
77 } |
|
78 |
|
79 LOGS_QDEBUG( "logs [ENG] <- LogsWorker::RunL()" ) |
|
80 } |
|
81 |
|
82 // ---------------------------------------------------------------------------- |
|
83 // LogsWorker::RunError |
|
84 // ---------------------------------------------------------------------------- |
|
85 // |
|
86 TInt LogsWorker::RunError(TInt error) |
|
87 { |
|
88 LOGS_QDEBUG_2( "logs [ENG] <-> LogsWorker::RunError(), err:", error ) |
|
89 |
|
90 return KErrNone; |
|
91 } |
|
92 |
|
93 // ---------------------------------------------------------------------------- |
|
94 // LogsWorker::DoCancel |
|
95 // ---------------------------------------------------------------------------- |
|
96 // |
|
97 void LogsWorker::DoCancel() |
|
98 { |
|
99 if ( mLogViewEvent ){ |
|
100 mLogViewEvent->Cancel(); |
|
101 } |
|
102 if ( mLogViewRecent ){ |
|
103 mLogViewRecent->Cancel(); |
|
104 } |
|
105 if ( mDuplicatesView ){ |
|
106 mDuplicatesView->Cancel(); |
|
107 } |
|
108 if ( mLogClient ){ |
|
109 mLogClient->Cancel(); |
|
110 } |
|
111 } |
|
112 |
|
113 // ---------------------------------------------------------------------------- |
|
114 // LogsWorker::setCurrentState |
|
115 // ---------------------------------------------------------------------------- |
|
116 // |
|
117 void LogsWorker::setCurrentState(const LogsStateBase& state) |
|
118 { |
|
119 bool found(false); |
|
120 for( int i = 0; i < mCurrentStateMachine->count() && !found; i++ ){ |
|
121 if ( mCurrentStateMachine->at(i) == &state ){ |
|
122 mCurrentStateIndex = i; |
|
123 found = true; |
|
124 LOGS_QDEBUG_2( "logs [ENG] <-> LogsWorker::setCurrentState, index:", |
|
125 mCurrentStateIndex ) |
|
126 } |
|
127 } |
|
128 } |
|
129 |
|
130 // ---------------------------------------------------------------------------- |
|
131 // LogsWorker::logView |
|
132 // ---------------------------------------------------------------------------- |
|
133 // |
|
134 CLogView& LogsWorker::logView() |
|
135 { |
|
136 if ( mLogViewRecent ){ |
|
137 return *mLogViewRecent; |
|
138 } |
|
139 return *mLogViewEvent; |
|
140 } |
|
141 |
|
142 // ---------------------------------------------------------------------------- |
|
143 // LogsWorker::duplicatesView |
|
144 // ---------------------------------------------------------------------------- |
|
145 // |
|
146 CLogViewDuplicate& LogsWorker::duplicatesView() |
|
147 { |
|
148 return *mDuplicatesView; |
|
149 } |
|
150 |
|
151 // ---------------------------------------------------------------------------- |
|
152 // LogsWorker::index |
|
153 // ---------------------------------------------------------------------------- |
|
154 // |
|
155 int& LogsWorker::index() |
|
156 { |
|
157 return mIndex; |
|
158 } |
|
159 |
|
160 // ---------------------------------------------------------------------------- |
|
161 // LogsWorker::reqStatus |
|
162 // ---------------------------------------------------------------------------- |
|
163 // |
|
164 TRequestStatus& LogsWorker::reqStatus() |
|
165 { |
|
166 return iStatus; |
|
167 } |
|
168 |
|
169 // ---------------------------------------------------------------------------- |
|
170 // LogsWorker::currentEventId |
|
171 // ---------------------------------------------------------------------------- |
|
172 // |
|
173 int LogsWorker::currentEventId() |
|
174 { |
|
175 return mCurrentEventId; |
|
176 } |
|
177 |
|
178 // ---------------------------------------------------------------------------- |
|
179 // LogsWorker::logClient |
|
180 // ---------------------------------------------------------------------------- |
|
181 // |
|
182 CLogClient& LogsWorker::logClient() |
|
183 { |
|
184 return *mLogClient; |
|
185 } |
|
186 |
|
187 // ---------------------------------------------------------------------------- |
|
188 // LogsWorker::isRecentView |
|
189 // ---------------------------------------------------------------------------- |
|
190 // |
|
191 bool LogsWorker::isRecentView() |
|
192 { |
|
193 return ( mLogViewRecent != 0 ); |
|
194 } |
|
195 |
|
196 // ---------------------------------------------------------------------------- |
|
197 // LogsWorker::currentState |
|
198 // ---------------------------------------------------------------------------- |
|
199 // |
|
200 LogsStateBase& LogsWorker::currentState() |
|
201 { |
|
202 return *(mCurrentStateMachine->at(mCurrentStateIndex)); |
|
203 } |