email/mail/EditorSrc/MsgMailEditorRemoveAttachment.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *		E-mail attachment remove operation
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <miutset.h> // KUidMsgTypeSMTP
       
    22 #include <miutmsg.h> // CImEmailMessage
       
    23 
       
    24 #include "MsgMailEditorRemoveAttachment.h"
       
    25 
       
    26 
       
    27 // ================= MEMBER FUNCTIONS =======================
       
    28 
       
    29 // Constructor
       
    30 CMsgMailEditorRemoveAttachmentOp::CMsgMailEditorRemoveAttachmentOp(CMsvSession& aMsvSession, 
       
    31     TRequestStatus& aObserverRequestStatus)
       
    32     : CMsvOperation(aMsvSession, EPriorityStandard, aObserverRequestStatus)
       
    33     {
       
    34     CActiveScheduler::Add(this);
       
    35     iMtm = KUidMsgTypeSMTP;
       
    36     }
       
    37 
       
    38 // Symbian OS constructor
       
    39 CMsgMailEditorRemoveAttachmentOp* 
       
    40 CMsgMailEditorRemoveAttachmentOp::NewLC(CMsvSession& aMsvSession, 
       
    41     TRequestStatus& aObserverRequestStatus, const TMsvId aMsgId, 
       
    42     const TMsvId aAttachmentId)
       
    43     {
       
    44     CMsgMailEditorRemoveAttachmentOp *op = new(ELeave) 
       
    45         CMsgMailEditorRemoveAttachmentOp(aMsvSession, aObserverRequestStatus);
       
    46     CleanupStack::PushL(op);
       
    47     op->ConstructL(aMsgId, aAttachmentId);
       
    48     return op;
       
    49     }
       
    50 
       
    51 // Destructor
       
    52 CMsgMailEditorRemoveAttachmentOp::~CMsgMailEditorRemoveAttachmentOp()
       
    53     {
       
    54     Cancel();
       
    55     delete iMsgEntry;
       
    56     delete iEmailMsg;
       
    57     }
       
    58 
       
    59 // 2nd phase constructor
       
    60 void CMsgMailEditorRemoveAttachmentOp::ConstructL(const TMsvId aMsgId, 
       
    61                                                   const TMsvId aAttachmentId)
       
    62     {
       
    63     iMsgEntry = iMsvSession.GetEntryL(aMsgId);
       
    64     iEmailMsg = CImEmailMessage::NewL(*iMsgEntry);
       
    65     iStatus = KRequestPending;
       
    66     iEmailMsg->DeleteAttachmentL(aMsgId, aAttachmentId, iStatus);
       
    67     SetActive();
       
    68     }
       
    69 
       
    70 // Returns progress of the operation using TMsvLocalOperationProgress
       
    71 const TDesC8& CMsgMailEditorRemoveAttachmentOp::ProgressL()
       
    72     {
       
    73     return iProgress;
       
    74     }
       
    75 
       
    76 // Cancels outstanding operation
       
    77 void CMsgMailEditorRemoveAttachmentOp::DoCancel()
       
    78     {
       
    79     if(iEmailMsg)
       
    80         {
       
    81         iEmailMsg->Cancel();
       
    82         iProgress().iError = KErrCancel;
       
    83         }
       
    84     }
       
    85 
       
    86 // Handles an active object’s request completion event
       
    87 void CMsgMailEditorRemoveAttachmentOp::RunL()
       
    88     {
       
    89     iProgress().iError = iStatus.Int();
       
    90     TRequestStatus* status = &iObserverRequestStatus;
       
    91     User::RequestComplete(status, KErrNone);
       
    92     }
       
    93 
       
    94 
       
    95 
       
    96 // End of File