messagingfw/wappushfw/plugins/PushAppHandler/CUAAppHandler.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
child 44 7c176670643f
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 // Local includes
       
    17 //
       
    18 #include "CUAAppHandler.h"
       
    19 
       
    20 // System includes
       
    21 //
       
    22 #include <push/pushlog.h>
       
    23 #include <push/pushmessage.h>
       
    24 #include <push/pluginkiller.h>
       
    25 #include "pushdispatcher.h"
       
    26 #include <push/ccontenthandlerbase.h>
       
    27 
       
    28 // Constants
       
    29 _LIT(KReserved, "Reserved");
       
    30 
       
    31 void CUAAppHandler::CPushHandlerBase_Reserved1()
       
    32 	{
       
    33 	User::Panic(KReserved, KErrNotSupported);
       
    34 	}
       
    35 
       
    36 void CUAAppHandler::CPushHandlerBase_Reserved2()
       
    37 	{
       
    38 	User::Panic(KReserved, KErrNotSupported);
       
    39 	}
       
    40 
       
    41 /** CUAAppHandler Constructor.
       
    42  * 
       
    43  */ 
       
    44 CUAAppHandler::CUAAppHandler()
       
    45 : CPushHandlerBase()
       
    46 	{
       
    47 	CActiveScheduler::Add(this);
       
    48 	}
       
    49 
       
    50 /** CUAAppHandler Static Factory Construction.
       
    51  * 
       
    52  */
       
    53 CUAAppHandler* CUAAppHandler::NewL()
       
    54 	{
       
    55 	CUAAppHandler* self = new (ELeave) CUAAppHandler;
       
    56 	return self;
       
    57 	}
       
    58 
       
    59 /**
       
    60  * Default Destructor.
       
    61  */
       
    62 CUAAppHandler::~CUAAppHandler()
       
    63 	{
       
    64 	__LOG_PTR_DEBUG("CUAAppHandler:: Destructor Called"); 
       
    65 	}
       
    66 
       
    67 /** Asynchronous Handling of Push Message.
       
    68  *
       
    69  *	@param aPushMsg  the received push message
       
    70  *	@param aStatus Status to be signalled when handling is complete
       
    71  */
       
    72 void CUAAppHandler::HandleMessageL(CPushMessage* aPushMsg, TRequestStatus& aStatus)
       
    73 	{
       
    74 	 __LOG_PTR_DEBUG("CUAAppHandler:: HandleMessageL Async Func. Called"); 	
       
    75 
       
    76 	SetConfirmationStatus(aStatus);
       
    77 
       
    78 	TPtrC contentType;
       
    79 	aPushMsg->GetContentType(contentType);
       
    80 	CContentHandlerBase& contentHandlerPi = PushContentTypeDispatcher::GetHandlerL(contentType, *iLog, *iManager);
       
    81 	iContentHandlerPi = &contentHandlerPi;
       
    82 	iContentHandlerPi->HandleMessageL(aPushMsg, iStatus);
       
    83 	SetActive();
       
    84 	}
       
    85 
       
    86 /**
       
    87  * Cancel any outstanding requests.
       
    88  */
       
    89 void CUAAppHandler::CancelHandleMessage()
       
    90 	{
       
    91 	if(*iConfirmStatus==KRequestPending)
       
    92 		{
       
    93 		iContentHandlerPi->CancelHandleMessage();
       
    94 		}
       
    95 	}
       
    96 
       
    97 /**
       
    98  *  HandleMessageL - Sync. Version
       
    99  *
       
   100  * 1. Get Content-Type from Msg
       
   101  * 2. Load the specific Content handler
       
   102  * 3. Pass the Push message to Content the handler
       
   103  * 4. Invoke the Killer object to delete the Plugin Owner
       
   104  *
       
   105  * @param aPushMsg the Push Message to be handled
       
   106  */
       
   107 void CUAAppHandler::HandleMessageL(CPushMessage* aPushMsg)
       
   108 	{
       
   109 	 __LOG_PTR_DEBUG("CUAAppHandler:: HandleMessageL Sync Func. Called"); 	
       
   110 
       
   111 	TPtrC contentType;
       
   112 	aPushMsg->GetContentType(contentType);
       
   113 	TRAPD( error, 
       
   114 		CleanupStack::PushL(aPushMsg);
       
   115 		CContentHandlerBase& contentHandlerPi = PushContentTypeDispatcher::GetHandlerL(contentType, *iLog, *iManager);
       
   116 		CleanupStack::Pop(aPushMsg);
       
   117 		iContentHandlerPi = &contentHandlerPi;
       
   118 		);
       
   119 
       
   120 	if( error == KErrNone )
       
   121 		{
       
   122 		TRAP( error, 
       
   123 			iContentHandlerPi->HandleMessageL(aPushMsg));
       
   124 		}
       
   125 	iPluginKiller->KillPushPlugin();
       
   126 	}
       
   127 
       
   128 /**
       
   129  * Cancel the handling of the message.
       
   130  * No Object need to be canceled in the case of CUnknownAppHandler.
       
   131  */
       
   132 void CUAAppHandler::DoCancel()
       
   133 	{
       
   134 	__LOG_PTR_DEBUG("CUAAppHandler:: DoCancel Called");
       
   135 	}
       
   136 
       
   137 /** CUAAppHandler State machine.
       
   138  *
       
   139  * Complete Active Object Returning the comfirmation status
       
   140  * and Suicide.
       
   141  */
       
   142 void CUAAppHandler::RunL()
       
   143 	{
       
   144 	__LOG_PTR_DEBUG("CUAAppHandler:: RunL Called");
       
   145 	SignalConfirmationStatus(KErrNone);
       
   146 	iPluginKiller->KillPushPlugin();
       
   147 	}