|
1 /* |
|
2 * Copyright (c) 2002 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: Dialog used for attachment handling |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 |
|
21 #include "MsgMailViewAttachmentsDlg.h" |
|
22 #include "msgmaileditor.hrh" |
|
23 #include "MsgMailEditorAppUi.h" |
|
24 #include <MsgMailUIDs.h> // Application Uid |
|
25 #include "MsgMailEditorDocument.h" |
|
26 #include "MailUtils.h" |
|
27 #include "CMailCRHandler.h" |
|
28 |
|
29 #include <akntoolbar.h> |
|
30 #include <akntoolbarextension.h> |
|
31 #include <StringLoader.h> |
|
32 |
|
33 #include <MsgMailEditor.rsg> |
|
34 #include <MsgEditorAppUi.hrh> |
|
35 #include <MsgAttachmentModelObserver.h> |
|
36 #include <MsgAttachmentModel.h> |
|
37 #include <MsgAttachmentInfo.h> |
|
38 #include <MsgEditorAppUi.rsg> |
|
39 |
|
40 #include <hlplch.h> |
|
41 #include <csxhelp/mail.hlp.hrh> |
|
42 |
|
43 #include <MsgMailEditor.rsg> |
|
44 #include <aknlistquerydialog.h> |
|
45 |
|
46 |
|
47 // ================= MEMBER FUNCTIONS ======================= |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // CMsgMailViewAttachmentsDlg::NewL |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CMsgMailViewAttachmentsDlg* CMsgMailViewAttachmentsDlg::NewL(TDesC& aTitle, // CSI: 61 # aTitle must be a non-const |
|
54 // because of CMsgViewAttachmentsDialog |
|
55 // takes a non-const parameter. |
|
56 CMsgAttachmentModel& aAttachmentModel, CMsgMailEditorAppUi& aAppUi, |
|
57 TBool aHelpSupported) |
|
58 { |
|
59 CMsgMailViewAttachmentsDlg* self = new (ELeave) CMsgMailViewAttachmentsDlg( |
|
60 aTitle, |
|
61 R_ATTACHMENTS_MENU, |
|
62 aAttachmentModel, |
|
63 aAppUi ); |
|
64 |
|
65 CleanupStack::PushL(self); |
|
66 self->ConstructL(self->iAppUi.Document()->CurrentEntry()); |
|
67 CleanupStack::Pop( self ); |
|
68 self->iHelpSupported = aHelpSupported; |
|
69 return self; |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CMsgMailViewAttachmentsDlg::CMsgMailViewAttachmentsDlg |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 CMsgMailViewAttachmentsDlg::CMsgMailViewAttachmentsDlg( |
|
77 TDesC& aTitle, TInt aMenuId, |
|
78 CMsgAttachmentModel& aAttachmentModel, CMsgMailEditorAppUi& aAppUi) |
|
79 :CMsgViewAttachmentsDialog(aTitle, aMenuId, aAttachmentModel), |
|
80 iAppUi(aAppUi) |
|
81 { |
|
82 // Dialer is enabled in attachment dialog |
|
83 iAppUi.SetDialerEnabled( ETrue ); |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CMsgMailViewAttachmentsDlg::CMsgMailViewAttachmentsDlg |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 CMsgMailViewAttachmentsDlg::~CMsgMailViewAttachmentsDlg() |
|
91 { |
|
92 // Dialer is disabled by default |
|
93 iAppUi.SetDialerEnabled( EFalse ); |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CMsgMailViewAttachmentsDlg::DynInitMenuPaneL |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 void CMsgMailViewAttachmentsDlg::DynInitMenuPaneL( |
|
101 TInt aMenuId, CEikMenuPane* aMenuPane) |
|
102 { |
|
103 CMsgViewAttachmentsDialog::DynInitMenuPaneL( aMenuId, aMenuPane ); |
|
104 |
|
105 if (aMenuId == R_MEB_ATTACHMENTS_MENUPANE) |
|
106 { |
|
107 if (!iAttachmentModel.NumberOfItems()) |
|
108 { |
|
109 aMenuPane->DeleteMenuItem(EMsgViewAttachmentCmdRemove); |
|
110 aMenuPane->DeleteMenuItem(EMsgViewAttachmentCmdOpen); |
|
111 } |
|
112 if ( iAppUi.Document()->MailCRHandler()->MailInsertToolBar() ) |
|
113 { |
|
114 aMenuPane->SetItemDimmed( |
|
115 EMsgMailEditorCmdInsertMenu, EFalse ); |
|
116 } |
|
117 else |
|
118 { |
|
119 aMenuPane->SetItemDimmed( |
|
120 EMsgMailEditorCmdInsertSubMenu, EFalse ); |
|
121 } |
|
122 aMenuPane->SetItemDimmed( EAknCmdHelp, !iHelpSupported); |
|
123 } |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CMsgMailViewAttachmentsDlg::OfferKeyEventL |
|
128 // ----------------------------------------------------------------------------- |
|
129 // |
|
130 TKeyResponse CMsgMailViewAttachmentsDlg::OfferKeyEventL( |
|
131 const TKeyEvent& aKeyEvent, TEventCode aType) |
|
132 { |
|
133 LOG1("CMsgMailViewAttachmentsDlg::OfferKeyEventL %d ", aKeyEvent.iCode ); |
|
134 |
|
135 // Consume send keys, so that they are not handled in the appui |
|
136 if( aType == EEventKey && aKeyEvent.iCode == EKeyYes ) |
|
137 { |
|
138 return EKeyWasConsumed; |
|
139 } |
|
140 |
|
141 TKeyResponse consumed( EKeyWasNotConsumed ); |
|
142 if ( iAppUi.PopupToolbar() && iAppUi.PopupToolbar()->IsShown() ) |
|
143 { |
|
144 LOG1("CMsgMailViewAttachmentsDlg::OfferKeyEventL - TB %d ", |
|
145 aKeyEvent.iCode ); |
|
146 |
|
147 consumed = iAppUi.PopupToolbar()->OfferKeyEventL( aKeyEvent, aType ); |
|
148 } |
|
149 |
|
150 if ( consumed == EKeyWasNotConsumed ) |
|
151 { |
|
152 if ( !MenuShowing() && aType == EEventKey ) |
|
153 { |
|
154 if (aKeyEvent.iCode == EKeyOK) |
|
155 { |
|
156 ProcessCommandL(EMsgViewAttachmentCmdOpen); |
|
157 return EKeyWasConsumed; |
|
158 } |
|
159 if (aKeyEvent.iCode == EKeyBackspace && |
|
160 iAttachmentModel.NumberOfItems()) |
|
161 { |
|
162 ProcessCommandL(EMsgViewAttachmentCmdRemove); |
|
163 return EKeyWasConsumed; |
|
164 } |
|
165 } |
|
166 consumed = CMsgViewAttachmentsDialog::OfferKeyEventL(aKeyEvent, aType); |
|
167 } |
|
168 return consumed; |
|
169 } |
|
170 |
|
171 // ----------------------------------------------------------------------------- |
|
172 // CMsgMailViewAttachmentsDlg::ProcessCommandL |
|
173 // ----------------------------------------------------------------------------- |
|
174 // |
|
175 void CMsgMailViewAttachmentsDlg::ProcessCommandL(TInt aCommandId) |
|
176 { |
|
177 LOG1("CMsgMailViewAttachmentsDlg::ProcessCommandL %d ", |
|
178 aCommandId); |
|
179 HideMenu(); |
|
180 iAppUi.UnlockEntry(); |
|
181 |
|
182 switch (aCommandId) |
|
183 { |
|
184 case EMsgMailEditorCmdInsertMenu: |
|
185 DoShowSelectionListL(); |
|
186 break; |
|
187 case EMsgMailEditorCmdInsertImage: |
|
188 // Falltrought |
|
189 case EMsgMailEditorCmdInsertAudio: |
|
190 // Falltrought |
|
191 case EMsgMailEditorCmdInsertVideo: |
|
192 // Falltrought |
|
193 case EMsgMailEditorCmdInsertNote: |
|
194 // Falltrought |
|
195 case EMsgMailEditorCmdInsertOther: |
|
196 { |
|
197 //Fetch selected file from file system. |
|
198 iAppUi.DoFetchFileL(aCommandId); |
|
199 break; |
|
200 } |
|
201 case EMsgViewAttachmentCmdRemove: |
|
202 { |
|
203 TParsePtrC parser(iAttachmentModel.AttachmentInfoAt( |
|
204 iListBox->CurrentItemIndex()).FileName()); |
|
205 HBufC* string = StringLoader::LoadLC(R_MAIL_REMOVE_ATTACHMENT, |
|
206 parser.NameAndExt(), |
|
207 iEikonEnv); |
|
208 |
|
209 // Using delete query resource to save ROM |
|
210 if ( MailUtils::ConfirmationQueryL( |
|
211 *string, R_MAIL_EDITOR_DELETE_MESSAGE ) ) |
|
212 { |
|
213 CMsgViewAttachmentsDialog::ProcessCommandL( aCommandId ); |
|
214 } |
|
215 CleanupStack::PopAndDestroy( string ); |
|
216 break; |
|
217 } |
|
218 case EMsgMailEditorAttachmentsCmdExit: |
|
219 iAppUi.LockEntryL(); |
|
220 TryExitL(EAknSoftkeyOk); |
|
221 return; |
|
222 |
|
223 case EMsgViewAttachmentCmdOpen: |
|
224 OpenAttachmentL(); |
|
225 break; |
|
226 |
|
227 case EAknCmdHelp: |
|
228 |
|
229 if (iHelpSupported) |
|
230 { |
|
231 // Launch help |
|
232 HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), |
|
233 iEikonEnv->EikAppUi()->AppHelpContextL() ); |
|
234 } |
|
235 break; |
|
236 |
|
237 default: |
|
238 // call parent class to process other commands. |
|
239 CMsgViewAttachmentsDialog::ProcessCommandL(aCommandId); |
|
240 break; |
|
241 } |
|
242 } |
|
243 |
|
244 // ---------------------------------------------------------------------------- |
|
245 // CMsgMailViewAttachmentsDlg::GetHelpContext |
|
246 // This function is called when Help application is launched. |
|
247 // ---------------------------------------------------------------------------- |
|
248 // |
|
249 void CMsgMailViewAttachmentsDlg::GetHelpContext( |
|
250 TCoeHelpContext& aContext) const |
|
251 { |
|
252 if (iHelpSupported) |
|
253 { |
|
254 aContext.iMajor = TUid::Uid( KUidMsgMailEditor ); |
|
255 aContext.iContext = KMAIL_HLP_ATTACHMENTS_EDITOR(); |
|
256 } |
|
257 } |
|
258 |
|
259 // ---------------------------------------------------------------------------- |
|
260 // CMsgMailViewAttachmentsDlg::HandleListBoxEventL |
|
261 // ---------------------------------------------------------------------------- |
|
262 // |
|
263 void CMsgMailViewAttachmentsDlg::HandleListBoxEventL( |
|
264 CEikListBox* aListBox, |
|
265 TListBoxEvent aEventType ) |
|
266 { |
|
267 LOG1("CMsgMailViewAttachmentsDlg::HandleListBoxEventL %d ", aEventType ); |
|
268 switch( aEventType ) |
|
269 { |
|
270 case EEventEnterKeyPressed: |
|
271 { |
|
272 ProcessCommandL( EMsgViewAttachmentCmdOpen ); |
|
273 break; |
|
274 } |
|
275 default: |
|
276 { |
|
277 CMsgViewAttachmentsDialog::HandleListBoxEventL( |
|
278 aListBox, aEventType ); |
|
279 } |
|
280 } |
|
281 } |
|
282 |
|
283 // ---------------------------------------------------------------------------- |
|
284 // CMsgMailViewAttachmentsDlg::OpenAttachmentL |
|
285 // ---------------------------------------------------------------------------- |
|
286 // |
|
287 void CMsgMailViewAttachmentsDlg::OpenAttachmentL() |
|
288 { |
|
289 const TInt index(CurrentListItemIndex()); |
|
290 if (index == KErrNotFound) |
|
291 { |
|
292 return; // no attachments |
|
293 } |
|
294 |
|
295 const TMsvId id(iAttachmentModel.AttachmentInfoAt(index).AttachmentId()); |
|
296 TMsvId service; |
|
297 TMsvEntry entry; |
|
298 User::LeaveIfError( |
|
299 iAppUi.Document()->CurrentEntry().Session().GetEntry( |
|
300 id, service, entry) ); |
|
301 |
|
302 if (entry.iType==KUidMsvMessageEntry) |
|
303 { |
|
304 iAppUi.Document()->OpenMailMessageEntryL( entry ); |
|
305 } |
|
306 else |
|
307 { |
|
308 CMsgViewAttachmentsDialog::ProcessCommandL(EMsgViewAttachmentCmdOpen); |
|
309 } |
|
310 } |
|
311 |
|
312 void CMsgMailViewAttachmentsDlg::DoShowSelectionListL() |
|
313 { |
|
314 TInt selection( 0 ); |
|
315 |
|
316 CAknListQueryDialog* dlg = new ( ELeave ) CAknListQueryDialog( &selection ); |
|
317 |
|
318 dlg->PrepareLC( R_MAILEDITOR_ATTACHMENTVIEW_INSERT_SELECTIONLIST ); |
|
319 |
|
320 if ( dlg->RunLD() ) |
|
321 { |
|
322 TInt commandId( EMsgMailFirstFreeCmdId ); |
|
323 switch( selection ) |
|
324 { |
|
325 case 0: |
|
326 commandId = EMsgMailEditorCmdInsertImage; |
|
327 break; |
|
328 case 1: |
|
329 commandId = EMsgMailEditorCmdInsertVideo; |
|
330 break; |
|
331 case 2: // CSI: 47 # switch case |
|
332 commandId = EMsgMailEditorCmdInsertAudio; |
|
333 break; |
|
334 #ifdef EMAIL_PRESENTATION_SUPPORT |
|
335 case 3: // CSI: 47 # switch case |
|
336 commandId = EMsgMailEditorCmdInsertPresentation; |
|
337 break; |
|
338 case 4: // CSI: 47 # switch case |
|
339 commandId = EMsgMailEditorCmdInsertOther; |
|
340 break; |
|
341 #else |
|
342 case 3: // CSI: 47 # switch case |
|
343 commandId = EMsgMailEditorCmdInsertOther; |
|
344 break; |
|
345 #endif //EMAIL_PRESENTATION SUPPORT |
|
346 } |
|
347 |
|
348 iAppUi.LockEntryL(); |
|
349 // Fetch selected file from file system. |
|
350 iAppUi.DoFetchFileL( commandId ); |
|
351 } |
|
352 } |
|
353 |
|
354 // End of File |