27
|
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: Messaging Settings sub-menu in General Settings.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
// INCLUDE FILES
|
|
21 |
|
|
22 |
|
|
23 |
|
|
24 |
#include <MuiuMsvUiServiceUtilities.h> //MsvUiServiceUtilities
|
|
25 |
#include <MtmExtendedCapabilities.hrh> // KUidMtmQueryCanCreateNewMsgValue
|
|
26 |
|
|
27 |
#include <mtudreg.h> // CMtmUiDataRegistry
|
|
28 |
#include <MTMStore.h> // CMtmStore
|
|
29 |
#include <msvids.h> // KMsvRootIndexEntryId, KMsvNullIndexEntryId
|
|
30 |
|
|
31 |
#include <MceSettingsArrays.h> // CMceUidNameArray
|
|
32 |
#include <MceSettingsSessionObserver.h> // CMceSettingsSessionObserver
|
|
33 |
#include <MceSettingsGeneralSettingsDialog.h> // CMceGeneralSettingsDialog
|
|
34 |
#include <MceSettingsMultipleServicesDialog.h> // CMceSettingsMultipleServicesDialog
|
|
35 |
#include <aknlists.h> // CAknSettingStyleListBox
|
|
36 |
#include <MceSettingsGSPluginRsc.rsg> // Resources
|
|
37 |
#include <RCustomerServiceProfileCache.h> // RCustomerServiceProfileCache
|
|
38 |
#include <SenduiMtmUids.h> // KSenduiMtmSmtpUid, KSenduiMtmSmsUid,
|
|
39 |
// KSenduiMtmMmsUid
|
|
40 |
#include <csxhelp/mce.hlp.hrh> // Help file
|
|
41 |
#include "MceSettingsGSPluginContainer.h" // own header
|
|
42 |
|
|
43 |
#include <featmgr.h> // CR : 401-1806
|
|
44 |
|
|
45 |
|
|
46 |
// CONSTANTS
|
|
47 |
const TUid KCBSApplicationId = {0x101F4CD3};
|
|
48 |
const TUid KCBSApplicationSettingsViewId = {6};
|
|
49 |
const TInt KMceSettingsExtraItems = 2;
|
|
50 |
const TInt KMceSettingsCBS = 2;
|
|
51 |
const TInt KMceSettingsCBSUid = 42;
|
|
52 |
const TUid KMceApplicationId = { 0x100058C5 };
|
|
53 |
|
|
54 |
//CMAIL Update
|
|
55 |
#define KUidMsgTypeFsMtmVal 0x2001F406
|
|
56 |
|
|
57 |
// ========================= MEMBER FUNCTIONS ================================
|
|
58 |
|
|
59 |
// ---------------------------------------------------------------------------
|
|
60 |
// CMceSettingsGSPluginContainer::CMceSettingsGSPluginContainer()
|
|
61 |
// Default constructor.
|
|
62 |
// ---------------------------------------------------------------------------
|
|
63 |
//
|
|
64 |
CMceSettingsGSPluginContainer::CMceSettingsGSPluginContainer()
|
|
65 |
{
|
|
66 |
iDialogOpen = EFalse;
|
|
67 |
}
|
|
68 |
|
|
69 |
|
|
70 |
// ---------------------------------------------------------------------------
|
|
71 |
// CMceSettingsGSPluginContainer::ConstructL(const TRect& aRect)
|
|
72 |
// Symbian OS phase 2 constructor
|
|
73 |
// ---------------------------------------------------------------------------
|
|
74 |
//
|
|
75 |
void CMceSettingsGSPluginContainer::ConstructL( const TRect& aRect )
|
|
76 |
{
|
|
77 |
// Construct iListBox
|
|
78 |
iListBox = new ( ELeave ) CAknSettingStyleListBox;
|
|
79 |
iMsvSession = CMsvSession::OpenSyncL(*this);
|
|
80 |
iAccountManager = CMceSettingsSessionObserver::NewL( iMsvSession );
|
|
81 |
iEmailFramework = EFalse;
|
|
82 |
|
|
83 |
FeatureManager::InitializeLibL();
|
|
84 |
|
|
85 |
if ( FeatureManager::FeatureSupported( KFeatureIdFfEmailFramework ) )
|
|
86 |
{
|
|
87 |
iEmailFramework = ETrue;
|
|
88 |
}
|
|
89 |
|
|
90 |
FeatureManager::UnInitializeLib();
|
|
91 |
|
|
92 |
|
|
93 |
BaseConstructL( aRect, R_MCEUI_MAINVIEW_TITLE, 0 );// last parameter 0, since dynamic listbox
|
|
94 |
}
|
|
95 |
|
|
96 |
|
|
97 |
// ---------------------------------------------------------------------------
|
|
98 |
// CMceSettingsGSPluginContainer::~CMceSettingsGSPluginContainer()
|
|
99 |
// Destructor
|
|
100 |
// ---------------------------------------------------------------------------
|
|
101 |
//
|
|
102 |
CMceSettingsGSPluginContainer::~CMceSettingsGSPluginContainer()
|
|
103 |
{
|
|
104 |
delete iAccountManager;
|
|
105 |
delete iMsgTypesSettings;
|
|
106 |
delete iMsvSession;
|
|
107 |
}
|
|
108 |
|
|
109 |
|
|
110 |
// ---------------------------------------------------------------------------
|
|
111 |
// CMceSettingsGSPluginContainer::ConstructListBoxL()
|
|
112 |
// See header for details.
|
|
113 |
// ---------------------------------------------------------------------------
|
|
114 |
//
|
|
115 |
void CMceSettingsGSPluginContainer::ConstructListBoxL( TInt /*aResLbxId*/ )
|
|
116 |
{
|
|
117 |
// listbox creation and initialization
|
|
118 |
iListBox->SetContainerWindowL( *this );
|
|
119 |
iListBox->ConstructL( this, EAknListBoxLoopScrolling );
|
|
120 |
iListBox->CreateScrollBarFrameL( ETrue );
|
|
121 |
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
|
|
122 |
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto );
|
|
123 |
|
|
124 |
UpdateSettingItemsL();
|
|
125 |
CTextListBoxModel* model = iListBox->Model();
|
|
126 |
model->SetItemTextArray( iMsgTypesSettings );
|
|
127 |
model->SetOwnershipType( ELbmDoesNotOwnItemArray );
|
|
128 |
}
|
|
129 |
|
|
130 |
|
|
131 |
// ---------------------------------------------------------------------------
|
|
132 |
// CMceSettingsGSPluginContainer::OfferKeyEventL()
|
|
133 |
// See header for details.
|
|
134 |
// ---------------------------------------------------------------------------
|
|
135 |
//
|
|
136 |
TKeyResponse CMceSettingsGSPluginContainer::OfferKeyEventL(
|
|
137 |
const TKeyEvent& aKeyEvent,
|
|
138 |
TEventCode aType )
|
|
139 |
{
|
|
140 |
return iListBox->OfferKeyEventL( aKeyEvent, aType );
|
|
141 |
}
|
|
142 |
|
|
143 |
|
|
144 |
// -----------------------------------------------------------------------------
|
|
145 |
// CMceSettingsGSPluginContainer::GetHelpContext()
|
|
146 |
// See header for details.
|
|
147 |
// -----------------------------------------------------------------------------
|
|
148 |
//
|
|
149 |
void CMceSettingsGSPluginContainer::GetHelpContext( TCoeHelpContext& aContext ) const
|
|
150 |
{
|
|
151 |
aContext.iMajor = KMceApplicationId;
|
|
152 |
aContext.iContext = KMCE_HLP_SETTINGS;
|
|
153 |
}
|
|
154 |
|
|
155 |
|
|
156 |
// -----------------------------------------------------------------------------
|
|
157 |
// CMceSettingsGSPluginContainer::UpdateSettingItemsL()
|
|
158 |
// See header for details.
|
|
159 |
// -----------------------------------------------------------------------------
|
|
160 |
//
|
|
161 |
void CMceSettingsGSPluginContainer::UpdateSettingItemsL()
|
|
162 |
{
|
|
163 |
if ( !iMsgTypesSettings )
|
|
164 |
{
|
|
165 |
iMsgTypesSettings = CMceUidNameArray::NewL();
|
|
166 |
}
|
|
167 |
else
|
|
168 |
{
|
|
169 |
iMsgTypesSettings->Reset();
|
|
170 |
}
|
|
171 |
|
|
172 |
CMtmUiDataRegistry* uiRegistry = iAccountManager->UiRegistry();
|
|
173 |
CMtmStore* mtmStore = iAccountManager->MtmStore();
|
|
174 |
const TInt count = uiRegistry->NumRegisteredMtmDlls();
|
|
175 |
TInt loop = 0;
|
|
176 |
for ( loop = 0; loop < count; loop++ )
|
|
177 |
{
|
|
178 |
LoadMtmL( uiRegistry->MtmTypeUid( loop ), *mtmStore );
|
|
179 |
}
|
|
180 |
|
|
181 |
// this is not used anywhere, two last items in the list are
|
|
182 |
// ALWAYS cbs settings and mce general settings
|
|
183 |
|
|
184 |
// Sort settings groups
|
|
185 |
SortAndChangeSmsMmsEmailFirstL();
|
|
186 |
|
|
187 |
// Check Cell Broadcast Csp bit
|
|
188 |
iCbs = CheckCspBitL();
|
|
189 |
|
|
190 |
|
|
191 |
TUid uid;
|
|
192 |
uid.iUid = KMceSettingsCBSUid;
|
|
193 |
if(iCbs)
|
|
194 |
{
|
|
195 |
HBufC* text = StringLoader::LoadL( R_MCEUI_CBS_SETTINGS_TEXT, iEikonEnv );
|
|
196 |
TUidNameInfo cbsSettings( uid, *text );
|
|
197 |
delete text;
|
|
198 |
iMsgTypesSettings->AppendL( cbsSettings );
|
|
199 |
}
|
|
200 |
|
|
201 |
HBufC* text = StringLoader::LoadL( R_MCEUI_GENERAL_SETTINGS_TEXT, iEikonEnv );
|
|
202 |
TUidNameInfo generalSettings( uid, *text );
|
|
203 |
delete text;
|
|
204 |
iMsgTypesSettings->AppendL( generalSettings );
|
|
205 |
}
|
|
206 |
|
|
207 |
|
|
208 |
// -----------------------------------------------------------------------------
|
|
209 |
// CMceSettingsGSPluginContainer::LoadMtmL
|
|
210 |
//
|
|
211 |
// -----------------------------------------------------------------------------
|
|
212 |
//
|
|
213 |
void CMceSettingsGSPluginContainer::LoadMtmL(
|
|
214 |
const TUid aMtmType,
|
|
215 |
CMtmStore& aMtmStore )
|
|
216 |
{
|
|
217 |
|
|
218 |
TUid mtmUid = TUid::Uid(aMtmType.iUid);
|
|
219 |
|
|
220 |
TBool notSelectableMtm = ( (mtmUid == KSenduiMtmSmtpUid)
|
|
221 |
|| (mtmUid == KSenduiMtmSyncMLEmailUid)
|
|
222 |
|| (aMtmType.iUid == KUidMsgTypeFsMtmVal) ) ;
|
|
223 |
|
|
224 |
// Cmail changes - EMail, Sync EMail, Freestyle Settings will not be populated in the Messaging settings
|
|
225 |
|
|
226 |
if( !( (iEmailFramework) && (notSelectableMtm) ) )
|
|
227 |
{
|
|
228 |
|
|
229 |
CBaseMtmUiData* uiData = NULL;
|
|
230 |
TRAPD( err, ( uiData = &(aMtmStore.MtmUiDataL(aMtmType)) ) );
|
|
231 |
if( err != KErrNone )
|
|
232 |
{
|
|
233 |
return;
|
|
234 |
}
|
|
235 |
TBool foundSettings = EFalse;
|
|
236 |
const CArrayFix<CBaseMtmUiData::TMtmUiFunction>& funcs =
|
|
237 |
uiData->MtmSpecificFunctions();
|
|
238 |
const TInt numFuncs = funcs.Count();
|
|
239 |
for (TInt funcIndex = 0; funcIndex < numFuncs && !foundSettings; funcIndex++ )
|
|
240 |
{
|
|
241 |
CBaseMtmUiData::TMtmUiFunction func = funcs.At( funcIndex );
|
|
242 |
if ( func.iFunctionId == KMtmUiMceSettings )
|
|
243 |
{
|
|
244 |
iMsgTypesSettings->AppendL( TUidNameInfo(
|
|
245 |
aMtmType,
|
|
246 |
func.iCaption ) );
|
|
247 |
foundSettings = ETrue;
|
|
248 |
}
|
|
249 |
} // end for
|
|
250 |
}//end if
|
|
251 |
|
|
252 |
}
|
|
253 |
|
|
254 |
|
|
255 |
// -----------------------------------------------------------------------------
|
|
256 |
// CMceUi::HandleSessionEventL
|
|
257 |
//
|
|
258 |
// -----------------------------------------------------------------------------
|
|
259 |
//
|
|
260 |
void CMceSettingsGSPluginContainer::HandleSessionEventL(
|
|
261 |
TMsvSessionEvent aEvent,
|
|
262 |
TAny* /*aArg1*/,
|
|
263 |
TAny* aArg2,
|
|
264 |
TAny* /*aArg3*/ )
|
|
265 |
{
|
|
266 |
TMsvId folderId = KMsvNullIndexEntryId;
|
|
267 |
|
|
268 |
// ConstructL must have left as we have returned to the active scheduler
|
|
269 |
// before complete construction
|
|
270 |
switch (aEvent)
|
|
271 |
{
|
|
272 |
case EMsvServerReady:
|
|
273 |
case EMsvCorruptedIndexRebuilt:
|
|
274 |
break;
|
|
275 |
case EMsvMtmGroupInstalled:
|
|
276 |
case EMsvMtmGroupDeInstalled:
|
|
277 |
UpdateSettingItemsL();
|
|
278 |
break;
|
|
279 |
case EMsvEntriesCreated:
|
|
280 |
case EMsvEntriesDeleted:
|
|
281 |
case EMsvEntriesChanged:
|
|
282 |
folderId = (*(TMsvId*) (aArg2));
|
|
283 |
if ( folderId == KMsvRootIndexEntryId )
|
|
284 |
{
|
|
285 |
UpdateSettingItemsL();
|
|
286 |
}
|
|
287 |
break;
|
|
288 |
|
|
289 |
case EMsvServerFailedToStart:
|
|
290 |
case EMsvServerTerminated:
|
|
291 |
case EMsvCloseSession:
|
|
292 |
case EMsvGeneralError:
|
|
293 |
case EMsvMediaUnavailable:
|
|
294 |
case EMsvMediaAvailable:
|
|
295 |
default:
|
|
296 |
break;
|
|
297 |
}
|
|
298 |
}
|
|
299 |
|
|
300 |
|
|
301 |
// -----------------------------------------------------------------------------
|
|
302 |
// CMceSettingsGSPluginContainer::EditSubSettingsL()
|
|
303 |
//
|
|
304 |
// -----------------------------------------------------------------------------
|
|
305 |
//
|
|
306 |
void CMceSettingsGSPluginContainer::EditSubSettingsL()
|
|
307 |
{
|
|
308 |
const TInt numberOfItems = iListBox->Model()->NumberOfItems();
|
|
309 |
TInt choice = iListBox->CurrentItemIndex();
|
|
310 |
// Run time Cell Broadcast variant.
|
|
311 |
TInt removedSettingItems = 0;
|
|
312 |
|
|
313 |
if ( !iCbs )
|
|
314 |
{
|
|
315 |
removedSettingItems++;
|
|
316 |
}
|
|
317 |
|
|
318 |
if ( choice < ( numberOfItems - KMceSettingsExtraItems ) + removedSettingItems )
|
|
319 |
{
|
|
320 |
|
|
321 |
TBool canCreateNewAccount = iAccountManager->CanCreateNewAccountL(
|
|
322 |
(*iMsgTypesSettings)[choice].iUid );
|
|
323 |
|
|
324 |
if ( canCreateNewAccount )
|
|
325 |
{
|
|
326 |
if( iDialogOpen )
|
|
327 |
{
|
|
328 |
return;
|
|
329 |
}
|
|
330 |
iDialogOpen = ETrue;
|
|
331 |
// if mtm supports account creation then open new dialog to handle many accounts
|
|
332 |
TInt value = CMceSettingsMultipleServicesDialog::CreateAndExecuteL(
|
|
333 |
*iAccountManager, (*iMsgTypesSettings)[choice].iUid, iMsvSession );
|
|
334 |
iDialogOpen = EFalse;
|
|
335 |
}
|
|
336 |
else
|
|
337 |
{
|
|
338 |
// mtm cannot create new accounts, edit only FIRST service if exists
|
|
339 |
CMsvEntrySelection* sel =
|
|
340 |
MsvUiServiceUtilities::GetListOfAccountsWithMTML( *iMsvSession, (*iMsgTypesSettings)[choice].iUid );
|
|
341 |
|
|
342 |
CleanupStack::PushL( sel );
|
|
343 |
|
|
344 |
if ( sel->Count() > 0 )
|
|
345 |
{
|
|
346 |
iAccountManager->EditAccountL( (*sel)[0] );
|
|
347 |
}
|
|
348 |
else
|
|
349 |
{ // service disappeared?
|
|
350 |
|
|
351 |
}
|
|
352 |
CleanupStack::PopAndDestroy( sel );
|
|
353 |
}
|
|
354 |
} // end if ( choice < numberOfItems )
|
|
355 |
else if ( /*iCbs &&*/ choice == numberOfItems - KMceSettingsCBS )
|
|
356 |
{
|
|
357 |
// CBS settings are second from the end of the list
|
|
358 |
TVwsViewId viewId( KCBSApplicationId, KCBSApplicationSettingsViewId );
|
|
359 |
STATIC_CAST( CCoeAppUi*, ControlEnv()->AppUi())->ActivateViewL( viewId );
|
|
360 |
}
|
|
361 |
else
|
|
362 |
{
|
|
363 |
// general settings are list item in the list
|
|
364 |
TInt value = CMceGeneralSettingsDialog::CreateAndExecuteL(
|
|
365 |
iMsvSession,
|
|
366 |
*this );
|
|
367 |
}
|
|
368 |
}
|
|
369 |
|
|
370 |
|
|
371 |
// ---------------------------------------------------------
|
|
372 |
// CMceSettingsGSPluginContainer::SortAndChangeSmsMmsEmailFirstL
|
|
373 |
// ---------------------------------------------------------
|
|
374 |
//
|
|
375 |
void CMceSettingsGSPluginContainer::SortAndChangeSmsMmsEmailFirstL()
|
|
376 |
{
|
|
377 |
iMsgTypesSettings->Sort(ECmpFolded);
|
|
378 |
|
|
379 |
ChangeMsgTypeTopL( *iMsgTypesSettings, KSenduiMtmPostcardUid );
|
|
380 |
ChangeMsgTypeTopL( *iMsgTypesSettings, KSenduiMtmSyncMLEmailUid );
|
|
381 |
ChangeMsgTypeTopL( *iMsgTypesSettings, KSenduiMtmSmtpUid );
|
|
382 |
ChangeMsgTypeTopL( *iMsgTypesSettings, KSenduiMtmAudioMessageUid );
|
|
383 |
// SMS & MMS still have own settings although the editor is common.
|
|
384 |
ChangeMsgTypeTopL( *iMsgTypesSettings, KSenduiMtmMmsUid );
|
|
385 |
ChangeMsgTypeTopL( *iMsgTypesSettings, KSenduiMtmSmsUid );
|
|
386 |
}
|
|
387 |
|
|
388 |
|
|
389 |
// ---------------------------------------------------------
|
|
390 |
// CMceSettingsGSPluginContainer::ChangeMsgTypeTopL
|
|
391 |
// ---------------------------------------------------------
|
|
392 |
//
|
|
393 |
void CMceSettingsGSPluginContainer::ChangeMsgTypeTopL(
|
|
394 |
CUidNameArray& aArray,
|
|
395 |
TUid aMsgType ) const
|
|
396 |
{
|
|
397 |
TInt loop = 0;
|
|
398 |
// first change email to the top
|
|
399 |
for (loop=1; loop < aArray.Count(); loop++)
|
|
400 |
{
|
|
401 |
if (aArray[loop].iUid == aMsgType)
|
|
402 |
{
|
|
403 |
TUidNameInfo info = aArray[loop];
|
|
404 |
aArray.InsertL( 0, info );
|
|
405 |
aArray.Delete( loop+1 );
|
|
406 |
break;
|
|
407 |
}
|
|
408 |
}
|
|
409 |
}
|
|
410 |
|
|
411 |
|
|
412 |
// ----------------------------------------------------
|
|
413 |
// CMceSettingsGSPluginContainer::CheckCspBitL
|
|
414 |
// returns ETrue if Cell Broadcast csp bit is on
|
|
415 |
//
|
|
416 |
// ----------------------------------------------------
|
|
417 |
TBool CMceSettingsGSPluginContainer::CheckCspBitL( ) const
|
|
418 |
{
|
|
419 |
RCustomerServiceProfileCache csp;
|
|
420 |
|
|
421 |
TInt error = csp.Open();
|
|
422 |
if ( error )
|
|
423 |
{
|
|
424 |
return ETrue;
|
|
425 |
}
|
|
426 |
|
|
427 |
RMobilePhone::TCspTeleservices params;
|
|
428 |
TInt retVal = csp.CspTeleServices( params );
|
|
429 |
csp.Close();
|
|
430 |
|
|
431 |
if ( retVal == KErrNone )
|
|
432 |
{
|
|
433 |
if ( ( params&RMobilePhone::KCspSMCB ) != 0 )
|
|
434 |
{
|
|
435 |
// Cell Broadcast CSP bit is on
|
|
436 |
return ETrue;
|
|
437 |
}
|
|
438 |
else
|
|
439 |
{
|
|
440 |
// Cell Broadcast CSP bit is off
|
|
441 |
return EFalse;
|
|
442 |
}
|
|
443 |
}
|
|
444 |
else
|
|
445 |
{
|
|
446 |
// Error: By default show CBS service
|
|
447 |
return ETrue;
|
|
448 |
}
|
|
449 |
|
|
450 |
}
|
|
451 |
|
|
452 |
|
|
453 |
// End of File
|