18
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2007 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: XDM GS plugin main list container.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
// INCLUDE FILES
|
|
22 |
#include "XDMExternalInterface.h"
|
|
23 |
|
|
24 |
#include <aknappui.h>
|
|
25 |
#include <akntitle.h>
|
|
26 |
#include <eikspane.h>
|
|
27 |
#include <barsread.h>
|
|
28 |
#include <eiktxlbm.h>
|
|
29 |
#include <StringLoader.h>
|
|
30 |
#include <aknlists.h>
|
|
31 |
#include <AknUtils.h>
|
|
32 |
#include <eiksbfrm.h>
|
|
33 |
#include <AknQueryDialog.h>
|
|
34 |
#include <XdmSettingsApi.h>
|
|
35 |
|
|
36 |
#include "SettingsData.h"
|
|
37 |
#include "XDMPluginContainer.h"
|
|
38 |
|
|
39 |
#include <csxhelp/xdm.hlp.hrh>
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
|
|
44 |
// ---------------------------------------------------------------------------
|
|
45 |
// CXDMPluginContainer::CXDMPluginContainer()
|
|
46 |
// ---------------------------------------------------------------------------
|
|
47 |
//
|
|
48 |
CXDMPluginContainer::CXDMPluginContainer(CAknView* aView) : iView(aView)
|
|
49 |
{
|
|
50 |
SetComponentsToInheritVisibility( ETrue );
|
|
51 |
}
|
|
52 |
|
|
53 |
// ---------------------------------------------------------------------------
|
|
54 |
// CXDMPluginContainer::ConstructL(const TRect& aRect)
|
|
55 |
// Symbian OS two phased constructor
|
|
56 |
//
|
|
57 |
// ---------------------------------------------------------------------------
|
|
58 |
//
|
|
59 |
void CXDMPluginContainer::ConstructL( const TRect& aRect )
|
|
60 |
{
|
|
61 |
#ifdef _DEBUG
|
|
62 |
RDebug::Print( _L( "[CXDMPluginContainer] ConstructL()" ) );
|
|
63 |
#endif
|
|
64 |
|
|
65 |
CEikStatusPane* sp = static_cast<CAknAppUi*>
|
|
66 |
( CEikonEnv::Static()->EikAppUi() )->StatusPane();
|
|
67 |
iTitlePane = static_cast<CAknTitlePane*>
|
|
68 |
( sp->ControlL( TUid::Uid( EEikStatusPaneUidTitle ) ) );
|
|
69 |
|
|
70 |
// Set title
|
|
71 |
|
|
72 |
StringLoader::Load ( iTitle, R_STR_XDM_TITLE_PANE_TEXT );
|
|
73 |
iTitlePane->SetTextL(iTitle);// FromResourceL( rReader );
|
|
74 |
CreateWindowL(); // Makes the control a window-owning control
|
|
75 |
|
|
76 |
// Main List creation and initialization
|
|
77 |
iMainList = new(ELeave) CAknSingleStyleListBox();
|
|
78 |
iMainList->SetContainerWindowL(*this);
|
|
79 |
iMainList->ConstructL(this, EAknListBoxLoopScrolling);
|
|
80 |
|
|
81 |
// Main list scroll bar issues
|
|
82 |
iMainList->CreateScrollBarFrameL(EFalse);
|
|
83 |
iMainList->ScrollBarFrame()->SetScrollBarVisibilityL(
|
|
84 |
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
|
|
85 |
|
|
86 |
// Empty text processing
|
|
87 |
_LIT (KStringHeader, "%S\n%S");
|
|
88 |
HBufC* emptyText = iEikonEnv->AllocReadResourceLC( R_STR_XDM_EMPTY_TEXT );
|
|
89 |
HBufC* emptyText2 = iEikonEnv->AllocReadResourceLC( R_STR_XDM_EMPTY_TEXT_SEC);
|
|
90 |
HBufC* emptyFinal = HBufC::NewLC(
|
|
91 |
emptyText->Length() + emptyText2->Length() + 2 );// 2 is length of "\n"
|
|
92 |
emptyFinal->Des().Format(KStringHeader, emptyText, emptyText2);
|
|
93 |
|
|
94 |
iMainList->SetListBoxObserver(this);
|
|
95 |
iMainList->View()->SetListEmptyTextL(*emptyFinal);
|
|
96 |
CleanupStack::PopAndDestroy(3, emptyText);//emptyText, emptyText2, emptyFinal
|
|
97 |
|
|
98 |
// This call fails if Problems in XDM API, so leave if error
|
|
99 |
TRAPD(err,SetupListL());
|
|
100 |
User::LeaveIfError(err);
|
|
101 |
|
|
102 |
SetRect( aRect );
|
|
103 |
ActivateL();
|
|
104 |
|
|
105 |
iEikMenuBar = new ( ELeave ) CEikMenuBar();
|
|
106 |
iEikMenuBar->ConstructL( this, NULL, R_GS_XDM_SETTINGS_MAIN_MENUBAR );
|
|
107 |
|
|
108 |
#ifdef _DEBUG
|
|
109 |
RDebug::Print( _L( "[CXDMPluginContainer] Construct done" ) );
|
|
110 |
#endif
|
|
111 |
|
|
112 |
}
|
|
113 |
|
|
114 |
// ---------------------------------------------------------------------------
|
|
115 |
// CXDMPluginContainer::~CXDMPluginContainer()
|
|
116 |
// Destructor
|
|
117 |
//
|
|
118 |
// ---------------------------------------------------------------------------
|
|
119 |
//
|
|
120 |
CXDMPluginContainer::~CXDMPluginContainer()
|
|
121 |
{
|
|
122 |
if (iMainList)
|
|
123 |
{
|
|
124 |
delete iMainList;
|
|
125 |
}
|
|
126 |
|
|
127 |
delete iEikMenuBar;
|
|
128 |
}
|
|
129 |
|
|
130 |
// ---------------------------------------------------------------------------
|
|
131 |
// CXDMPluginContainer::SizeChanged()
|
|
132 |
// ---------------------------------------------------------------------------
|
|
133 |
//
|
|
134 |
void CXDMPluginContainer::SizeChanged()
|
|
135 |
{
|
|
136 |
iMainList->SetRect(Rect());
|
|
137 |
}
|
|
138 |
|
|
139 |
// ---------------------------------------------------------------------------
|
|
140 |
// CXDMPluginContainer::CountComponentControls() const
|
|
141 |
// ---------------------------------------------------------------------------
|
|
142 |
//
|
|
143 |
TInt CXDMPluginContainer::CountComponentControls() const
|
|
144 |
{
|
|
145 |
return 1;
|
|
146 |
}
|
|
147 |
|
|
148 |
// ---------------------------------------------------------------------------
|
|
149 |
// CXDMPluginContainer::ComponentControl() const
|
|
150 |
// ---------------------------------------------------------------------------
|
|
151 |
//
|
|
152 |
CCoeControl* CXDMPluginContainer::ComponentControl( TInt aIndex ) const
|
|
153 |
{
|
|
154 |
switch ( aIndex )
|
|
155 |
{
|
|
156 |
case 0:
|
|
157 |
return iMainList;
|
|
158 |
default:
|
|
159 |
return NULL;
|
|
160 |
}
|
|
161 |
}
|
|
162 |
|
|
163 |
// ---------------------------------------------------------------------------
|
|
164 |
// CXDMPluginContainer::EditCurrentItemL()
|
|
165 |
// ---------------------------------------------------------------------------
|
|
166 |
//
|
|
167 |
void CXDMPluginContainer::EditCurrentItemL()
|
|
168 |
{
|
|
169 |
TPtrC16 xDMSetName;
|
|
170 |
TPtrC16 xDMSetNameClipped;
|
|
171 |
xDMSetName.Set(iSettingListArray->MdcaPoint(iMainList->CurrentItemIndex()));
|
|
172 |
xDMSetNameClipped.Set(xDMSetName.Mid(1)); // remove '/t' from the begining
|
|
173 |
CXDMPlugin* iTempView = static_cast<CXDMPlugin*> (iView);
|
|
174 |
iTempView->LoadSettingsViewL(EEditExisting, xDMSetNameClipped);
|
|
175 |
}
|
|
176 |
|
|
177 |
// ---------------------------------------------------------------------------
|
|
178 |
// CXDMPluginContainer::GetCurrentSetNameLC()
|
|
179 |
// ---------------------------------------------------------------------------
|
|
180 |
//
|
|
181 |
HBufC* CXDMPluginContainer::GetCurrentSetNameLC()
|
|
182 |
{
|
|
183 |
TPtrC16 xDMSetName;
|
|
184 |
TPtrC16 xDMSetNameClipped;
|
|
185 |
xDMSetName.Set(iSettingListArray->MdcaPoint(iMainList->CurrentItemIndex()));
|
|
186 |
xDMSetNameClipped.Set(xDMSetName.Mid(1)); // remove '/t' from the begining
|
|
187 |
|
|
188 |
HBufC* name = xDMSetNameClipped.AllocLC();
|
|
189 |
TPtr ptr(name->Des());
|
|
190 |
AknTextUtils::ConvertDigitsTo(ptr, EDigitTypeWestern );
|
|
191 |
|
|
192 |
return name;
|
|
193 |
}
|
|
194 |
|
|
195 |
|
|
196 |
// ---------------------------------------------------------------------------
|
|
197 |
// CXDMPluginContainer::OfferKeyEventL()
|
|
198 |
// ---------------------------------------------------------------------------
|
|
199 |
//
|
|
200 |
TKeyResponse CXDMPluginContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent,
|
|
201 |
TEventCode aType )
|
|
202 |
{
|
|
203 |
if (iMainList)
|
|
204 |
{
|
|
205 |
// if cancel key is pressed and list is not empty, invoke deletion
|
|
206 |
if ((aKeyEvent.iCode == EKeyBackspace ) && (aType == EEventKey) &&
|
|
207 |
iEikMenuBar->ItemSpecificCommandsEnabled() )
|
|
208 |
{
|
|
209 |
if(!IsListEmpty())
|
|
210 |
DeleteSetProcedureL();
|
|
211 |
CXDMPlugin* iTempView = static_cast<CXDMPlugin*> (iView);
|
|
212 |
iTempView->UpdateMskL();
|
|
213 |
return EKeyWasConsumed;
|
|
214 |
}
|
|
215 |
else
|
|
216 |
{
|
|
217 |
return iMainList->OfferKeyEventL (aKeyEvent, aType);
|
|
218 |
}
|
|
219 |
}
|
|
220 |
return EKeyWasNotConsumed;
|
|
221 |
}
|
|
222 |
|
|
223 |
// ---------------------------------------------------------------------------
|
|
224 |
// CXDMPluginContainer::HandleListBoxEventL()
|
|
225 |
// ---------------------------------------------------------------------------
|
|
226 |
//
|
|
227 |
void CXDMPluginContainer::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aListBoxEvent)
|
|
228 |
{
|
|
229 |
// if the Select Key has been pressed
|
|
230 |
if ((aListBoxEvent == MEikListBoxObserver::EEventEnterKeyPressed) ||
|
|
231 |
(aListBoxEvent == MEikListBoxObserver::EEventItemSingleClicked))
|
|
232 |
{
|
|
233 |
EditCurrentItemL();
|
|
234 |
}
|
|
235 |
}
|
|
236 |
|
|
237 |
// ---------------------------------------------------------------------------
|
|
238 |
// CXDMPluginContainer::SetupListL()
|
|
239 |
// ---------------------------------------------------------------------------
|
|
240 |
//
|
|
241 |
void CXDMPluginContainer::SetupListL()
|
|
242 |
{
|
|
243 |
CTextListBoxModel* model = iMainList->Model();
|
|
244 |
model->SetOwnershipType(ELbmOwnsItemArray);
|
|
245 |
|
|
246 |
iSettingListArray = STATIC_CAST(CDesCArray*,model->ItemTextArray());
|
|
247 |
LoadSettingsListArrayL();
|
|
248 |
}
|
|
249 |
|
|
250 |
// ---------------------------------------------------------------------------
|
|
251 |
// CXDMPluginContainer::LoadSettingsListArrayL()
|
|
252 |
// ---------------------------------------------------------------------------
|
|
253 |
//
|
|
254 |
void CXDMPluginContainer::LoadSettingsListArrayL()
|
|
255 |
{
|
|
256 |
iTitlePane->SetTextL(iTitle);
|
|
257 |
_LIT (KStringHeader, "\t%S");
|
|
258 |
TBuf <KMaxSettingSetNameLength+2> myString; // maximum name + \t
|
|
259 |
RArray<TInt> settingIds;
|
|
260 |
CleanupClosePushL(settingIds);
|
|
261 |
CDesCArray* xdmSetList = NULL;
|
|
262 |
TRAPD(err, xdmSetList = LoadCollectionNamesL(settingIds));
|
|
263 |
if(err!=KErrNone)
|
|
264 |
{
|
|
265 |
CleanupStack::PopAndDestroy(1); //settingIds
|
|
266 |
return;
|
|
267 |
}
|
|
268 |
CleanupStack::PushL(xdmSetList);
|
|
269 |
TInt xdmSetListCount = xdmSetList->Count();
|
|
270 |
iSettingListArray->Reset();
|
|
271 |
for (TInt i = 0; i< xdmSetListCount; i++)
|
|
272 |
{
|
|
273 |
myString.Format(KStringHeader, &(xdmSetList->MdcaPoint(i)));
|
|
274 |
AknTextUtils::LanguageSpecificNumberConversion(myString);
|
|
275 |
iSettingListArray->AppendL (myString);
|
|
276 |
}
|
|
277 |
iSettingListArray->Sort(ECmpCollated);
|
|
278 |
CleanupStack::PopAndDestroy(2); //xdmSetList,settingIds
|
|
279 |
iMainList->HandleItemRemovalL();
|
|
280 |
iMainList->HandleItemAdditionL();
|
|
281 |
}
|
|
282 |
|
|
283 |
// ---------------------------------------------------------------------------
|
|
284 |
// CXDMPluginContainer::IsListEmpty()
|
|
285 |
// ---------------------------------------------------------------------------
|
|
286 |
//
|
|
287 |
TBool CXDMPluginContainer::IsListEmpty()
|
|
288 |
{
|
|
289 |
if (iSettingListArray->Count())
|
|
290 |
return EFalse;
|
|
291 |
return ETrue;
|
|
292 |
}
|
|
293 |
|
|
294 |
// ---------------------------------------------------------------------------
|
|
295 |
// CXDMPluginContainer::IsLastItem()
|
|
296 |
// ---------------------------------------------------------------------------
|
|
297 |
//
|
|
298 |
TBool CXDMPluginContainer::IsLastItem()
|
|
299 |
{
|
|
300 |
if (iSettingListArray->Count() == 1)
|
|
301 |
return ETrue;
|
|
302 |
return EFalse;
|
|
303 |
}
|
|
304 |
|
|
305 |
// ---------------------------------------------------------------------------
|
|
306 |
// CXDMPluginContainer::DeleteCurrentSetL()
|
|
307 |
// ---------------------------------------------------------------------------
|
|
308 |
//
|
|
309 |
void CXDMPluginContainer::DeleteCurrentSetL()
|
|
310 |
{
|
|
311 |
TXdmSettingsApi::RemoveCollectionL( GetCurrentSetIdL() );
|
|
312 |
TInt deletedItemIndex = iMainList->CurrentItemIndex();
|
|
313 |
iSettingListArray->Delete( deletedItemIndex );
|
|
314 |
|
|
315 |
AknListBoxUtils::HandleItemRemovalAndPositionHighlightL(
|
|
316 |
iMainList, deletedItemIndex, ETrue );
|
|
317 |
iMainList->DrawNow();
|
|
318 |
}
|
|
319 |
|
|
320 |
// ---------------------------------------------------------------------------
|
|
321 |
// CXDMPluginContainer::GetCurrentSetIdL()
|
|
322 |
// ---------------------------------------------------------------------------
|
|
323 |
//
|
|
324 |
TInt CXDMPluginContainer::GetCurrentSetIdL()
|
|
325 |
{
|
|
326 |
TInt myId(-1);
|
|
327 |
RArray<TInt> settingIds;
|
|
328 |
CleanupClosePushL(settingIds);
|
|
329 |
CDesCArray* xdmSetList = NULL;
|
|
330 |
|
|
331 |
TRAPD(err, xdmSetList = LoadCollectionNamesL(settingIds));
|
|
332 |
if(err!=KErrNone)
|
|
333 |
{
|
|
334 |
CleanupStack::PopAndDestroy(1); //settingIds
|
|
335 |
return myId;
|
|
336 |
}
|
|
337 |
CleanupStack::PushL(xdmSetList);
|
|
338 |
|
|
339 |
TInt xdmSetListCount = xdmSetList->Count();
|
|
340 |
HBufC* currentSetName = GetCurrentSetNameLC();
|
|
341 |
for (TInt i = 0; i< xdmSetListCount; i++)
|
|
342 |
{
|
|
343 |
if (!((xdmSetList->MdcaPoint(i)).Compare(*currentSetName))) // if equal
|
|
344 |
{
|
|
345 |
myId = settingIds[i];
|
|
346 |
break;
|
|
347 |
}
|
|
348 |
}
|
|
349 |
CleanupStack::PopAndDestroy(3); //xdmSetList,settingIds,currentSetName
|
|
350 |
return myId;
|
|
351 |
}
|
|
352 |
|
|
353 |
// ---------------------------------------------------------------------------
|
|
354 |
// CXDMPluginContainer::LoadCollectionNamesL()
|
|
355 |
// ---------------------------------------------------------------------------
|
|
356 |
//
|
|
357 |
CDesCArray* CXDMPluginContainer::LoadCollectionNamesL(RArray<TInt>& aSettingIDs)
|
|
358 |
{
|
|
359 |
CDesCArray* myArray = TXdmSettingsApi::CollectionNamesLC(aSettingIDs);
|
|
360 |
CleanupStack::Pop(1); // will be pop if above doesnt leave
|
|
361 |
return myArray;
|
|
362 |
}
|
|
363 |
|
|
364 |
// ---------------------------------------------------------
|
|
365 |
// CXDMPluginContainer::GetHelpContext
|
|
366 |
// This function is called when Help application is launched
|
|
367 |
// (other items were commented in a header).
|
|
368 |
// ---------------------------------------------------------
|
|
369 |
//
|
|
370 |
void CXDMPluginContainer::GetHelpContext( TCoeHelpContext& aContext ) const
|
|
371 |
{
|
|
372 |
aContext.iMajor = KGSXDMPluginUid;
|
|
373 |
aContext.iContext = KXDM_HLP_LIST_VIEW;
|
|
374 |
}
|
|
375 |
|
|
376 |
// ---------------------------------------------------------------------------
|
|
377 |
// CXDMPluginContainer::DeleteSetProcedureL()
|
|
378 |
// ---------------------------------------------------------------------------
|
|
379 |
//
|
|
380 |
void CXDMPluginContainer::DeleteSetProcedureL()
|
|
381 |
{
|
|
382 |
HBufC* myDisplayMessage = NULL;
|
|
383 |
HBufC* currentSetName = GetCurrentSetNameLC();
|
|
384 |
TPtr myname(currentSetName->Des());
|
|
385 |
AknTextUtils::LanguageSpecificNumberConversion(myname);
|
|
386 |
|
|
387 |
CAknQueryDialog* query = CAknQueryDialog::NewL(CAknQueryDialog::EConfirmationTone);
|
|
388 |
if (IsLastItem())
|
|
389 |
myDisplayMessage = StringLoader::LoadLC(R_STR_XDM_CONF_DELETE_LAST, *currentSetName );
|
|
390 |
else
|
|
391 |
myDisplayMessage = StringLoader::LoadLC(R_STR_XDM_CONF_DELETE, *currentSetName );
|
|
392 |
|
|
393 |
if ( query->ExecuteLD( R_CONFIRMATION_QUERY, *myDisplayMessage ) )
|
|
394 |
{
|
|
395 |
DeleteCurrentSetL();
|
|
396 |
}
|
|
397 |
CleanupStack::PopAndDestroy(2); //currentSetName, myDisplayMessage
|
|
398 |
}
|
|
399 |
|
|
400 |
// ---------------------------------------------------------------------------
|
|
401 |
// CXDMPluginContainer::HandleResourceChange()
|
|
402 |
// ---------------------------------------------------------------------------
|
|
403 |
void CXDMPluginContainer::HandleResourceChange( TInt aType )
|
|
404 |
{
|
|
405 |
if ( aType == KAknsMessageSkinChange ||
|
|
406 |
aType == KEikDynamicLayoutVariantSwitch )
|
|
407 |
{
|
|
408 |
CXDMPlugin* iTempView = static_cast<CXDMPlugin*> (iView);
|
|
409 |
iTempView->HandleResourceChangeManual(aType);
|
|
410 |
}
|
|
411 |
CCoeControl::HandleResourceChange( aType );
|
|
412 |
}
|
|
413 |
|
|
414 |
// ---------------------------------------------------------------------------
|
|
415 |
// CXDMPluginContainer::HandleResourceChangeManual()
|
|
416 |
// ---------------------------------------------------------------------------
|
|
417 |
void CXDMPluginContainer::HandleResourceChangeManual(TInt aType)
|
|
418 |
{
|
|
419 |
TRect mainPaneRect;
|
|
420 |
AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane,
|
|
421 |
mainPaneRect);
|
|
422 |
SetRect( mainPaneRect );
|
|
423 |
//DrawNow();
|
|
424 |
|
|
425 |
iMainList->HandleResourceChange(aType);
|
|
426 |
}
|
|
427 |
|
|
428 |
// ---------------------------------------------------------------------------
|
|
429 |
// CXDMPluginContainer::FocusChanged
|
|
430 |
// Set focus on the selected listbox. For animated skins feature.
|
|
431 |
// ---------------------------------------------------------------------------
|
|
432 |
void CXDMPluginContainer::FocusChanged(TDrawNow aDrawNow)
|
|
433 |
{
|
|
434 |
if(iMainList)
|
|
435 |
{
|
|
436 |
iMainList->SetFocus( IsFocused(),aDrawNow );
|
|
437 |
}
|
|
438 |
}
|
|
439 |
|
|
440 |
// ---------------------------------------------------------------------------
|
|
441 |
// CXDMPluginContainer::SetFocusIfExist
|
|
442 |
// Set focus on the given set name
|
|
443 |
// ---------------------------------------------------------------------------
|
|
444 |
void CXDMPluginContainer::SetFocusIfExist(TDes& aSetName)
|
|
445 |
{
|
|
446 |
_LIT (KStringHeader, "\t%S");
|
|
447 |
TBuf <KMaxSettingSetNameLength+2> myString; // maximum name + \t
|
|
448 |
myString.Format(KStringHeader, &aSetName);
|
|
449 |
AknTextUtils::LanguageSpecificNumberConversion(myString);
|
|
450 |
|
|
451 |
TInt xdmSetListCount = iSettingListArray->Count();
|
|
452 |
for (TInt i = 0; i< xdmSetListCount; i++)
|
|
453 |
{
|
|
454 |
if (!((iSettingListArray->MdcaPoint(i)).Compare(myString))) // if equal
|
|
455 |
{
|
|
456 |
iMainList->SetCurrentItemIndex(i);
|
|
457 |
break;
|
|
458 |
}
|
|
459 |
}
|
|
460 |
}
|
|
461 |
|
|
462 |
// End of File
|