email/pop3andsmtpmtm/imapservermtm/src/IMPSUTIL.CPP
changeset 25 84d9eb65b26f
equal deleted inserted replaced
23:238255e8b033 25:84d9eb65b26f
       
     1 // Copyright (c) 1998-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 // IMAP4 utils.
       
    15 // 
       
    16 //
       
    17 
       
    18 #include <e32base.h>
       
    19 #include <msvstd.h>
       
    20 #include <miuthdr.h>
       
    21 #include <imcvutil.h>
       
    22 #include <msventry.h>
       
    23 #include <logwrap.h>
       
    24 
       
    25 #include "impsutil.h"
       
    26 
       
    27 CImap4Utils* CImap4Utils::NewL(CMsvServerEntry* aEntry) 
       
    28 	{
       
    29 	CImap4Utils* self=new (ELeave) CImap4Utils();
       
    30 	CleanupStack::PushL(self);
       
    31 	self->ConstructL(aEntry);
       
    32 	CleanupStack::Pop();
       
    33 	return self;
       
    34 	}
       
    35 
       
    36 CImap4Utils::~CImap4Utils()
       
    37 	{
       
    38 	delete iLogMessage;
       
    39 	}
       
    40 
       
    41 void CImap4Utils::ConstructL(CMsvServerEntry* aEntry)
       
    42 	{
       
    43 	iEntry = aEntry;
       
    44 	
       
    45 	// get the logger (discard errors)
       
    46 	TRAPD(err,iLogMessage=CImLogMessage::NewL(iEntry->FileSession()));
       
    47 	}
       
    48 
       
    49 void CImap4Utils::ClearLogMessage()
       
    50 	{
       
    51 	if (iLogMessage)
       
    52 		iLogMessage->LogEvent().SetLink(KLogNullLink);
       
    53 	}
       
    54 
       
    55 // Helper function to set up the iLogEntry object 
       
    56 void CImap4Utils::SetUpLogMessageL(TMsvId aId)
       
    57 	{
       
    58 	if (iLogMessage)
       
    59 		{
       
    60 		TBuf<KLogMaxSharedStringLength> string;
       
    61 
       
    62 		// if the entry isn't there then setup what we can of the log
       
    63 		// message anyway
       
    64 		if (iEntry->SetEntry(aId) == KErrNone)
       
    65 			{
       
    66 			TMsvEmailEntry entry = iEntry->Entry();
       
    67 			iLogMessage->LogEvent().SetRemoteParty(entry.iDetails);
       
    68 			iLogMessage->LogEvent().SetSubject(entry.iDescription);
       
    69 			}
       
    70 		else
       
    71 			{
       
    72 			iLogMessage->GetString(string, R_LOG_REMOTE_UNKNOWN);
       
    73 			iLogMessage->LogEvent().SetRemoteParty(string);
       
    74 
       
    75 			iLogMessage->GetString(string, R_LOG_SUBJECT_NONE);
       
    76 			iLogMessage->LogEvent().SetSubject(string);
       
    77 			}
       
    78 		
       
    79 		// Set up the log event.
       
    80 		iLogMessage->LogEvent().SetEventType(KLogMailEventTypeUid);
       
    81 
       
    82 		iLogMessage->GetString(string, R_LOG_DIR_FETCHED);
       
    83 		iLogMessage->LogEvent().SetDirection(string);
       
    84 
       
    85 		iLogMessage->LogEvent().SetLink(aId);
       
    86 		}
       
    87 	}
       
    88 
       
    89 // Send the log message set up by SetUpLogMessageL()
       
    90 TBool CImap4Utils::SendLogMessageL(TInt aError, TRequestStatus &aStatus)
       
    91 	{
       
    92 	if (iLogMessage && iLogMessage->LogEvent().Link() != KLogNullLink)
       
    93 		{
       
    94 		// Run the iLogMessage operation.
       
    95 		iLogMessage->Start(aError, aStatus);
       
    96 
       
    97 		return ETrue;
       
    98 		}
       
    99 
       
   100 	return EFalse;
       
   101 	}
       
   102 
       
   103 // eof IMPSUTIL.CPP