email/pop3andsmtpmtm/popservermtm/src/cpopupsresponsewaiter.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 // Copyright (c) 2007-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 <msvids.h>
       
    17 #include <pop3set.h>
       
    18 
       
    19 #include "cpopupsresponsewaiter.h"
       
    20 #include "POPS.H"
       
    21 // panics
       
    22 #include "POPS.PAN"
       
    23 
       
    24 /**
       
    25 Construction method
       
    26 @return a new instance of CPopUpsResponseWaiter
       
    27 */
       
    28 CPopUpsResponseWaiter* CPopUpsResponseWaiter::NewL()
       
    29 	{
       
    30 	return new(ELeave)CPopUpsResponseWaiter();
       
    31 	}
       
    32 
       
    33 /**
       
    34 Default constructor.
       
    35 */
       
    36 CPopUpsResponseWaiter::CPopUpsResponseWaiter()
       
    37 	: CMsgActive(EPriorityStandard)
       
    38 	{
       
    39 	CActiveScheduler::Add(this);
       
    40 	}
       
    41 
       
    42 /**
       
    43 Destructor.
       
    44 */	
       
    45 CPopUpsResponseWaiter::~CPopUpsResponseWaiter()
       
    46 	{
       
    47 	Cancel();
       
    48 	iUpsSubsession.Close();
       
    49 	iUpsSession.Close();
       
    50 	}
       
    51 
       
    52 /**
       
    53 Connect to UPS server and check if the client thread has the capability to check to the 
       
    54 pop server.
       
    55 @param aPopSettings 		The CImPop3Settings object.
       
    56 @param aClientThread		The Rthread of the client application.
       
    57 @param aHasCapability		TBool indicating if the client has passes the server's check on capability.		
       
    58 @param aStatus				TRequestStatus of the Active Object.
       
    59 @return void.
       
    60 */
       
    61 void CPopUpsResponseWaiter::AuthoriseAndConnectL(CImPop3Settings* aPopSettings, TThreadId aClientThreadId, TBool aHasCapability, TRequestStatus& aStatus)
       
    62 	{ 
       
    63 	iPopSettings = aPopSettings;
       
    64 	
       
    65 	iDecision = EUpsDecNo;	
       
    66 	User::LeaveIfError(iUpsSession.Connect());
       
    67 	
       
    68 	RThread clientThread;
       
    69  	User::LeaveIfError(clientThread.Open(aClientThreadId));
       
    70 	CleanupClosePushL(clientThread);
       
    71  	User::LeaveIfError(iUpsSubsession.Initialise(iUpsSession, clientThread));
       
    72 	CleanupStack::PopAndDestroy(&clientThread);
       
    73 	
       
    74 	Queue(aStatus);	
       
    75 	
       
    76 	iUpsSubsession.Authorise(aHasCapability, KUidPOPService, iPopSettings->ServerAddress(), iDecision, iStatus);
       
    77 	SetActive();
       
    78 	}
       
    79 
       
    80 void CPopUpsResponseWaiter::DoRunL()
       
    81 	{
       
    82 	User::LeaveIfError(iStatus.Int());
       
    83 	if(iDecision != EUpsDecYes && iDecision != EUpsDecSessionYes)
       
    84 		{
       
    85 		User::Leave(KErrPermissionDenied);
       
    86 		}
       
    87 	Complete(iStatus.Int());
       
    88 	}
       
    89 
       
    90 void CPopUpsResponseWaiter::DoCancel()
       
    91 	{
       
    92 	// Cancel the Prompt request
       
    93 	iUpsSubsession.CancelPrompt();
       
    94 
       
    95 	CMsgActive::DoCancel();
       
    96 	}