author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:11:15 +0300 | |
branch | RCL_3 |
changeset 80 | 726fba06891a |
parent 64 | 3533d4323edc |
permissions | -rw-r--r-- |
64 | 1 |
/* |
2 |
* Copyright (c) 2007-2008 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: Implementation of notification handler manager |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#include "emailtrace.h" |
|
20 |
#include <ecom/ecom.h> // FinalClose() |
|
21 |
//<cmail> |
|
22 |
#include "cfsmailclient.h" |
|
23 |
//</cmail> |
|
24 |
#include <sysutil.h> |
|
25 |
//<cmail> |
|
26 |
#include <fsmailserver.rsg> |
|
27 |
#include "cmailhandlerpluginuids.h" |
|
28 |
#include "fsnotificationhandlerbase.h" |
|
29 |
#include "FsEmailGlobalDialogsAppUi.h" |
|
30 |
#include "FsEmailMessageQueryDialog.h" |
|
31 |
#include "FsEmailAuthenticationDialog.h" |
|
32 |
//</cmail> |
|
33 |
#include "fsnotificationhandlermgrimpl.h" |
|
34 |
//<cmail> |
|
35 |
#include "FsEmailGlobalDialogsAppUi.h" |
|
36 |
//</cmail> |
|
37 |
||
38 |
||
39 |
static const TInt64 KMegaByte = 1048576; |
|
40 |
||
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
41 |
_LIT( KFSMailServerPanic, "FS mail server" ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
42 |
const TInt KUndefinedState = 1; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
43 |
const TTimeIntervalMicroSeconds32 KDelay = 5000000; // 5 seconds |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
44 |
|
64 | 45 |
// ======== MEMBER FUNCTIONS ======== |
46 |
||
47 |
||
48 |
// --------------------------------------------------------------------------- |
|
49 |
// |
|
50 |
// --------------------------------------------------------------------------- |
|
51 |
// |
|
52 |
//<cmail> // aAppUi parameter no longer used, created by its own |
|
53 |
CFSNotificationHandlerMgr::CFSNotificationHandlerMgr(CFsEmailGlobalDialogsAppUi* aAppUi) : |
|
54 |
//</cmail> |
|
55 |
CActive( EPriorityStandard ), |
|
56 |
iAppUi( aAppUi ) |
|
57 |
{ |
|
58 |
FUNC_LOG; |
|
59 |
CActiveScheduler::Add( this ); |
|
60 |
} |
|
61 |
||
62 |
// --------------------------------------------------------------------------- |
|
63 |
// |
|
64 |
// --------------------------------------------------------------------------- |
|
65 |
// |
|
66 |
void CFSNotificationHandlerMgr::ConstructL() |
|
67 |
{ |
|
68 |
FUNC_LOG; |
|
69 |
// Performs the time consuming initialization asynchronously in RunL, in order |
|
70 |
// to let the process startup finish quicker |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
71 |
iTimer.CreateLocal(); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
72 |
SetActive(); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
73 |
iState = EPrepareInitialization; |
64 | 74 |
TRequestStatus* status = &iStatus; |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
75 |
User::RequestComplete( status, KErrNone ); |
64 | 76 |
} |
77 |
||
78 |
// --------------------------------------------------------------------------- |
|
79 |
// Finishes the initialization |
|
80 |
// --------------------------------------------------------------------------- |
|
81 |
// |
|
82 |
void CFSNotificationHandlerMgr::RunL() |
|
83 |
{ |
|
84 |
FUNC_LOG; |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
85 |
|
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
86 |
TBool goToNextState = ETrue; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
87 |
|
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
88 |
switch( iState ) |
64 | 89 |
{ |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
90 |
case EPrepareInitialization: |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
91 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
92 |
// Create mail client |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
93 |
iMailClient = CFSMailClient::NewL(); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
94 |
if ( iMailClient == NULL ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
95 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
96 |
User::Leave( KErrNoMemory ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
97 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
98 |
// Once mail client is created ok, disk space needs to be checked |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
99 |
// and cleaned if necessary |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
100 |
CleanTempFilesIfNeededL(); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
101 |
break; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
102 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
103 |
case EInitializeMailIconHandler: |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
104 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
105 |
CreateAndStoreHandlerL( KMailIconHandlerUid ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
106 |
break; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
107 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
108 |
case EInitializeLedHandler: |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
109 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
110 |
CreateAndStoreHandlerL( KLedHandlerUid ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
111 |
break; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
112 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
113 |
#ifndef __WINS__ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
114 |
case ESoundHandler: |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
115 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
116 |
// Earlier RefreshData() was called for the soundhandler |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
117 |
// object after creation, but as it does not do anything |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
118 |
// it is not called anymore. |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
119 |
CreateAndStoreHandlerL( KSoundHandlerUid ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
120 |
break; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
121 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
122 |
#endif |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
123 |
case EInitializeMtmHandler: |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
124 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
125 |
CreateAndStoreHandlerL( KMtmHandlerUid ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
126 |
break; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
127 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
128 |
case EInitializeOutofMemoryHandler: |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
129 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
130 |
CreateAndStoreHandlerL( KOutofMemoryHandlerUid ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
131 |
break; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
132 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
133 |
case EInitializeAuthenticationHandler: |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
134 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
135 |
CreateAndStoreHandlerL( KAuthenticationHandlerUid ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
136 |
break; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
137 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
138 |
case EInitializeMessageQueryHandlerUid: |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
139 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
140 |
CreateAndStoreHandlerL( KMessageQueryHandlerUid ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
141 |
break; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
142 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
143 |
case EWaitForPluginsReady: |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
144 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
145 |
if ( !iMailClient->AreAllPluginsLoaded() ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
146 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
147 |
goToNextState = EFalse; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
148 |
SetActive(); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
149 |
iTimer.After( iStatus, KDelay ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
150 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
151 |
break; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
152 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
153 |
case EInitializeCMailCpsHandlerUid: |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
154 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
155 |
CreateAndStoreHandlerL( KCMailCpsHandlerUid ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
156 |
break; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
157 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
158 |
case EFinish: |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
159 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
160 |
StartObservingL(); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
161 |
goToNextState = EFalse; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
162 |
break; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
163 |
} |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
164 |
default: |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
165 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
166 |
User::Panic( KFSMailServerPanic, KUndefinedState ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
167 |
break; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
168 |
} |
64 | 169 |
} |
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
170 |
if ( goToNextState ) |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
171 |
{ |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
172 |
iState = TState( iState + 1 ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
173 |
SetActive(); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
174 |
TRequestStatus* status = &iStatus; |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
175 |
User::RequestComplete( status, KErrNone ); |
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
176 |
} |
64 | 177 |
} |
178 |
||
179 |
// --------------------------------------------------------------------------- |
|
180 |
// |
|
181 |
// --------------------------------------------------------------------------- |
|
182 |
// |
|
183 |
void CFSNotificationHandlerMgr::DoCancel() |
|
184 |
{ |
|
185 |
FUNC_LOG; |
|
186 |
// Nothing to cancel |
|
187 |
} |
|
188 |
||
189 |
// --------------------------------------------------------------------------- |
|
190 |
// |
|
191 |
// --------------------------------------------------------------------------- |
|
192 |
// |
|
193 |
void CFSNotificationHandlerMgr::CreateAndStoreHandlerL( TInt aImplementationUid ) |
|
194 |
{ |
|
195 |
FUNC_LOG; |
|
196 |
CFSNotificationHandlerBase* handler = NULL; |
|
197 |
TRAPD( error, handler = CFSNotificationHandlerBase::NewL( aImplementationUid, *this ) ); |
|
198 |
if( handler && (error == KErrNone) ) |
|
199 |
{ |
|
200 |
iHandlers.Append( handler ); |
|
201 |
} |
|
202 |
} |
|
203 |
||
204 |
// --------------------------------------------------------------------------- |
|
205 |
// |
|
206 |
// --------------------------------------------------------------------------- |
|
207 |
// |
|
208 |
//<cmail> |
|
209 |
CFSNotificationHandlerMgr* CFSNotificationHandlerMgr::NewL(CFsEmailGlobalDialogsAppUi* aAppUi) |
|
210 |
//</cmail> |
|
211 |
{ |
|
212 |
FUNC_LOG; |
|
213 |
CFSNotificationHandlerMgr* self = CFSNotificationHandlerMgr::NewLC( aAppUi ); |
|
214 |
CleanupStack::Pop( self ); |
|
215 |
return self; |
|
216 |
} |
|
217 |
||
218 |
// --------------------------------------------------------------------------- |
|
219 |
// |
|
220 |
// --------------------------------------------------------------------------- |
|
221 |
// |
|
222 |
//<cmail> |
|
223 |
CFSNotificationHandlerMgr* CFSNotificationHandlerMgr::NewLC(CFsEmailGlobalDialogsAppUi* aAppUi) |
|
224 |
//</cmail> |
|
225 |
{ |
|
226 |
FUNC_LOG; |
|
227 |
CFSNotificationHandlerMgr* self = new( ELeave ) CFSNotificationHandlerMgr( aAppUi ); |
|
228 |
CleanupStack::PushL( self ); |
|
229 |
self->ConstructL(); |
|
230 |
return self; |
|
231 |
} |
|
232 |
||
233 |
// --------------------------------------------------------------------------- |
|
234 |
// |
|
235 |
// --------------------------------------------------------------------------- |
|
236 |
// |
|
237 |
CFSNotificationHandlerMgr::~CFSNotificationHandlerMgr() |
|
238 |
{ |
|
239 |
FUNC_LOG; |
|
240 |
Cancel(); |
|
241 |
||
242 |
StopObserving(); |
|
243 |
||
244 |
iHandlers.ResetAndDestroy(); |
|
245 |
||
246 |
iHSConnection = NULL; |
|
247 |
||
248 |
if( iMailClient ) |
|
249 |
{ |
|
250 |
iMailClient->Close(); |
|
251 |
iMailClient = NULL; |
|
252 |
} |
|
253 |
||
254 |
iAppUi = NULL; |
|
80
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
255 |
|
726fba06891a
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
64
diff
changeset
|
256 |
iTimer.Close(); |
64 | 257 |
|
258 |
// Finished using ECom |
|
259 |
// ECom used at least in CFSMailHSUpdateHandler |
|
260 |
REComSession::FinalClose(); |
|
261 |
} |
|
262 |
||
263 |
// --------------------------------------------------------------------------- |
|
264 |
// |
|
265 |
// --------------------------------------------------------------------------- |
|
266 |
// |
|
267 |
void CFSNotificationHandlerMgr::EventL( |
|
268 |
TFSMailEvent aEvent, |
|
269 |
TFSMailMsgId aMailbox, |
|
270 |
TAny* aParam1, |
|
271 |
TAny* aParam2, |
|
272 |
TAny* aParam3 ) |
|
273 |
{ |
|
274 |
FUNC_LOG; |
|
275 |
// First we check each event here. This is done so we know |
|
276 |
// if something has must be done before passing the event on |
|
277 |
// to handlers. For example we may want to register to |
|
278 |
// mailbox events. |
|
279 |
||
280 |
switch ( aEvent ) |
|
281 |
{ |
|
282 |
case TFSEventNewMailbox: |
|
283 |
{ |
|
284 |
iMailClient->SubscribeMailboxEventsL( aMailbox, *this ); |
|
285 |
iMailClient->GetBrandManagerL().UpdateMailboxNamesL( aMailbox ); |
|
286 |
break; |
|
287 |
} |
|
288 |
case TFSEventMailboxDeleted: |
|
289 |
{ |
|
290 |
// Observing has ended when the mailbox is deleted. |
|
291 |
||
292 |
// reset mailbox cached values |
|
293 |
iPreviousParentFolderId = TFSMailMsgId(); |
|
294 |
iPreviousMailbox = TFSMailMsgId(); |
|
295 |
break; |
|
296 |
} |
|
297 |
case TFSMailboxAvailable: // Flow through |
|
298 |
case TFSMailboxUnavailable: // Flow through |
|
299 |
case TFSEventMailboxRenamed: |
|
300 |
{ |
|
301 |
break; |
|
302 |
} |
|
303 |
case TFSEventNewMail: |
|
304 |
{ |
|
305 |
// If this is a pre-installed version and we receive a new mail we |
|
306 |
// update the current status of the HS here before passing |
|
307 |
// the events to handlers so they don't have to do it. If they |
|
308 |
// do it, it is done several times which is not desired. |
|
309 |
// The drawback is that by doing it here we might also do it |
|
310 |
// in situations where the handlers would actually not need it. |
|
311 |
// Possibly the best solution would be to initialize the |
|
312 |
// iHSConnection once and then let it observe for changes in |
|
313 |
// central repository. Currently that solution is not implemented |
|
314 |
// as it would require more time to implement. |
|
315 |
} |
|
316 |
default: |
|
317 |
{ |
|
318 |
break; |
|
319 |
} |
|
320 |
} |
|
321 |
||
322 |
||
323 |
// Let's pass all events to handlers also. |
|
324 |
const TInt handlerCount( iHandlers.Count() ); |
|
325 |
TInt handlerIndex( 0 ); |
|
326 |
||
327 |
while ( handlerIndex < handlerCount ) |
|
328 |
{ |
|
329 |
// Event is passed to each handler. If one fails the |
|
330 |
// event is still passed to others as they are not |
|
331 |
// necessarily dependent on the same services. This way |
|
332 |
// If one fails the others can still succeed. |
|
333 |
TRAP_IGNORE( |
|
334 |
iHandlers[handlerIndex]->EventL( aEvent, |
|
335 |
aMailbox, |
|
336 |
aParam1, |
|
337 |
aParam2, |
|
338 |
aParam3 ) ); |
|
339 |
++handlerIndex; |
|
340 |
} |
|
341 |
} |
|
342 |
||
343 |
CFSMailClient& CFSNotificationHandlerMgr::MailClient() const |
|
344 |
{ |
|
345 |
FUNC_LOG; |
|
346 |
// Instance of this class does not exist without the |
|
347 |
// mail client so it is safe to return a reference to the |
|
348 |
// pointed object. |
|
349 |
return *iMailClient; |
|
350 |
} |
|
351 |
||
352 |
CFSNotificationHandlerHSConnection* CFSNotificationHandlerMgr::HSConnection() const |
|
353 |
{ |
|
354 |
FUNC_LOG; |
|
355 |
return iHSConnection; |
|
356 |
} |
|
357 |
||
358 |
void CFSNotificationHandlerMgr::IncreaseDialogCount() |
|
359 |
{ |
|
360 |
FUNC_LOG; |
|
361 |
iDialogCount++; |
|
362 |
} |
|
363 |
||
364 |
void CFSNotificationHandlerMgr::DecreaseDialogCount() |
|
365 |
{ |
|
366 |
FUNC_LOG; |
|
367 |
iDialogCount--; |
|
368 |
} |
|
369 |
||
370 |
TInt CFSNotificationHandlerMgr::GetDialogCount() |
|
371 |
{ |
|
372 |
FUNC_LOG; |
|
373 |
return iDialogCount; |
|
374 |
} |
|
375 |
||
376 |
//<cmail> |
|
377 |
void CFSNotificationHandlerMgr::MessageQueryL( TDesC& aMailboxName, |
|
378 |
TRequestStatus& aStatus, |
|
379 |
const TDesC& aCustomMessageText, |
|
380 |
TFsEmailNotifierSystemMessageType aMessageType ) |
|
381 |
{ |
|
382 |
FUNC_LOG; |
|
383 |
CFsEmailMessageQueryDialog* dialog = |
|
384 |
CFsEmailMessageQueryDialog::NewLC( |
|
385 |
aStatus, aMailboxName, aMessageType, aCustomMessageText ); |
|
386 |
// RunLD pops dialog from cleanup stack |
|
387 |
dialog->RunLD(); |
|
388 |
} |
|
389 |
//</cmail> |
|
390 |
||
391 |
TInt CFSNotificationHandlerMgr::AuthenticateL( TDes& aPassword, |
|
392 |
TDesC& aMailboxName, |
|
393 |
TRequestStatus& aStatus ) |
|
394 |
{ |
|
395 |
FUNC_LOG; |
|
396 |
CFsEmailAuthenticationDialog* dialog = CFsEmailAuthenticationDialog::NewL( aStatus, aMailboxName, aPassword ); |
|
397 |
TRAPD( err, dialog->ExecuteLD( R_FS_MSERVER_DIALOG_AUTHENTICATION ) ); |
|
398 |
return err; |
|
399 |
} |
|
400 |
||
401 |
||
402 |
TFSFolderType CFSNotificationHandlerMgr::GetFolderTypeL( TFSMailMsgId& aMailbox, TFSMailMsgId* parentFolderId ) |
|
403 |
{ |
|
404 |
TFSFolderType folderType( EFSInbox ); |
|
405 |
if ( parentFolderId ) |
|
406 |
{ |
|
407 |
if ( (*parentFolderId) == iPreviousParentFolderId && |
|
408 |
aMailbox == iPreviousMailbox ) |
|
409 |
{ |
|
410 |
// we assume that folder with some id does not change |
|
411 |
// its type during mail synchronization |
|
412 |
folderType = iPreviousParentFolderType; |
|
413 |
} |
|
414 |
else |
|
415 |
{ |
|
416 |
iPreviousParentFolderId = (*parentFolderId); |
|
417 |
// Get the parent folder object |
|
418 |
CFSMailFolder* parentFolder = iMailClient->GetFolderByUidL( |
|
419 |
aMailbox, *parentFolderId ); |
|
420 |
if ( parentFolder ) |
|
421 |
{ |
|
422 |
folderType = parentFolder->GetFolderType(); |
|
423 |
iPreviousParentFolderType = folderType; |
|
424 |
delete parentFolder; |
|
425 |
parentFolder = NULL; |
|
426 |
} |
|
427 |
} |
|
428 |
} |
|
429 |
||
430 |
return folderType; |
|
431 |
} |
|
432 |
// --------------------------------------------------------------------------- |
|
433 |
// |
|
434 |
// --------------------------------------------------------------------------- |
|
435 |
// |
|
436 |
void CFSNotificationHandlerMgr::StartObservingL() |
|
437 |
{ |
|
438 |
FUNC_LOG; |
|
439 |
iMailClient->AddObserverL( *this ); |
|
440 |
||
441 |
RPointerArray<CFSMailBox> mailBoxList; |
|
442 |
// Null id given as a plugin id. mailboxes of all plugins retrieved. |
|
443 |
// Notice that ownership of the mailboxes is not passed to here. |
|
444 |
iMailClient->ListMailBoxes( TFSMailMsgId(), mailBoxList ); |
|
445 |
||
446 |
TInt mailBoxCount( mailBoxList.Count() ); |
|
447 |
TInt mailboxIndexer( 0 ); |
|
448 |
while ( mailboxIndexer < mailBoxCount ) |
|
449 |
{ |
|
450 |
||
451 |
// Here could be prevented the observing of mailboxes |
|
452 |
// that don't contain inbox but it is probably rather |
|
453 |
// improbable and it also would complicate the implementation. |
|
454 |
// So not implemented. |
|
455 |
TFSMailMsgId currentMailboxId( |
|
456 |
mailBoxList[mailboxIndexer]->GetId() ); |
|
457 |
TInt error = KErrNone; |
|
458 |
TRAP( error, iMailClient->SubscribeMailboxEventsL( currentMailboxId, |
|
459 |
*this ) ); |
|
460 |
||
461 |
// Although an error would occur in subscribing to some mailbox |
|
462 |
// the execution is still continued so that one mailbox won't |
|
463 |
// prevent mail server from using the other mailboxes. |
|
464 |
||
465 |
++mailboxIndexer; |
|
466 |
} |
|
467 |
||
468 |
mailBoxList.ResetAndDestroy(); |
|
469 |
} |
|
470 |
||
471 |
// --------------------------------------------------------------------------- |
|
472 |
// |
|
473 |
// --------------------------------------------------------------------------- |
|
474 |
// |
|
475 |
void CFSNotificationHandlerMgr::StopObserving() |
|
476 |
{ |
|
477 |
FUNC_LOG; |
|
478 |
||
479 |
// Removeobserver is also called for each mailbox |
|
480 |
// We should be an observer for each mailbox so this should not |
|
481 |
// bring up any problems normally. |
|
482 |
||
483 |
RPointerArray<CFSMailBox> mailBoxList; |
|
484 |
// Null id given as a plugin id. mailboxes of all plugins retrieved. |
|
485 |
// Notice that ownership of the mailboxes is not passed to here. |
|
486 |
iMailClient->ListMailBoxes( TFSMailMsgId(), mailBoxList ); |
|
487 |
||
488 |
TInt mailBoxCount( mailBoxList.Count() ); |
|
489 |
TInt mailboxIndexer( 0 ); |
|
490 |
while ( mailboxIndexer < mailBoxCount ) |
|
491 |
{ |
|
492 |
TFSMailMsgId currentMailboxId( |
|
493 |
mailBoxList[mailboxIndexer]->GetId() ); |
|
494 |
iMailClient->UnsubscribeMailboxEvents( currentMailboxId, |
|
495 |
*this ); |
|
496 |
||
497 |
++mailboxIndexer; |
|
498 |
} |
|
499 |
||
500 |
mailBoxList.ResetAndDestroy(); |
|
501 |
||
502 |
||
503 |
iMailClient->RemoveObserver( *this ); |
|
504 |
||
505 |
} |
|
506 |
||
507 |
// --------------------------------------------------------------------------- |
|
508 |
// Function cleans up downloaded files of mailboxes if disk space is low |
|
509 |
// --------------------------------------------------------------------------- |
|
510 |
// |
|
511 |
void CFSNotificationHandlerMgr::CleanTempFilesIfNeededL() |
|
512 |
{ |
|
513 |
FUNC_LOG; |
|
514 |
RFs fsSession; |
|
515 |
User::LeaveIfError(fsSession.Connect()); |
|
516 |
CleanupClosePushL(fsSession); |
|
517 |
// Check whether disk space is below 3MB, in that case start cleaning up |
|
518 |
// downloaded attachments from mailboxes. |
|
519 |
if ( SysUtil::DiskSpaceBelowCriticalLevelL( &fsSession, 3*KMegaByte, EDriveC ) ) |
|
520 |
{ |
|
521 |
RPointerArray<CFSMailBox> mailBoxList; |
|
522 |
// Null id given as a plugin id. mailboxes of all plugins retrieved. |
|
523 |
// Notice that ownership of the mailboxes is not passed to here. |
|
524 |
iMailClient->ListMailBoxes( TFSMailMsgId(), mailBoxList ); |
|
525 |
for ( TInt i = 0 ; i < mailBoxList.Count() ; ++i ) |
|
526 |
{ |
|
527 |
TRAP_IGNORE( mailBoxList[i]->RemoveDownLoadedAttachmentsL() ); |
|
528 |
} |
|
529 |
mailBoxList.ResetAndDestroy(); |
|
530 |
} |
|
531 |
CleanupStack::PopAndDestroy( &fsSession ); |
|
532 |
} |
|
533 |
||
534 |
||
535 |
//<cmail> |
|
536 |
// --------------------------------------------------------------------------- |
|
537 |
// CFSNotificationHandlerMgr::SendAppUiToBackground() |
|
538 |
// --------------------------------------------------------------------------- |
|
539 |
// |
|
540 |
void CFSNotificationHandlerMgr::SendAppUiToBackground() |
|
541 |
{ |
|
542 |
FUNC_LOG; |
|
543 |
if(iAppUi) |
|
544 |
iAppUi->SendToBackground(); |
|
545 |
} |
|
546 |
||
547 |
// --------------------------------------------------------------------------- |
|
548 |
// CFSNotificationHandlerMgr::BringAppUiToForeground() |
|
549 |
// --------------------------------------------------------------------------- |
|
550 |
// |
|
551 |
void CFSNotificationHandlerMgr::BringAppUiToForeground() |
|
552 |
{ |
|
553 |
FUNC_LOG; |
|
554 |
if(iAppUi) |
|
555 |
iAppUi->BringToForeground(); |
|
556 |
} |
|
557 |
//</cmail> |
|
558 |
||
559 |
// End of file |
|
560 |