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