|
1 /* |
|
2 * Copyright (c) 2007 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: The MUS application's UI class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "musuiviewcontainer.h" |
|
20 #include "musuidialogutil.h" |
|
21 #include "musuidefinitions.h" |
|
22 #include "muslogger.h" // debug logging |
|
23 #include "musuigeneralview.h" |
|
24 #include <musui.rsg> |
|
25 |
|
26 #include <AknWaitDialog.h> |
|
27 |
|
28 |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 // ----------------------------------------------------------------------------- |
|
32 // |
|
33 CMusUiViewContainer::~CMusUiViewContainer() |
|
34 { |
|
35 MUS_LOG( "mus: [MUSUI ] -> CMusUiViewContainer::~CMusUiViewContainer" ); |
|
36 |
|
37 CancelWaitTimer(); |
|
38 delete iWaitDialogTimer; |
|
39 |
|
40 if ( iWaitDialog ) |
|
41 { |
|
42 TRAP_IGNORE( iWaitDialog->ProcessFinishedL() ); |
|
43 } |
|
44 |
|
45 MUS_LOG( "mus: [MUSUI ] <- CMusUiViewContainer::~CMusUiViewContainer" ); |
|
46 } |
|
47 |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 void CMusUiViewContainer::CancelWaitTimer() |
|
54 { |
|
55 MUS_LOG( "mus: [MUSUI ] -> CMusUiViewContainer::CancelWaitTimer" ); |
|
56 if ( iWaitDialogTimer ) |
|
57 { |
|
58 iWaitDialogTimer->Cancel(); |
|
59 } |
|
60 MUS_LOG( "mus: [MUSUI ] <- CMusUiViewContainer::CancelWaitTimer" ); |
|
61 } |
|
62 |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // Dismisses the current active wait note, if any. |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 void CMusUiViewContainer::DismissWaitDialogL( TBool aReturnValue ) |
|
69 { |
|
70 MUS_LOG( "mus: [MUSUI ] -> CMusUiViewContainer::DismissWaitDialogL" ); |
|
71 |
|
72 if ( iWaitDialog ) |
|
73 { |
|
74 iInvitationWaitDialogDismissed = ETrue; |
|
75 iWaitDialogReturnValueWhenDismissed = aReturnValue; |
|
76 |
|
77 iWaitDialog->ProcessFinishedL(); |
|
78 iWaitDialog = NULL; |
|
79 } |
|
80 |
|
81 MUS_LOG( "mus: [MUSUI ] <- CMusUiViewContainer::DismissWaitDialogL" ); |
|
82 } |
|
83 |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // Runs the Inviting recipient wait note |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 TBool CMusUiViewContainer::RunWaitDialogL( const TDesC& aPrompt, |
|
90 TInt aTimerInSeconds, |
|
91 TInt aExpirationMessageResourceId ) |
|
92 { |
|
93 MUS_LOG_TDESC( "mus: [MUSUI ] -> CMusUiViewContainer::RunWaitDialogL: ", aPrompt ); |
|
94 |
|
95 __ASSERT_ALWAYS( !iWaitDialog, User::Leave( KErrAlreadyExists ) ); |
|
96 __ASSERT_ALWAYS( !iWaitDialogTimer, User::Leave( KErrAlreadyExists ) ); |
|
97 |
|
98 MUS_LOG( " No previous wait dialog, continue " ) |
|
99 |
|
100 iExpirationMessageResourceId = aExpirationMessageResourceId; |
|
101 |
|
102 iWaitDialog = new( ELeave ) CAknWaitDialog( |
|
103 reinterpret_cast<CEikDialog**>(&iWaitDialog) ); |
|
104 |
|
105 iWaitDialog->SetTextL( aPrompt ); |
|
106 |
|
107 TBool retVal = ETrue; |
|
108 iWaitDialog->PrepareLC( R_MUS_VIEW_INVITING_WAIT_NOTE ); |
|
109 |
|
110 if ( aTimerInSeconds > 0 ) |
|
111 { |
|
112 iWaitDialogTimer = CPeriodic::NewL( CActive::EPriorityStandard ); |
|
113 iWaitDialogTimer->Start( KMusOneSecond * aTimerInSeconds, |
|
114 KMusOneSecond * aTimerInSeconds, |
|
115 TCallBack( DoWaitNoteTimeout, this ) ); |
|
116 } |
|
117 |
|
118 iShowingWaitDialog = ETrue; |
|
119 retVal = iWaitDialog->RunLD(); |
|
120 iShowingWaitDialog = EFalse; |
|
121 iWaitDialog = NULL; |
|
122 |
|
123 MUS_LOG( " Wait dialog's RunLD returned" ) |
|
124 |
|
125 if ( iToolbarHandler ) |
|
126 { |
|
127 MUS_LOG( " Completing toobar request" ) |
|
128 iToolbarHandler->SetToolbarVisibility( ETrue ); |
|
129 iToolbarHandler = NULL; |
|
130 } |
|
131 |
|
132 // Cancel timer when dialog returns. |
|
133 CancelWaitTimer(); |
|
134 delete iWaitDialogTimer; |
|
135 iWaitDialogTimer = NULL; |
|
136 |
|
137 if ( iInvitationWaitDialogDismissed ) |
|
138 { |
|
139 iInvitationWaitDialogDismissed = EFalse; |
|
140 retVal = iWaitDialogReturnValueWhenDismissed; |
|
141 } |
|
142 |
|
143 MUS_LOG( "mus: [MUSUI ] <- CMusUiViewContainer::RunWaitDialogL" ); |
|
144 return retVal; |
|
145 } |
|
146 |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 void CMusUiViewContainer::SetWaitDialogCallbackL( MProgressDialogCallback* aCallback ) |
|
153 { |
|
154 __ASSERT_ALWAYS( iWaitDialog, User::Leave( KErrNotReady ) ); |
|
155 iWaitDialog->SetCallback( aCallback ); |
|
156 } |
|
157 |
|
158 |
|
159 // ----------------------------------------------------------------------------- |
|
160 // |
|
161 // ----------------------------------------------------------------------------- |
|
162 // |
|
163 TBool CMusUiViewContainer::WaitDialogShown() const |
|
164 { |
|
165 return iShowingWaitDialog; |
|
166 } |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 // ----------------------------------------------------------------------------- |
|
171 // |
|
172 void CMusUiViewContainer::RequestToolbarVisibilityOnceDialogDismissed( |
|
173 CMusUiGeneralView* aToolbarHandler ) |
|
174 { |
|
175 MUS_LOG1( |
|
176 "mus: [MUSUI ] <-> \ |
|
177 CMusUiViewContainer::RequestToolbarVisibilityOnceDialogDismissed, handler:%d", |
|
178 reinterpret_cast<TUint32>( aToolbarHandler ) ); |
|
179 |
|
180 iToolbarHandler = aToolbarHandler; |
|
181 } |
|
182 |
|
183 // ----------------------------------------------------------------------------- |
|
184 // |
|
185 // ----------------------------------------------------------------------------- |
|
186 // |
|
187 CMusUiViewContainer::CMusUiViewContainer() |
|
188 { |
|
189 // NOP |
|
190 } |
|
191 |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // Tick handler, callback function directly called by periodic timer |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 TInt CMusUiViewContainer::DoWaitNoteTimeout( TAny* aObject ) |
|
198 { |
|
199 // Cast, and call non-static function. |
|
200 MUS_LOG( "mus: [MUSUI ] -> CMusUiViewContainer::DoWaitNoteTimeout" ); |
|
201 |
|
202 CMusUiViewContainer* self = |
|
203 static_cast<CMusUiViewContainer*>( aObject ); |
|
204 |
|
205 TRAP_IGNORE( self->DismissWaitDialogL( EFalse ) ); |
|
206 |
|
207 if ( self->iExpirationMessageResourceId != 0 ) |
|
208 { |
|
209 TRAP_IGNORE( MusUiDialogUtil::ShowGlobalInformationDialogL( |
|
210 self->iExpirationMessageResourceId ) ) |
|
211 } |
|
212 |
|
213 MUS_LOG( "mus: [MUSUI ] <- CMusUiViewContainer::DoWaitNoteTimeout" ); |
|
214 // Return 0 ( false ) to indicate that we don't want more ticks |
|
215 return KErrNone; |
|
216 } |
|
217 |
|
218 |
|
219 // end of file |