1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <aknviewappui.h> |
|
19 #include <eikmenub.h> |
|
20 #include <avkon.hrh> |
|
21 #include <akncontext.h> |
|
22 #include <akntitle.h> |
|
23 #include <stringloader.h> |
|
24 #include <barsread.h> |
|
25 #include <eikbtgpc.h> |
|
26 #include <SyncFwCustomizer.rsg> |
|
27 #include <centralrepository.h> |
|
28 #include <NSmlOperatorDataCRKeys.h> |
|
29 #include <syncmlclient.h> |
|
30 #include <syncmlclientds.h> |
|
31 #include <syncmldef.h> |
|
32 #include <AknQueryDialog.h> |
|
33 |
|
34 #include "SyncFwCustomizer.hrh" |
|
35 #include "SyncFwCustomizerSettingItemListView.h" |
|
36 #include "SyncFwCustomizerSettingItemList.hrh" |
|
37 #include "SyncFwCustomizerSettingItemList.h" |
|
38 |
|
39 const TInt KOperatorProfileId = 4; |
|
40 |
|
41 /** |
|
42 * First phase of Symbian two-phase construction. Should not contain any |
|
43 * code that could leave. |
|
44 */ |
|
45 CSyncFwCustomizerSettingItemListView::CSyncFwCustomizerSettingItemListView() |
|
46 { |
|
47 } |
|
48 |
|
49 /** |
|
50 * The view's destructor removes the container from the control |
|
51 * stack and destroys it. |
|
52 */ |
|
53 CSyncFwCustomizerSettingItemListView::~CSyncFwCustomizerSettingItemListView() |
|
54 { |
|
55 delete iRepository; |
|
56 } |
|
57 |
|
58 /** |
|
59 * Symbian two-phase constructor. |
|
60 * This creates an instance then calls the second-phase constructor |
|
61 * without leaving the instance on the cleanup stack. |
|
62 * @return new instance of CSyncFwCustomizerSettingItemListView |
|
63 */ |
|
64 CSyncFwCustomizerSettingItemListView* CSyncFwCustomizerSettingItemListView::NewL() |
|
65 { |
|
66 CSyncFwCustomizerSettingItemListView* self = CSyncFwCustomizerSettingItemListView::NewLC(); |
|
67 CleanupStack::Pop( self ); |
|
68 return self; |
|
69 } |
|
70 |
|
71 /** |
|
72 * Symbian two-phase constructor. |
|
73 * This creates an instance, pushes it on the cleanup stack, |
|
74 * then calls the second-phase constructor. |
|
75 * @return new instance of CSyncFwCustomizerSettingItemListView |
|
76 */ |
|
77 CSyncFwCustomizerSettingItemListView* CSyncFwCustomizerSettingItemListView::NewLC() |
|
78 { |
|
79 CSyncFwCustomizerSettingItemListView* self = new ( ELeave ) CSyncFwCustomizerSettingItemListView(); |
|
80 CleanupStack::PushL( self ); |
|
81 self->ConstructL(); |
|
82 return self; |
|
83 } |
|
84 |
|
85 /** |
|
86 * Second-phase constructor for view. |
|
87 * Initialize contents from resource. |
|
88 */ |
|
89 void CSyncFwCustomizerSettingItemListView::ConstructL() |
|
90 { |
|
91 BaseConstructL( R_SYNC_FW_CUSTOMIZER_SETTING_ITEM_LIST_SYNC_FW_CUSTOMIZER_SETTING_ITEM_LIST_VIEW ); |
|
92 iRepository = CRepository::NewL( KCRUidOperatorDatasyncInternalKeys ); |
|
93 } |
|
94 |
|
95 /** |
|
96 * @return The UID for this view |
|
97 */ |
|
98 TUid CSyncFwCustomizerSettingItemListView::Id() const |
|
99 { |
|
100 return TUid::Uid( ESyncFwCustomizerSettingItemListViewId ); |
|
101 } |
|
102 |
|
103 /** |
|
104 * Handle a command for this view (override) |
|
105 * @param aCommand command id to be handled |
|
106 */ |
|
107 void CSyncFwCustomizerSettingItemListView::HandleCommandL( TInt aCommand ) |
|
108 { |
|
109 TBool commandHandled = EFalse; |
|
110 switch ( aCommand ) |
|
111 { // code to dispatch to the AknView's menu and CBA commands is generated here |
|
112 case ESyncFwCustomizerSettingEdit: |
|
113 commandHandled = HandleChangeSelectedSettingItemL(); |
|
114 break; |
|
115 case ESyncFwCustomizerSettingReset: |
|
116 commandHandled = ResetSelectedSettingItemL(); |
|
117 break; |
|
118 case ESyncFwCustomizerSettingSync: |
|
119 commandHandled = StartSyncL(); |
|
120 break; |
|
121 |
|
122 default: |
|
123 break; |
|
124 } |
|
125 |
|
126 if ( !commandHandled ) |
|
127 { |
|
128 if ( aCommand == EAknSoftkeyExit ) |
|
129 { |
|
130 AppUi()->HandleCommandL( EEikCmdExit ); |
|
131 } |
|
132 } |
|
133 } |
|
134 |
|
135 /** |
|
136 * Handles user actions during activation of the view, |
|
137 * such as initializing the content. |
|
138 */ |
|
139 void CSyncFwCustomizerSettingItemListView::DoActivateL( |
|
140 const TVwsViewId& /*aPrevViewId*/, |
|
141 TUid /*aCustomMessageId*/, |
|
142 const TDesC8& /*aCustomMessage*/ ) |
|
143 { |
|
144 SetupStatusPaneL(); |
|
145 |
|
146 if ( iSyncFwCustomizerSettingItemList == NULL ) |
|
147 { |
|
148 iSettings = TSyncFwCustomizerSettingItemListSettings::NewL(*iRepository); |
|
149 iSyncFwCustomizerSettingItemList = new ( ELeave ) CSyncFwCustomizerSettingItemList( *iSettings, this, *iRepository ); |
|
150 iSyncFwCustomizerSettingItemList->SetMopParent( this ); |
|
151 iSyncFwCustomizerSettingItemList->ConstructFromResourceL( R_SYNC_FW_CUSTOMIZER_SETTING_ITEM_LIST_SYNC_FW_CUSTOMIZER_SETTING_ITEM_LIST ); |
|
152 iSyncFwCustomizerSettingItemList->ActivateL(); |
|
153 iSyncFwCustomizerSettingItemList->LoadSettingValuesL(); |
|
154 iSyncFwCustomizerSettingItemList->LoadSettingsL(); |
|
155 AppUi()->AddToStackL( *this, iSyncFwCustomizerSettingItemList ); |
|
156 } |
|
157 } |
|
158 |
|
159 /** |
|
160 */ |
|
161 void CSyncFwCustomizerSettingItemListView::DoDeactivate() |
|
162 { |
|
163 CleanupStatusPane(); |
|
164 |
|
165 if ( iSyncFwCustomizerSettingItemList != NULL ) |
|
166 { |
|
167 AppUi()->RemoveFromStack( iSyncFwCustomizerSettingItemList ); |
|
168 delete iSyncFwCustomizerSettingItemList; |
|
169 iSyncFwCustomizerSettingItemList = NULL; |
|
170 delete iSettings; |
|
171 iSettings = NULL; |
|
172 } |
|
173 } |
|
174 |
|
175 /** |
|
176 * Handle status pane size change for this view (override) |
|
177 */ |
|
178 void CSyncFwCustomizerSettingItemListView::HandleStatusPaneSizeChange() |
|
179 { |
|
180 CAknView::HandleStatusPaneSizeChange(); |
|
181 |
|
182 // this may fail, but we're not able to propagate exceptions here |
|
183 TVwsViewId view; |
|
184 AppUi()->GetActiveViewId( view ); |
|
185 if ( view.iViewUid == Id() ) |
|
186 { |
|
187 TInt result; |
|
188 TRAP( result, SetupStatusPaneL() ); |
|
189 } |
|
190 } |
|
191 |
|
192 void CSyncFwCustomizerSettingItemListView::SetupStatusPaneL() |
|
193 { |
|
194 // reset the context pane |
|
195 TUid contextPaneUid = TUid::Uid( EEikStatusPaneUidContext ); |
|
196 CEikStatusPaneBase::TPaneCapabilities subPaneContext = |
|
197 StatusPane()->PaneCapabilities( contextPaneUid ); |
|
198 if ( subPaneContext.IsPresent() && subPaneContext.IsAppOwned() ) |
|
199 { |
|
200 CAknContextPane* context = static_cast< CAknContextPane* > ( |
|
201 StatusPane()->ControlL( contextPaneUid ) ); |
|
202 context->SetPictureToDefaultL(); |
|
203 } |
|
204 |
|
205 // setup the title pane |
|
206 TUid titlePaneUid = TUid::Uid( EEikStatusPaneUidTitle ); |
|
207 CEikStatusPaneBase::TPaneCapabilities subPaneTitle = |
|
208 StatusPane()->PaneCapabilities( titlePaneUid ); |
|
209 if ( subPaneTitle.IsPresent() && subPaneTitle.IsAppOwned() ) |
|
210 { |
|
211 CAknTitlePane* title = static_cast< CAknTitlePane* >( |
|
212 StatusPane()->ControlL( titlePaneUid ) ); |
|
213 TResourceReader reader; |
|
214 iEikonEnv->CreateResourceReaderLC( reader, R_SYNC_FW_CUSTOMIZER_SETTING_ITEM_LIST_TITLE_RESOURCE ); |
|
215 title->SetFromResourceL( reader ); |
|
216 CleanupStack::PopAndDestroy(); // reader internal state |
|
217 } |
|
218 } |
|
219 |
|
220 void CSyncFwCustomizerSettingItemListView::CleanupStatusPane() |
|
221 { |
|
222 } |
|
223 |
|
224 /** |
|
225 * Handle the selected event. |
|
226 * @param aCommand the command id invoked |
|
227 * @return ETrue if the command was handled, EFalse if not |
|
228 */ |
|
229 TBool CSyncFwCustomizerSettingItemListView::HandleChangeSelectedSettingItemL() |
|
230 { |
|
231 iSyncFwCustomizerSettingItemList->ChangeSelectedItemL(); |
|
232 return ETrue; |
|
233 } |
|
234 |
|
235 TBool CSyncFwCustomizerSettingItemListView::ResetSelectedSettingItemL( ) |
|
236 { |
|
237 iSyncFwCustomizerSettingItemList->ResetSelectedItemL(); |
|
238 return ETrue; |
|
239 } |
|
240 |
|
241 TBool CSyncFwCustomizerSettingItemListView::StartSyncL( ) |
|
242 { |
|
243 // Open syncML session |
|
244 RSyncMLSession syncMLSession; |
|
245 RSyncMLDataSyncJob job; |
|
246 CleanupClosePushL(syncMLSession); |
|
247 CleanupClosePushL(job); |
|
248 syncMLSession.OpenL(); |
|
249 |
|
250 // Need instance of data sync class |
|
251 // For creating a data sync job, need to specify id of the profile used for synchronization |
|
252 // If profile selected is PCSuite, it searches for the bluetooth device to sync with |
|
253 TInt profileId = KOperatorProfileId; |
|
254 CAknNumberQueryDialog* d = CAknNumberQueryDialog::NewL( profileId ); |
|
255 d->ExecuteLD( R_SYNC_FW_CUSTOMIZER_NUMBER_QUERY ); |
|
256 job.CreateL( syncMLSession, profileId ); |
|
257 // close the job |
|
258 job.Close(); |
|
259 // close the syncML session |
|
260 CleanupStack::PopAndDestroy(&job); |
|
261 CleanupStack::PopAndDestroy(&syncMLSession); |
|
262 return ETrue; |
|
263 } |
|