|
1 /* |
|
2 * Copyright (c) 2002 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 |
|
19 // INCLUDE FILES |
|
20 #include "AknWaitNoteWrapper.h" // This class's declaration |
|
21 #include <AknWaitDialog.h> |
|
22 #include <aknenv.h> |
|
23 |
|
24 |
|
25 // MODULE DATA STRUCTURES |
|
26 |
|
27 enum TPanicCode |
|
28 { |
|
29 EPanicAlreadyExecuted =1 |
|
30 }; |
|
31 |
|
32 // LOCAL FUNCTION PROTOTYPES |
|
33 // ==================== LOCAL FUNCTIONS ==================== |
|
34 |
|
35 // ================= MEMBER FUNCTIONS ======================= |
|
36 |
|
37 inline CAknWaitNoteWrapper::CAknWaitNoteWrapper() : |
|
38 CActive(EPriorityIdle), |
|
39 iIsDialogCanceled(EFalse) |
|
40 { |
|
41 CActiveScheduler::Add(this); |
|
42 } |
|
43 |
|
44 EXPORT_C CAknWaitNoteWrapper* CAknWaitNoteWrapper::NewL() |
|
45 { |
|
46 CAknWaitNoteWrapper* self = new(ELeave) CAknWaitNoteWrapper; |
|
47 return self; |
|
48 } |
|
49 |
|
50 EXPORT_C CAknWaitNoteWrapper::~CAknWaitNoteWrapper() |
|
51 { |
|
52 Cancel(); |
|
53 iTimer.Close(); |
|
54 delete iWaitDialog; |
|
55 } |
|
56 |
|
57 EXPORT_C TBool CAknWaitNoteWrapper::ExecuteL |
|
58 (TInt aResId,MAknBackgroundProcess& aBackgroundProcess, |
|
59 TBool aVisibilityDelayOff, const CAknNoteDialog::TTone& aTone) |
|
60 { |
|
61 iBackgroundProcess = &aBackgroundProcess; |
|
62 CreateDialogL(aVisibilityDelayOff,aTone); |
|
63 iWaitDialog->ExecuteLD(aResId); |
|
64 return NextCycleAndReturnL(); |
|
65 } |
|
66 |
|
67 EXPORT_C TBool CAknWaitNoteWrapper::ExecuteL |
|
68 (TInt aResId,MAknBackgroundProcess& aBackgroundProcess, |
|
69 const TDesC& aPrompt, TBool aVisibilityDelayOff, const CAknNoteDialog::TTone& aTone) |
|
70 { |
|
71 iBackgroundProcess = &aBackgroundProcess; |
|
72 CreateDialogL(aVisibilityDelayOff,aTone); |
|
73 iWaitDialog->PrepareLC(aResId); |
|
74 iWaitDialog->SetTextL(aPrompt); |
|
75 iWaitDialog->RunLD(); |
|
76 return NextCycleAndReturnL(); |
|
77 } |
|
78 |
|
79 void CAknWaitNoteWrapper::DoCancel() |
|
80 { |
|
81 if (IsActive()) |
|
82 { |
|
83 iTimer.Cancel(); |
|
84 CAknEnv::StopSchedulerWaitWithBusyMessage(iWait); |
|
85 } |
|
86 } |
|
87 |
|
88 void CAknWaitNoteWrapper::RunL() |
|
89 { |
|
90 if (iBackgroundProcess->IsProcessDone() || !iWaitDialog) |
|
91 { |
|
92 iBackgroundProcess->ProcessFinished(); |
|
93 if (iWaitDialog) |
|
94 { |
|
95 iWaitDialog->ProcessFinishedL(); |
|
96 iIsDialogCanceled = EFalse; |
|
97 } |
|
98 CAknEnv::StopSchedulerWaitWithBusyMessage(iWait); |
|
99 } |
|
100 else |
|
101 { |
|
102 // do one step of processing |
|
103 iBackgroundProcess->StepL(); |
|
104 // Request next cycle |
|
105 NextCycle(); |
|
106 } |
|
107 } |
|
108 |
|
109 TInt CAknWaitNoteWrapper::RunError(TInt aError) |
|
110 { |
|
111 iRunError = iBackgroundProcess->CycleError(aError); |
|
112 if (iRunError == KErrNone) |
|
113 { |
|
114 NextCycle(); |
|
115 } |
|
116 else |
|
117 { |
|
118 CAknEnv::StopSchedulerWaitWithBusyMessage(iWait); |
|
119 } |
|
120 return KErrNone; |
|
121 } |
|
122 |
|
123 void CAknWaitNoteWrapper::DialogDismissedL(TInt aButtonId) |
|
124 { |
|
125 iWaitDialog = NULL; |
|
126 iBackgroundProcess->DialogDismissedL( aButtonId ); |
|
127 } |
|
128 |
|
129 void CAknWaitNoteWrapper::NextCycle() |
|
130 { |
|
131 iTimer.After(iStatus, 0); |
|
132 SetActive(); |
|
133 } |
|
134 |
|
135 TBool CAknWaitNoteWrapper::NextCycleAndReturnL() |
|
136 { |
|
137 User::LeaveIfError(iTimer.CreateLocal()); |
|
138 iIsDialogCanceled = ETrue; |
|
139 |
|
140 NextCycle(); |
|
141 iWait.Start(); |
|
142 iTimer.Close(); |
|
143 |
|
144 User::LeaveIfError(iRunError); |
|
145 return !iIsDialogCanceled; |
|
146 } |
|
147 |
|
148 void CAknWaitNoteWrapper::CreateDialogL(TBool aVisibilityDelayOff, const CAknNoteDialog::TTone& aTone) |
|
149 { |
|
150 if (iWaitDialog) |
|
151 { |
|
152 delete iWaitDialog; |
|
153 iWaitDialog = NULL; |
|
154 } |
|
155 |
|
156 iWaitDialog = new (ELeave) CAknWaitDialog((CEikDialog**)&iWaitDialog, aVisibilityDelayOff); |
|
157 iWaitDialog->SetCallback(this); |
|
158 iWaitDialog->SetTone(aTone); |
|
159 } |
|
160 |
|
161 // End of File |
|
162 |