messagingfw/wappushfw/tpush/t_release2.cpp
changeset 0 8e480a14352b
equal deleted inserted replaced
-1:000000000000 0:8e480a14352b
       
     1 // Copyright (c) 2000-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 // T_SLMESSAGE.CPP
       
    15 // 
       
    16 //
       
    17 
       
    18 #include "pushtests.h"
       
    19 
       
    20 #include "dummywapstack.h"
       
    21 #include "pushcpoint.h"
       
    22 
       
    23 _LIT(KTextDoingStuff,"Doing some stuff");
       
    24 _LIT(KTextFinished,"All finished");
       
    25 
       
    26 void CWapPushR2Test::RunL()
       
    27 	{
       
    28 	switch (iState)
       
    29 		{
       
    30 	case EInitialisation:
       
    31 		{
       
    32 		// Create WAP Stack passing MDummyWapStackObserver derived instance
       
    33 		// Create Connection Manager, once WAP stack setup
       
    34 		iWapStack = CDummyWapStack::NewL(*this);
       
    35 		iConnMan =  CConnectionManager::NewL(*this);
       
    36 		MoveToNextState();
       
    37 		return;
       
    38 		}
       
    39 	case ESendSIA:
       
    40 		{
       
    41 		// call the connection manager export which creates a
       
    42 		// connection-orientated connection.
       
    43  		_LIT8(KPushR2RemoteHost,"129.0.0.1");
       
    44  		TPushConnPoint cp;
       
    45  		cp.iHost=KPushR2RemoteHost;
       
    46 		cp.iPort = KPushPortSecure;  //use secure port directly
       
    47  		iConnMan->CMOpenConnectionL(cp);		
       
    48 		iResponseState=ESessionConfirm;
       
    49 		MoveToNextState();
       
    50 		iAck = EFalse;
       
    51 		return;
       
    52 		}
       
    53 	case EWaitForAcknowledge:
       
    54 		{	
       
    55 		if (iAck)
       
    56 			MoveToNextState();
       
    57 		return;
       
    58 		}
       
    59 	case EFinished:
       
    60 		{
       
    61 		Printf(KTextFinished);
       
    62 		SetPriority(EPriorityIdle);
       
    63 		MoveToNextState();
       
    64 		return;
       
    65 		}
       
    66 	default:
       
    67 		// Finished
       
    68 		iEngine->TestCompleted(iStatus.Int());
       
    69 		return;
       
    70 		}
       
    71 	};
       
    72 
       
    73 
       
    74 CWapPushR2Test::~CWapPushR2Test()
       
    75 	{
       
    76 	delete iConnMan;
       
    77 	delete iWapStack;
       
    78 	}	
       
    79 
       
    80 void CWapPushR2Test::DoCancel()
       
    81 	{
       
    82 	delete iConnMan;
       
    83 	delete iWapStack;
       
    84 	iEngine->TestCompleted(KErrCancel);
       
    85 	}
       
    86 
       
    87 void CWapPushR2Test::MoveToNextState()
       
    88 	{ 
       
    89 	iState = (TState)(iState+1); 
       
    90 	CompleteOwnRequest();
       
    91 	}
       
    92 
       
    93 void CWapPushR2Test::CompleteOwnRequest()
       
    94 	{
       
    95 	TRequestStatus* stat = &iStatus;
       
    96 	User::RequestComplete(stat,KErrNone);	
       
    97 	SetActive();
       
    98 	}
       
    99 
       
   100 const TDesC& CWapPushR2Test::TestName()
       
   101 	{
       
   102 	_LIT(KTextSLMessageTest,"Release Two");
       
   103 	return KTextSLMessageTest;
       
   104 	}
       
   105 
       
   106 
       
   107 /** 
       
   108 	called by DummyWapStack and returns the push message
       
   109 	@param CDummyWSPCLConn
       
   110 	@return CDummyWSPCLConn with WAP Push message
       
   111 */
       
   112 void CWapPushR2Test::DWSOUnitWaitPushL(CDummyWSPCLConn& /*aDummyCLConn*/)	
       
   113 	{
       
   114 	}
       
   115 
       
   116 /**
       
   117 	display error message
       
   118 	@param	string 
       
   119 	@param	line number
       
   120 */
       
   121 void CWapPushR2Test::DWSOError(const TDesC& aDes, TInt /*aLineNum*/)
       
   122 	{
       
   123 	iEngine->Printf(TestName(),aDes);
       
   124 	}
       
   125 
       
   126 /**
       
   127 	Wap Stack Server closing...
       
   128 */
       
   129 void CWapPushR2Test::DWSOServerShutDown()
       
   130 	{
       
   131 	// TO DO: 
       
   132 	iEngine->Printf(TestName(), _L(" ServerShutDown called"));
       
   133 	}
       
   134 
       
   135 /**
       
   136 	Cancel pushwait operation
       
   137 */
       
   138 void CWapPushR2Test::DWSOCancelUnitWaitPush(CDummyWSPCLConn& /*aDummyCLConn */)
       
   139 	{
       
   140 	}	
       
   141 
       
   142 void CWapPushR2Test::DWSOConnect(CDummyWSPCOConn& /*aDummyCOConn*/)
       
   143 	{
       
   144 	}
       
   145 
       
   146 void CWapPushR2Test::DWSOGetEventL(CDummyWSPCOConn& aDummyCOConn)
       
   147 	{
       
   148 	// only go through once
       
   149 	if (!iAck)
       
   150 		{
       
   151 		RWSPCOConn::TEvent event;
       
   152 		CDummyWSPCOTrans* dummyTransaction=NULL; 
       
   153 		switch (iResponseState)
       
   154 			{
       
   155 			case CWapPushR2Test::ESessionConfirm:
       
   156 				dummyTransaction = new (ELeave) CDummyWSPCOTrans(aDummyCOConn);
       
   157 				event=RWSPCOConn::EConnect_cnf_s;
       
   158 				iResponseState=CWapPushR2Test::ETransaction;
       
   159 				aDummyCOConn.CompleteGetEventL(event,*dummyTransaction);
       
   160 				break;
       
   161 			case CWapPushR2Test::ETransaction:
       
   162 				dummyTransaction = new (ELeave) CDummyWSPCOTrans(aDummyCOConn);
       
   163 				CreateMultiMixedPushMsg(); //Create Hard coded test Push Msg Body and Header
       
   164 				dummyTransaction->SetData(iHeadersBuf, RWSPCOTrans::EPushHeaders);
       
   165 				dummyTransaction->SetData(iBodyBuf, RWSPCOTrans::EPushBody);
       
   166 
       
   167 				event=RWSPCOConn::EConfirmedPush_ind_t;
       
   168 				aDummyCOConn.CompleteGetEventL(event,*dummyTransaction);
       
   169 				break;
       
   170 			default:
       
   171 				dummyTransaction = new (ELeave) CDummyWSPCOTrans(aDummyCOConn);
       
   172 				event=RWSPCOConn::EConfirmedPush_ind_t;
       
   173 				aDummyCOConn.CompleteGetEventL(event,*dummyTransaction);
       
   174 				break;
       
   175 			}
       
   176 		}
       
   177 	}
       
   178 
       
   179 void CWapPushR2Test::DWSOCancelGetEvent(CDummyWSPCOConn& aDummyCOConn)
       
   180 	{
       
   181 	// only go through once
       
   182 	if (!iAck)
       
   183 		aDummyCOConn.CancelGetEvent();
       
   184 	}
       
   185 
       
   186 void CWapPushR2Test::DWSOAckTransaction(CDummyWSPCOTrans& /*aDummyCOTrans*/)
       
   187 	{
       
   188 	// only go through once
       
   189 	if (!iAck)
       
   190 		{
       
   191 		iAck = ETrue;
       
   192 		CompleteOwnRequest();
       
   193 		}
       
   194 	}
       
   195 
       
   196 /**
       
   197  * Hardcoded Creation of a Test Push Message
       
   198  *  -Todo Need to be Modified to use different
       
   199  *    Push messages.
       
   200  */
       
   201 void CWapPushR2Test::CreatePushMsg()	
       
   202 	{
       
   203 
       
   204 	// create hardcoded SL test message (Julia's code)
       
   205 	const TUint8 KMessageHeader2[] = 
       
   206 		{
       
   207 		0xAF,  //Content type "application/vnd.wap.sl" 
       
   208 		0x92,  // Date
       
   209 		0x04,  // length of field
       
   210 		0x39,  // Monday 15 August 2000 10:41:37 GMT
       
   211 		0x90,	
       
   212 		0x6a,
       
   213 		0xd0,
       
   214 		0x94,  // Expires 
       
   215 		0x04,  // length of field
       
   216 		0x39,  // Monday 15 August 2000 10:41:37 GMT
       
   217 		0x9a,	
       
   218 		0x6a,
       
   219 		0xd0,
       
   220 		0xAF,  //X-Wap-Application-ID
       
   221 		0x82  // Short int - 0x02 represent x-wap-application:push.ua
       
   222 		};	
       
   223 
       
   224 
       
   225 	TBuf8<40> tempBuf;
       
   226 	TUint8 value;
       
   227 	
       
   228 	for (TInt i = 0; i < 15; i++)
       
   229 		{
       
   230 		value = KMessageHeader2[i];
       
   231 		tempBuf.Append(value);
       
   232 		}
       
   233 
       
   234 	iHeadersBuf.Copy(tempBuf);
       
   235 	tempBuf.Copy(_L8(""));
       
   236 
       
   237 
       
   238   	_LIT(LF, "\n");
       
   239   	//Hard coded SL Text Msg
       
   240   	_LIT(KSL1stLine,"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>");
       
   241   	_LIT(KSL2ndLine,"<!DOCTYPE sl PUBLIC \"-//WAPFORUM//DTD SL 1.0//EN\"");
       
   242   	_LIT(KSL3rdLine,"\"http://www.wapforum.org/DTD/sl.dtd\">");
       
   243   	_LIT(KSL4thLine,"<sl");
       
   244   	_LIT(KSL5thLine,"href=\"http://www.xyz.com/ppaid/123/abc.wml\"");
       
   245   	_LIT(KSL6thLine,"action=\"execute-high\">");
       
   246   	_LIT(KSL7thLine,"</sl>");
       
   247    
       
   248   	iBodyBuf.Append(KSL1stLine);
       
   249   	iBodyBuf.Append(LF);
       
   250   	iBodyBuf.Append(KSL2ndLine);
       
   251   	iBodyBuf.Append(LF);
       
   252   	iBodyBuf.Append(KSL3rdLine);
       
   253   	iBodyBuf.Append(LF);
       
   254   	iBodyBuf.Append(KSL4thLine);
       
   255   	iBodyBuf.Append(LF);
       
   256   	iBodyBuf.Append(KSL5thLine);
       
   257   	iBodyBuf.Append(LF);
       
   258   	iBodyBuf.Append(KSL6thLine);
       
   259   	iBodyBuf.Append(LF);
       
   260   	iBodyBuf.Append(KSL7thLine);
       
   261 	}
       
   262 
       
   263 /* Create a hard code Mulipart Push message.
       
   264  * The Multipart Push Message Contains:
       
   265  *		- 1. Sl
       
   266  *		- 2. Slc
       
   267  *		- 3. Si
       
   268  *		- 4. Sic
       
   269  *		- 5. vCard
       
   270  */
       
   271 void CWapPushR2Test::CreateMultiMixedPushMsg()	
       
   272 	{
       
   273 	// The Multipart Header
       
   274 	const TUint8 KMessageHeaderMultipart[]=
       
   275 		{
       
   276 		0xA3,  //Content type "application/vnd.wap.multipart.mixed"
       
   277 		0x94,  // Date
       
   278 		0x04,  // length of field
       
   279 		0x35,  // Thur 23 Apr 1998 13:41:37 GMT
       
   280 		0x3F,	
       
   281 		0x45,
       
   282 		0x11,
       
   283 		0xAF,  //X-Wap-Application-ID
       
   284 		0x82,  // Short int - 0x02 represent x-wap-application:push.ua
       
   285 		};
       
   286 	
       
   287 	iHeadersBuf.Copy(KMessageHeaderMultipart, sizeof(KMessageHeaderMultipart));
       
   288 	
       
   289 	// Number of parts
       
   290 	const TUint8 KNumParts[] = {0x05};
       
   291 	iBodyBuf.Copy(KNumParts, sizeof(KNumParts));
       
   292 	
       
   293 	
       
   294 	//----- Push Message Part No.1 ---------
       
   295 	// SL Header with multipart code
       
   296 	const TUint8 KSLMultiHeader1[]=
       
   297 		{
       
   298 		0x0A,	// part 1 header size
       
   299 		0x81,	// part 1 body size (208) UintVar 10000001
       
   300 		0x50,	// 01010000
       
   301 		0xAF,	// content type application/vnd.wap.sl ... the headers:
       
   302 		0x94,	// Date
       
   303 		0x04,	// length of field
       
   304 		0x35,	// Thur 23 Apr 1998 13:41:37 GMT
       
   305 		0x3F,	
       
   306 		0x45,
       
   307 		0x11,
       
   308 		0x3F,	
       
   309 		0x45,
       
   310 		0x11
       
   311 	};
       
   312 
       
   313 	// SL Body
       
   314   	const TUint8 KSLMultiBody1[] = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"	\
       
   315   					"<!DOCTYPE sl PUBLIC \"-//WAPFORUM//DTD SL 1.0//EN\"\n"	\
       
   316 					"\"http://www.wapforum.org/DTD/sl.dtd\">\n"	\
       
   317 					"<sl\n"	\
       
   318 					"href=\"http://www.xyz.com/ppaid/123/abc.wml\"\n"	\
       
   319 					"action=\"execute-high\">\n"	\
       
   320 					"</sl>";
       
   321 
       
   322 	
       
   323 	iBodyBuf.Append(KSLMultiHeader1, sizeof(KSLMultiHeader1));
       
   324 	iBodyBuf.Append(KSLMultiBody1, sizeof(KSLMultiBody1)-1);
       
   325 
       
   326 
       
   327 	//----- Push Message Part No.2 ---------
       
   328 	// Slc Message with Multipart Code
       
   329 	const TUint8 KSLCMultipart2[]=
       
   330 		{
       
   331 		0x0A,	// part 2 header size
       
   332 		0x1D,	// part 2 body size
       
   333 		0xB0,	// content type application/vnd.wap.slc ... the headers:
       
   334 		0x94,	// Date
       
   335 		0x04,	// length of field
       
   336 		0x35,	// Thur 23 Apr 1998 13:41:37 GMT
       
   337 		0x3F,	
       
   338 		0x45,
       
   339 		0x11,
       
   340 		0x3F,	
       
   341 		0x45,
       
   342 		0x11,
       
   343 		0x01,	// Body - slc (www.schmookie.com)
       
   344 		0x06,
       
   345 		0x6A,
       
   346 		0x00,
       
   347 		0x85,
       
   348 		0x09,
       
   349 		0x03,
       
   350 		0x6D,
       
   351 		0x6D,
       
   352 		0x6D,
       
   353 		0x2E,
       
   354 		0x73,
       
   355 		0x63,
       
   356 		0x68,
       
   357 		0x6D,
       
   358 		0x6F,
       
   359 		0x6F,
       
   360 		0x6B,
       
   361 		0x69,
       
   362 		0x65,
       
   363 		0x2E,
       
   364 		0x63,
       
   365 		0x6F,
       
   366 		0x64,
       
   367 		0x65,
       
   368 		0x2F,
       
   369 		0x00,
       
   370 		0x05, // [0x05, //xecute-low]  [0x06, //execute-high] [//0x07, //cache]
       
   371 		0x01
       
   372 	};
       
   373 
       
   374 	iBodyBuf.Append(KSLCMultipart2, sizeof(KSLCMultipart2));
       
   375 
       
   376 
       
   377 //----- Push Message Part No.3 ---------
       
   378 	// Si Message with Multipart Code
       
   379 	const TUint8 KSIMultiHeader3[]=
       
   380 		{
       
   381 		0x0A,	// part 3 header size
       
   382 		0x82 ,	// part 3 body size (334) UintVar 10000010
       
   383 		0x4E,	// 01001110
       
   384 		0xAD,	// content type application/vnd.wap.si ... the headers:
       
   385 		0x94,	// Date
       
   386 		0x04,	// length of field
       
   387 		0x35,	// Thur 23 Apr 1998 13:41:37 GMT
       
   388 		0x3F,	
       
   389 		0x45,
       
   390 		0x11,
       
   391 		0x3F,	
       
   392 		0x45,
       
   393 		0x11
       
   394 	};
       
   395 	
       
   396 	// Si Body
       
   397   	const TUint8 KSIMultiBody3[] = "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n"	\
       
   398 										"<!DOCTYPE si PUBLIC \"-//WAPFORUM//DTD SI 1.0//EN\"\n"	\
       
   399 										"\"http://www.wapforum.org/DTD/si.dtd\">\n"	\
       
   400 										" <si>\n" \
       
   401 										" <indication\n" \
       
   402 										"	action=\"signal-none\"\n"	\
       
   403 										"	href=\"http://mmm.ppp.qqq/\"\n"	\
       
   404 										"	si-id=\"123123\"\n"	\
       
   405 										"	created=\"2000-08-29T16:46:03Z\"\n"	\
       
   406 										"	si-expires=\"2000-08-30T16:46:03Z\"\n"	\
       
   407 										"	>\n"	\
       
   408 										"	This is displayed text.\n"	\
       
   409 										" </indication>\n"	\
       
   410 										"</si>	\n";
       
   411 
       
   412 	iBodyBuf.Append(KSIMultiHeader3, sizeof(KSIMultiHeader3));
       
   413 	iBodyBuf.Append(KSIMultiBody3, sizeof(KSIMultiBody3)-1);
       
   414 
       
   415 
       
   416 //----- Push Message Part No.4 ---------
       
   417 	// Sic Message with Multipart Code
       
   418 	const TUint8 KSiCMultipart4[]=
       
   419 		{
       
   420 		0x0A,	// part 2 header size
       
   421 		0x64,	// part 2 body size 
       
   422 		0xAE,	// content type application/vnd.wap.sic ... the headers:
       
   423 		0x94,	// Date
       
   424 		0x04,	// length of field
       
   425 		0x35,	// Thur 23 Apr 1998 13:41:37 GMT
       
   426 		0x3F,	
       
   427 		0x45,
       
   428 		0x11,
       
   429 		0x3F,	
       
   430 		0x45,
       
   431 		0x11, 
       
   432 		0x01, 0x05, 0x6A, 0x12, 0x65, 0x6D, 0x61, 0x69,  0x6C, 0x2F, 0x31, 0x32, 0x33, 0x2F, 0x61, 0x62,
       
   433 		0x63, 0x2E, 0x77, 0x6D, 0x6C, 0x00, 0x45, 0xC6,  0x05, 0x0D, 0x03, 0x78, 0x79, 0x7A, 0x00, 0x85,
       
   434 		0x83, 0x00, 0x11, 0x03, 0x68, 0x74, 0x74, 0x70,  0x3A, 0x2F, 0x2F, 0x77, 0x77, 0x77, 0x2E, 0x78,
       
   435 		0x79, 0x7A, 0x00, 0x85, 0x83, 0x00, 0x0A, 0xC3,  0x07, 0x19, 0x99, 0x06, 0x25, 0x15, 0x23, 0x15,
       
   436 		0x10, 0xC3, 0x04, 0x19, 0x99, 0x06, 0x30, 0x01,  0x03, 0x20, 0x59, 0x6F, 0x75, 0x20, 0x68, 0x61,
       
   437 		0x76, 0x65, 0x20, 0x34, 0x20, 0x6E, 0x65, 0x77,  0x20, 0x65, 0x6D, 0x61, 0x69, 0x6C, 0x73, 0x2E,
       
   438 		0x20, 0x00, 0x01, 0x01};
       
   439 
       
   440 	iBodyBuf.Append(KSiCMultipart4, sizeof(KSiCMultipart4));
       
   441 
       
   442 	//----- Push Message Part No.5 ---------
       
   443 	// vCard Message 
       
   444 
       
   445 	// vCard Message with Multipart Code
       
   446 	const TUint8 KvCardMultiHeader5[]=
       
   447 		{
       
   448 		0x0A,	// part 3 header size
       
   449 		0x83,	// part 3 body size (496) UintVar 10000011
       
   450 		0x70,	// 01110000 
       
   451 		0x87,	// content type "text/x-vCard" 
       
   452 		0x94,	// Date
       
   453 		0x04,	// length of field
       
   454 		0x35,	// Thur 23 Apr 1998 13:41:37 GMT
       
   455 		0x3F,	
       
   456 		0x45,
       
   457 		0x11,
       
   458 		0x3F,	
       
   459 		0x45,
       
   460 		0x11
       
   461 	};
       
   462 
       
   463 	// vCard Body
       
   464   	const TUint8 KvCardMultiBody5[] =	"BEGIN:VCARD\r\n" \
       
   465 										"VERSION:2.1\r\n" \
       
   466 										"N:Wibble;Barney\r\n" \
       
   467 										"FN:Barney Wibble\r\n" \
       
   468 										"ORG:WibCo\r\n" \
       
   469 										"TITLE:Wib Monitor\r\n" \
       
   470 										"TEL;WORK;VOICE:+44 012345345\r\n" \
       
   471 										"TEL;HOME;VOICE:+44 12143234\r\n" \
       
   472 										"ADR;WORK;ENCODING=QUOTED-PRINTABLE:;;23 The Wibble=0D=0AWibble Street;WibbleHampton;Wibbleshire;;United Kingdom\r\n" \
       
   473 										"LABEL;WORK;ENCODING=QUOTED-PRINTABLE:23 The Wibble=0D=0AWibble Street=0D=0AWibbleHampton, Wibbleshire=0D=0AUnited=Kingdom\r\n" \
       
   474 										"URL:http://www.wibbleweb.wib\r\n" \
       
   475 										"EMAIL;PREF;INTERNET:barney.wibble@wibco.co.uk\r\n" \
       
   476 										"REV:20000322T104543Z\r\n" \
       
   477 										"END:VCARD\r\n";
       
   478 
       
   479 
       
   480 	iBodyBuf.Append(KvCardMultiHeader5, sizeof(KvCardMultiHeader5));
       
   481 	iBodyBuf.Append(KvCardMultiBody5, sizeof(KvCardMultiBody5)-1);
       
   482 
       
   483 	//-- end of Mulitipart message ---
       
   484 	}