64
|
1 |
/*
|
|
2 |
* Copyright (c) 2009 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: Source file for FSMailServer global dialogs app ui
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "emailtrace.h"
|
|
20 |
#include "fsmailserverdefinitions.h"
|
|
21 |
#include "fsnotificationhandlermgrimpl.h"
|
|
22 |
#include "FsEmailGlobalDialogsAppUi.h"
|
|
23 |
#include "emailservershutdownobserver.h"
|
|
24 |
|
|
25 |
|
|
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
|
|
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.
|
|
30 |
// '- 1' is needed for the VKB to work correctly
|
|
31 |
const TInt KFsEmailDialogsWinPriorityActive = ECoeWinPriorityNormal;
|
|
32 |
|
|
33 |
// To be used as FSMailServer window group priority when there is no displayable
|
|
34 |
// content.
|
|
35 |
const TInt KFsEmailDialogsWinPriorityInactive = ECoeWinPriorityNeverAtFront;
|
|
36 |
|
|
37 |
const TInt KPosBringToFront = 0;
|
|
38 |
const TInt KPosSendToBack = -1;
|
|
39 |
|
|
40 |
const TUid KFSMailServerUidAsTUid = { KFSMailServerUid };
|
|
41 |
|
|
42 |
const TInt KDefaultArrayGranularity = 5;
|
|
43 |
|
|
44 |
|
|
45 |
// ---------------------------------------------------------------------------
|
|
46 |
// Constructor
|
|
47 |
// ---------------------------------------------------------------------------
|
|
48 |
//
|
|
49 |
CFsEmailGlobalDialogsAppUi::CFsEmailGlobalDialogsAppUi()
|
|
50 |
{
|
|
51 |
FUNC_LOG;
|
|
52 |
// We are not showing any full screen content, only popup dialogs
|
|
53 |
SetFullScreenApp( EFalse );
|
|
54 |
}
|
|
55 |
|
|
56 |
// ---------------------------------------------------------------------------
|
|
57 |
// Destructor
|
|
58 |
// ---------------------------------------------------------------------------
|
|
59 |
//
|
|
60 |
CFsEmailGlobalDialogsAppUi::~CFsEmailGlobalDialogsAppUi()
|
|
61 |
{
|
|
62 |
FUNC_LOG;
|
|
63 |
delete iShutdownObserver;
|
|
64 |
iShutdownObserver = NULL;
|
|
65 |
}
|
|
66 |
|
|
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 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 |
// ---------------------------------------------------------------------------
|
|
118 |
// Overriden CAknAppUi::Exit
|
|
119 |
// ---------------------------------------------------------------------------
|
|
120 |
//
|
|
121 |
void CFsEmailGlobalDialogsAppUi::HandleForegroundEventL( TBool aForeground )
|
|
122 |
{
|
|
123 |
FUNC_LOG;
|
|
124 |
iForeground = aForeground;
|
|
125 |
}
|
|
126 |
|
|
127 |
// ---------------------------------------------------------------------------
|
|
128 |
// Overriden CAknAppUi::Exit
|
|
129 |
// ---------------------------------------------------------------------------
|
|
130 |
//
|
|
131 |
void CFsEmailGlobalDialogsAppUi::Exit()
|
|
132 |
{
|
|
133 |
FUNC_LOG;
|
|
134 |
// Cancel shutdown observer as we are already shutting down
|
|
135 |
if( iShutdownObserver )
|
|
136 |
{
|
|
137 |
iShutdownObserver->Cancel();
|
|
138 |
}
|
|
139 |
|
|
140 |
// We need to delete notification handler already here, because mail
|
|
141 |
// client destructor might need some AppUi resources like CleanupStack
|
|
142 |
delete iNotificationHandlerMgr;
|
|
143 |
iNotificationHandlerMgr = NULL;
|
|
144 |
|
|
145 |
// Call base class Exit
|
|
146 |
CAknAppUi::Exit();
|
|
147 |
}
|
|
148 |
|
|
149 |
// ---------------------------------------------------------------------------
|
|
150 |
// 2nd phase constructor
|
|
151 |
// ---------------------------------------------------------------------------
|
|
152 |
//
|
|
153 |
void CFsEmailGlobalDialogsAppUi::ConstructL()
|
|
154 |
{
|
|
155 |
FUNC_LOG;
|
|
156 |
// For debug builds create log file directory automatically. Best way
|
|
157 |
// would be to do this already when server is started, but because
|
|
158 |
// EikonEnv's FsSession is not yet ready there, we can't do it until now.
|
|
159 |
#ifdef _DEBUG
|
|
160 |
EnsureDebugDirExists();
|
|
161 |
#endif
|
|
162 |
|
|
163 |
|
|
164 |
BaseConstructL( ENonStandardResourceFile|ENoScreenFurniture|EAknEnableSkin );
|
|
165 |
|
|
166 |
// Hide application from fast swap window, and sent it to background
|
|
167 |
HideApplicationFromFSW();
|
|
168 |
SendToBackground();
|
|
169 |
|
|
170 |
// Set Srv application to be system application.
|
|
171 |
// System applications can't be closed by the user.
|
|
172 |
iEikonEnv->SetSystem( ETrue );
|
|
173 |
|
|
174 |
// Create notification handler, which implements actual functionality
|
|
175 |
iNotificationHandlerMgr = CFSNotificationHandlerMgr::NewL( this );
|
|
176 |
|
|
177 |
// Create shutdown watcher, which will close the server gracefully
|
|
178 |
// when it gets event indicating that sis-update is starting
|
|
179 |
TRAP_IGNORE
|
|
180 |
(
|
|
181 |
// Errors can be ignored, as there's no point to shutdown whole server
|
|
182 |
// just because shutdown watcher is not working. Sis-updates are
|
|
183 |
// anyway happening quite rarely, and the shutter exe will anyway
|
|
184 |
// kill all running processes if they don't respond to shutdown event.
|
|
185 |
iShutdownObserver = CEmailServerShutdownObserver::NewL( *this );
|
|
186 |
);
|
|
187 |
|
|
188 |
}
|
|
189 |
|
|
190 |
// ---------------------------------------------------------------------------
|
|
191 |
// Brings the FSMailServer to the foreground so notes can be displayed.
|
|
192 |
// ---------------------------------------------------------------------------
|
|
193 |
//
|
|
194 |
void CFsEmailGlobalDialogsAppUi::BringToForeground()
|
|
195 |
{
|
|
196 |
FUNC_LOG;
|
|
197 |
|
|
198 |
|
|
199 |
// Bring own application to foreground
|
|
200 |
TApaTaskList taskList( iEikonEnv->WsSession() );
|
|
201 |
TApaTask task = taskList.FindApp( KFSMailServerUidAsTUid );
|
|
202 |
if ( task.Exists() )
|
|
203 |
{
|
|
204 |
task.BringToForeground();
|
|
205 |
}
|
|
206 |
|
|
207 |
// Bring window group to foreground
|
|
208 |
iEikonEnv->BringOwnerToFront();
|
|
209 |
iEikonEnv->RootWin().SetOrdinalPosition(
|
|
210 |
KPosBringToFront,
|
|
211 |
KFsEmailDialogsWinPriorityActive );
|
|
212 |
|
|
213 |
iEikonEnv->RootWin().EnableGroupListChangeEvents();
|
|
214 |
|
|
215 |
// Enable keyboard focus when showing some content
|
|
216 |
iEikonEnv->RootWin().EnableReceiptOfFocus( ETrue );
|
|
217 |
}
|
|
218 |
|
|
219 |
// ---------------------------------------------------------------------------
|
|
220 |
// Sends FSMailServer to the background when notes are dismissed.
|
|
221 |
// ---------------------------------------------------------------------------
|
|
222 |
//
|
|
223 |
void CFsEmailGlobalDialogsAppUi::SendToBackground()
|
|
224 |
{
|
|
225 |
FUNC_LOG;
|
|
226 |
|
|
227 |
// Send own application to background
|
|
228 |
TApaTaskList taskList( iEikonEnv->WsSession() );
|
|
229 |
TApaTask task = taskList.FindApp( KFSMailServerUidAsTUid );
|
|
230 |
if ( task.Exists() )
|
|
231 |
{
|
|
232 |
task.SendToBackground();
|
|
233 |
}
|
|
234 |
|
|
235 |
// Send window group to background
|
|
236 |
iEikonEnv->RootWin().SetOrdinalPosition(
|
|
237 |
KPosSendToBack,
|
|
238 |
KFsEmailDialogsWinPriorityInactive );
|
|
239 |
|
|
240 |
// Disable keyboard focus when not showing any content
|
|
241 |
iEikonEnv->RootWin().EnableReceiptOfFocus( EFalse );
|
|
242 |
|
|
243 |
iEikonEnv->RootWin().DisableGroupListChangeEvents();
|
|
244 |
}
|
|
245 |
|
|
246 |
#ifdef _DEBUG
|
|
247 |
// ---------------------------------------------------------------------------
|
|
248 |
// Creates debug logging directory automatically if it doesn't exist already
|
|
249 |
// ---------------------------------------------------------------------------
|
|
250 |
//
|
|
251 |
void CFsEmailGlobalDialogsAppUi::EnsureDebugDirExists()
|
|
252 |
{
|
|
253 |
FUNC_LOG;
|
|
254 |
// OK to have hard-coded drive letter (despite of CodeScanner warning)
|
|
255 |
// as we want the debug logs to go always to phone memory
|
|
256 |
_LIT( KDebugLogDir, "c:\\logs\\debuglogger\\" );
|
|
257 |
|
|
258 |
// Use MkDirAll instead of BaflUtils::EnsurePathExistsL so that we know
|
|
259 |
// wheter the folder already existed or was it just created. This
|
|
260 |
// might make a difference when reading the debug log as there are
|
|
261 |
// some traces already before this point.
|
|
262 |
TInt error=iEikonEnv->FsSession().MkDirAll( KDebugLogDir );
|
|
263 |
|
|
264 |
|
|
265 |
// If the directory didn't exist before MkDirAll, KErrNone is returned.
|
|
266 |
// If it existed before MkDirAll, KErrAlreadyExist is returned.
|
|
267 |
if( error == KErrNone )
|
|
268 |
{
|
|
269 |
// Inform that it's OK that there are no logging before this point.
|
|
270 |
// All other error codes can be ignored.
|
|
271 |
}
|
|
272 |
|
|
273 |
}
|
|
274 |
#endif
|
|
275 |
|
|
276 |
// End of File
|
|
277 |
|