applayerprotocols/httpservice/src/chttpcontentwriter.cpp
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 // Copyright (c) 2003-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 "chttpcontentwriter.h"
       
    17 #include "mhttpdatareceiver.h"
       
    18 
       
    19 
       
    20 CHttpFileWriter* CHttpFileWriter::New(RFile aFile, MHttpDataReceiver& aReceiver)
       
    21     {
       
    22     CHttpFileWriter* self = new CHttpFileWriter(aFile, aReceiver);
       
    23     return self;
       
    24     }
       
    25 
       
    26 
       
    27 CHttpFileWriter::CHttpFileWriter(RFile aFile, MHttpDataReceiver& aReceiver)
       
    28 : CActive(EPriorityStandard),
       
    29 iFile(aFile),
       
    30 iDataReceiver(aReceiver)
       
    31     {
       
    32     CActiveScheduler::Add(this);    
       
    33     }
       
    34 CHttpFileWriter::~CHttpFileWriter()
       
    35     {
       
    36     Cancel();    
       
    37     }
       
    38 
       
    39 void CHttpFileWriter::Write(const TDesC8& aData)
       
    40     {
       
    41     iFile.Write(aData, iStatus);
       
    42     SetActive();
       
    43     }
       
    44 
       
    45 // From CActive
       
    46 void CHttpFileWriter::RunL()
       
    47     {
       
    48     User::LeaveIfError(iStatus.Int());
       
    49     iDataReceiver.Release();
       
    50     }
       
    51 
       
    52 void CHttpFileWriter::DoCancel()
       
    53     {
       
    54     }
       
    55 
       
    56 TInt CHttpFileWriter::RunError(TInt aError)
       
    57     {
       
    58     iDataReceiver.Error(aError);
       
    59     return KErrNone;
       
    60     }    
       
    61