messagingfw/suplwappushhandler/src/LbsSuplWapPush.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 // The main SUPL WAP Push Plug-in class. It implements the ECOM interface, listens for the incoming messages,
       
    15 // and notifies the SPM via the SUPL Push API.
       
    16 // 
       
    17 //
       
    18 
       
    19 /**
       
    20  @file
       
    21  @internalComponent
       
    22  @prototype
       
    23 */
       
    24 
       
    25 #include <ecom/implementationproxy.h>
       
    26 
       
    27 #include "LbsSuplWapPush.h"
       
    28 #include "lbsdevloggermacros.h"
       
    29 
       
    30 
       
    31 /** ECOM implementation table */
       
    32 const TImplementationProxy ImplementationTable[] = 
       
    33 	{
       
    34 	IMPLEMENTATION_PROXY_ENTRY(0x10283758, CLbsSuplWapPush::NewL)
       
    35 	};
       
    36 
       
    37 /** The only exported ECOM entry point function */
       
    38 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount)
       
    39 	{
       
    40 	aTableCount = sizeof(ImplementationTable) / sizeof(TImplementationProxy);
       
    41 	return ImplementationTable;
       
    42 	}
       
    43 
       
    44 /**
       
    45 Static factory method for creating an instance of the CLbsSuplWapPush class.
       
    46 
       
    47 @return An instance of the class. The calling application becomes the
       
    48 owner of the returned instance and is responsible its disposal.
       
    49 
       
    50 @leave If a error happens, it leaves with one of the system error codes.
       
    51 */
       
    52 CLbsSuplWapPush* CLbsSuplWapPush::NewL()
       
    53 	{
       
    54 	CLbsSuplWapPush* self= new (ELeave) CLbsSuplWapPush();
       
    55 	CleanupStack::PushL(self);
       
    56 	self->ConstructL();
       
    57 	CleanupStack::Pop();
       
    58 	return self;
       
    59 	}
       
    60 
       
    61 /**
       
    62 Constructor.
       
    63 
       
    64 @see CLbsSuplWapPush::NewL
       
    65 */
       
    66 CLbsSuplWapPush::CLbsSuplWapPush()
       
    67 	{
       
    68 	}
       
    69 
       
    70 
       
    71 /**
       
    72 Destructor. Deletes the SUPL Push API object.
       
    73 */
       
    74 CLbsSuplWapPush::~CLbsSuplWapPush()
       
    75 	{
       
    76 	LBSLOG(ELogP2, "SUPL WAP Push : CLbsSuplWapPush::~CLbsSuplWapPush");
       
    77 	delete iSuplPush;
       
    78 	}
       
    79 
       
    80 /**
       
    81 2nd phase constructor. Creates the SUPL Push API object.
       
    82 
       
    83 @leave If a error happens, it leaves with one of the system error codes.
       
    84 
       
    85 @see CLbsSuplWapPush::NewL
       
    86 */
       
    87 void CLbsSuplWapPush::ConstructL()
       
    88 	{
       
    89 	LBSLOG(ELogP2, "SUPL WAP Push : CLbsSuplWapPush::ConstructL");
       
    90 	iSuplPush = CLbsSuplPush::NewL(ELbsSuplPushChannelWAP, *this);
       
    91 	}
       
    92 
       
    93 /**
       
    94  	From MLbsSuplPushObserver.
       
    95 	Receive notification that the SUPL Init message has been sent to the LBS sub-system.
       
    96 	The call-back is invoked immediately after delivery of the SUPL INIT request and 
       
    97 	does not provide any information about it's outcome, e.g. conflict control results,
       
    98 	host validation results, connection results etc.
       
    99 	
       
   100 	@param aChannel  [In] The channel the call-back is related to.
       
   101 	@param aReqId    [In] An Id of the request the call-back is related to.
       
   102 	@param aError    [In] KErrNone if successful, KErrTimeout if it was not possible to deliver
       
   103 	                      the request before the timeout period, KErrArgument if the structure 
       
   104 	                      or content of the SUPL INIT message was incorrect. 
       
   105 	                      Any system wide error code otherwise.
       
   106 	@param aReserved [In] Reserved for future use.
       
   107 	
       
   108 	@see CLbsSuplPush::SuplInit
       
   109 	@see MLbsSuplPushObserver::OnSuplInitComplete
       
   110 */
       
   111 void CLbsSuplWapPush::OnSuplInitComplete(TLbsSuplPushChannel /*aChannel*/, TLbsSuplPushRequestId aReqId, 
       
   112 			TInt aError, TInt /*aReserved*/)
       
   113 	{
       
   114 	if(aError==KErrNone)
       
   115 		{
       
   116 		LBSLOG2(ELogP3,"SUPL WAP Push : Message delivered successfully, reqId=%d", aReqId);
       
   117 		}
       
   118 	else
       
   119 		{
       
   120 		LBSLOG3(ELogP3,"SUPL WAP Push : Message delivery failed, reqId=%d, err=%d", aReqId, aError);
       
   121 		}
       
   122 #ifndef TE_UNITTESTMODE_ON
       
   123 	__ASSERT_DEBUG(iPluginKiller, User::Invariant());
       
   124 	iPluginKiller->KillPushPlugin();
       
   125 #endif //TE_UNITTESTMODE_ON
       
   126 	}
       
   127 
       
   128 
       
   129 /**
       
   130 Handles a push message asynchronously. It is not used since Symbian OS 8.0 when the 
       
   131 implementation of the WAP Stack was cut down and support for the connection-oriented 
       
   132 WAP Push was stopped.
       
   133 
       
   134 @param aPushMsg [In]  Push message. Ownership of the message is passed to the object.
       
   135 @param aStatus  [Out] Asynchronous status word.
       
   136 
       
   137 @leave If a error happens, it leaves with one of the system error codes.
       
   138 */
       
   139 void CLbsSuplWapPush::HandleMessageL(CPushMessage* /*aPushMsg*/, TRequestStatus& /*aStatus*/)
       
   140 	{
       
   141 	//Intentionally left blank
       
   142 	}
       
   143 
       
   144 /**
       
   145 Handles a push message synchronously. 
       
   146 
       
   147 @param aPushMsg [In]  Push message. Ownership of the message is passed to the object.
       
   148 
       
   149 @leave If a error happens, it leaves with one of the system error codes.
       
   150 */
       
   151 void CLbsSuplWapPush::HandleMessageL(CPushMessage* aPushMsg)
       
   152 	{
       
   153 	LBSLOG(ELogP3, "SUPL WAP Push : CLbsSuplWapPush::HandleMessageL");
       
   154 	if(aPushMsg)
       
   155 		{
       
   156 		TPtrC8 body;
       
   157 		TBool hasBody=aPushMsg->GetMessageBody(body);
       
   158 		if(hasBody)
       
   159 			{
       
   160 			TLbsSuplPushRequestId reqId;
       
   161 			TInt err=iSuplPush->SuplInit(reqId, body, 0);
       
   162 			if(KErrNone==err)
       
   163 				{
       
   164 				LBSLOG2(ELogP3,"SUPL WAP Push : Started to deliver the message, reqId=%d", reqId);
       
   165 				delete aPushMsg;
       
   166 				return;
       
   167 				}
       
   168 			else
       
   169 				{
       
   170 				LBSLOG2(ELogP3,"SUPL WAP Push : CLbsSuplPush::SuplInit failed, err=%d", err);
       
   171 				}
       
   172 			}
       
   173 		else
       
   174 			{
       
   175 			LBSLOG(ELogP3, "SUPL WAP Push : Empty message body, the message is skipped");
       
   176 			}
       
   177 		delete aPushMsg;
       
   178 		}
       
   179 	else
       
   180 		{
       
   181 		LBSLOG(ELogP3, "SUPL WAP Push : Null message pointer, the message is skipped");
       
   182 		}
       
   183 #ifndef TE_UNITTESTMODE_ON	
       
   184 	__ASSERT_DEBUG(iPluginKiller, User::Invariant());
       
   185 	iPluginKiller->KillPushPlugin();
       
   186 #endif //TE_UNITTESTMODE_ON	
       
   187 	}
       
   188 
       
   189 
       
   190 /**
       
   191 Cancels an outstanding HandleMessageL call. It is not used since Symbian OS 8.0 when the 
       
   192 implementation of the WAP Stack was cut down and support for the connection-oriented WAP Push 
       
   193 was stopped.
       
   194 */
       
   195 void CLbsSuplWapPush::CancelHandleMessage()
       
   196 	{
       
   197 	//Intentionally left blank
       
   198 	}
       
   199 
       
   200 /**
       
   201 Reserved for future expansion.
       
   202 */
       
   203 void CLbsSuplWapPush::CPushHandlerBase_Reserved1()
       
   204 	{
       
   205 	//Intentionally left blank
       
   206 	}
       
   207 
       
   208 /**
       
   209 Reserved for future expansion.
       
   210 */
       
   211 void CLbsSuplWapPush::CPushHandlerBase_Reserved2()
       
   212 	{
       
   213 	//Intentionally left blank
       
   214 	}
       
   215 
       
   216 /**
       
   217 Called when CActive::Cancel method is called. It is not used in this implementation.
       
   218 
       
   219 @see CActive::DoCancel
       
   220 */
       
   221 void CLbsSuplWapPush::DoCancel()
       
   222 	{
       
   223 	//Intentionally left blank
       
   224 	}
       
   225 
       
   226 /**
       
   227 Overrides pure virtual CActive::RunL. It is not used in this implementation.
       
   228 
       
   229 @see CActive::RunL
       
   230 */
       
   231 void CLbsSuplWapPush::RunL()
       
   232 	{
       
   233 	//Intentionally left blank
       
   234 	}
       
   235