email/imap4mtm/imapmailstore/src/cqueueentrybase.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 // Copyright (c) 2006-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 
       
    17 #include "cqueueentrybase.h"
       
    18 #include <miuthdr.h>
       
    19 
       
    20 /**
       
    21 Constructor.
       
    22 */
       
    23 CQueueEntryBase::CQueueEntryBase(TMsvId aId,TQueueEntryType aQueueEntryType,CImapMailStore& aParent,CMsvServerEntry& aServerEntry,MMailStoreObserver& aObserver)
       
    24 	:CActive(EPriorityStandard), iId(aId),iObserver(aObserver),iQueueEntryType(aQueueEntryType), iParent(aParent), iServerEntry(aServerEntry)
       
    25 	{
       
    26 	}
       
    27 	
       
    28 void CQueueEntryBase::BaseConstructL()
       
    29 	{
       
    30 	CActiveScheduler::Add(this); 
       
    31 	}
       
    32 
       
    33 /**
       
    34 Destructor.
       
    35 */
       
    36 CQueueEntryBase::~CQueueEntryBase()
       
    37 	{
       
    38 	Cancel();
       
    39 	}
       
    40 
       
    41 /**
       
    42 Calls back to the client observer with the result of the operation and the entry id.
       
    43 @param aErrorCode   The result of the store operation
       
    44 @return
       
    45 */		
       
    46 void CQueueEntryBase::StoreComplete(TInt aErrorCode)
       
    47 	{
       
    48 	iObserver.StoreOperationComplete(iId,aErrorCode);				
       
    49 	}
       
    50 	
       
    51 /**
       
    52 Sets the queue entry active.
       
    53 @param
       
    54 @return
       
    55 */
       
    56 void CQueueEntryBase::CompleteSelf()
       
    57 	{
       
    58 	SetActive();
       
    59 	TRequestStatus* status = &iStatus;
       
    60 	User::RequestComplete(status, KErrNone);
       
    61 	}
       
    62 	
       
    63 TMsvId CQueueEntryBase::GetId() const 
       
    64 	{
       
    65 	return iId;
       
    66 	}
       
    67 
       
    68 CQueueEntryBase::TQueueEntryType CQueueEntryBase::GetEntryType() const
       
    69 	{
       
    70 	return iQueueEntryType;
       
    71 	}
       
    72 
       
    73 MMailStoreObserver& CQueueEntryBase::GetObserver()
       
    74 	{
       
    75 	return iObserver;
       
    76 	}
       
    77 	
       
    78 void CQueueEntryBase::DoCancel()
       
    79 	{
       
    80 	//default implementation  does nothing		
       
    81 	}
       
    82 
       
    83 void CQueueEntryBase::CancelRequest()
       
    84 	{
       
    85 	//default implementation  does nothing	
       
    86 	}
       
    87 	
       
    88 	
       
    89 /**
       
    90 Calls StoreComplete with the error code and removes the request from the queue.
       
    91 @param		aError the error code	
       
    92 @return		KErrNone
       
    93 */
       
    94 TInt CQueueEntryBase::RunError(TInt aError)
       
    95 	{
       
    96 	StoreComplete(aError);
       
    97 	iParent.RemoveFromQueueAndDelete(this);	
       
    98 	return KErrNone;	
       
    99 	}