applayerprotocols/ftpengine/inc/SETERROR.H
changeset 0 b16258d2340f
equal deleted inserted replaced
-1:000000000000 0:b16258d2340f
       
     1 /**
       
     2 * Copyright (c) 1998-2009 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 * Active object to set an error asynchronously
       
    16 * Author:	Philippe Gabriel
       
    17 * Set an error condition to be reported asynchronously
       
    18 * so the client get the error condition from the scheduler
       
    19 * 
       
    20 *
       
    21 */
       
    22 
       
    23 
       
    24 
       
    25 /**
       
    26  @file SETERROR.H
       
    27  @internalComponent
       
    28 */
       
    29 
       
    30 #if !defined(__SETERROR_H__)
       
    31 #define __SETERROR_H__
       
    32 
       
    33 #include "DEBUG.H"
       
    34 #include "SETERROR.H"
       
    35 #include <e32base.h>
       
    36 
       
    37 //////////////////////////////////////////////////////////////
       
    38 // Definitions
       
    39 //////////////////////////////////////////////////////////////
       
    40 
       
    41 class MSetErrorNotifier
       
    42 /**
       
    43 @internalComponent
       
    44 */
       
    45 {
       
    46 public:
       
    47 	virtual ~MSetErrorNotifier(){};
       
    48 	// Notify of normal completion of an operation
       
    49 	virtual void SetErrorNotifier(const TInt)=0;
       
    50 };
       
    51 
       
    52 class CFTPSetError : public CActive
       
    53 /**
       
    54 @internalComponent
       
    55 */
       
    56 {
       
    57 public:
       
    58 
       
    59 CFTPSetError(MSetErrorNotifier *aNotifier):CActive(CActive::EPriorityStandard)
       
    60 {
       
    61 	iNotifier = aNotifier;
       
    62 }
       
    63 
       
    64 static CFTPSetError* NewL(MSetErrorNotifier* aNotifier)
       
    65 {
       
    66 	CFTPSetError* self = new (ELeave) CFTPSetError(aNotifier);
       
    67 	CActiveScheduler::Add(self);
       
    68 	return self;
       
    69 } 
       
    70 ~CFTPSetError()
       
    71 {
       
    72 	FTPPROTDEBUG(_DBGFtpseterr,_L("CFTPSetError::~CFTPSetError called\n"));
       
    73 }
       
    74 
       
    75 void SetError(const TInt aError)
       
    76 {
       
    77 TRequestStatus* p=&iStatus;	
       
    78 iError = aError;
       
    79 // Complete immediately
       
    80 SetActive();
       
    81 User::RequestComplete(p, KErrNone);
       
    82 }
       
    83 protected:
       
    84 void RunL()
       
    85 	{
       
    86 	// 
       
    87 	FTPPROTDEBUG(_DBGFtpseterr,_L("CFTPSetError::RunL called "));
       
    88 	switch (iStatus.Int())
       
    89 		{
       
    90 		case KErrNone:
       
    91 			FTPPROTDEBUG(_DBGFtpseterr,_L("iStatus: NoError\n"));
       
    92 			// Call Upper layer notifier
       
    93 			iNotifier->SetErrorNotifier(iError);
       
    94 			break;
       
    95 		default:
       
    96 			__ASSERT_DEBUG(FALSE, User::Panic(_L("CFtpSetError"), 0));
       
    97 			break;
       
    98 		}
       
    99 	} 
       
   100 void DoCancel()
       
   101 {
       
   102 }
       
   103 private:
       
   104 	/** The error to report to my client */
       
   105 	TInt	iError; 
       
   106 	/** Notifier to call to report error */
       
   107 	MSetErrorNotifier* iNotifier; 
       
   108 };
       
   109 #endif // __SETERROR_H__