messagingfw/wappushfw/examples/PushAppHandlerEx/PushAppHandlerEx.cpp
changeset 62 db3f5fa34ec7
parent 0 8e480a14352b
equal deleted inserted replaced
60:9f5ae1728557 62:db3f5fa34ec7
       
     1 // Copyright (c) 2001-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 // CMMSAppHandler.cpp
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <push/ccontenthandlerbase.h>
       
    19 #include "pushdispatcher.h"
       
    20 #include "PushAppHandlerEx.h"
       
    21 
       
    22 
       
    23 _LIT(KReserved, "Reserved");
       
    24 
       
    25 void CPushAppHandlerEx::CPushHandlerBase_Reserved1()
       
    26 	{
       
    27 	User::Panic(KReserved, KErrNotSupported);
       
    28 	}
       
    29 
       
    30 void CPushAppHandlerEx::CPushHandlerBase_Reserved2()
       
    31 	{
       
    32 	User::Panic(KReserved, KErrNotSupported);
       
    33 	}
       
    34 
       
    35 CPushAppHandlerEx::CPushAppHandlerEx()
       
    36 : CPushHandlerBase()
       
    37 	{
       
    38 	CActiveScheduler::Add(this);
       
    39 	}
       
    40 
       
    41 void CPushAppHandlerEx::ConstructL()
       
    42 	{
       
    43 	// TODO Add any more required construction to class
       
    44 	}
       
    45 
       
    46 CPushAppHandlerEx* CPushAppHandlerEx::NewL()
       
    47 	{
       
    48 	CPushAppHandlerEx* self = new (ELeave) CPushAppHandlerEx();
       
    49 	self->ConstructL();
       
    50 	return self;
       
    51 	}
       
    52 
       
    53 CPushAppHandlerEx::~CPushAppHandlerEx()
       
    54 	{
       
    55 	__LOG_PTR_DEBUG("CPushAppHandlerEx:: Destructor Called"); 
       
    56 	// TODO Add any more required destruction to class
       
    57 	delete iMessage;
       
    58 	}
       
    59 
       
    60 void CPushAppHandlerEx::IdleComplete()
       
    61 	{
       
    62 	TRequestStatus* pS = &iStatus;
       
    63 	User::RequestComplete(pS,KErrNone);
       
    64 	SetActive();
       
    65 	}
       
    66 
       
    67 void CPushAppHandlerEx::Done(TInt aError)
       
    68 	{
       
    69 	__LOG_PTR_DEBUG("CPushAppHandlerEx:: EDone");
       
    70 	if (iAsyncHandling)
       
    71 		SignalConfirmationStatus(aError);
       
    72 	// Time to commit suicide
       
    73 	iPluginKiller->KillPushPlugin();
       
    74 	}
       
    75 
       
    76 
       
    77 void CPushAppHandlerEx::HandleMessageL(CPushMessage* aPushMsg, TRequestStatus& aStatus)
       
    78 	{
       
    79 	 __LOG_PTR_DEBUG("CPushAppHandlerEx:: HandleMessageL Async Func. Called"); 
       
    80 	 
       
    81 	iAsyncHandling = ETrue;
       
    82 	SetConfirmationStatus(aStatus);
       
    83 	HandleMessageL(aPushMsg);
       
    84 	}
       
    85 
       
    86 
       
    87 void CPushAppHandlerEx::HandleMessageL(CPushMessage* aPushMsg)
       
    88 	{
       
    89 	 __LOG_PTR_DEBUG("CPushAppHandlerEx:: HandleMessageL Sync Func. Called"); 	
       
    90 	
       
    91 	iMessage = aPushMsg;
       
    92 	iState = EParsing;
       
    93 	IdleComplete();
       
    94 	}
       
    95 
       
    96 
       
    97 void CPushAppHandlerEx::CancelHandleMessage()
       
    98 	{
       
    99 	__LOG_PTR_DEBUG("CPushAppHandlerEx:: CancelHandleMessage Called");
       
   100 	// TODO Add Cancel code for any outstanding requests
       
   101 	Done(KErrCancel);
       
   102 	}
       
   103 
       
   104 
       
   105 void CPushAppHandlerEx::DoCancel()
       
   106 	{
       
   107 	__LOG_PTR_DEBUG("CPushAppHandlerEx:: DoCancel Called");
       
   108 	// TODO Add Cancel code for any outstanding requests
       
   109 	Done(KErrCancel);
       
   110 	}
       
   111 
       
   112 
       
   113 void CPushAppHandlerEx::RunL()
       
   114 	{
       
   115 	__LOG_PTR_DEBUG("CPushAppHandlerEx:: RunL Called");
       
   116 
       
   117 	// TODO Create a State Machine for specific actions
       
   118 	switch (iState)
       
   119 		{
       
   120 	case EParsing :
       
   121 		iState = EProcessing;
       
   122 		ParsePushMsgL();
       
   123 		break;
       
   124 	case EProcessing:
       
   125 		iState = EDone;
       
   126 		ProcessPushMsgL();
       
   127 		break;
       
   128 	case EDone:
       
   129 		Done(KErrNone);
       
   130 		break;
       
   131 	default:
       
   132 		break;
       
   133 		}
       
   134 	}
       
   135 
       
   136 void CPushAppHandlerEx::ParsePushMsgL()
       
   137 	{
       
   138 	__LOG_PTR_DEBUG("CPushAppHandlerEx:: ParsePushMsgL Called");
       
   139 	IdleComplete();
       
   140 	}
       
   141 
       
   142 
       
   143 void CPushAppHandlerEx::ProcessPushMsgL()
       
   144 	{
       
   145 	__LOG_PTR_DEBUG("CPushAppHandlerEx:: ProcessPushMsgL Called");
       
   146 	IdleComplete();
       
   147 	}
       
   148 
       
   149 
       
   150