buildverification/smoketest/messaging/Src/TestMessSetDefaultSC.cpp
branchRCL_3
changeset 19 4ca382093dae
parent 5 6beaa9cf4752
child 20 493058e57c8c
equal deleted inserted replaced
5:6beaa9cf4752 19:4ca382093dae
     1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // This contains TestMessSetDefaultSc which sets an SMS
       
    15 // SC as default SC.
       
    16 // 
       
    17 //
       
    18 
       
    19 #include "TestMessSetDefaultSC.h"
       
    20 
       
    21 // EPOC includes
       
    22 #include <msvids.h>
       
    23 #include <miutset.h>
       
    24 #include <smutset.h>
       
    25 #include <etelmm.h>
       
    26 #include <msvstore.h>
       
    27 #include <csmsaccount.h>
       
    28 
       
    29 _LIT(KSCName,		"scname");
       
    30 
       
    31 CTestMessSetDefaultSc::CTestMessSetDefaultSc()
       
    32 :	CTestMessBase(EFalse)
       
    33 	{
       
    34 	SetTestStepName(_L("SetSmsSc"));
       
    35 	}
       
    36 
       
    37 TVerdict CTestMessSetDefaultSc::doTestStepL()
       
    38 	{
       
    39 	// Printing to the console and log file
       
    40 	INFO_PRINTF1(_L("Set Default Service Center"));
       
    41 
       
    42 	CSmsSettings*		smsSettings = CSmsSettings::NewL();
       
    43 	CleanupStack::PushL(smsSettings);
       
    44 	SetEntryL(KMsvRootIndexEntryId);
       
    45 
       
    46 	EntryL().SetSortTypeL(SelectionOrdering());
       
    47 	CMsvEntrySelection*	selection=EntryL().ChildrenWithTypeL(KUidMsvServiceEntry);
       
    48 	CleanupStack::PushL(selection);
       
    49 	TInt				count=selection->Count();
       
    50 	TBool				found=EFalse;
       
    51 	for (TInt i=count; i>0 && !found; )
       
    52 		{
       
    53 		SetEntryL(selection->At(--i));
       
    54 
       
    55 		//	Log child
       
    56 		if	(	EntryL().Entry().iMtm == KUidMsgTypeSMS &&
       
    57 				EntryL().Entry().iType == KUidMsvServiceEntry
       
    58 			)
       
    59 			{
       
    60 			found=ETrue;
       
    61 			}
       
    62 		}
       
    63 
       
    64 	if ( !found )
       
    65 		{
       
    66 		ERR_PRINTF1(_L("No SMS Account found"));
       
    67 		SetTestStepResult(EFail);
       
    68 		}
       
    69 
       
    70 	TName	network;
       
    71 //IMK	TBool	returnValue=(GetPhoneSmsNetworkL(network)==KErrNone);
       
    72 TBool	returnValue=false; //IMK
       
    73 	TPtrC	ptrSCName(network);
       
    74 
       
    75 	if ( !returnValue )
       
    76 		{
       
    77 		returnValue=GetStringFromConfig(ConfigSection(), KSCName, ptrSCName);
       
    78 		}
       
    79 	if ( !returnValue )
       
    80 		{
       
    81 		ERR_PRINTF1(_L("No SC specified in script/ini file"));
       
    82 		SetTestStepResult(EFail);
       
    83 		}
       
    84 
       
    85 	INFO_PRINTF2(_L("SC Name = %S"), &ptrSCName);
       
    86 
       
    87 	if ( TestStepResult()==EPass )
       
    88 		{
       
    89 		CSmsAccount*	smsAccount = CSmsAccount::NewLC();
       
    90 		smsAccount->LoadSettingsL(*smsSettings);
       
    91 		const TInt	numSCAddr = smsSettings->ServiceCenterCount();
       
    92 
       
    93 		if( !numSCAddr )
       
    94 			{
       
    95 			ERR_PRINTF1(_L("No SC found"));
       
    96 			SetTestStepResult(EFail);
       
    97 			}
       
    98 
       
    99 		TBool	scFound	= EFalse;
       
   100 		for( TInt index=0; (index<numSCAddr) && (!scFound);index++ )
       
   101 			{
       
   102 			CSmsServiceCenter&	scAddr = smsSettings->GetServiceCenter(index);
       
   103 			if( (scAddr.Name()).CompareF(ptrSCName) == 0)
       
   104 				{
       
   105 				smsSettings->SetDefaultServiceCenter(index);
       
   106 				smsAccount->SaveSettingsL(*smsSettings);
       
   107 				scFound = ETrue;
       
   108 				}
       
   109 			}
       
   110 
       
   111 		if ( !scFound )
       
   112 			{
       
   113 			ERR_PRINTF2(_L("%S NOT Found"), &ptrSCName);
       
   114 			SetTestStepResult(EFail);
       
   115 			}
       
   116 
       
   117 		CleanupStack::PopAndDestroy(smsAccount);
       
   118 		}
       
   119 	CleanupStack::PopAndDestroy(2, smsSettings);
       
   120 
       
   121 	return TestStepResult();
       
   122 	}