|
1 /* |
|
2 * Copyright (c) 2006 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: Send sheduling setting item and setting page |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "cmsgmailshedulingsetting.h" |
|
20 #include "MsgMailEditorDocument.h" |
|
21 #include "MailLog.h" |
|
22 #include <MsgMailEditor.rsg> |
|
23 #include <StringLoader.h> |
|
24 |
|
25 |
|
26 inline void CMsgMailEditorShedulingSettingItem::ConstructL() |
|
27 { |
|
28 SetSettingValueL(); |
|
29 } |
|
30 |
|
31 CMsgMailEditorShedulingSettingItem* |
|
32 CMsgMailEditorShedulingSettingItem::NewL( |
|
33 TInt aIdentifier, CMsgMailEditorDocument& aDocument ) |
|
34 { |
|
35 CMsgMailEditorShedulingSettingItem* self = |
|
36 new( ELeave ) CMsgMailEditorShedulingSettingItem( |
|
37 aIdentifier, aDocument ); |
|
38 CleanupStack::PushL( self ); |
|
39 self->ConstructL(); |
|
40 CleanupStack::Pop(self); // self |
|
41 return self; |
|
42 } |
|
43 |
|
44 |
|
45 CMsgMailEditorShedulingSettingItem::CMsgMailEditorShedulingSettingItem( |
|
46 TInt aIdentifier, |
|
47 CMsgMailEditorDocument& aDocument ): |
|
48 CAknTextSettingItem( aIdentifier, iSettingValue ), |
|
49 iDocument( aDocument ) |
|
50 { |
|
51 // iSettingValue is set later |
|
52 } |
|
53 |
|
54 CMsgMailEditorShedulingSettingItem::~CMsgMailEditorShedulingSettingItem() |
|
55 { |
|
56 iSettingValue.Close(); |
|
57 delete iShedulingItems; |
|
58 } |
|
59 |
|
60 // ---------------------------------------------------------------------------- |
|
61 // // From CAknTextSettingItem |
|
62 // ---------------------------------------------------------------------------- |
|
63 // |
|
64 void CMsgMailEditorShedulingSettingItem::EditItemL( |
|
65 TBool aCalledFromMenu ) |
|
66 { |
|
67 if ( aCalledFromMenu ) |
|
68 { |
|
69 TPtrC settingName = SettingName(); |
|
70 TInt currentSelection( 0 ); |
|
71 NameArrayL( currentSelection ); |
|
72 |
|
73 CAknSettingPage* dlg = new( ELeave )CAknRadioButtonSettingPage( |
|
74 &settingName, |
|
75 SettingNumber(), |
|
76 EEikCtTextButton, |
|
77 SettingEditorResourceId(), |
|
78 SettingPageResourceId(), |
|
79 currentSelection, |
|
80 iShedulingItems ); |
|
81 SetSettingPage( dlg ); |
|
82 SettingPage()->SetSettingPageObserver( this ); // not used |
|
83 SettingPage()->ExecuteLD( CAknSettingPage::EUpdateWhenAccepted ); |
|
84 |
|
85 SaveSettingValueL( currentSelection ); |
|
86 SetSettingValueL(); |
|
87 LoadL(); // update setting value to listbox |
|
88 UpdateListBoxTextL(); |
|
89 SetSettingPage( 0 ); // it is deleted now |
|
90 } |
|
91 else |
|
92 { |
|
93 // change value |
|
94 DoChangeValueL(); |
|
95 SetSettingValueL(); |
|
96 LoadL(); // update setting value to listbox |
|
97 UpdateListBoxTextL(); |
|
98 } |
|
99 } |
|
100 |
|
101 // ---------------------------------------------------------------------------- |
|
102 // Create name array |
|
103 // ---------------------------------------------------------------------------- |
|
104 // |
|
105 void CMsgMailEditorShedulingSettingItem::NameArrayL( |
|
106 TInt& aSelected ) |
|
107 { |
|
108 LOG("CMsgMailEditorShedulingSettingItem::NameArrayL"); |
|
109 |
|
110 delete iShedulingItems; |
|
111 iShedulingItems = NULL; |
|
112 iShedulingItems = new(ELeave)CDesCArrayFlat(2); // CSI: 47 # For two texts. |
|
113 |
|
114 CCoeEnv* coeEnv = CCoeEnv::Static(); |
|
115 HBufC* text = StringLoader::LoadLC(R_TEXT_SHED_NOW, coeEnv); |
|
116 iShedulingItems->AppendL(*text); |
|
117 CleanupStack::PopAndDestroy(text); // text |
|
118 text = StringLoader::LoadLC(R_TEXT_SHED_NEXT, coeEnv); |
|
119 iShedulingItems->AppendL(*text); |
|
120 CleanupStack::PopAndDestroy(text); // text |
|
121 |
|
122 CMsgMailPreferences& prefs = iDocument.SendOptions(); |
|
123 |
|
124 aSelected = ( prefs.MessageScheduling() == |
|
125 CMsgMailPreferences::EMsgMailSchedulingNow ) ? 0 : 1; |
|
126 } |
|
127 |
|
128 // ---------------------------------------------------------------------------- |
|
129 // Save to settings |
|
130 // ---------------------------------------------------------------------------- |
|
131 // |
|
132 void CMsgMailEditorShedulingSettingItem::SaveSettingValueL( TInt aSelected ) |
|
133 { |
|
134 ASSERT( aSelected >= 0 && aSelected <= 1 ); |
|
135 |
|
136 CMsgMailPreferences& prefs = iDocument.SendOptions(); |
|
137 if ( aSelected == 0 ) |
|
138 { |
|
139 prefs.SetMessageScheduling( |
|
140 CMsgMailPreferences::EMsgMailSchedulingNow); |
|
141 } |
|
142 else |
|
143 { |
|
144 prefs.SetMessageScheduling( |
|
145 CMsgMailPreferences::EMsgMailSchedulingNextConn); |
|
146 } |
|
147 iDocument.SetChanged( ETrue ); |
|
148 } |
|
149 |
|
150 // ---------------------------------------------------------------------------- |
|
151 // Set current value to setting list |
|
152 // ---------------------------------------------------------------------------- |
|
153 // |
|
154 void CMsgMailEditorShedulingSettingItem::SetSettingValueL() |
|
155 { |
|
156 TInt stringResource(R_TEXT_SHED_NOW); |
|
157 |
|
158 CMsgMailPreferences& prefs = iDocument.SendOptions(); |
|
159 if( prefs.MessageScheduling() == |
|
160 CMsgMailPreferences::EMsgMailSchedulingNextConn ) |
|
161 { |
|
162 stringResource = R_TEXT_SHED_NEXT; |
|
163 } |
|
164 |
|
165 HBufC* sheduling = StringLoader::LoadLC( stringResource ); |
|
166 iSettingValue.Close(); |
|
167 iSettingValue.CreateL( *sheduling ); |
|
168 CleanupStack::PopAndDestroy( sheduling ); |
|
169 } |
|
170 |
|
171 //----------------------------------------------------------------------------- |
|
172 // Swap betveen values |
|
173 //----------------------------------------------------------------------------- |
|
174 void CMsgMailEditorShedulingSettingItem::DoChangeValueL() |
|
175 { |
|
176 CMsgMailPreferences& prefs = iDocument.SendOptions(); |
|
177 |
|
178 if ( prefs.MessageScheduling() == |
|
179 CMsgMailPreferences::EMsgMailSchedulingNow ) |
|
180 { |
|
181 prefs.SetMessageScheduling( |
|
182 CMsgMailPreferences::EMsgMailSchedulingNextConn ); |
|
183 } |
|
184 else |
|
185 { |
|
186 prefs.SetMessageScheduling( |
|
187 CMsgMailPreferences::EMsgMailSchedulingNow ); |
|
188 } |
|
189 |
|
190 iDocument.SetChanged(ETrue); |
|
191 } |
|
192 |
|
193 // End of File |