messagingfw/wappushfw/examples/PushAppHandlerEx/PushAppHandlerEx.cpp
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Fri, 19 Feb 2010 23:18:09 +0200
branchRCL_3
changeset 6 fe71b07a6401
parent 0 8e480a14352b
permissions -rw-r--r--
Revision: 201003 Kit: 201007

// Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies).
// All rights reserved.
// This component and the accompanying materials are made available
// under the terms of "Eclipse Public License v1.0"
// which accompanies this distribution, and is available
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
//
// Initial Contributors:
// Nokia Corporation - initial contribution.
//
// Contributors:
//
// Description:
// CMMSAppHandler.cpp
// 
//

#include <push/ccontenthandlerbase.h>
#include "pushdispatcher.h"
#include "PushAppHandlerEx.h"


_LIT(KReserved, "Reserved");

void CPushAppHandlerEx::CPushHandlerBase_Reserved1()
	{
	User::Panic(KReserved, KErrNotSupported);
	}

void CPushAppHandlerEx::CPushHandlerBase_Reserved2()
	{
	User::Panic(KReserved, KErrNotSupported);
	}

CPushAppHandlerEx::CPushAppHandlerEx()
: CPushHandlerBase()
	{
	CActiveScheduler::Add(this);
	}

void CPushAppHandlerEx::ConstructL()
	{
	// TODO Add any more required construction to class
	}

CPushAppHandlerEx* CPushAppHandlerEx::NewL()
	{
	CPushAppHandlerEx* self = new (ELeave) CPushAppHandlerEx();
	self->ConstructL();
	return self;
	}

CPushAppHandlerEx::~CPushAppHandlerEx()
	{
	__LOG_PTR_DEBUG("CPushAppHandlerEx:: Destructor Called"); 
	// TODO Add any more required destruction to class
	delete iMessage;
	}

void CPushAppHandlerEx::IdleComplete()
	{
	TRequestStatus* pS = &iStatus;
	User::RequestComplete(pS,KErrNone);
	SetActive();
	}

void CPushAppHandlerEx::Done(TInt aError)
	{
	__LOG_PTR_DEBUG("CPushAppHandlerEx:: EDone");
	if (iAsyncHandling)
		SignalConfirmationStatus(aError);
	// Time to commit suicide
	iPluginKiller->KillPushPlugin();
	}


void CPushAppHandlerEx::HandleMessageL(CPushMessage* aPushMsg, TRequestStatus& aStatus)
	{
	 __LOG_PTR_DEBUG("CPushAppHandlerEx:: HandleMessageL Async Func. Called"); 
	 
	iAsyncHandling = ETrue;
	SetConfirmationStatus(aStatus);
	HandleMessageL(aPushMsg);
	}


void CPushAppHandlerEx::HandleMessageL(CPushMessage* aPushMsg)
	{
	 __LOG_PTR_DEBUG("CPushAppHandlerEx:: HandleMessageL Sync Func. Called"); 	
	
	iMessage = aPushMsg;
	iState = EParsing;
	IdleComplete();
	}


void CPushAppHandlerEx::CancelHandleMessage()
	{
	__LOG_PTR_DEBUG("CPushAppHandlerEx:: CancelHandleMessage Called");
	// TODO Add Cancel code for any outstanding requests
	Done(KErrCancel);
	}


void CPushAppHandlerEx::DoCancel()
	{
	__LOG_PTR_DEBUG("CPushAppHandlerEx:: DoCancel Called");
	// TODO Add Cancel code for any outstanding requests
	Done(KErrCancel);
	}


void CPushAppHandlerEx::RunL()
	{
	__LOG_PTR_DEBUG("CPushAppHandlerEx:: RunL Called");

	// TODO Create a State Machine for specific actions
	switch (iState)
		{
	case EParsing :
		iState = EProcessing;
		ParsePushMsgL();
		break;
	case EProcessing:
		iState = EDone;
		ProcessPushMsgL();
		break;
	case EDone:
		Done(KErrNone);
		break;
	default:
		break;
		}
	}

void CPushAppHandlerEx::ParsePushMsgL()
	{
	__LOG_PTR_DEBUG("CPushAppHandlerEx:: ParsePushMsgL Called");
	IdleComplete();
	}


void CPushAppHandlerEx::ProcessPushMsgL()
	{
	__LOG_PTR_DEBUG("CPushAppHandlerEx:: ProcessPushMsgL Called");
	IdleComplete();
	}