|
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: Class to handle mail led turning on. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 //<cmail> |
|
20 #include "emailtrace.h" |
|
21 #include "CFSMailClient.h" |
|
22 //</cmail> |
|
23 #include <aknlists.h> |
|
24 #include <e32cmn.h> |
|
25 #include <f32file.h> |
|
26 #include <bautils.h> |
|
27 #include <StringLoader.h> |
|
28 |
|
29 #include <fsmailserver.rsg> |
|
30 |
|
31 #include "fsmailoutofmemoryhandler.h" |
|
32 #include "fsnotificationhandlertimer.h" |
|
33 |
|
34 const TInt32 KReshowNoteDelay = 60000000; //60 seconds |
|
35 |
|
36 |
|
37 CFSMailOutOfMemoryHandler* CFSMailOutOfMemoryHandler::NewL( |
|
38 MFSNotificationHandlerMgr& aOwner ) |
|
39 { |
|
40 FUNC_LOG; |
|
41 CFSMailOutOfMemoryHandler* self = |
|
42 new (ELeave) CFSMailOutOfMemoryHandler( aOwner ); |
|
43 CleanupStack::PushL( self ); |
|
44 self->ConstructL(); |
|
45 CleanupStack::Pop( self ); |
|
46 return self; |
|
47 } |
|
48 |
|
49 CFSMailOutOfMemoryHandler::CFSMailOutOfMemoryHandler( |
|
50 MFSNotificationHandlerMgr& aOwner ) : |
|
51 CFSNotificationHandlerBase( aOwner ) |
|
52 { |
|
53 FUNC_LOG; |
|
54 } |
|
55 |
|
56 void CFSMailOutOfMemoryHandler::ConstructL() |
|
57 { |
|
58 FUNC_LOG; |
|
59 CFSNotificationHandlerBase::ConstructL(); |
|
60 |
|
61 iTimer = CFSNotificationHandlerTimer::NewL( *this ); |
|
62 |
|
63 // We are now ready to observe mail events |
|
64 SetObserving( ETrue ); |
|
65 } |
|
66 |
|
67 CFSMailOutOfMemoryHandler::~CFSMailOutOfMemoryHandler() |
|
68 { |
|
69 FUNC_LOG; |
|
70 delete iNotifierInitiator; |
|
71 iNotifierInitiator = NULL; |
|
72 |
|
73 delete iTimer; |
|
74 iTimer = NULL; |
|
75 } |
|
76 |
|
77 void CFSMailOutOfMemoryHandler::NotifierInitiatorDoneL( |
|
78 CFSNotificationHandlerNotifierInitiator* aInitiator ) |
|
79 { |
|
80 FUNC_LOG; |
|
81 if ( aInitiator != iNotifierInitiator ) |
|
82 { |
|
83 User::Leave( KErrNotFound ); |
|
84 } |
|
85 |
|
86 delete iNotifierInitiator; |
|
87 iNotifierInitiator = NULL; |
|
88 |
|
89 // User has just seen and accepted the note. Let's wait |
|
90 // a proper time before showing the note again. |
|
91 |
|
92 SetObserving( EFalse ); |
|
93 //cancel the current timer |
|
94 iTimer->Cancel(); |
|
95 //start a new timer |
|
96 iTimer->After( KReshowNoteDelay ); |
|
97 } |
|
98 |
|
99 // --------------------------------------------------------------------------- |
|
100 // Method to be called by when the timer expires. |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 void CFSMailOutOfMemoryHandler::TimerCallBackL( TInt aError ) |
|
104 { |
|
105 FUNC_LOG; |
|
106 if ( aError == KErrNone ) |
|
107 { |
|
108 //enable note showing again |
|
109 SetObserving( ETrue ); |
|
110 } |
|
111 } |
|
112 |
|
113 TBool CFSMailOutOfMemoryHandler::CapabilitiesToContinueL( |
|
114 TFSMailEvent /*aEvent*/, |
|
115 TFSMailMsgId /*aMailbox*/, |
|
116 TAny* /*aParam1*/, |
|
117 TAny* /*aParam2*/, |
|
118 TAny* /*aParam3*/ ) const |
|
119 { |
|
120 FUNC_LOG; |
|
121 // Out of memory is always shown by instance of this class. |
|
122 return ETrue; |
|
123 } |
|
124 |
|
125 void CFSMailOutOfMemoryHandler::HandleEventL( |
|
126 TFSMailEvent aEvent, |
|
127 TFSMailMsgId aMailbox, |
|
128 TAny* aParam1, |
|
129 TAny* /*aParam2*/, |
|
130 TAny* /*aParam3*/ ) |
|
131 { |
|
132 FUNC_LOG; |
|
133 switch ( aEvent ) |
|
134 { |
|
135 case TFSEventMailboxSyncStateChanged: |
|
136 { |
|
137 TSSMailSyncState& state = *static_cast<TSSMailSyncState*>( aParam1 ); |
|
138 |
|
139 |
|
140 if ( state == OutOfDiskSpace ) |
|
141 { |
|
142 ShowOutOfMemoryNoteL( aMailbox ); |
|
143 } |
|
144 break; |
|
145 } |
|
146 default: |
|
147 { |
|
148 break; |
|
149 } |
|
150 } |
|
151 } |
|
152 |
|
153 |
|
154 void CFSMailOutOfMemoryHandler::ShowOutOfMemoryNoteL( |
|
155 TFSMailMsgId aMailboxId ) |
|
156 { |
|
157 FUNC_LOG; |
|
158 |
|
159 if ( !iNotifierInitiator ) |
|
160 { |
|
161 |
|
162 CFSMailBox* mailBox( |
|
163 MailClient().GetMailBoxByUidL( aMailboxId ) ); |
|
164 User::LeaveIfNull( mailBox ); |
|
165 CleanupStack::PushL( mailBox ); |
|
166 TDesC& mailboxName( mailBox->GetName() ); |
|
167 |
|
168 iNotifierInitiator = CFSNotificationHandlerNotifierInitiator::NewL( |
|
169 *this, iOwner ); |
|
170 iNotifierInitiator->RequestMessageQueryL( |
|
171 mailboxName, |
|
172 EFsEmailNotifErrOutOfMemory ); |
|
173 |
|
174 CleanupStack::PopAndDestroy( mailBox ); |
|
175 } |
|
176 else |
|
177 { |
|
178 // iEmailNotifierInitiator exists so we are already showing |
|
179 // an error note. Let's not show a new one. |
|
180 } |
|
181 } |
|
182 |
|
183 void CFSMailOutOfMemoryHandler::TurnNotificationOn() |
|
184 { |
|
185 FUNC_LOG; |
|
186 } |
|
187 |
|
188 void CFSMailOutOfMemoryHandler::TurnNotificationOff() |
|
189 { |
|
190 FUNC_LOG; |
|
191 } |
|
192 |