|
1 // Copyright (c) 2005-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 "CActiveLoop.h" |
|
17 |
|
18 void CActiveLoop::Register(MActiveLoopCallBack & aCallBack, TBool aUseTimer) |
|
19 { |
|
20 iCallBack = &aCallBack; |
|
21 if (aUseTimer) |
|
22 { //Timer required for Cancel Asynchronous operation use case. |
|
23 After(0); |
|
24 } |
|
25 else |
|
26 { |
|
27 CActive::SetActive(); |
|
28 TRequestStatus* status = &iStatus; |
|
29 User::RequestComplete(status, KErrNone); |
|
30 } |
|
31 } |
|
32 |
|
33 |
|
34 |
|
35 void CActiveLoop::RunL() |
|
36 { |
|
37 if (iCallBack->DoStepL()) |
|
38 { |
|
39 CActive::SetActive(); |
|
40 TRequestStatus* status = &iStatus; |
|
41 User::RequestComplete(status, KErrNone); |
|
42 } |
|
43 } |
|
44 |
|
45 CActiveLoop* CActiveLoop::NewL() |
|
46 { |
|
47 CActiveLoop* active = new (ELeave) CActiveLoop(); |
|
48 CleanupStack::PushL(active); |
|
49 active->ConstructL(); |
|
50 CleanupStack::Pop(active); |
|
51 return active; |
|
52 } |
|
53 |
|
54 void CActiveLoop::DoCancel() |
|
55 { |
|
56 } |
|
57 |
|
58 CActiveLoop::CActiveLoop() :CTimer(EPriorityStandard) |
|
59 { |
|
60 CActiveScheduler::Add(this); |
|
61 } |
|
62 |
|
63 |
|
64 CActiveLoop::~CActiveLoop() |
|
65 { |
|
66 Cancel(); |
|
67 } |
|
68 |
|
69 TInt CActiveLoop::RunError(TInt aError) |
|
70 { |
|
71 iCallBack->DoError(aError); |
|
72 return KErrNone; |
|
73 } |