wapstack/wapmessageapi/sws/WapFullySpecCLPush.cpp
author hgs
Mon, 19 Jul 2010 14:53:33 +0100
changeset 52 60785a088077
parent 44 8b72faa1200f
permissions -rw-r--r--
201025_04
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
44
8b72faa1200f 201024_02
hgs
parents:
diff changeset
     1
// Copyright (c) 2003-2009 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
//
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    15
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    16
#include "WapFullySpecCLPush.h"
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    17
#include "WapMsgUtils.h"
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    18
#include <wapmsgerr.h>
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    19
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    20
CSWSWapFullySpecCLPushService* CSWSWapFullySpecCLPushService::NewL()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    21
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    22
Static new function
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    23
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    24
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    25
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    26
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    27
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    28
	CSWSWapFullySpecCLPushService* me = new(ELeave)CSWSWapFullySpecCLPushService();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    29
	CleanupStack::PushL(me);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    30
	me->ConstructL();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    31
	CleanupStack::Pop(me);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    32
	return me;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    33
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    34
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    35
CSWSWapFullySpecCLPushService::~CSWSWapFullySpecCLPushService()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    36
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    37
Destructor
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    38
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    39
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    40
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    41
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    42
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    43
	delete iAgent;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    44
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    45
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    46
CSWSWapFullySpecCLPushService::CSWSWapFullySpecCLPushService()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    47
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    48
Constructor
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    49
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    50
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    51
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    52
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    53
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    54
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    55
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    56
void CSWSWapFullySpecCLPushService::ConstructL()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    57
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    58
Second Phase Constructor
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    59
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    60
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    61
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    62
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    63
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    64
	// Parent class construction
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    65
	CWapFullySpecCLPushService::ConstructL();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    66
	iAgent=CWspMessageApiAgent::NewL();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    67
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    68
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    69
TInt CSWSWapFullySpecCLPushService::Connect(const TDesC8& aRemoteHost, Wap::TPort aRemotePort, Wap::TBearer aBearer, TBool aSecure, TInetAddr /*aInetAddr*/)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    70
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    71
Opens a socket which is to be used only with a single, named remote host.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    72
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    73
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    74
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    75
@param aRemoteHost the bearer-dependent address of the remote host with which the data will be exchanged
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    76
@param aRemotePort the port on the remote host to which data will be sent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    77
@param aBearer the bearer to use (not EAll)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    78
@param aSecure security flag indicates whether WTLS will be used or not
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    79
@param aInetAddr the address of the adapter to use
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    80
@returns KErrNone on successful completion, or one of the system error codes on failure.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    81
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    82
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    83
	if(aSecure) 
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    84
		{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    85
		return KErrNotSupported;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    86
		}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    87
	return iAgent->Connect(aRemoteHost, aRemotePort, aBearer, aSecure);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    88
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    89
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    90
TInt CSWSWapFullySpecCLPushService::Connect(const TDesC8& aRemoteHost, Wap::TPort aRemotePort, Wap::TBearer aBearer, TBool aSecure)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    91
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    92
Opens a socket which is to be used only with a single, named remote host.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    93
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    94
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    95
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    96
@param aRemoteHost (in) the bearer-dependent address of the remote host with which the data will be exchanged
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    97
@param aRemotePort (in) the port on the remote host to which data will be sent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    98
@param aBearer (in) the bearer to use (not EAll)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
    99
@param aSecure (in) security flag indicates whether WTLS will be used or not
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   100
@returns KErrNone on successful completion, or one of the system error codes on failure.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   101
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   102
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   103
	TInetAddr inetAddr( KInetAddrAny, 0);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   104
	return( Connect(aRemoteHost, aRemotePort, aBearer, aSecure, inetAddr) );
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   105
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   106
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   107
TInt CSWSWapFullySpecCLPushService::AwaitPush(TDes8& aPushHeaders, TDes8& aPushBody, TPckgBuf<TUint8>& aPushIdPckg, TRequestStatus& aReqStatus)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   108
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   109
Request an asynchronous notification upon arrival of the next push messages on the listening connection.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   110
The request completes upon receipt of the message, filling the buffers with as much received data as possible.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   111
A return code will indicate whether further data remains.  The call must be re-issued for subsequent messages
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   112
or to receive remaining data from a previous push message.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   113
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   114
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   115
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   116
@param aPushHeaders (out) (client-allocated) - when a push message arrives the header data is written here
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   117
@param aPushBody (out) (client-allocated) - when a push message arrives the body data is written here
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   118
@param aPushIdPckg (out) when a push message arrives an integer ID that uniquely specifies the message is written here
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   119
@param aReqStatus (inout) used by the service provider to notify the client when a push has arrived
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   120
@returns KErrNone on successful completion, or one of the system error codes on failure.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   121
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   122
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   123
	TInt err = iAgent->ReceiveWspMessage(aPushHeaders, aPushBody, aPushIdPckg, iWspStatus, aReqStatus, 0);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   124
	if(err == Wap::EMoreData)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   125
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   126
		return KErrNone;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   127
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   128
	return err;
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   129
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   130
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   131
void CSWSWapFullySpecCLPushService::CancelAwaitPush()
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   132
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   133
Cancel a previously-requested push message notification.  If a push message arrives the client will not be notified.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   134
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   135
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   136
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   137
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   138
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   139
	iAgent->CancelRequest();
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   140
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   141
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   142
TInt CSWSWapFullySpecCLPushService::GetLocalPort(Wap::TPort& aPort)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   143
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   144
Get the local port of this endpoint.Useful if one was chosen automatically.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   145
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   146
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   147
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   148
@param aPort (out) the port number
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   149
@returns KErrNone on successful completion, or one of the system error codes on failure.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   150
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   151
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   152
	return iAgent->GetLocalPort(aPort);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   153
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   154
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   155
TInt CSWSWapFullySpecCLPushService::GetLocalAddress(HBufC8*& aLocalHost)
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   156
/**
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   157
Get the local address of this endpoint.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   158
@internalComponent
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   159
@released
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   160
@since v8.0
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   161
@param aLocalHost (inout) the address of the local host. A reference to a HBufC8 pointer should 
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   162
be passed in. This pointer MUST be null! A HBufC8 will be allocated to hold the address, ownership 
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   163
of this buffer will be passed over to the client.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   164
@returns KErrNone on successful completion, or one of the system error codes on failure.
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   165
*/
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   166
	{
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   167
	return iAgent->GetLocalAddress(aLocalHost);
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   168
	}
8b72faa1200f 201024_02
hgs
parents:
diff changeset
   169