messagingfw/wappushfw/tpushscriptbased/t_sislmessage.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 2007-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 //
       
    15 
       
    16 #include <push/sislpushmsgutils.h>
       
    17 
       
    18 #include "pushtests.h"
       
    19 #include "dummywapstack.h"
       
    20 #include "wappushmsggen.h"
       
    21 
       
    22 #include "httptestutils.h"
       
    23 #if !defined(__TESTSCRIPTS_H__)
       
    24 #include "TestScripts.h"
       
    25 #endif
       
    26 
       
    27 
       
    28 _LIT(KWapIniFolder, 	"wapini");
       
    29 _LIT(KWapIni, 			"wap.ini");
       
    30 
       
    31 _LIT(KServerAddr,	"ServerAddr");
       
    32 _LIT(KHRef,			"HRef");
       
    33 _LIT(KAction,		"Action");
       
    34 
       
    35 const TUint KDoubleQuote ('"');
       
    36 
       
    37 CWapPushMessageTest::CWapPushMessageTest(TInt aIndex, CHTTPTestUtils* aTestUtils)
       
    38 	{
       
    39 	iSectionIndex = aIndex;
       
    40 	iTestUtils = aTestUtils;
       
    41 	}
       
    42 	
       
    43 CWapPushMessageTest::~CWapPushMessageTest()
       
    44 	{
       
    45 	delete iUri;
       
    46 	delete iHRef;
       
    47 	delete iAction;
       
    48 	}
       
    49 	
       
    50 void CWapPushMessageTest::RemoveQuotes(HBufC8* aHBufPtr) 
       
    51 	{
       
    52 	if ((( *aHBufPtr )[0]) == KDoubleQuote)
       
    53 		{
       
    54 		( aHBufPtr->Des() ).Delete(0,1);
       
    55 		}	
       
    56 		
       
    57 	TInt lastChar = ((aHBufPtr->Des()).Length());
       
    58 	--lastChar;
       
    59 	
       
    60 	if (( *aHBufPtr )[lastChar] == KDoubleQuote)
       
    61 		{
       
    62 		( aHBufPtr->Des() ).Delete(lastChar,1);
       
    63 		}
       
    64 		
       
    65 	}	
       
    66 	
       
    67 TDesC8& CWapPushMessageTest::GetHRef() const
       
    68 	{
       
    69 	return (*(iHRef));	
       
    70 	}
       
    71 	
       
    72 TDesC8& CWapPushMessageTest::GetAction() const
       
    73 	{
       
    74 	return(*(iAction));	
       
    75 	}
       
    76 	
       
    77 void CWapPushMessageTest::ReadAndSetParamsFromIniFileL()
       
    78 	{
       
    79 	// Delete previously read buffers.
       
    80 	delete iUri;
       
    81 	delete iHRef;
       
    82 	delete iAction;
       
    83 			
       
    84 	CScriptFile* iniFile = NULL;
       
    85 	iniFile = CScriptFile::NewL(*iTestUtils, KWapIniFolder(), KWapIni());
       
    86 	CleanupStack::PushL(iniFile); 
       
    87 		
       
    88 	TInt itemFieldCount= iniFile->Section(iSectionIndex).Items().Count();
       
    89 	
       
    90 	TBuf8<200> itemFieldValue8;
       
    91 	
       
    92 	for (TInt fctr=0; fctr < itemFieldCount ; ++fctr)
       
    93 		{
       
    94 		TPtrC itemFieldPtr(iniFile->Section(iSectionIndex).Item(fctr).Item());
       
    95 		itemFieldValue8.Copy(iniFile->Section(iSectionIndex).Item(fctr).Value());
       
    96 		
       
    97 		if(itemFieldPtr.Compare(KServerAddr) == 0)
       
    98 			{
       
    99 			iUri = itemFieldValue8.AllocL();
       
   100 			RemoveQuotes(iUri);
       
   101 			}
       
   102 		else if(itemFieldPtr.Compare(KHRef) == 0)
       
   103 			{
       
   104 			iHRef = itemFieldValue8.AllocL();
       
   105 			RemoveQuotes(iHRef);	
       
   106 			}
       
   107 		else if(itemFieldPtr.Compare(KAction) == 0)
       
   108 			{
       
   109 			iAction = itemFieldValue8.AllocL();
       
   110 			RemoveQuotes(iAction);
       
   111 			}
       
   112 		}
       
   113 	CleanupStack::PopAndDestroy(iniFile);	
       
   114 	}
       
   115 
       
   116 
       
   117 
       
   118 
       
   119 
       
   120 	
       
   121 	
       
   122 
       
   123 
       
   124