|
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: Implements a dialog for view/edit sending options |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "MsgMailUIDs.h" |
|
21 #include "MsgMailOptionsDlg.h" |
|
22 #include "MsgMailEditorAppUi.h" |
|
23 #include "MsgMailEditorDocument.h" |
|
24 #include "msgmaileditor.hrh" |
|
25 #include "cmsgmaileditorsettinglist.h" |
|
26 #include "csxhelp/mail.hlp.hrh" |
|
27 #include <akntitle.h> |
|
28 #include <hlplch.h> |
|
29 #include <MsgEditor.hrh> |
|
30 #include <MsgMailEditor.rsg> |
|
31 #include <StringLoader.h> |
|
32 |
|
33 |
|
34 // ================= MEMBER FUNCTIONS ======================= |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // CMsgMailOptionsDlg::NewL |
|
38 // ----------------------------------------------------------------------------- |
|
39 CMsgMailOptionsDlg* CMsgMailOptionsDlg::NewL(CMsgMailEditorDocument* aDocument, |
|
40 TBool aHelpSupported) |
|
41 { |
|
42 ASSERT(aDocument); |
|
43 CMsgMailOptionsDlg* self = new( ELeave ) CMsgMailOptionsDlg; |
|
44 self->iDocument = aDocument; |
|
45 self->ConstructL(); |
|
46 self->iHelpSupported = aHelpSupported; |
|
47 return self; |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // Constructor |
|
52 // ----------------------------------------------------------------------------- |
|
53 CMsgMailOptionsDlg::CMsgMailOptionsDlg() |
|
54 {} |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CMsgMailOptionsDlg::ConstructL() |
|
58 // ----------------------------------------------------------------------------- |
|
59 inline void CMsgMailOptionsDlg::ConstructL() |
|
60 { |
|
61 CAknDialog::ConstructL( R_SEND_OPTIONS_MENUBAR ); |
|
62 CEikStatusPane *sp = |
|
63 static_cast<CAknAppUi*> ( iEikonEnv->EikAppUi() )->StatusPane(); |
|
64 iTitlePane = static_cast<CAknTitlePane *> ( sp->ControlL( |
|
65 TUid::Uid(EEikStatusPaneUidTitle))); |
|
66 |
|
67 iOldTitlePaneText = iTitlePane->Text()->AllocL(); |
|
68 TResourceReader reader; |
|
69 iCoeEnv->CreateResourceReaderLC(reader, R_SEND_OPTIONS_TITLE_TEXT); |
|
70 iTitlePane->SetFromResourceL(reader); |
|
71 CleanupStack::PopAndDestroy(); // CSI: 12 # reader |
|
72 } |
|
73 |
|
74 //----------------------------------------------------------------------------- |
|
75 // Destructor |
|
76 //----------------------------------------------------------------------------- |
|
77 CMsgMailOptionsDlg::~CMsgMailOptionsDlg() |
|
78 { |
|
79 delete iSettingList; |
|
80 |
|
81 if ( iOldTitlePaneText && iTitlePane ) |
|
82 { |
|
83 // Code scanner warning ignored, since existance of data |
|
84 // member is checked before accessing |
|
85 iTitlePane->SetText(iOldTitlePaneText); // CSI: 23 # See comment above |
|
86 } |
|
87 } |
|
88 |
|
89 //----------------------------------------------------------------------------- |
|
90 // CMsgMailOptionsDlg::OkToExitL() |
|
91 //----------------------------------------------------------------------------- |
|
92 TBool CMsgMailOptionsDlg::OkToExitL(TInt aButtonId) |
|
93 { |
|
94 if ( aButtonId == EAknSoftkeyBack ) |
|
95 { |
|
96 return ETrue; |
|
97 } |
|
98 else if( aButtonId == EMsgMailSendOptionsChange ) |
|
99 { |
|
100 ProcessCommandL( aButtonId ); |
|
101 return EFalse; |
|
102 } |
|
103 |
|
104 return CAknDialog::OkToExitL(aButtonId); |
|
105 } |
|
106 |
|
107 //----------------------------------------------------------------------------- |
|
108 // CMsgMailOptionsDlg::ProcessCommandL() |
|
109 //----------------------------------------------------------------------------- |
|
110 void CMsgMailOptionsDlg::ProcessCommandL(TInt aCommandId) |
|
111 { |
|
112 const TBool calledFromMenu( MenuShowing() ); |
|
113 CAknDialog::ProcessCommandL(aCommandId); |
|
114 |
|
115 if ( aCommandId == EAknCmdHelp && iHelpSupported ) |
|
116 { |
|
117 |
|
118 CArrayFix<TCoeHelpContext>* help = |
|
119 new( ELeave ) CArrayFixFlat<TCoeHelpContext>( 1 ); |
|
120 |
|
121 TCoeHelpContext helpContext; |
|
122 |
|
123 |
|
124 helpContext = TCoeHelpContext( TUid::Uid( KUidMsgMailEditor ), |
|
125 KMAIL_HLP_SENDING_OPTIONS() ); |
|
126 |
|
127 help->AppendL(helpContext); |
|
128 |
|
129 // Launch help |
|
130 HlpLauncher::LaunchHelpApplicationL( iEikonEnv->WsSession(), |
|
131 help ); |
|
132 |
|
133 } |
|
134 else if ( aCommandId == EMsgMailEditorSendOptionsCmdExit ) |
|
135 { |
|
136 TryExitL(EAknSoftkeyOk); |
|
137 } |
|
138 else if ( aCommandId == EMsgMailSendOptionsChange ) |
|
139 { |
|
140 TInt index = iSettingList->ListBox()->CurrentItemIndex(); |
|
141 iSettingList->EditItemL( index, calledFromMenu ); |
|
142 //Update settings after editing. This needs to be done because |
|
143 //changing mailbox affects also on reply-to setting. |
|
144 iSettingList->LoadSettingsL(); |
|
145 iSettingList->DrawNow(); |
|
146 |
|
147 } |
|
148 } |
|
149 |
|
150 //----------------------------------------------------------------------------- |
|
151 // CMsgMailOptionsDlg::OfferKeyEventL() |
|
152 //----------------------------------------------------------------------------- |
|
153 TKeyResponse CMsgMailOptionsDlg::OfferKeyEventL( |
|
154 const TKeyEvent& aKeyEvent, |
|
155 TEventCode aType ) |
|
156 { |
|
157 ASSERT( iSettingList ); |
|
158 |
|
159 TKeyResponse response = iSettingList->OfferKeyEventL( aKeyEvent, aType ); |
|
160 |
|
161 if ( response == EKeyWasNotConsumed ) |
|
162 { |
|
163 // Let the base class handle the event |
|
164 response = CAknDialog::OfferKeyEventL( aKeyEvent, aType ); |
|
165 } |
|
166 |
|
167 if (aType == EEventKey && aKeyEvent.iCode == EKeyEscape) |
|
168 { // must exit application (e.g. End key) |
|
169 ProcessCommandL(EMsgMailEditorSendOptionsCmdExit); |
|
170 } |
|
171 |
|
172 return response; |
|
173 } |
|
174 |
|
175 //----------------------------------------------------------------------------- |
|
176 // CMsgMailOptionsDlg::DynInitMenuPaneL() |
|
177 //----------------------------------------------------------------------------- |
|
178 void CMsgMailOptionsDlg::DynInitMenuPaneL(TInt aMenuId, CEikMenuPane* aMenuPane) |
|
179 { |
|
180 if (aMenuId == R_SEND_OPTIONS_MENU) |
|
181 { |
|
182 aMenuPane->SetItemDimmed( EAknCmdHelp, !iHelpSupported); |
|
183 } |
|
184 } |
|
185 |
|
186 //----------------------------------------------------------------------------- |
|
187 // From CEikDialog |
|
188 //----------------------------------------------------------------------------- |
|
189 void CMsgMailOptionsDlg::PreLayoutDynInitL() |
|
190 { |
|
191 iSettingList = CMailEditorSettingList::NewL( |
|
192 *iDocument, R_SERVICE_SETTINGS_LIST ); |
|
193 ASSERT( iSettingList ); |
|
194 |
|
195 iSettingList->ListBox()->SetListBoxObserver( this ); |
|
196 iSettingList->SetMopParent( this ); |
|
197 iSettingList->MakeVisible( ETrue ); |
|
198 iSettingList->ActivateL(); |
|
199 } |
|
200 |
|
201 |
|
202 //----------------------------------------------------------------------------- |
|
203 // CMsgMailOptionsDlg::SizeChanged() |
|
204 //----------------------------------------------------------------------------- |
|
205 void CMsgMailOptionsDlg::SizeChanged() |
|
206 { |
|
207 CAknDialog::SizeChanged(); |
|
208 |
|
209 if ( iSettingList ) |
|
210 { |
|
211 TRect parent; |
|
212 AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, parent ); |
|
213 AknLayoutUtils::LayoutControl( |
|
214 iSettingList, parent, AknLayout::list_gen_pane( 0 ) ); |
|
215 } |
|
216 } |
|
217 |
|
218 //----------------------------------------------------------------------------- |
|
219 // CMsgMailOptionsDlg::SizeChanged() |
|
220 //----------------------------------------------------------------------------- |
|
221 void CMsgMailOptionsDlg::HandleResourceChange( TInt aType ) |
|
222 { |
|
223 // We mustn't call SizeChanged for all resource changes since that |
|
224 // isn't needed for KAknsMessageSkinChange events and would slow down |
|
225 // skin change operation. CAknDialog and other controls can handle |
|
226 // resizing on their own. |
|
227 |
|
228 CAknDialog::HandleResourceChange(aType); |
|
229 |
|
230 CEikStatusPane* statusPane = iAvkonAppUi->StatusPane(); |
|
231 if ( statusPane ) |
|
232 { |
|
233 statusPane->HandleResourceChange( aType ); |
|
234 } |
|
235 if ( iSettingList ) |
|
236 { |
|
237 iSettingList->HandleResourceChange( aType ); |
|
238 } |
|
239 } |
|
240 |
|
241 //----------------------------------------------------------------------------- |
|
242 // CMsgMailOptionsDlg::HandleListBoxEventL() |
|
243 //----------------------------------------------------------------------------- |
|
244 void CMsgMailOptionsDlg::HandleListBoxEventL(CEikListBox* aListBox, |
|
245 TListBoxEvent aEventType) |
|
246 { |
|
247 iSettingList->HandleListBoxEventL( aListBox, aEventType ); |
|
248 |
|
249 // Refresh settings listbox when items are edited |
|
250 if ( aEventType == EEventItemDoubleClicked ) |
|
251 { |
|
252 iSettingList->LoadSettingsL(); |
|
253 iSettingList->DrawNow(); |
|
254 } |
|
255 |
|
256 } |
|
257 // End of File |