--- a/emailservices/emailclientapi/src/emailcontent.cpp Thu Aug 19 09:38:05 2010 +0300
+++ b/emailservices/emailclientapi/src/emailcontent.cpp Tue Aug 31 15:04:17 2010 +0300
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
* All rights reserved.
* This component and the accompanying materials are made available
* under the terms of "Eclipse Public License v1.0"
@@ -18,33 +18,30 @@
#include <apmstd.h>
#include "emailcontent.h"
-#include "cfsmailclient.h"
+#include "CFSMailClient.h"
#include "emailclientapi.hrh"
#include "emailapiutils.h"
-
-
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
CEmailMessageContent* CEmailMessageContent::NewL(
CPluginData& aPluginData,
const TMessageContentId& aMsgContentId,
- CFSMailMessagePart* aPart)
+ CFSMailMessagePart* aPart )
{
-
- CEmailMessageContent* self = new ( ELeave ) CEmailMessageContent( aPluginData, aMsgContentId, aPart );
+
+ CEmailMessageContent* self = new ( ELeave )
+ CEmailMessageContent( aPluginData, aMsgContentId, aPart );
CleanupStack::PushL( self );
self->ConstructL();
- CleanupStack::Pop();
+ CleanupStack::Pop( self );
return self;
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
CFSMailMessagePart& CEmailMessageContent::Part()
{
return *iPart;
@@ -53,8 +50,7 @@
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
-void CEmailMessageContent::SetPart(CFSMailMessagePart* aPart)
+void CEmailMessageContent::SetPart( CFSMailMessagePart* aPart )
{
iPart = aPart;
}
@@ -62,7 +58,6 @@
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
CPluginData& CEmailMessageContent::PluginData()
{
return iPluginData;
@@ -71,8 +66,7 @@
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
-void CEmailMessageContent::ConstructL( )
+void CEmailMessageContent::ConstructL()
{
iPlugin = iPluginData.ClaimInstanceL();
}
@@ -80,7 +74,6 @@
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
CEmailMessageContent::~CEmailMessageContent()
{
iPluginData.ReleaseInstance();
@@ -91,28 +84,29 @@
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
CEmailMessageContent::CEmailMessageContent(
CPluginData& aPluginData,
const TMessageContentId& aMsgContentId,
CFSMailMessagePart* aPart):
- iPluginData( aPluginData ), iPart(aPart), iMsgContentId( aMsgContentId ), iBuf(NULL), iUsed(0)
+ iPluginData( aPluginData ),
+ iPart( aPart ),
+ iMsgContentId( aMsgContentId ),
+ iBuf( NULL ),
+ iUsed( 0 )
{
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
TEmailTypeId CEmailMessageContent::InterfaceId() const
{
return KEmailIFUidMessageContent;
}
-
+
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
void CEmailMessageContent::Release()
{
delete this;
@@ -121,7 +115,6 @@
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
TMessageContentId CEmailMessageContent::Id() const
{
return iMsgContentId;
@@ -130,124 +123,165 @@
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
TPtrC CEmailMessageContent::ContentType() const
{
- return iPart->GetContentType();
+ if (iPart)
+ {
+ return iPart->GetContentType();
+ }
+ else
+ {
+ return TPtrC(0,0);
+ }
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
void CEmailMessageContent::SetContentType( const TDesC& aContentType )
{
- iPart->SetContentType( aContentType );
+ if (iPart)
+ iPart->SetContentType( aContentType );
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
TPtrC CEmailMessageContent::ContentId() const
{
- return iPart->ContentID();
+ if (iPart)
+ {
+ return iPart->ContentID();
+ }
+ else
+ {
+ return TPtrC(0,0);
+ }
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
void CEmailMessageContent::SetContentId( const TDesC& aContentId )
{
- TRAP_IGNORE( iPart->SetContentIDL( aContentId ) );
+ if (iPart)
+ TRAP_IGNORE( iPart->SetContentIDL( aContentId ) );
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
TPtrC CEmailMessageContent::ContentDescription() const
{
- return iPart->ContentDescription();
+ if (iPart)
+ {
+ return iPart->ContentDescription();
+ }
+ else
+ {
+ return TPtrC(0,0);
+ }
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
void CEmailMessageContent::SetContentDescription(
const TDesC& aContentDescription )
{
- iPart->SetContentDescription( aContentDescription );
+ if (iPart)
+ iPart->SetContentDescription( aContentDescription );
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
TPtrC CEmailMessageContent::ContentDisposition() const
{
- return iPart->ContentDisposition();
+ if (iPart)
+ {
+ return iPart->ContentDisposition();
+ }
+ else
+ {
+ return TPtrC(0,0);
+ }
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
void CEmailMessageContent::SetContentDisposition(
const TDesC& aContentDisposition )
{
- iPart->SetContentDisposition( aContentDisposition );
+ if (iPart)
+ iPart->SetContentDisposition( aContentDisposition );
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
TPtrC CEmailMessageContent::ContentClass() const
{
- return iPart->GetContentClass();
+ if (iPart)
+ {
+ return iPart->GetContentClass();
+ }
+ else
+ {
+ return TPtrC(0,0);
+ }
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
void CEmailMessageContent::SetContentClass( const TDesC& aContentClass )
{
- iPart->SetContentClass( aContentClass );
+ if (iPart)
+ iPart->SetContentClass( aContentClass );
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
TInt CEmailMessageContent::AvailableSize() const
{
- return iPart->FetchedContentSize();
+ if (iPart)
+ {
+ return iPart->FetchedContentSize();
+ }
+ else
+ {
+ return 0;
+ }
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
TInt CEmailMessageContent::TotalSize() const
{
- return iPart->ContentSize();
+ if (iPart)
+ {
+ return iPart->ContentSize();
+ }
+ else
+ {
+ return 0;
+ }
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
TPtrC CEmailMessageContent::ContentL() const
{
TInt size = AvailableSize();
TPtr16 ptr( 0, size );
if ( size != 0 )
{
- if ( iBuf == NULL )
+ if ( !iBuf )
{
iBuf = HBufC::NewL( size );
}
@@ -257,65 +291,60 @@
iBuf = iBuf->ReAlloc( size );
}
ptr.Set( iBuf->Des() );
- if(iUsed < size)
- {
- iPart->GetContentToBufferL( ptr, iUsed );
- iUsed += size;
- }
- }
+ iPart->GetContentToBufferL( ptr, iUsed );
+ iUsed += size;
+ }
return ptr;
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
void CEmailMessageContent::SetContentL( const TDesC& aContent )
{
+ User::LeaveIfNull( iPart );
iPart->SetContentSize( aContent.Length() );
iPart->SetFetchedContentSize( aContent.Length() );
- iPlugin->SetContentL(aContent,
- FsMsgId(iPluginData, iMsgContentId.iMessageId.iFolderId.iMailboxId),
- FsMsgId(iPluginData, iMsgContentId.iMessageId.iFolderId),
- FsMsgId(iPluginData, iMsgContentId.iMessageId),
- FsMsgId(iPluginData, iMsgContentId));
+ iPlugin->SetContentL( aContent,
+ FsMsgId( iPluginData, iMsgContentId.iMessageId.iFolderId.iMailboxId ),
+ FsMsgId( iPluginData, iMsgContentId.iMessageId.iFolderId ),
+ FsMsgId( iPluginData, iMsgContentId.iMessageId ),
+ FsMsgId( iPluginData, iMsgContentId ) );
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
void CEmailMessageContent::FetchL( MEmailFetchObserver& aObserver )
{
+ User::LeaveIfNull( iPart );
const TFSMailMsgId fsId = FsMsgId(iPluginData, iMsgContentId);
if ( !iFetchObserver )
{
- iFetchObserver = new (ELeave) CContentRequestObserver( *this );
+ iFetchObserver = new ( ELeave ) CContentRequestObserver( *this );
}
- iFetchObserver->SetObserverL(&aObserver);
- iRequestId = iPart->FetchMessagePartL(fsId, *iFetchObserver, TUint(0));
-
+ iFetchObserver->SetObserverL( &aObserver );
+ iRequestId = iPart->FetchMessagePartL( fsId, *iFetchObserver, TUint( 0 ) );
+
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
void CEmailMessageContent::CancelFetch()
{
- TRAP_IGNORE( iPlugin->CancelL(iRequestId) );
+ TRAP_IGNORE( iPlugin->CancelL( iRequestId ) );
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
void CEmailMessageContent::SaveToFileL( const TDesC& aPath )
{
iPlugin->CopyMessagePartFileL(
- FsMsgId( iPluginData, iMsgContentId.iMessageId.iFolderId.iMailboxId ),
- FsMsgId( iPluginData, iMsgContentId.iMessageId.iFolderId ),
- FsMsgId( iPluginData, iMsgContentId.iMessageId ),
+ FsMsgId( iPluginData, iMsgContentId.iMessageId.iFolderId.iMailboxId ),
+ FsMsgId( iPluginData, iMsgContentId.iMessageId.iFolderId ),
+ FsMsgId( iPluginData, iMsgContentId.iMessageId ),
FsMsgId( iPluginData, iMsgContentId ),
aPath );
}
@@ -329,8 +358,7 @@
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
-MEmailTextContent* CEmailMessageContent::AsTextContentOrNull()const
+MEmailTextContent* CEmailMessageContent::AsTextContentOrNull() const
{
return NULL;
}
@@ -338,31 +366,26 @@
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
MEmailAttachment* CEmailMessageContent::AsAttachmentOrNull() const
{
return NULL;
}
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+CEmailMessageContent::CContentRequestObserver::CContentRequestObserver(
+ CEmailMessageContent& aParent ) : iObserver( NULL ), iParent( aParent )
+ {
+ }
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
-CEmailMessageContent::CContentRequestObserver::CContentRequestObserver(
- CEmailMessageContent& aParent ) : iObserver( NULL ), iParent( aParent )
- {
- }
-
-
-// ---------------------------------------------------------------------------
-//
-// ---------------------------------------------------------------------------
-//
void CEmailMessageContent::CContentRequestObserver::RequestResponseL(
TFSProgress aEvent, TInt /* aRequestId */ )
{
- if (aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete)
+ if ( aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete )
{
delete iParent.iPart;
iParent.iPart = NULL;
@@ -372,17 +395,18 @@
FsMsgId( iParent.iPluginData, iParent.iMsgContentId.iMessageId ),
FsMsgId( iParent.iPluginData, iParent.iMsgContentId ) );
iParent.SetPart( part );
- iObserver->DataFetchedL(aEvent.iError);
+
+ if ( iObserver )
+ iObserver->DataFetchedL( aEvent.iError );
}
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-//
void CEmailMessageContent::CContentRequestObserver::SetObserverL( MEmailFetchObserver* aObserver )
{
iObserver = aObserver;
}
-// End of file.
+// End of file