messagingfw/wappushfw/tpush/DummyStack/Dummywapclient.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     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 //
       
    15 
       
    16 #include <e32std.h>
       
    17 #include "Dummywapstd.h"
       
    18 #include "DummyWapClient.h"
       
    19 #include "dummywapstack.h"
       
    20 
       
    21 
       
    22 
       
    23 /** Bound Connectionless Push
       
    24 */
       
    25 EXPORT_C CWapBoundCLPushService* CWapBoundCLPushService::NewL()
       
    26 	{
       
    27 	CWapBoundCLPushService* me = new (ELeave) CWapBoundCLPushService();
       
    28 	return me;
       
    29 	}
       
    30 
       
    31 EXPORT_C CWapBoundCLPushService::~CWapBoundCLPushService()
       
    32 	{
       
    33 	if(iSessHandle&&iClConnHandle)
       
    34 		{
       
    35 		iSessHandle->Close();
       
    36 		}
       
    37 	STATIC_CAST(CDummyWapStack* , Dll::Tls())->CloseSession(iSessHandle);
       
    38 	delete iClConnHandle;
       
    39  	}
       
    40 
       
    41 
       
    42 TInt CWapBoundCLPushService::Connect(Wap::TBearer /*aBearer*/, Wap::TPort aPort, TBool /*aSecure*/)
       
    43 	{
       
    44 	TInt err = KErrNone;
       
    45 	if (!iSessHandle)
       
    46 		{
       
    47 		TRAP(err, iSessHandle=  STATIC_CAST(CDummyWapStack* , Dll::Tls())->NewSessionL());
       
    48 		}
       
    49 	if (!iSessHandle)
       
    50 		return KErrServerTerminated;
       
    51 
       
    52 	TRAP(err,iClConnHandle =iSessHandle->NewWSPCLConnL(aPort));
       
    53 	if(err)
       
    54 		return err;
       
    55 	return KErrNone; 
       
    56 	}
       
    57 
       
    58 
       
    59 /**
       
    60  * Return the "dummy" wap session associated with this client session
       
    61  */
       
    62 CDummyWapSession* CWapBoundCLPushService::DummyWapSession()
       
    63 	{
       
    64 	return iSessHandle;
       
    65 	}
       
    66 
       
    67 TInt CWapBoundCLPushService::AwaitPush(TDes8& aPushHeaders, TDes8& aPushBody, TPckgBuf<TUint8>& aPushIdPckg, TRequestStatus& aReqStatus)
       
    68 	{
       
    69 	TPushID pushID;
       
    70 	pushID() = aPushIdPckg();
       
    71 	TRAPD(err,iClConnHandle->UnitWaitPushL(aPushBody,aPushHeaders,pushID, aReqStatus));
       
    72 	return err;
       
    73 	}
       
    74 
       
    75 void CWapBoundCLPushService::CancelAwaitPush()
       
    76 	{
       
    77 	iClConnHandle->CancelUnitWaitPush();
       
    78 	}
       
    79 
       
    80 TInt CWapBoundCLPushService::GetServerAddressL(HBufC8*& aRemoteHost) 
       
    81 	{
       
    82 	__ASSERT_ALWAYS(aRemoteHost==NULL, User::Invariant());
       
    83 
       
    84 	if((iClConnHandle->GetServerAddr()).Compare(_L8("")) == 0)
       
    85 		{
       
    86 		_LIT8(KRemoteAddress, "www.zappow.com");
       
    87 		aRemoteHost = KRemoteAddress().AllocL();
       
    88 		}
       
    89 	else
       
    90 		{
       
    91 		aRemoteHost = iClConnHandle->GetServerAddr().AllocL();	
       
    92 		}	
       
    93 	return KErrNone;
       
    94 	}
       
    95 
       
    96 EXPORT_C CWapBoundCLPushService::CWapBoundCLPushService() 
       
    97 	{
       
    98 	}
       
    99 
       
   100 
       
   101 
       
   102 /**
       
   103  * Constructor
       
   104  */
       
   105 EXPORT_C RWAPServ::RWAPServ()
       
   106 	{
       
   107 	}
       
   108 
       
   109 /**
       
   110  * Creates a session with the dummy wap stack
       
   111  * Get the pointer to the stack from TLS
       
   112  * @param TInt aDefaultMessageSlots Ignored in the dummy stack
       
   113  */
       
   114 EXPORT_C TInt RWAPServ::Connect(TInt /*aDefaultMessageSlots*/)
       
   115 	{
       
   116 	TRAPD(err, iSessHandle=  STATIC_CAST(CDummyWapStack* , Dll::Tls())->NewSessionL());
       
   117 	if (err)
       
   118 		return err;
       
   119 
       
   120 	if (!iSessHandle)
       
   121 		return KErrServerTerminated;
       
   122 
       
   123 	return KErrNone; 
       
   124 	}
       
   125 	
       
   126 /**
       
   127  * Closes a previously created WAP session
       
   128  */
       
   129 EXPORT_C void RWAPServ::Close()
       
   130 	{
       
   131 	STATIC_CAST(CDummyWapStack* , Dll::Tls())->CloseSession(iSessHandle);
       
   132 	}
       
   133 
       
   134 /**
       
   135  * Return the "dummy" wap session associated with this client session
       
   136  */
       
   137 CDummyWapSession* RWAPServ::DummyWapSession()
       
   138 	{
       
   139 	return iSessHandle;
       
   140 	}
       
   141 
       
   142 
       
   143 
       
   144 
       
   145 
       
   146 
       
   147 
       
   148 /**
       
   149  * Closes an open connection
       
   150  */
       
   151 EXPORT_C TInt RWAPConn::Close()
       
   152 	{
       
   153 	if (iDummyConn)
       
   154 		iDummyConn->Close();
       
   155 	return KErrNone;
       
   156 	}
       
   157 
       
   158 /**
       
   159  * Return the RWTLS object on which the WTLS functions are available
       
   160  */
       
   161 EXPORT_C RWTLS RWAPConn::Wtls()
       
   162 	{
       
   163 	RWTLS wtls; 
       
   164 	wtls.iDummyWTLS = iDummyConn->WtlsL();
       
   165 	return wtls;
       
   166 	}
       
   167 
       
   168 
       
   169 
       
   170 
       
   171 
       
   172 
       
   173 
       
   174 /**
       
   175  * Set suggested security parameters before (re)negotiating with the server. 
       
   176  * These return ETrue on success otherwise EFalse.
       
   177  */
       
   178 EXPORT_C TInt RWTLS::SetKeyExchangeSuite(TKeyExchangeSuite aSuite,TIdType aIdType,const TDesC8& aKeyId)
       
   179 	{
       
   180 	iDummyWTLS->SetKeyExchangeSuite(aSuite,aIdType,aKeyId);
       
   181 	return ETrue;
       
   182 	}
       
   183 
       
   184 /**
       
   185  * Set suggested security parameters before (re)negotiating with the server. 
       
   186  * These return ETrue on success otherwise EFalse.
       
   187  */
       
   188 EXPORT_C TInt RWTLS::SetCipherSuites(const CipherSuiteArray& aCipherSuites)
       
   189 	{
       
   190 	iDummyWTLS->SetCipherSuites(aCipherSuites);
       
   191 	return ETrue;
       
   192 	}
       
   193 
       
   194 /**
       
   195  * Set suggested security parameters before (re)negotiating with the server. 
       
   196  * These return ETrue on success otherwise EFalse.
       
   197  */
       
   198 EXPORT_C TInt RWTLS::SetSequenceNumberMode(TSequenceNumberMode aMode)
       
   199 	{
       
   200 	iDummyWTLS->SetSequenceNumberMode(aMode);
       
   201 	return ETrue;
       
   202 	}
       
   203 
       
   204 /**
       
   205  * Set suggested security parameters before (re)negotiating with the server. 
       
   206  * These return ETrue on success otherwise EFalse.
       
   207  */
       
   208 EXPORT_C TInt RWTLS::SetKeyRefreshRate(TUint8 aRate)
       
   209 	{
       
   210 	iDummyWTLS->SetKeyRefreshRate(aRate);
       
   211 	return ETrue;
       
   212 	}
       
   213 
       
   214 /**
       
   215  * Set suggested security parameters before (re)negotiating with the server. 
       
   216  * These return ETrue on success otherwise EFalse.
       
   217  */
       
   218 EXPORT_C TInt RWTLS::SetSharedSecret(const TDesC8& aSharedSecret)
       
   219 	{
       
   220 	iDummyWTLS->SetSharedSecret(aSharedSecret);
       
   221 	return ETrue;
       
   222 	}
       
   223 
       
   224 /**
       
   225  * Set suggested security parameters before (re)negotiating with the server. 
       
   226  * These return ETrue on success otherwise EFalse.
       
   227  */
       
   228 EXPORT_C TInt RWTLS::SetRecordLengthUsage(TBool aUsage)
       
   229 	{
       
   230 	iDummyWTLS->SetRecordLengthUsage(aUsage);
       
   231 	return ETrue;
       
   232 	}
       
   233 
       
   234 /** 
       
   235  * Make the handshake with the server to agree on the security parameters.
       
   236  * The connection must be Opened (in secure mode) before this. 
       
   237  * Optionally the parameter setters may precede this call. 
       
   238  * If called more than once a renegotiation is done with possibly 
       
   239  * new parameters.
       
   240  * aTwoPhaseHandshake may be set to ETrue to return half way through to check
       
   241  * the server certificate. CancelConnect() or ConnectPhaseTwo() should succeed
       
   242  * this call if two phase connect is used.
       
   243  */
       
   244 EXPORT_C void RWTLS::Connect(TRequestStatus& aStatus, TBool aTwoPhaseHandshake)
       
   245 	{
       
   246 	// assert that the connection has been opened
       
   247 	iDummyWTLS->Connect(aStatus,aTwoPhaseHandshake);
       
   248 	}
       
   249 
       
   250 /**
       
   251  * Cancels the secure handshake. May be called after the first phase.
       
   252  */
       
   253 EXPORT_C void RWTLS::CancelConnect()
       
   254 	{
       
   255 	iDummyWTLS->CancelConnect();
       
   256 	}
       
   257 
       
   258 /**
       
   259  * Continue the secure handshake after the first phase has completed.
       
   260  */
       
   261 EXPORT_C TInt RWTLS::ConnectPhaseTwo(TRequestStatus& aStatus)
       
   262 	{
       
   263 	iDummyWTLS->ConnectPhaseTwo(aStatus);
       
   264 	return KErrNone;
       
   265 	}
       
   266 
       
   267 /** 
       
   268  * Cancel second phase connection
       
   269  */
       
   270 EXPORT_C void RWTLS::CancelConnectPhaseTwo()
       
   271 	{
       
   272 	iDummyWTLS->CancelConnectPhaseTwo();
       
   273 	}
       
   274 
       
   275 /**
       
   276  * Use the getters to see which values where agreed upon.
       
   277  */
       
   278 EXPORT_C TInt RWTLS::GetCipherSuite(TCipherSuite& aCipherSuite) const
       
   279 	{
       
   280 	iDummyWTLS->GetCipherSuite(aCipherSuite);
       
   281 	return KErrNone;
       
   282 	}
       
   283 
       
   284 /**
       
   285  * Use the getters to see which values where agreed upon.
       
   286  */
       
   287 EXPORT_C TInt RWTLS::GetSequenceNumberMode(TSequenceNumberMode& aMode) const
       
   288 	{
       
   289 	iDummyWTLS->GetSequenceNumberMode(aMode);
       
   290 	return KErrNone;
       
   291 	}
       
   292 
       
   293 /**
       
   294  * Use the getters to see which values where agreed upon.
       
   295  */
       
   296 EXPORT_C TInt RWTLS::GetKeyRefreshRate(TUint8& aRate) const
       
   297 	{
       
   298 	iDummyWTLS->GetKeyRefreshRate(aRate);
       
   299 	return KErrNone;
       
   300 	}
       
   301 
       
   302 /**
       
   303  * Use the getters to see which values where agreed upon.
       
   304  */
       
   305 EXPORT_C RCertificate RWTLS::ServerCert()
       
   306 	{
       
   307 	RCertificate certificate = RCertificate();
       
   308 	return certificate;
       
   309 	}
       
   310 
       
   311 
       
   312 
       
   313 
       
   314 
       
   315 
       
   316 /** 
       
   317  * Load a new certificate from persistent storage. Identified by subject.
       
   318  * NB: Not currently supported - returns KErrNotSupported
       
   319  */
       
   320 EXPORT_C TInt RCertificate::Load(const TDesC8& /*aSubject*/)
       
   321 	{
       
   322 	return KErrNotSupported;
       
   323 	}
       
   324 
       
   325 /**
       
   326  * Load a new certificate from persistent storage. Identified by id.
       
   327  * NB: Not currently supported - returns KErrNotSupported
       
   328  */
       
   329 EXPORT_C TInt RCertificate::LoadById(const TCertId& /*aId*/)
       
   330 	{
       
   331 	return KErrNotSupported;
       
   332 	}
       
   333 
       
   334 /** Delete certificate identified by subject from the certificate store */
       
   335 EXPORT_C TInt RCertificate::Delete(const TDesC8& /*aSubject*/)
       
   336 	{
       
   337 	return KErrNotSupported;
       
   338 	}
       
   339 
       
   340 /** Save this cert to persistent storage */
       
   341 EXPORT_C TInt RCertificate::Save(const TCertificate& /*aCertificate*/, TDes8& /*aSubject*/)
       
   342 	{
       
   343 	return KErrNotSupported;
       
   344 	}
       
   345 
       
   346 /**
       
   347  * Find subject of first cert in persistent storage. Use aId to find next.
       
   348  * NB: Not currently supported - returns KErrNotSupported
       
   349  */
       
   350 EXPORT_C TInt RCertificate::FindFirst(TDes8& /*aSubject*/, TCertId& /*aId*/) const
       
   351 	{
       
   352 	return KErrNotSupported;
       
   353 	}
       
   354 
       
   355 /**
       
   356  * Find subject of next cert
       
   357  * NB: Not currently supported - returns KErrNotSupported
       
   358  */
       
   359 EXPORT_C TInt RCertificate::FindNext(TDes8& /*aSubject*/, TCertId& /*aId*/) const
       
   360 	{
       
   361 	return KErrNotSupported;
       
   362 	}
       
   363 
       
   364 /**
       
   365  * Get the details of the server certificate of this secure connection OR the 
       
   366  * certificate explicitly loaded from persistent storage.
       
   367  */
       
   368 EXPORT_C TInt RCertificate::Info(TInfo& /*aInfo*/) const
       
   369 	{
       
   370 	return KErrNotSupported;
       
   371 	}
       
   372 
       
   373 
       
   374 
       
   375 
       
   376 
       
   377 
       
   378 
       
   379 /**
       
   380  *  Creates a Push Connectionless type connection
       
   381  *  @param aServ Reference to RWAPServ object that Created the WAP Sesssion
       
   382  */
       
   383 EXPORT_C TInt RWSPCLConn::Open(RWAPServ& aServer, TPort aLocalPort)
       
   384 	{	
       
   385 	TRAPD(err,iClConnHandle =aServer.DummyWapSession()->NewWSPCLConnL(aLocalPort));
       
   386 	if(err)
       
   387 		return err;
       
   388 	iDummyConn=iClConnHandle;
       
   389 	return KErrNone; 
       
   390 	}
       
   391 
       
   392 /**
       
   393  *  Creates a Push Connectionless type connection
       
   394  *  @param aServ Reference to RWAPServ object that Created the WAP Sesssion
       
   395  *  @param aRemotePort Port Number the Server is going to send on
       
   396  *  @param aLocalPort Local Port, if set to 0 it's allocated automatically
       
   397  *  @param aBearer enum, can be EIP, ESMS, EMSM7, EALL
       
   398  *  @param aSecureConn ETrue WTLS will be used, EFalse, it wont
       
   399  */
       
   400 EXPORT_C TInt RWSPCLConn::Open(RWAPServ& aServer,
       
   401 						const TDesC8& /*aRemoteHost*/,
       
   402 						TPort /*aRemotePort*/,
       
   403 						TPort aLocalPort,
       
   404 						Wap::TBearer /*aBearer*/,
       
   405 						TBool /*aSecureConn*/)
       
   406 	{	
       
   407 	TRAPD(err,iClConnHandle =aServer.DummyWapSession()->NewWSPCLConnL(aLocalPort));
       
   408 	if(err)
       
   409 		return err;
       
   410 	iDummyConn=iClConnHandle;
       
   411 	return KErrNone; 
       
   412 	}
       
   413 
       
   414 
       
   415 /**
       
   416  *  Wait for push from the server. Assumes a bound RWSPCLConn object.
       
   417  */
       
   418 EXPORT_C TInt RWSPCLConn::AwaitPush(TDes8& aPushHeaders, TDes8& aPushBody, TUint& aPushId, TRequestStatus& aReqStatus)
       
   419 	{
       
   420 	TRAPD(err,iClConnHandle->UnitWaitPushL(aPushBody,aPushHeaders,(TPushID&)aPushId, aReqStatus));
       
   421 	return err;
       
   422 	}
       
   423 
       
   424 /**
       
   425  *  Wait for push from the server. Assumes a bound RWSPCLConn object.
       
   426  */
       
   427 EXPORT_C void RWSPCLConn::UnitWaitPush(TDes8& aBody,TDes8& aHeaders,TPushID& aID,TRequestStatus& aStatus)
       
   428 	{
       
   429 	TRAPD(err,iClConnHandle->UnitWaitPushL(aBody,aHeaders,aID, aStatus));
       
   430 	if(err)
       
   431 		User::Panic(_L("RWSPCLConn::UnitWaitPush() --NewWSPCLConnL --"),err);
       
   432 	}
       
   433 
       
   434 /**
       
   435  *  Cancel the asynchronous UnitWaitPush operation.
       
   436  */
       
   437 EXPORT_C void RWSPCLConn::CancelAwaitPush()
       
   438 	{
       
   439 	iClConnHandle->CancelUnitWaitPush();
       
   440 	}
       
   441 
       
   442 
       
   443 	/**
       
   444  *  Cancel the asynchronous UnitWaitPush operation.
       
   445  */
       
   446 EXPORT_C void RWSPCLConn::CancelUnitWaitPush()
       
   447 	{
       
   448 	iClConnHandle->CancelUnitWaitPush();
       
   449 	}
       
   450 
       
   451 /**
       
   452  *  The synchronous version
       
   453  */
       
   454 EXPORT_C TInt RWSPCLConn::UnitWaitPush(TDes8& aBody,TDes8& aHeaders,TPushID& aID)
       
   455 	{
       
   456 
       
   457 	TRAPD(err,iClConnHandle->UnitWaitPushL(aBody, aHeaders, aID));
       
   458 	if(err)
       
   459 		return err;
       
   460 
       
   461 	return KErrNone;
       
   462 	}
       
   463 
       
   464 
       
   465 //
       
   466 // -- connection-orientated transaction --
       
   467 //
       
   468 
       
   469 /**
       
   470  * Constructor for connection-orientated transaction
       
   471  */
       
   472 EXPORT_C RWSPCOTrans::RWSPCOTrans() : iCoTransHandle(0)
       
   473 	{
       
   474 	}
       
   475 
       
   476 /**
       
   477  * Destructor for connection-orientated transaction
       
   478  */
       
   479 EXPORT_C RWSPCOTrans::~RWSPCOTrans()
       
   480 	{
       
   481 	}
       
   482 
       
   483 /**
       
   484  * Acknowledges a transaction. 
       
   485  * This must be used to accept a confirmed push from the server. 
       
   486  *
       
   487  */
       
   488 EXPORT_C TInt RWSPCOTrans::Acknowledge(const TDesC8& aAckHeaders)
       
   489 	{
       
   490 	// if the handle to the server's transaction is NULL then
       
   491 	// return RWSPCOConn::EInvalidTransaction;
       
   492 	if (!iCoTransHandle)
       
   493 		return RWSPCOConn::EInvalidTransaction;
       
   494 	
       
   495 	return iCoTransHandle->Acknowledge(aAckHeaders); 
       
   496 	}
       
   497 
       
   498 /**
       
   499  * Get the data for this transaction
       
   500  * If the allocated buffer is too small the function will return EMoreData and
       
   501  * the remaining data can be read with successive calls
       
   502  * 
       
   503  * @param aBuffer The user allocated buffer to be filled with the requested data (output)
       
   504  * @param aDataType The type of data to be returned (input)
       
   505  */
       
   506 EXPORT_C TInt RWSPCOTrans::GetData(TDes8& aBuffer, TDataType aDataType, TInt* aSizeLeft) const
       
   507 	{
       
   508 	// if the handle to the server's transaction is NULL then
       
   509 	// return RWSPCOConn::EInvalidTransaction;
       
   510 	if (!iCoTransHandle)
       
   511 		return RWSPCOConn::EInvalidTransaction;
       
   512 
       
   513 	return iCoTransHandle->GetData(aBuffer,aDataType,aSizeLeft);
       
   514 	};
       
   515 
       
   516 /**
       
   517  * Retrieve the state the transaction is in
       
   518  * Can be one of EInit, ERequesting, EReplying, EDone, EAborted, EPushing
       
   519  */
       
   520 EXPORT_C TInt RWSPCOTrans::GetState(TState& aState) const
       
   521 	{
       
   522 	// if the handle to the server's transaction is NULL then
       
   523 	// return RWSPCOConn::EInvalidTransaction;
       
   524 	if (!iCoTransHandle)
       
   525 		return RWSPCOConn::EInvalidTransaction;
       
   526 
       
   527 	return iCoTransHandle->GetState(aState);
       
   528 	}
       
   529 
       
   530 /**
       
   531  * Aborts a method invoke or push transaction 
       
   532  * State of the transaction can be EInit or ERequesting
       
   533  */
       
   534 EXPORT_C TInt RWSPCOTrans::Abort(TAbortReason aReason)
       
   535 	{
       
   536 	// if the handle to the server's transaction is NULL then
       
   537 	// return RWSPCOConn::EInvalidTransaction;
       
   538 	if (!iCoTransHandle)
       
   539 		return RWSPCOConn::EInvalidTransaction;
       
   540 	//
       
   541 	// assert that the state of the transaction is EInit or ERequesting
       
   542 	return iCoTransHandle->Abort(aReason);
       
   543 	}
       
   544 
       
   545 /** 
       
   546  * Releases a transaction
       
   547  * Must be called after use. Causes the resources reserved by the transaction
       
   548  * to be released. Function succeeds only if the state of the transaction is 
       
   549  * EInit, EAborted or EDone. If the transaction is in any other state the 
       
   550  * transaction should be aborted first.
       
   551  */
       
   552 EXPORT_C TInt RWSPCOTrans::Release()
       
   553 	{
       
   554 	// if the handle to the server's transaction is NULL then
       
   555 	// return RWSPCOConn::EInvalidTransaction;
       
   556 	if (!iCoTransHandle)
       
   557 		return RWSPCOConn::EInvalidTransaction;
       
   558 	//
       
   559 	// assert that the transaction state is EInit, EAborted or EDone
       
   560 
       
   561 	return iCoTransHandle->Release();
       
   562 	}
       
   563 
       
   564 EXPORT_C TInt RWSPCOTrans::Id(TTransID& aId)
       
   565 	{
       
   566 	// if the handle to the server's transaction is NULL then
       
   567 	// return RWSPCOConn::EInvalidTransaction;
       
   568 	if (!iCoTransHandle)
       
   569 		return RWSPCOConn::EInvalidTransaction;
       
   570 	// else return handle
       
   571 	return iCoTransHandle->Id(aId);
       
   572 	}
       
   573 
       
   574 
       
   575 
       
   576 
       
   577 //
       
   578 // -- connection-orientated connection --
       
   579 //
       
   580 
       
   581 
       
   582 /**
       
   583  * Fully defined open
       
   584  *
       
   585  */
       
   586 EXPORT_C TInt RWSPCOConn::Open(RWAPServ& aServer, const TDesC8& /*aRemoteHost*/, TPort /*aRemotePort*/, TPort /*aLocalPort*/, 
       
   587 							   TBearer /*aBearer*/, TBool /*aSecureConn*/)
       
   588 	{
       
   589 	TRAPD(err,iCoConnHandle=aServer.DummyWapSession()->NewWSPCOConnL());
       
   590 	if(err)
       
   591 		return err;
       
   592 	iDummyConn=iCoConnHandle;
       
   593 	return KErrNone;
       
   594 	}
       
   595 
       
   596 /**
       
   597  * Close CO connection
       
   598  */
       
   599 EXPORT_C TInt RWSPCOConn::Close()
       
   600 	{
       
   601 	iDummyConn->Close();
       
   602 	return KErrNone;
       
   603 	}
       
   604 
       
   605 /**
       
   606  * Establishes a WSP session with the server
       
   607  * Session creation status is retrieved by calls to GetEvent
       
   608  * @param aClientHeaders Session headers communicated to the server during 
       
   609  *                       session establishment
       
   610  * @param aCap           Proposed capabilities
       
   611  */
       
   612 EXPORT_C TInt RWSPCOConn::Connect(const TDesC8& aClientHeaders, class CCapCodec* aCap)
       
   613 	{
       
   614 	return iCoConnHandle->Connect(aClientHeaders,aCap);
       
   615 	}
       
   616 
       
   617 /**
       
   618  * Disconnects the session and aborts all pending transactions
       
   619  */
       
   620 EXPORT_C TInt RWSPCOConn::Disconnect()
       
   621 	{
       
   622 	return iCoConnHandle->Disconnect();
       
   623 	}
       
   624 
       
   625 /** 
       
   626  * Suspends a session. No incoming or outgoing activity is allowed within the 
       
   627  * session. All pending transactions of the session are aborted, events 
       
   628  * corresponding to aborted transactions are NOT delivered via WSP_GetEvent()
       
   629  */
       
   630 EXPORT_C TInt RWSPCOConn::Suspend()
       
   631 	{
       
   632 	return KErrNotSupported;
       
   633 	}
       
   634 
       
   635 /**
       
   636  * Resumes a suspended session
       
   637  */
       
   638 EXPORT_C TInt RWSPCOConn::Resume(RWSPCOConn& /*aBlankConn*/, const TDesC8& /*aHeaders*/)
       
   639 	{
       
   640 	return KErrNotSupported;
       
   641 	}
       
   642 
       
   643 /** 
       
   644  * Returns the state of the session
       
   645  */
       
   646 EXPORT_C TInt RWSPCOConn::GetSessionState(TSessionState& aState) const
       
   647 	{
       
   648 	return iCoConnHandle->GetSessionState(aState);
       
   649 	}
       
   650 
       
   651 /**
       
   652  * Retrieves data associated with a session
       
   653  * If the allocated buffer is too small,the function will return EMoreData and
       
   654  * the remaining data can be read with successive calls.
       
   655  * @param aData The user allocated buffer to be filled with the requested data
       
   656  * @param aType The type of the requested data. 
       
   657  */
       
   658 EXPORT_C TInt RWSPCOConn::GetSessionData(TDes8& /*aData*/, TSessionDataType /*aType*/) const
       
   659 	{
       
   660 	return KErrNone;
       
   661 	}
       
   662 
       
   663 /** 
       
   664  * Create a transaction
       
   665  * Creates and invokes a methodInvoke in the context of the session
       
   666  * @param aMethod  HTTP method. May be either of EGet, EOptions, EHead, EDelete, 
       
   667  *                 ETrace, EPost or EPut
       
   668  * @param aURI     Uniform Resource Identifier. Must not be empty
       
   669  * @param aHeaders Request headers. Content type must be the first header field 
       
   670  *                 if aBody is given. Can be empty
       
   671  * @param aBody    Data associated with the invoke. Semantically equivalent to 
       
   672  *                 HTTP entity body. If aMethod doesn't require a body. then
       
   673  *                 this must be empty
       
   674  * @param aTrans   The created transaction
       
   675  */
       
   676 EXPORT_C TInt RWSPCOConn::CreateTransaction(TMethod /*aMethod*/, const TDesC& /*aURI*/, const TDesC8& /*aHeaders*/, const TDesC8& /*aBody*/, RWSPCOTrans& /*aTrans*/)
       
   677 	{
       
   678 	// assert that aURI isn't empty
       
   679 	// assert if aMethod doesn't require a body - no body is provided
       
   680 
       
   681 	return KErrNotSupported;
       
   682 	}
       
   683 
       
   684 /** 
       
   685  * Gets next session or transaction event on this session 
       
   686  * @param aEvent The event. Use the function operator to get the value of the event
       
   687  * @param aTrans The transaction, if aEvent is a transaction event
       
   688  * @param aStatus Indicates completion of this asynchronous request
       
   689  */
       
   690 EXPORT_C void RWSPCOConn::GetEvent(TEvent& aEvent, RWSPCOTrans& aTrans, TRequestStatus& aStatus) const
       
   691 	{
       
   692 	iCoConnHandle->GetEvent(aEvent,aTrans,aStatus);
       
   693 	}
       
   694 
       
   695 /** 
       
   696  * Cancel the asynchronous GetEvent operation 
       
   697  */		
       
   698 EXPORT_C void RWSPCOConn::CancelGetEvent()
       
   699 	{
       
   700 	iCoConnHandle->CancelGetEvent();
       
   701 	}
       
   702 
       
   703 /** 
       
   704  * Gets next session or transaction event on this session (synchronous version) 
       
   705  * This isn't implemented in the dummy stack
       
   706  * @param aEvent The event. Use the function operator to get the value of the event
       
   707  * @param aTrans The transaction, if aEvent is a transaction event
       
   708  */
       
   709 EXPORT_C TInt RWSPCOConn::GetEvent(TEvent& /*aEvent*/, RWSPCOTrans& /*aTrans*/) const 
       
   710 	{
       
   711 	return KErrNotSupported;
       
   712 	}
       
   713 	
       
   714 /** 
       
   715  * Return the number of events pending for the session 
       
   716  * @param aNrOfEvents The number of events pending 
       
   717  */
       
   718 EXPORT_C TInt RWSPCOConn::GetNrOfEvents(TUint& aNrOfEvents) const
       
   719 	{
       
   720 	return iCoConnHandle->GetNrOfEvents(aNrOfEvents);
       
   721 	}
       
   722