--- a/emailservices/emailclientapi/src/emailcontent.cpp Tue Aug 31 15:04:17 2010 +0300
+++ b/emailservices/emailclientapi/src/emailcontent.cpp Wed Sep 01 12:28:57 2010 +0100
@@ -1,5 +1,5 @@
/*
-* Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2009 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,30 +18,33 @@
#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( self );
+ CleanupStack::Pop();
return self;
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
+//
CFSMailMessagePart& CEmailMessageContent::Part()
{
return *iPart;
@@ -50,7 +53,8 @@
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-void CEmailMessageContent::SetPart( CFSMailMessagePart* aPart )
+//
+void CEmailMessageContent::SetPart(CFSMailMessagePart* aPart)
{
iPart = aPart;
}
@@ -58,6 +62,7 @@
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
+//
CPluginData& CEmailMessageContent::PluginData()
{
return iPluginData;
@@ -66,7 +71,8 @@
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-void CEmailMessageContent::ConstructL()
+//
+void CEmailMessageContent::ConstructL( )
{
iPlugin = iPluginData.ClaimInstanceL();
}
@@ -74,6 +80,7 @@
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
+//
CEmailMessageContent::~CEmailMessageContent()
{
iPluginData.ReleaseInstance();
@@ -84,29 +91,28 @@
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
+//
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;
@@ -115,6 +121,7 @@
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
+//
TMessageContentId CEmailMessageContent::Id() const
{
return iMsgContentId;
@@ -123,165 +130,124 @@
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
+//
TPtrC CEmailMessageContent::ContentType() const
{
- if (iPart)
- {
- return iPart->GetContentType();
- }
- else
- {
- return TPtrC(0,0);
- }
+ return iPart->GetContentType();
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
+//
void CEmailMessageContent::SetContentType( const TDesC& aContentType )
{
- if (iPart)
- iPart->SetContentType( aContentType );
+ iPart->SetContentType( aContentType );
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
+//
TPtrC CEmailMessageContent::ContentId() const
{
- if (iPart)
- {
- return iPart->ContentID();
- }
- else
- {
- return TPtrC(0,0);
- }
+ return iPart->ContentID();
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
+//
void CEmailMessageContent::SetContentId( const TDesC& aContentId )
{
- if (iPart)
- TRAP_IGNORE( iPart->SetContentIDL( aContentId ) );
+ TRAP_IGNORE( iPart->SetContentIDL( aContentId ) );
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
+//
TPtrC CEmailMessageContent::ContentDescription() const
{
- if (iPart)
- {
- return iPart->ContentDescription();
- }
- else
- {
- return TPtrC(0,0);
- }
+ return iPart->ContentDescription();
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
+//
void CEmailMessageContent::SetContentDescription(
const TDesC& aContentDescription )
{
- if (iPart)
- iPart->SetContentDescription( aContentDescription );
+ iPart->SetContentDescription( aContentDescription );
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
+//
TPtrC CEmailMessageContent::ContentDisposition() const
{
- if (iPart)
- {
- return iPart->ContentDisposition();
- }
- else
- {
- return TPtrC(0,0);
- }
+ return iPart->ContentDisposition();
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
+//
void CEmailMessageContent::SetContentDisposition(
const TDesC& aContentDisposition )
{
- if (iPart)
- iPart->SetContentDisposition( aContentDisposition );
+ iPart->SetContentDisposition( aContentDisposition );
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
+//
TPtrC CEmailMessageContent::ContentClass() const
{
- if (iPart)
- {
- return iPart->GetContentClass();
- }
- else
- {
- return TPtrC(0,0);
- }
+ return iPart->GetContentClass();
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
+//
void CEmailMessageContent::SetContentClass( const TDesC& aContentClass )
{
- if (iPart)
- iPart->SetContentClass( aContentClass );
+ iPart->SetContentClass( aContentClass );
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
+//
TInt CEmailMessageContent::AvailableSize() const
{
- if (iPart)
- {
- return iPart->FetchedContentSize();
- }
- else
- {
- return 0;
- }
+ return iPart->FetchedContentSize();
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
+//
TInt CEmailMessageContent::TotalSize() const
{
- if (iPart)
- {
- return iPart->ContentSize();
- }
- else
- {
- return 0;
- }
+ return iPart->ContentSize();
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
+//
TPtrC CEmailMessageContent::ContentL() const
{
TInt size = AvailableSize();
TPtr16 ptr( 0, size );
if ( size != 0 )
{
- if ( !iBuf )
+ if ( iBuf == NULL )
{
iBuf = HBufC::NewL( size );
}
@@ -291,60 +257,65 @@
iBuf = iBuf->ReAlloc( size );
}
ptr.Set( iBuf->Des() );
- iPart->GetContentToBufferL( ptr, iUsed );
- iUsed += size;
- }
+ if(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 );
}
@@ -358,7 +329,8 @@
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
-MEmailTextContent* CEmailMessageContent::AsTextContentOrNull() const
+//
+MEmailTextContent* CEmailMessageContent::AsTextContentOrNull()const
{
return NULL;
}
@@ -366,26 +338,31 @@
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
+//
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;
@@ -395,18 +372,17 @@
FsMsgId( iParent.iPluginData, iParent.iMsgContentId.iMessageId ),
FsMsgId( iParent.iPluginData, iParent.iMsgContentId ) );
iParent.SetPart( part );
-
- if ( iObserver )
- iObserver->DataFetchedL( aEvent.iError );
+ iObserver->DataFetchedL(aEvent.iError);
}
}
// ---------------------------------------------------------------------------
//
// ---------------------------------------------------------------------------
+//
void CEmailMessageContent::CContentRequestObserver::SetObserverL( MEmailFetchObserver* aObserver )
{
iObserver = aObserver;
}
-// End of file
+// End of file.