1 /* |
1 /* |
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
3 * All rights reserved. |
3 * All rights reserved. |
4 * This component and the accompanying materials are made available |
4 * This component and the accompanying materials are made available |
5 * under the terms of "Eclipse Public License v1.0" |
5 * under the terms of the License "Eclipse Public License v1.0" |
6 * which accompanies this distribution, and is available |
6 * which accompanies this distribution, and is available |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
8 * |
8 * |
9 * Initial Contributors: |
9 * Initial Contributors: |
10 * Nokia Corporation - initial contribution. |
10 * Nokia Corporation - initial contribution. |
11 * |
11 * |
12 * Contributors: |
12 * Contributors: |
25 |
25 |
26 // To be used as FSMailServer window group priority when there is some |
26 // To be used as FSMailServer window group priority when there is some |
27 // displayable content. We need to keep FSMailServer always on top, because it |
27 // displayable content. We need to keep FSMailServer always on top, because it |
28 // is hided from task list so it's not possible switch FSMailServer back to |
28 // is hided from task list so it's not possible switch FSMailServer back to |
29 // foreground if user switches to Idle before dismissing the note. |
29 // foreground if user switches to Idle before dismissing the note. |
30 const TCoeWinPriority KFsEmailDialogsWinPriorityActive = ECoeWinPriorityAlwaysAtFront; |
30 // '- 1' is needed for the VKB to work correctly |
|
31 const TInt KFsEmailDialogsWinPriorityActive = ECoeWinPriorityAlwaysAtFront - 1; |
31 |
32 |
32 // To be used as FSMailServer window group priority when there is no displayable |
33 // To be used as FSMailServer window group priority when there is no displayable |
33 // content. |
34 // content. |
34 const TCoeWinPriority KFsEmailDialogsWinPriorityInactive = ECoeWinPriorityNeverAtFront; |
35 const TInt KFsEmailDialogsWinPriorityInactive = ECoeWinPriorityNeverAtFront; |
35 |
36 |
36 const TInt KPosBringToFront = 0; |
37 const TInt KPosBringToFront = 0; |
37 const TInt KPosSendToBack = -1; |
38 const TInt KPosSendToBack = -1; |
38 |
39 |
39 const TUid KFSMailServerUidAsTUid = { KFSMailServerUid }; |
40 const TUid KFSMailServerUidAsTUid = { KFSMailServerUid }; |
40 |
41 |
|
42 const TInt KDefaultArrayGranularity = 5; |
|
43 |
41 |
44 |
42 // --------------------------------------------------------------------------- |
45 // --------------------------------------------------------------------------- |
43 // Constructor |
46 // Constructor |
44 // --------------------------------------------------------------------------- |
47 // --------------------------------------------------------------------------- |
45 // |
48 // |
60 delete iShutdownObserver; |
63 delete iShutdownObserver; |
61 iShutdownObserver = NULL; |
64 iShutdownObserver = NULL; |
62 } |
65 } |
63 |
66 |
64 // --------------------------------------------------------------------------- |
67 // --------------------------------------------------------------------------- |
|
68 // Overriden CAknAppUi::HandleWsEventL |
|
69 // --------------------------------------------------------------------------- |
|
70 // |
|
71 void CFsEmailGlobalDialogsAppUi::HandleWsEventL( const TWsEvent& aEvent, |
|
72 CCoeControl* aDestination ) |
|
73 { |
|
74 FUNC_LOG; |
|
75 // Updates the foreground flag |
|
76 CAknAppUi::HandleWsEventL( aEvent, aDestination ); |
|
77 |
|
78 RWindowGroup& rwin = iEikonEnv->RootWin(); |
|
79 |
|
80 TBool isActive = |
|
81 ( rwin.OrdinalPriority() == KFsEmailDialogsWinPriorityActive ); |
|
82 |
|
83 if ( aEvent.Type() == EEventWindowGroupListChanged && isActive ) |
|
84 { |
|
85 RWsSession& ws = iEikonEnv->WsSession(); |
|
86 |
|
87 CArrayFixFlat<TInt>* wgList = |
|
88 new (ELeave) CArrayFixFlat<TInt>( KDefaultArrayGranularity ); |
|
89 |
|
90 TInt err = ws.WindowGroupList( |
|
91 KFsEmailDialogsWinPriorityActive, wgList ); |
|
92 |
|
93 if ( err == KErrNone ) |
|
94 { |
|
95 TBool topmost = ( wgList->Count() > 0 ) && |
|
96 ( wgList->At( 0 ) == rwin.Identifier() ); |
|
97 |
|
98 if ( iForeground && topmost && iForegroundNotTopmost ) |
|
99 { |
|
100 // This hack ensures the screen is refreshed when going back |
|
101 // from the VKB window |
|
102 SendToBackground(); |
|
103 BringToForeground(); |
|
104 } |
|
105 |
|
106 // Update this flag all the time when we are active |
|
107 // The flag is true when VKB window is shown for the password |
|
108 // query. |
|
109 iForegroundNotTopmost = ( iForeground && !topmost ); |
|
110 } |
|
111 |
|
112 delete wgList; |
|
113 wgList = NULL; |
|
114 } |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------------------------- |
65 // Overriden CAknAppUi::Exit |
118 // Overriden CAknAppUi::Exit |
66 // --------------------------------------------------------------------------- |
119 // --------------------------------------------------------------------------- |
67 // |
120 // |
|
121 void CFsEmailGlobalDialogsAppUi::HandleForegroundEventL( TBool aForeground ) |
|
122 { |
|
123 FUNC_LOG; |
|
124 iForeground = aForeground; |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------------------------- |
|
128 // Overriden CAknAppUi::Exit |
|
129 // --------------------------------------------------------------------------- |
|
130 // |
68 void CFsEmailGlobalDialogsAppUi::Exit() |
131 void CFsEmailGlobalDialogsAppUi::Exit() |
69 { |
132 { |
|
133 FUNC_LOG; |
70 // Cancel shutdown observer as we are already shutting down |
134 // Cancel shutdown observer as we are already shutting down |
71 if( iShutdownObserver ) |
135 if( iShutdownObserver ) |
72 { |
136 { |
73 iShutdownObserver->Cancel(); |
137 iShutdownObserver->Cancel(); |
74 } |
138 } |
128 // --------------------------------------------------------------------------- |
192 // --------------------------------------------------------------------------- |
129 // |
193 // |
130 void CFsEmailGlobalDialogsAppUi::BringToForeground() |
194 void CFsEmailGlobalDialogsAppUi::BringToForeground() |
131 { |
195 { |
132 FUNC_LOG; |
196 FUNC_LOG; |
133 // Enable keyboard focus when showing some content |
197 |
134 iEikonEnv->RootWin().EnableReceiptOfFocus( ETrue ); |
|
135 |
198 |
136 // Bring own application to foreground |
199 // Bring own application to foreground |
137 TApaTaskList taskList( iEikonEnv->WsSession() ); |
200 TApaTaskList taskList( iEikonEnv->WsSession() ); |
138 TApaTask task = taskList.FindApp( KFSMailServerUidAsTUid ); |
201 TApaTask task = taskList.FindApp( KFSMailServerUidAsTUid ); |
139 if ( task.Exists() ) |
202 if ( task.Exists() ) |
144 // Bring window group to foreground |
207 // Bring window group to foreground |
145 iEikonEnv->BringOwnerToFront(); |
208 iEikonEnv->BringOwnerToFront(); |
146 iEikonEnv->RootWin().SetOrdinalPosition( |
209 iEikonEnv->RootWin().SetOrdinalPosition( |
147 KPosBringToFront, |
210 KPosBringToFront, |
148 KFsEmailDialogsWinPriorityActive ); |
211 KFsEmailDialogsWinPriorityActive ); |
|
212 |
|
213 iEikonEnv->RootWin().EnableGroupListChangeEvents(); |
|
214 |
|
215 // Enable keyboard focus when showing some content |
|
216 iEikonEnv->RootWin().EnableReceiptOfFocus( ETrue ); |
149 } |
217 } |
150 |
218 |
151 // --------------------------------------------------------------------------- |
219 // --------------------------------------------------------------------------- |
152 // Sends FSMailServer to the background when notes are dismissed. |
220 // Sends FSMailServer to the background when notes are dismissed. |
153 // --------------------------------------------------------------------------- |
221 // --------------------------------------------------------------------------- |
154 // |
222 // |
155 void CFsEmailGlobalDialogsAppUi::SendToBackground() |
223 void CFsEmailGlobalDialogsAppUi::SendToBackground() |
156 { |
224 { |
157 FUNC_LOG; |
225 FUNC_LOG; |
|
226 |
158 // Send own application to background |
227 // Send own application to background |
159 TApaTaskList taskList( iEikonEnv->WsSession() ); |
228 TApaTaskList taskList( iEikonEnv->WsSession() ); |
160 TApaTask task = taskList.FindApp( KFSMailServerUidAsTUid ); |
229 TApaTask task = taskList.FindApp( KFSMailServerUidAsTUid ); |
161 if ( task.Exists() ) |
230 if ( task.Exists() ) |
162 { |
231 { |
168 KPosSendToBack, |
237 KPosSendToBack, |
169 KFsEmailDialogsWinPriorityInactive ); |
238 KFsEmailDialogsWinPriorityInactive ); |
170 |
239 |
171 // Disable keyboard focus when not showing any content |
240 // Disable keyboard focus when not showing any content |
172 iEikonEnv->RootWin().EnableReceiptOfFocus( EFalse ); |
241 iEikonEnv->RootWin().EnableReceiptOfFocus( EFalse ); |
|
242 |
|
243 iEikonEnv->RootWin().DisableGroupListChangeEvents(); |
173 } |
244 } |
174 |
245 |
175 #ifdef _DEBUG |
246 #ifdef _DEBUG |
176 // --------------------------------------------------------------------------- |
247 // --------------------------------------------------------------------------- |
177 // Creates debug logging directory automatically if it doesn't exist already |
248 // Creates debug logging directory automatically if it doesn't exist already |