networkcontrol/qosipscpr/src/asyncwriter.cpp
changeset 0 af10295192d8
equal deleted inserted replaced
-1:000000000000 0:af10295192d8
       
     1 // Copyright (c) 2005-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 #include "asyncwriter.h"
       
    17 
       
    18 
       
    19 CAsyncWriter* CAsyncWriter::NewL(CQoSMsgWriter* aWriter)
       
    20 	{
       
    21 	CAsyncWriter* self = new (ELeave) CAsyncWriter(aWriter);
       
    22 	CleanupStack::PushL(self);
       
    23 	self->ConstructL();
       
    24 	CleanupStack::Pop(self);
       
    25 	return self;
       
    26 	}
       
    27 	
       
    28 CAsyncWriter::CAsyncWriter(CQoSMsgWriter* aWriter) :
       
    29 	CActive(EPriorityNormal),
       
    30 	iWriter(aWriter)
       
    31 	{
       
    32     }
       
    33 
       
    34 void CAsyncWriter::ConstructL()
       
    35 	{
       
    36 	CActiveScheduler::Add(this);
       
    37 	}
       
    38 
       
    39 void CAsyncWriter::Send(CQoSMsg* aMessage)
       
    40 	{
       
    41 	iMessage = aMessage;
       
    42 	iStatus = KRequestPending;
       
    43  		SetActive();
       
    44  		TRequestStatus* stat = &iStatus;
       
    45  		User::RequestComplete(stat,KErrNone);
       
    46 	}
       
    47 	
       
    48 void CAsyncWriter::RunL()
       
    49 	{
       
    50 	ASSERT(iMessage);
       
    51 	ASSERT(iWriter);
       
    52 	iWriter->Send(iMessage);
       
    53 	}
       
    54 	
       
    55 void CAsyncWriter::DoCancel()
       
    56 	{
       
    57 	//No code needed here becuase the request is completed immediately on activation
       
    58 	}