wapstack/wapmessageapi/sws/ActiveSocket.cpp
author hgs
Mon, 28 Jun 2010 17:02:18 +0100
changeset 45 28dbf5a297f4
parent 44 8b72faa1200f
permissions -rw-r--r--
201024_05
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     1
// Copyright (c) 2003-2010 Nokia Corporation and/or its subsidiary(-ies).
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     2
// All rights reserved.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     3
// This component and the accompanying materials are made available
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     4
// under the terms of "Eclipse Public License v1.0"
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     5
// which accompanies this distribution, and is available
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     7
//
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     8
// Initial Contributors:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     9
// Nokia Corporation - initial contribution.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    10
//
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    11
// Contributors:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    12
//
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    13
// Description:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    14
//
45
28dbf5a297f4 201024_05
hgs
parents: 44
diff changeset
    15
#include "OstTraceDefinitions.h"
28dbf5a297f4 201024_05
hgs
parents: 44
diff changeset
    16
#ifdef OST_TRACE_COMPILER_IN_USE
28dbf5a297f4 201024_05
hgs
parents: 44
diff changeset
    17
#include "ActiveSocketTraces.h"
28dbf5a297f4 201024_05
hgs
parents: 44
diff changeset
    18
#endif
44
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    19
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    20
#include "ActiveSocket.h"
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    21
#include <es_wsms.h>
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    22
#include "CLWSPPduHandler.h"
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    23
#include "wapmsgerr.h"
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    24
#include <wap_sock.h>
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    25
#include "WapMessageApiAgent.h"
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    26
#include "WapMsgUtils.h"
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    27
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    28
using namespace Wap;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    29
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    30
void CActiveSocket::NewL(RSocketServ& aSocketServ, RPointerArray<CActiveSocket>& aActiveSockets, Wap::TBearer aBearer, TWapMessageType aType, MProgressNotify* aNotify, Wap::TPort aLocalPort, RConnection* aConnection)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    31
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    32
The static new function instanciates corresponding Bearers in terms of the input bearer type.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    33
This function is used by Bound Wap APIs which listen the incoming packet to a specific port. 
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    34
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    35
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    36
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    37
@param aSocketServ the shared RSocketServ instance used in the Wap messaging API which owns this bearer
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    38
@param aActiveSockets the bearer array used in the Wap messaging API which owns the bearer
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    39
@param aBearer  the bearer to listen on (use EAll for all bearers)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    40
@param aType  the type of the wap message that will received
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    41
@param aNotify  the instance to be notified when a wap message is received
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    42
@param aLocalPort  the port to listen on
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    43
@param aConnection the shared connection from Wap messaging API client
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    44
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    45
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    46
	//Instanciate the corresponding
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    47
	switch(aBearer)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    48
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    49
		case Wap::ESMS7:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    50
		case Wap::ESMS:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    51
		case Wap::EWAPSMS7:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    52
		case Wap::EWAPSMS:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    53
			{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    54
			CActiveSocket* me = new(ELeave) CActiveSocketSMS(aSocketServ, aNotify, aBearer, aLocalPort);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    55
			CleanupStack::PushL(me);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    56
			me->ConstructL(aType);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    57
			aActiveSockets.AppendL(me);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    58
			CleanupStack::Pop(me);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    59
			break;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    60
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    61
		case Wap::EIP:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    62
			{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    63
			CActiveSocket* me = new(ELeave) CActiveSocketUDP(aSocketServ, aNotify, aBearer, aLocalPort, aConnection);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    64
			CleanupStack::PushL(me);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    65
			me->ConstructL(aType);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    66
			aActiveSockets.AppendL(me);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    67
			CleanupStack::Pop(me);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    68
			break;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    69
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    70
		case Wap::EAll:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    71
			{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    72
			CActiveSocket* me = new(ELeave) CActiveSocketUDP(aSocketServ, aNotify, Wap::EIP, aLocalPort, aConnection);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    73
			CleanupStack::PushL(me);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    74
			me->ConstructL(aType);          
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    75
			CActiveSocket* me1 = new(ELeave) CActiveSocketSMS(aSocketServ, aNotify, Wap::ESMS, aLocalPort);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    76
			CleanupStack::PushL(me1);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    77
			me1->ConstructL(aType);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    78
			aActiveSockets.ReserveL(2); // pre-allocate the memory                                           
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    79
			aActiveSockets.AppendL(me1);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    80
			CleanupStack::Pop(me1);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    81
			aActiveSockets.AppendL(me);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    82
			CleanupStack::Pop(me);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    83
			break;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    84
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    85
		default:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    86
		    {
45
28dbf5a297f4 201024_05
hgs
parents: 44
diff changeset
    87
            OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKET_NEWL_1, "CActiveSocket::NewL Unknown Bearer Type");
44
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    88
			User::Leave(Wap::EBearerError);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    89
		    }
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    90
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    91
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    92
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    93
void CActiveSocket::NewL(RSocketServ& aSocketServ, RPointerArray<CActiveSocket>& aActiveSockets, Wap::TBearer aBearer, TWapMessageType aType, MProgressNotify* aNotify, const TSockAddr& aRemoteAddr, RConnection* aConnection)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    94
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    95
The static new function instanciates corresponding Bearers in terms of the input bearer type.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    96
This function is used by Fully specified Wap APIs which will open a socket with a single, named remote host. 
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    97
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    98
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    99
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   100
@param aSocketServ the shared RSocketServ instance used in the Wap messaging API which owns this bearer
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   101
@param aActiveSockets the bearer array used in the Wap messaging API which owns the bearer
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   102
@param aBearer the bearer to listen on (use EAll for all bearers)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   103
@param aType the type of the wap message that will received
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   104
@param aNotify the instance to be notified when a wap message is received
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   105
@param aRemoteAddr the remote host to be communicate with
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   106
@param aConnection the shared connection from Wap messaging API client
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   107
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   108
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   109
	//Instanciate the corresponding
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   110
	switch(aBearer)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   111
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   112
		case Wap::ESMS7:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   113
		case Wap::ESMS:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   114
		case Wap::EWAPSMS7:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   115
		case Wap::EWAPSMS:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   116
			{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   117
			CActiveSocket* me = new(ELeave) CActiveSocketSMS(aSocketServ, aNotify, aBearer, aRemoteAddr);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   118
			CleanupStack::PushL(me);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   119
			me->ConstructL(aType);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   120
            aActiveSockets.AppendL(me);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   121
			CleanupStack::Pop(me);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   122
			break;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   123
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   124
		case Wap::EIP:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   125
			{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   126
			CActiveSocket* me = new(ELeave) CActiveSocketUDP(aSocketServ, aNotify, aBearer, aRemoteAddr, aConnection);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   127
			CleanupStack::PushL(me);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   128
			me->ConstructL(aType);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   129
            aActiveSockets.AppendL(me);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   130
			CleanupStack::Pop(me);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   131
			break;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   132
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   133
		case Wap::EAll:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   134
			{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   135
			CActiveSocket* me = new(ELeave) CActiveSocketUDP(aSocketServ, aNotify, aBearer, aRemoteAddr, aConnection);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   136
			CleanupStack::PushL(me);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   137
			me->ConstructL(aType);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   138
			CActiveSocket* me1 = new(ELeave) CActiveSocketSMS(aSocketServ, aNotify, aBearer, aRemoteAddr);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   139
			CleanupStack::PushL(me1);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   140
			me1->ConstructL(aType);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   141
            aActiveSockets.ReserveL(2); // pre-allocate the memory    
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   142
			aActiveSockets.AppendL(me1);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   143
            CleanupStack::Pop(me1);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   144
            aActiveSockets.AppendL(me);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   145
            CleanupStack::Pop(me);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   146
			break;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   147
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   148
		default:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   149
		    {
45
28dbf5a297f4 201024_05
hgs
parents: 44
diff changeset
   150
		    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKET_NEWL_1_1, "CActiveSocket::NewL Unknown Bearer Type");
44
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   151
			User::Leave(Wap::EBearerError);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   152
		    }
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   153
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   154
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   155
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   156
CActiveSocket::CActiveSocket(RSocketServ& aSocketServ, Wap::TBearer aBearerType, MProgressNotify* aNotify, Wap::TPort aLocalPort)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   157
:CActive(EPriorityStandard), iLocalAddr(0), iSocketServ(aSocketServ), iBearerType(aBearerType), iLocalPort(aLocalPort), iSocketState(ESocketIdle),iNotify(aNotify), iBuf(0,0), iRxlength(0), iBufCon(0,0)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   158
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   159
Constructor of bearer base class for Bound Wap APIs
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   160
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   161
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   162
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   163
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   164
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   165
	CActiveScheduler::Add(this);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   166
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   167
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   168
CActiveSocket::CActiveSocket(RSocketServ& aSocketServ, Wap::TBearer aBearerType, MProgressNotify* aNotify, const TSockAddr& aRemoteAddr, Wap::TPort aLocalPort): CActive(EPriorityStandard), 
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   169
iRemoteAddr(aRemoteAddr), iLocalAddr(0), iSocketServ(aSocketServ), iBearerType(aBearerType), iLocalPort(aLocalPort), iSocketState(ESocketIdle), iNotify(aNotify), iBuf(0,0), iRxlength(0), iBufCon(0,0)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   170
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   171
Constructor of bearer base class for fully specified Wap APIs
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   172
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   173
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   174
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   175
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   176
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   177
	CActiveScheduler::Add(this);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   178
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   179
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   180
CActiveSocket::~CActiveSocket()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   181
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   182
Destructor
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   183
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   184
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   185
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   186
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   187
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   188
	Cancel();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   189
	iSocket.Close();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   190
	if (iMessageRecord) 
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   191
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   192
		delete iMessageRecord;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   193
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   194
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   195
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   196
void CActiveSocket::ConstructL(TWapMessageType aType)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   197
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   198
Second Phase Constructor
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   199
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   200
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   201
@param aType the type of Wap message which is received. 
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   202
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   203
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   204
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   205
	iMessageRecord=CWapMessageRecord::NewL(aType);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   206
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   207
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   208
RSocket& CActiveSocket::Socket()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   209
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   210
To get the RSocket instance ownd by this bearer
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   211
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   212
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   213
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   214
@returns the reference of the RSocket instance.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   215
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   216
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   217
	return iSocket;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   218
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   219
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   220
Wap::TBearer CActiveSocket::GetBearerType()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   221
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   222
To get the bearer type of this bearer
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   223
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   224
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   225
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   226
@returns the bearer type
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   227
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   228
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   229
	return iBearerType;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   230
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   231
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   232
TSockAddr& CActiveSocket::GetLocalAddress()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   233
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   234
To get the local address of this bearer
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   235
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   236
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   237
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   238
@returns the lcoal address instance
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   239
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   240
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   241
	iSocket.LocalName(iLocalAddr);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   242
	return iLocalAddr;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   243
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   244
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   245
TSockAddr& CActiveSocket::GetRemoteAddress()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   246
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   247
To get the remote address of the last received packet
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   248
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   249
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   250
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   251
@returns the remote address instance
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   252
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   253
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   254
	return iRemoteAddr;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   255
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   256
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   257
TInt CActiveSocket::GetRemoteAddress(HBufC8*& aAddr)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   258
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   259
To get the remote address of the last received packet
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   260
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   261
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   262
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   263
@param aAddr the remote host name
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   264
@returns KErrNone on successful completion, or one of the system error codes on failure.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   265
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   266
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   267
	TRAPD(err, aAddr=iRemoteAddr.AllocL())
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   268
	if (err==KErrNone)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   269
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   270
		Wap::TPort port;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   271
		TPtr8 des=aAddr->Des();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   272
		TRAP(err, CSWSWapMsgUtils::AnalyseAddrL(iRemoteAddr, iBearerType, des, port))
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   273
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   274
	else
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   275
		{
45
28dbf5a297f4 201024_05
hgs
parents: 44
diff changeset
   276
        OstTraceDef1(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKET_GETREMOTEADDRESS_1, "CActiveSocket::GetRemoteAddress: Alloc Memory Err=%d", err);
44
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   277
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   278
	return err;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   279
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   280
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   281
TInt CActiveSocket::GetLocalPort(Wap::TPort& aLocalPort)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   282
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   283
To get the lcoal port of this bearer
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   284
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   285
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   286
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   287
@param aLocalPort the local port of this bearer
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   288
@returns KErrNone on successful completion, or one of the system error codes on failure.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   289
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   290
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   291
	GetLocalAddress();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   292
	aLocalPort=Wap::TPort(iLocalAddr.Port());
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   293
	return KErrNone;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   294
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   295
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   296
TUint32 CActiveSocket::GetPduSize()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   297
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   298
To get the received Wdp Pdu length
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   299
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   300
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   301
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   302
@returns the length of the received Wdp pdu.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   303
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   304
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   305
	return iMessageRecord->GetPduSize();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   306
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   307
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   308
TWapMessageState CActiveSocket::GetDataState()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   309
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   310
To get the state of the data that is being received
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   311
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   312
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   313
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   314
@returns the state of the data that is being received
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   315
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   316
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   317
	return iMessageRecord->GetDataState();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   318
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   319
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   320
void CActiveSocket::SetDataState(TWapMessageState aState)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   321
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   322
To set the state of the data that is being received
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   323
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   324
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   325
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   326
@param aState the state of the data that is being received
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   327
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   328
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   329
	iMessageRecord->SetDataState(aState);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   330
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   331
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   332
TInt CActiveSocket::GetPduData(TDes8& aBuffer, TBool& aTruncated)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   333
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   334
To get the received Wdp pdu.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   335
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   336
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   337
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   338
@param aBuffer the buffer to read the received WDP pdu
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   339
@param aTruncated the flag to represent if the data has be truncated or not
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   340
@returns KErrNone on successful completion, or one of the system error codes on failure.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   341
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   342
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   343
	return iMessageRecord->GetPduData(aBuffer, aTruncated);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   344
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   345
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   346
TInt CActiveSocket::GetWspData(TDes8& aWspHeader, TDes8& aWspBody, TUint8& aTransactionId, TWSPStatus& aStatus)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   347
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   348
To get the received Wsp header, body, tranaction ID and Wsp status.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   349
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   350
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   351
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   352
@param aWspHeader the buffer to read the received Wsp header
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   353
@param aWspBody the buffer to read the received Wsp body
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   354
@param aTransactionId the transaction ID of the received Wsp Message
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   355
@param aStatus the Wsp status of  the received Wsp Message
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   356
@returns KErrNone on successful completion, or one of the system error codes on failure.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   357
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   358
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   359
	return iMessageRecord->GetWspData(aWspHeader, aWspBody, aTransactionId, aStatus);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   360
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   361
void CActiveSocket::UnpackPduToWspDataL()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   362
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   363
To extract the Wsp header, body, transaction ID and status from the received WDP pdu
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   364
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   365
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   366
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   367
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   368
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   369
	iMessageRecord->UnpackPduToWspDataL();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   370
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   371
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   372
void CActiveSocket::CleanUpData()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   373
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   374
	TPtr8 zero(0,0);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   375
	iBuf.Set(zero);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   376
	iBufCon.Set(zero);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   377
	iMessageRecord->CleanUpData();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   378
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   379
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   380
/** SMS active socket
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   381
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   382
CActiveSocketSMS::CActiveSocketSMS(RSocketServ& aSocketServ, MProgressNotify* aNotify, Wap::TBearer aBearer, Wap::TPort aLocalPort)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   383
:CActiveSocket(aSocketServ, aBearer, aNotify, aLocalPort)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   384
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   385
Constructor of SMS bearer for Bound Wap APIs
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   386
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   387
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   388
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   389
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   390
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   391
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   392
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   393
CActiveSocketSMS::CActiveSocketSMS(RSocketServ& aSocketServ, MProgressNotify* aNotify, Wap::TBearer aBearer, const TSockAddr& aRemoteAddr)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   394
:CActiveSocket(aSocketServ, aBearer, aNotify, aRemoteAddr, (Wap::TPort)EWapPortUnspecified)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   395
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   396
Constructor of SMS bearer for fully specified Wap APIs
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   397
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   398
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   399
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   400
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   401
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   402
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   403
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   404
CActiveSocketSMS::~CActiveSocketSMS() 
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   405
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   406
Destructor of SMS bearer for fully specified Wap APIs
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   407
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   408
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   409
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   410
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   411
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   412
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   413
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   414
void CActiveSocketSMS::ConstructL(TWapMessageType aType)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   415
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   416
Second Phase Constructor
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   417
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   418
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   419
@param aType the type of Wap message which is received.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   420
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   421
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   422
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   423
	CActiveSocket::ConstructL(aType);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   424
	User::LeaveIfError(iSocket.Open(iSocketServ, KWAPSMSAddrFamily, KSockDatagram, KWAPSMSDatagramProtocol));
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   425
	User::LeaveIfError(iSocket.SetOpt(KWapSmsOptionNewStyleClient,KWapSmsOptionLevel, 0));
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   426
	TWapAddr wapAddr;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   427
	wapAddr.SetWapPort(TWapPortNumber(iLocalPort));
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   428
	TInt err=iSocket.Bind(wapAddr);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   429
	if (err==KErrInUse)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   430
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   431
		User::Leave(Wap::EPortAlreadyBound);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   432
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   433
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   434
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   435
TInt CActiveSocketSMS::AwaitRecvDataSize()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   436
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   437
Read the received Wdp pdu length.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   438
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   439
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   440
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   441
@returns KErrNone on successful completion, or one of the system error codes on failure.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   442
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   443
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   444
	TPckgBuf<TUint32>* length=iMessageRecord->GetPduSizeRef();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   445
	iSocket.Ioctl(KSOGetLength, iStatus, length, KSolWapProv);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   446
	iMessageRecord->SetDataState(ERequestingLength);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   447
	iSocketState=ESocketWaitingForLength;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   448
	SetActive();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   449
	return KErrNone;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   450
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   451
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   452
TInt CActiveSocketSMS::Receive()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   453
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   454
Read the received Wdp pdu.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   455
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   456
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   457
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   458
@returns KErrNone on successful completion, or one of the system error codes on failure.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   459
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   460
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   461
	TInt err=KErrNone;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   462
	TRAP(err, iMessageRecord->CreatePduBufferL(EFalse))
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   463
	if (err!=KErrNone)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   464
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   465
		return err;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   466
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   467
	HBufC8*& pdu=iMessageRecord->GetPduPtr();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   468
	iBuf.Set(pdu->Des());
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   469
	iSocket.RecvFrom(iBuf, iRemoteAddr, 0, iStatus);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   470
	iMessageRecord->SetDataState(ERequestingData);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   471
	iSocketState=ESocketWaitingForData;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   472
	SetActive();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   473
	return KErrNone;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   474
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   475
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   476
void CActiveSocketSMS::RunL() 
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   477
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   478
Overload the CActive virtual methods
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   479
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   480
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   481
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   482
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   483
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   484
	switch (iSocketState)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   485
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   486
	case ESocketWaitingForLength:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   487
			{
45
28dbf5a297f4 201024_05
hgs
parents: 44
diff changeset
   488
			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKETSMS_RUNL_1, "CActiveSocketSMS::RunL() ESocketWaitingForLength");
44
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   489
			iMessageRecord->SetDataState(EPendingLength);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   490
			iSocketState=ESocketIdle;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   491
			TWapNotificationInfo info(iBearerType, iStatus.Int());
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   492
			TWapNotificationInfoBuf infoBuf(info);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   493
			iNotify->Notification(EPduLengthReceived, infoBuf);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   494
			break;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   495
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   496
	case ESocketWaitingForData:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   497
			{
45
28dbf5a297f4 201024_05
hgs
parents: 44
diff changeset
   498
			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKETSMS_RUNL_2, "CActiveSocketSMS::RunL() ESocketWaitingForData");
44
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   499
			iMessageRecord->SetDataState(EPendingData);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   500
			iSocketState=ESocketIdle;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   501
			TWapNotificationInfo info(iBearerType, iStatus.Int());
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   502
			TWapNotificationInfoBuf infoBuf(info);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   503
			iNotify->Notification(EPduReceived, infoBuf);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   504
			iSocket.SetOpt(KWapSmsOptionOKToDeleteMessage,KWapSmsOptionLevel, 0);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   505
			break;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   506
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   507
	default:
45
28dbf5a297f4 201024_05
hgs
parents: 44
diff changeset
   508
	    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKETSMS_RUNL_3, "CActiveSocketSMS::RunL() Unknown State");
44
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   509
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   510
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   511
void CActiveSocketSMS::DoCancel() 
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   512
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   513
Overload the CActive virtual methods
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   514
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   515
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   516
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   517
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   518
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   519
	switch (iSocketState)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   520
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   521
	case ESocketWaitingForLength:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   522
			{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   523
			iSocket.CancelIoctl();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   524
			break;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   525
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   526
	case ESocketWaitingForData:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   527
			{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   528
			iSocket.CancelRecv();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   529
			break;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   530
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   531
	default:
45
28dbf5a297f4 201024_05
hgs
parents: 44
diff changeset
   532
	    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKETSMS_DOCANCEL_1, "CActiveSocketSMS::DoCancel() Unknown State");	
44
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   533
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   534
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   535
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   536
//
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   537
// UDP active socket
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   538
//
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   539
CActiveSocketUDP::CActiveSocketUDP(RSocketServ& aSocketServ, MProgressNotify* aNotify, Wap::TBearer aBearer, Wap::TPort aLocalPort, RConnection* aConnection)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   540
:CActiveSocket(aSocketServ, aBearer, aNotify, aLocalPort),iConnection(aConnection)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   541
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   542
Constructor for Bound Wap APIs
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   543
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   544
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   545
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   546
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   547
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   548
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   549
	
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   550
CActiveSocketUDP::CActiveSocketUDP(RSocketServ& aSocketServ, MProgressNotify* aNotify, Wap::TBearer aBearer, const TSockAddr& aRemoteAddr, RConnection* aConnection)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   551
:CActiveSocket(aSocketServ, aBearer, aNotify, aRemoteAddr,0), iConnection(aConnection)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   552
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   553
Constructor for FullySpec Wap APIs
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   554
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   555
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   556
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   557
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   558
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   559
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   560
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   561
void CActiveSocketUDP::ConstructL(TWapMessageType aType)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   562
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   563
Second Phase constructor
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   564
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   565
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   566
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   567
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   568
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   569
	CActiveSocket::ConstructL(aType);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   570
	if (!iConnection)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   571
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   572
		User::LeaveIfError(iSocket.Open(iSocketServ, KAfInet, KSockDatagram, KProtocolInetUdp));
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   573
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   574
	else
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   575
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   576
		User::LeaveIfError(iSocket.Open(iSocketServ, KAfInet, KSockDatagram, KProtocolInetUdp, *iConnection));
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   577
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   578
	TInetAddr inetAddr(iLocalPort);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   579
	TInt err=iSocket.Bind(inetAddr);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   580
	if (err==KErrInUse)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   581
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   582
		User::Leave(Wap::EPortAlreadyBound);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   583
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   584
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   585
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   586
CActiveSocketUDP::~CActiveSocketUDP() 
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   587
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   588
Destructor
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   589
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   590
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   591
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   592
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   593
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   594
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   595
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   596
TInt CActiveSocketUDP::AwaitRecvDataSize()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   597
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   598
Wait for Pdu data size
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   599
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   600
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   601
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   602
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   603
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   604
	iRxlength=0;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   605
	TRAPD(err, iMessageRecord->CreatePduBufferL(ETrue))
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   606
	if (err!=KErrNone)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   607
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   608
		return err;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   609
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   610
	HBufC8*& pdu=iMessageRecord->GetPduPtr();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   611
	iBuf.Set(pdu->Des());
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   612
	iSocket.RecvFrom(iBuf, iRemoteAddr, 0, iStatus, iRxlength);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   613
	iMessageRecord->SetDataState(ERequestingLength);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   614
	iSocketState=ESocketWaitingForLength;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   615
	SetActive();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   616
	return KErrNone;	
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   617
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   618
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   619
TInt CActiveSocketUDP::Receive()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   620
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   621
Receive the pdu
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   622
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   623
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   624
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   625
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   626
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   627
	if(iMessageRecord->GetDataState()==EContinuous)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   628
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   629
		TRAPD(err, iMessageRecord->CreatePduBufferL(ETrue))
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   630
		if (err!=KErrNone)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   631
			{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   632
			return err;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   633
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   634
		HBufC8*& pdu=iMessageRecord->GetPduPtr();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   635
		iBuf.Set(pdu->Des());
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   636
		iBuf.SetLength(iBuf.Length()+1);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   637
		iBufCon.Set(&iBuf[iBuf.Length()-1],0,iBuf.MaxLength()-iBuf.Length());
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   638
		iBuf.SetLength(iBuf.Length()+iRxlength()-1);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   639
		iSocket.RecvFrom(iBufCon, iRemoteAddr, KSockReadContinuation, iStatus,iRxlength);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   640
		iMessageRecord->SetDataState(ERequestingData);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   641
		iSocketState=ESocketWaitingForData;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   642
		SetActive();	
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   643
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   644
	else
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   645
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   646
		iMessageRecord->SetDataState(ERequestingData);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   647
		iSocketState=ESocketWaitingForData;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   648
		iStatus = KRequestPending;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   649
		SetActive();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   650
		TRequestStatus* reqStatus=&iStatus;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   651
		User::RequestComplete(reqStatus, KErrNone);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   652
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   653
	return KErrNone;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   654
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   655
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   656
void CActiveSocketUDP::RunL()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   657
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   658
RunL()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   659
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   660
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   661
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   662
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   663
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   664
	switch (iSocketState)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   665
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   666
	case ESocketWaitingForLength:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   667
			{
45
28dbf5a297f4 201024_05
hgs
parents: 44
diff changeset
   668
			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKETUDP_RUNL_1, "CActiveSocketUDP::RunL() ESocketWaitingForLength");        
44
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   669
			iMessageRecord->SetPduSize(iBuf.Length()+ iRxlength());
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   670
			if(iRxlength() > 0)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   671
				{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   672
				iMessageRecord->SetDataState(EContinuous);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   673
				}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   674
			else 
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   675
				{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   676
				iMessageRecord->SetDataState(EPendingLength);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   677
				}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   678
			iSocketState=ESocketIdle;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   679
			TWapNotificationInfo info(iBearerType, iStatus.Int());
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   680
			TWapNotificationInfoBuf infoBuf(info);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   681
			iNotify->Notification(EPduLengthReceived, infoBuf);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   682
			break;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   683
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   684
	case ESocketWaitingForData:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   685
			{
45
28dbf5a297f4 201024_05
hgs
parents: 44
diff changeset
   686
			OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKETUDP_RUNL_2, "CActiveSocketUDP::RunL() ESocketWaitingForData");
44
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   687
			iMessageRecord->SetDataState(EPendingData);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   688
			iSocketState=ESocketIdle;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   689
			TWapNotificationInfo info(iBearerType, iStatus.Int());
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   690
			TWapNotificationInfoBuf infoBuf(info);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   691
			iNotify->Notification(EPduReceived, infoBuf);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   692
			break;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   693
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   694
	default:
45
28dbf5a297f4 201024_05
hgs
parents: 44
diff changeset
   695
	    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKETUDP_RUNL_3, "CActiveSocketUDP::RunL() Unknown State");
44
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   696
		break;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   697
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   698
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   699
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   700
void CActiveSocketUDP::DoCancel()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   701
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   702
Cancel the outstanding request on UDP bearer
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   703
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   704
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   705
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   706
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   707
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   708
	switch (iSocketState)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   709
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   710
	case ESocketWaitingForLength:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   711
			{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   712
			iSocket.CancelRecv();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   713
			break;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   714
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   715
	case ESocketWaitingForData:
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   716
			{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   717
			break;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   718
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   719
	default:
45
28dbf5a297f4 201024_05
hgs
parents: 44
diff changeset
   720
	    OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CACTIVESOCKETUDP_DOCANCEL_1, "CActiveSocketUDP::DoCancel() Unknown State");	
44
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   721
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   722
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   723
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   724
//
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   725
//CWapMessageRecord
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   726
//
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   727
CWapMessageRecord* CWapMessageRecord::NewL(TWapMessageType aType)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   728
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   729
The static funtion to instanciate the Pdu data record
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   730
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   731
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   732
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   733
@param aType the type of Wap message which is received.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   734
@returns the data record instance.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   735
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   736
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   737
	CWapMessageRecord* me;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   738
	if (aType==EWapWsp)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   739
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   740
		me = new(ELeave) CWspMessageRecord();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   741
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   742
	else
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   743
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   744
		me = new(ELeave) CWdpMessageRecord();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   745
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   746
	return me;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   747
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   748
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   749
CWapMessageRecord::CWapMessageRecord()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   750
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   751
Constructor
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   752
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   753
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   754
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   755
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   756
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   757
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   758
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   759
CWapMessageRecord::~CWapMessageRecord()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   760
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   761
Destructor
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   762
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   763
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   764
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   765
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   766
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   767
	if (iPdu)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   768
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   769
		delete iPdu;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   770
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   771
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   772
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   773
TWapMessageState CWapMessageRecord::GetDataState()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   774
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   775
To get the state of the data that is being received
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   776
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   777
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   778
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   779
returns the state of the data that is being received
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   780
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   781
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   782
	return iState;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   783
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   784
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   785
void CWapMessageRecord::SetDataState(TWapMessageState aState)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   786
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   787
To set the state of the data that is being received
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   788
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   789
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   790
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   791
@param the state of the data that is being received
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   792
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   793
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   794
	iState=aState;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   795
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   796
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   797
TPckgBuf<TUint32>* CWapMessageRecord::GetPduSizeRef()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   798
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   799
To get the buffer which is used to contain the received data length
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   800
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   801
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   802
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   803
@returns the pointer to the buffer length
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   804
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   805
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   806
	return &iDataLength;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   807
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   808
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   809
void CWapMessageRecord::SetPduSize(TUint32 aLength)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   810
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   811
	iDataLength=aLength;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   812
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   813
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   814
TUint32 CWapMessageRecord::GetPduSize()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   815
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   816
To get the received wdp pdu length
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   817
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   818
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   819
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   820
@returns the received wdp pdu length
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   821
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   822
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   823
	iState=EGotLength;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   824
	return iDataLength();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   825
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   826
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   827
HBufC8*& CWapMessageRecord::GetPduPtr()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   828
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   829
To get the received wdp pdu.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   830
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   831
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   832
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   833
@returns the pointer the received wdp buffer
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   834
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   835
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   836
	return iPdu;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   837
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   838
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   839
void CWapMessageRecord::CreatePduBufferL(TBool aFixLengthFlag)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   840
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   841
create the wdp pdu buffer according to the length
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   842
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   843
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   844
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   845
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   846
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   847
	if (iState==EContinuous)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   848
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   849
		iPdu = iPdu->ReAllocL(iDataLength());
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   850
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   851
	else if (!aFixLengthFlag)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   852
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   853
		iPdu=HBufC8::NewL(iDataLength());
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   854
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   855
	else
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   856
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   857
		iPdu=HBufC8::NewL(KMaxUdpBearerDataBufferLength);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   858
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   859
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   860
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   861
void CWapMessageRecord::CleanUpData()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   862
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   863
clean up the receive buffer.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   864
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   865
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   866
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   867
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   868
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   869
	if (iPdu)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   870
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   871
		delete iPdu;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   872
		iPdu=NULL;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   873
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   874
	iDataLength.FillZ();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   875
	iState=EIdle;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   876
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   877
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   878
//
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   879
//CWspMessageRecord methods
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   880
//
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   881
CWspMessageRecord::CWspMessageRecord()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   882
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   883
Constructor
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   884
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   885
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   886
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   887
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   888
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   889
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   890
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   891
CWspMessageRecord::~CWspMessageRecord()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   892
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   893
Destructor
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   894
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   895
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   896
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   897
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   898
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   899
	if (iWspHeader)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   900
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   901
		delete iWspHeader;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   902
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   903
	if (iWspBody)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   904
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   905
		delete iWspBody;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   906
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   907
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   908
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   909
void CWspMessageRecord::UnpackPduToWspDataL()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   910
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   911
To unpack the received wdp pdu to wsp message.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   912
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   913
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   914
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   915
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   916
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   917
	TWSPPduType type;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   918
	CCLWSPPduHandler::UnpackWSPPduL(iPdu, type, iWspHeader, iWspBody, iTransactionId, iWspStatus);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   919
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   920
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   921
TInt CWspMessageRecord::GetWspData(TDes8& aWspHeader, TDes8& aWspBody, TUint8& aTransactionId, TWSPStatus& aWspStatus)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   922
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   923
To read the wsp message from the buffer
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   924
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   925
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   926
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   927
@param aWspHeader the buffer to contain the wsp header
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   928
@param aWspBody the buffer to contain the wsp body
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   929
@param iTransactionId the received transaction ID
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   930
@param aWspStatus the received wsp status
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   931
@returns KErrNone on successful completion, or one of the system error codes on failure.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   932
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   933
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   934
	if (!iWspHeader && !iWspBody)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   935
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   936
		// if no data, should not be here at all
45
28dbf5a297f4 201024_05
hgs
parents: 44
diff changeset
   937
        OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWSPMESSAGERECORD_GETWSPDATA_1, "CWspMessageRecord::GetWspData() No Data Available");
44
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   938
		CleanUpData();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   939
		return KErrBadDescriptor;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   940
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   941
	TInt ret=KErrNone;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   942
	//Copy the transaction ID
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   943
	aTransactionId=iTransactionId;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   944
	aWspStatus=iWspStatus;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   945
	//Copy the header
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   946
	TInt bufferLength;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   947
	if (iWspHeader)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   948
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   949
		bufferLength=aWspHeader.MaxLength();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   950
		TPtrC8 remainHeader=iWspHeader->Mid(iHeaderOffset);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   951
		//Client Header buffer is not long enough
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   952
		if (bufferLength<remainHeader.Length())
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   953
			{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   954
			aWspHeader.Copy(remainHeader.Ptr(), bufferLength);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   955
			iHeaderOffset+=bufferLength;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   956
			iState=EReading;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   957
			ret=Wap::EMoreData;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   958
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   959
		else
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   960
			{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   961
			aWspHeader.Copy(remainHeader);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   962
			iHeaderOffset=0;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   963
			delete iWspHeader;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   964
			iWspHeader=NULL;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   965
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   966
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   967
	if (iWspBody)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   968
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   969
		//Copy the Body
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   970
		bufferLength=aWspBody.MaxLength();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   971
		TPtrC8 remainBody=iWspBody->Mid(iBodyOffset);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   972
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   973
		//Client Header buffer is not long enough
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   974
		if (bufferLength<remainBody.Length())
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   975
			{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   976
			aWspBody.Copy(remainBody.Ptr(), bufferLength);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   977
			iBodyOffset+=bufferLength;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   978
			iState=EReading;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   979
			ret=Wap::EMoreData;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   980
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   981
		else
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   982
			{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   983
			aWspBody.Copy(remainBody);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   984
			iBodyOffset=0;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   985
			delete iWspBody;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   986
			iWspBody=NULL;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   987
			}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   988
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   989
	//All Wsp Data has been read.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   990
	if (ret==KErrNone)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   991
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   992
		delete iPdu;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   993
		iPdu=NULL;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   994
		iDataLength.FillZ();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   995
		iState=EIdle;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   996
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   997
	return ret;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   998
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   999
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1000
TInt CWspMessageRecord::GetPduData(TDes8& /*aBuffer*/, TBool& /*aTruncated*/)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1001
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1002
Not supported
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1003
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1004
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1005
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1006
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1007
	{//Should not be used
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1008
	return KErrNotSupported;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1009
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1010
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1011
void CWspMessageRecord::CleanUpData()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1012
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1013
To clean up the wsp related data
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1014
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1015
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1016
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1017
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1018
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1019
	CWapMessageRecord::CleanUpData();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1020
	if (iWspHeader)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1021
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1022
		delete iWspHeader;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1023
		iWspHeader=NULL;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1024
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1025
	if (iWspBody)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1026
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1027
		delete iWspBody;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1028
		iWspBody=NULL;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1029
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1030
	iTransactionId=0;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1031
	iHeaderOffset=0;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1032
	iBodyOffset=0;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1033
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1034
//
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1035
//CWspMessageRecord method
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1036
//
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1037
CWdpMessageRecord::CWdpMessageRecord()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1038
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1039
Constructor
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1040
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1041
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1042
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1043
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1044
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1045
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1046
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1047
CWdpMessageRecord::~CWdpMessageRecord()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1048
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1049
Destructor
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1050
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1051
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1052
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1053
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1054
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1055
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1056
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1057
TInt CWdpMessageRecord::GetPduData(TDes8& aBuffer, TBool& aTruncated)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1058
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1059
To read the received Wdp pdu
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1060
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1061
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1062
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1063
@param aBuffer the buffer to contain the received wdp pdu
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1064
@param aTruncated the flag to represent if the data is truncated or not
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1065
@returns KErrNone on successful completion, or one of the system error codes on failure.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1066
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1067
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1068
	if (!iPdu)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1069
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1070
		//Should not be here at all
45
28dbf5a297f4 201024_05
hgs
parents: 44
diff changeset
  1071
        OstTraceDef0(OST_TRACE_CATEGORY_DEBUG, TRACE_INTERNALS, CWDPMESSAGERECORD_GETPDUDATA_1, "CWdpMessageRecord::GetPduData No Data Available");
44
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1072
		CleanUpData();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1073
		return KErrBadDescriptor;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1074
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1075
	TInt ret=KErrNone;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1076
	TInt bufLength=aBuffer.MaxLength();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1077
	TPtrC8 remainPdu=iPdu->Mid(iPduOffset);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1078
	if (bufLength<remainPdu.Length())
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1079
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1080
		aBuffer.Copy(remainPdu.Ptr(), bufLength);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1081
		iPduOffset+=bufLength;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1082
		iState=EReading;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1083
		aTruncated=ETrue;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1084
		ret=Wap::EMoreData;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1085
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1086
	else
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1087
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1088
		aBuffer.Copy(remainPdu);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1089
		aTruncated=EFalse;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1090
		CleanUpData();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1091
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1092
	return ret;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1093
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1094
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1095
void CWdpMessageRecord::UnpackPduToWspDataL()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1096
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1097
Not supported
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1098
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1099
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1100
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1101
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1102
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1103
	//Should not be used
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1104
	User::Leave(KErrNotSupported);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1105
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1106
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1107
TInt CWdpMessageRecord::GetWspData(TDes8& /*aWspHeader*/, TDes8& /*aWspBody*/, TUint8& /*aTransactionId*/, TWSPStatus& /*aWspStatus*/)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1108
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1109
Not supported
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1110
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1111
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1112
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1113
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1114
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1115
	//Should not be used
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1116
	return KErrNotSupported;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1117
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1118
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1119
void CWdpMessageRecord::CleanUpData()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1120
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1121
To clean up the wdp related data
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1122
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1123
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1124
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1125
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1126
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1127
	CWapMessageRecord::CleanUpData();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1128
	iPduOffset=0;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
  1129
	}