|
1 /* |
|
2 * Copyright (c) 2004-2005 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: Implements the CLandmarksLmOpWrapper class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include <EPos_Landmarks.h> |
|
21 #include <EPos_CPosLmOperation.h> |
|
22 |
|
23 #include "LandmarksLmOpWrapper.h" |
|
24 |
|
25 // ============================ MEMBER FUNCTIONS =============================== |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 CLandmarksLmOpWrapper::CLandmarksLmOpWrapper() |
|
31 : CActive(CActive::EPriorityStandard) |
|
32 { |
|
33 CActiveScheduler::Add(this); |
|
34 } |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 CLandmarksLmOpWrapper::~CLandmarksLmOpWrapper() |
|
40 { |
|
41 Cancel(); |
|
42 delete iLmOperation; |
|
43 iLmOperation = NULL; |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // ----------------------------------------------------------------------------- |
|
48 // |
|
49 void CLandmarksLmOpWrapper::StartOperation( |
|
50 CPosLmOperation* aLmOperation, |
|
51 TRequestStatus& aStatus, |
|
52 TBool aReportProgress) |
|
53 { |
|
54 delete iLmOperation; |
|
55 iLmOperation = aLmOperation; |
|
56 iCallerStatus = &aStatus; |
|
57 iReportProgress = aReportProgress; |
|
58 iProgress = 0; |
|
59 |
|
60 ExecuteNextStep(); |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // ----------------------------------------------------------------------------- |
|
65 // |
|
66 CPosLmOperation* CLandmarksLmOpWrapper::LmOperationPtr() |
|
67 { |
|
68 return iLmOperation; |
|
69 } |
|
70 |
|
71 // ----------------------------------------------------------------------------- |
|
72 // ----------------------------------------------------------------------------- |
|
73 // |
|
74 void CLandmarksLmOpWrapper::ExecuteNextStep(TRequestStatus& aStatus) |
|
75 { |
|
76 iCallerStatus = &aStatus; |
|
77 ExecuteNextStep(); |
|
78 } |
|
79 |
|
80 // ----------------------------------------------------------------------------- |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 TInt CLandmarksLmOpWrapper::Progress() |
|
84 { |
|
85 return (TInt) (iProgress * 100); |
|
86 } |
|
87 |
|
88 // ----------------------------------------------------------------------------- |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 void CLandmarksLmOpWrapper::DoCancel() |
|
92 { |
|
93 delete iLmOperation; |
|
94 iLmOperation = NULL; |
|
95 User::RequestComplete(iCallerStatus, KErrCancel); |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // ----------------------------------------------------------------------------- |
|
100 // |
|
101 void CLandmarksLmOpWrapper::RunL() |
|
102 { |
|
103 if (iStatus == KErrNone) |
|
104 { |
|
105 // Operation finished. |
|
106 User::RequestComplete(iCallerStatus, KErrNone); |
|
107 } |
|
108 else if (iStatus == KPosLmOperationNotComplete) |
|
109 { |
|
110 if (iReportProgress) |
|
111 { |
|
112 User::RequestComplete(iCallerStatus, KPosLmOperationNotComplete); |
|
113 } |
|
114 else |
|
115 { |
|
116 ExecuteNextStep(); |
|
117 } |
|
118 } |
|
119 } |
|
120 |
|
121 // ----------------------------------------------------------------------------- |
|
122 // ----------------------------------------------------------------------------- |
|
123 // |
|
124 void CLandmarksLmOpWrapper::ExecuteNextStep() |
|
125 { |
|
126 iStatus = KRequestPending; |
|
127 iLmOperation->NextStep(iStatus, iProgress); |
|
128 SetActive(); |
|
129 } |
|
130 |
|
131 |