# HG changeset patch
# User hgs
# Date 1277379138 -10800
# Node ID f83bd4ae1fe37b4a1fb564238368637b202f588e
# Parent 780f926bc26cddf74e5c48bf8705da32223f2219
201025
diff -r 780f926bc26c -r f83bd4ae1fe3 email_plat/email_client_api/email_client_api.metaxml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/email_client_api.metaxml Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,13 @@
+
+
+ email client api
+ Email client api allows listing and accessing mailboxes and email messages. Messages can be created, replied, forwared and searched. Specific mailbox can be launched in the Email application.
+ c++
+ email_plat
+
+
+
+ no
+ no
+
+
diff -r 780f926bc26c -r f83bd4ae1fe3 email_plat/email_client_api/email_client_api.pri
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/email_client_api.pri Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,35 @@
+#
+# 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"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+#
+symbian*: {
+ # Build.inf rules
+ BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include " \
+ "email_client_api/emailinterfacefactory.h APP_LAYER_PLATFORM_EXPORT_PATH(emailinterfacefactory.h)" \
+ "email_client_api/emailinterfacefactory.inl APP_LAYER_PLATFORM_EXPORT_PATH(emailinterfacefactory.inl)" \
+ "email_client_api/emailclientapi.hrh APP_LAYER_PLATFORM_EXPORT_PATH(emailclientapi.hrh)" \
+ "email_client_api/emailapidefs.h APP_LAYER_PLATFORM_EXPORT_PATH(emailapidefs.h)" \
+ "email_client_api/emailsorting.h APP_LAYER_PLATFORM_EXPORT_PATH(emailsorting.h)" \
+ "email_client_api/mmessageiterator.h APP_LAYER_PLATFORM_EXPORT_PATH(mmessageiterator.h)" \
+ "email_client_api/memailclientapi.h APP_LAYER_PLATFORM_EXPORT_PATH(memailclientapi.h)" \
+ "email_client_api/memailmailbox.h APP_LAYER_PLATFORM_EXPORT_PATH(memailmailbox.h)" \
+ "email_client_api/memailmessage.h APP_LAYER_PLATFORM_EXPORT_PATH(memailmessage.h)" \
+ "email_client_api/memailfolder.h APP_LAYER_PLATFORM_EXPORT_PATH(memailfolder.h)" \
+ "email_client_api/memailaddress.h APP_LAYER_PLATFORM_EXPORT_PATH(memailaddress.h)" \
+ "email_client_api/memailcontent.h APP_LAYER_PLATFORM_EXPORT_PATH(memailcontent.h)" \
+ "email_client_api/memailmessagesearch.h APP_LAYER_PLATFORM_EXPORT_PATH(memailmessagesearch.h)" \
+ "email_client_api/mmailboxsyncobserver.h APP_LAYER_PLATFORM_EXPORT_PATH(mmailboxsyncobserver.h)" \
+ "email_client_api/mmailboxcontentobserver.h APP_LAYER_PLATFORM_EXPORT_PATH(mmailboxcontentobserver.h)"
+}
diff -r 780f926bc26c -r f83bd4ae1fe3 email_plat/email_client_api/emailapidefs.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/emailapidefs.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,158 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Email Client API definitions
+*
+*/
+
+#ifndef __EMAILAPIDEFS
+#define __EMAILAPIDEFS
+
+#include
+#include
+
+namespace EmailInterface {
+
+/**
+* Id for message, message part, folder and mailbox entries
+*/
+typedef TUint TEntryId;
+
+/**
+* Interface id. Each implementation of MEmailInterface has unique id value.
+*/
+typedef TInt TEmailTypeId;
+
+const TEntryId KUndefinedEntryId = 0;
+
+/**
+ * base interface for all email interfaces available to clients
+ * @since S60 v5.0
+ */
+class MEmailInterface
+{
+public:
+ /** returns interface id (kind of RTTI) */
+ virtual TEmailTypeId InterfaceId() const = 0;
+
+ /** frees memory allocated by interface impl. */
+ virtual void Release() = 0;
+};
+
+/**
+ * Defines abstraction for entry ID. Used by message, folder, mailbox etc types.
+ * @since S60 v5.0
+ */
+class TBaseId
+{
+public:
+ inline TBaseId() : iId( KUndefinedEntryId ){}
+ inline TBaseId( TEntryId aId ) : iId( aId ){}
+
+ TEntryId iId;
+};
+
+/**
+ * Defines mailbox ID
+ * @since S60 v5.0
+ */
+class TMailboxId : public TBaseId
+{
+public:
+ inline TMailboxId() :
+ TBaseId(){}
+ inline TMailboxId( TEntryId aId ) : TBaseId( aId ){}
+ inline TBool operator==( const TMailboxId& aMailboxId ) const {
+ return ( aMailboxId.iId == iId ); }
+};
+
+/**
+ * Defines folder ID which is associated with a mailbox
+ * @since S60 v5.0
+ */
+class TFolderId : public TBaseId
+{
+public:
+ // parent mailbox
+ TMailboxId iMailboxId;
+ inline TFolderId( TEntryId aId, const TMailboxId& aMailboxId ) :
+ TBaseId( aId ),iMailboxId( aMailboxId.iId ){}
+
+ inline TFolderId() : TBaseId(), iMailboxId() {}
+
+ inline TBool operator==( const TFolderId& aFolderId ) const {
+ return ( iMailboxId.iId == aFolderId.iMailboxId.iId &&
+ iId == aFolderId.iId ); }
+
+ inline TBool operator!=( const TFolderId& aFolderId ) const {
+ return !( aFolderId == *this ); }
+};
+
+/**
+ * Defines email message ID which is associated with a mailbox and folder
+ * @since S60 v5.0
+ */
+class TMessageId : public TBaseId
+{
+public:
+ inline TMessageId() : TBaseId(), iFolderId(){}
+
+ inline TMessageId( TEntryId aMsgId, TEntryId aFolderId, TMailboxId aMailboxId ) :
+ TBaseId( aMsgId ), iFolderId( aFolderId, aMailboxId ){}
+
+ inline TBool operator==( const TMessageId& aMessageId ) const {
+ return ( iFolderId == aMessageId.iFolderId &&
+ iId == aMessageId.iId ); }
+
+ inline TBool operator!=( const TMessageId& aMessageId ) const {
+ return !( aMessageId == *this ); }
+
+ /**
+ * parent folder id.
+ */
+ TFolderId iFolderId;
+};
+
+
+/**
+ * Message content (part) id
+ * @since S60 v5.0
+ */
+class TMessageContentId : public TBaseId
+{
+public:
+ inline TMessageContentId(): TBaseId(), iMessageId() {}
+
+ inline TMessageContentId( TEntryId aContentId, TEntryId aMsgId, TEntryId aFolderId, TMailboxId aMailboxId ) :
+ TBaseId( aContentId ), iMessageId( aMsgId, aFolderId, aMailboxId ){}
+
+ inline TBool operator==( const TMessageContentId& aContentId ) const {
+ return ( iMessageId == aContentId.iMessageId &&
+ iId == aContentId.iId ); }
+
+ inline TBool operator!=( const TMessageContentId& aContentId ) const {
+ return !( aContentId == *this ); }
+
+ // parent message
+ TMessageId iMessageId;
+};
+
+typedef RArray REmailMessageIdArray;
+
+typedef RArray REmailFolderIdArray;
+
+typedef RArray REmailMailboxIdArray;
+
+} // EmailInterface
+
+#endif // __EMAILAPIDEFS
diff -r 780f926bc26c -r f83bd4ae1fe3 email_plat/email_client_api/emailclientapi.hrh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/emailclientapi.hrh Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,44 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Interface IDs for sub interfaces
+*
+*/
+
+#ifndef __EMAILCLIENTAPI_HRH
+#define __EMAILCLIENTAPI_HRH
+
+// ECom interface UID for email API
+#define KEmailClientFactoryApiUid 0x20022D62
+
+
+// Interface ids (not ECom) for accessing "sub interfaces" via
+// MEmailInterface* CEmailInterfaceFactory::InterfaceL( const TInt aInterfaceId )
+// to be checked if all should be published to clients (some are not
+// meant to be instantiated via factory method but by other means, e.g.
+// user never instantiates mailbox from scratch but asks it from MEmailClientApi
+
+#define KEmailClientApiInterface 0x20022D63
+#define KEmailIFUidMailbox 0x20022D64
+#define KEmailIFUidMessage 0x20022D65
+#define KEmailIFUidFolder 0x20022D66
+#define KEmailIFUidAddress 0x20022D67
+#define KEmailIFUidMessageContent 0x20022D68
+#define KEmailIFUidSearch 0x20022D69
+#define KEmailIFUidTextContent 0x20022D6B
+#define KEmailIFUidMessageIterator 0x20022D6C
+#define KEmailIFUidMultipart 0x20022D6D
+#define KEmailIFUidAttachment 0x20022D6E
+
+
+#endif // __EMAILCLIENTAPI_HRH
diff -r 780f926bc26c -r f83bd4ae1fe3 email_plat/email_client_api/emailinterfacefactory.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/emailinterfacefactory.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,119 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: ECom interface for Email Client API
+*
+*/
+
+
+#ifndef CEMAILINTERFACEFACTORY_H
+#define CEMAILINTERFACEFACTORY_H
+
+#include
+#include
+#include
+#include
+
+namespace EmailInterface {
+
+/**
+ * ECom factory class for Email Client API.
+ * @since S60 v5.0
+ *
+ */
+NONSHARABLE_CLASS( CEmailInterfaceFactory ) : public CBase
+{
+public:
+
+ /**
+ * Contructor
+ * @return factory for creating interface instances.
+ */
+ inline static CEmailInterfaceFactory* NewL();
+
+ /**
+ * destructor
+ */
+ inline ~CEmailInterfaceFactory();
+
+ /**
+ * Returns email interface pointer by id
+ * @param aInterfaceId interface id, see emailclientapi.hrh for available ids
+ * @return pointer to interface
+ * @exception KErrNotFound if unkown interface id is given
+ *
+ * @code
+
+ #include
+
+ using namespace EmailInterface;
+
+ CEmailInterfaceFactory* factory = CEmailInterfaceFactory::NewL();
+ CleanupStack::PushL( factory );
+ MEmailInterface* ifPtr = factory->InterfaceL( KEmailClientApiInterface );
+ MEmailClientApi* clientApi = static_cast( ifPtr );
+ CleanupReleasePushL( *clientApi );
+ //
+ CleanupStack::PopAndDestroy( 2 ); // clientApi and factory
+ @endcode
+ *
+ */
+ virtual EmailInterface::MEmailInterface* InterfaceL(
+ const TInt aInterfaceId ) = 0;
+
+private:
+
+ // Unique instance identifier key
+ TUid iDtor_ID_Key;
+};
+
+
+/**
+ * Cleanup support for pointer arrays with MEmailInterface elements which are
+ * destroyed with Release() method.
+ * @since S60 v5.0
+ @code
+ using namespace EmailInterface;
+
+ RMailboxPtrArray mailboxes; // array of MEmailMailbox pointers
+ // note: PushL can take any pointer array of elements with Release()
+ // method
+ CleanupResetAndRelease::PushL( mailboxes );
+ //
+ mailClient->GetMailboxesL( mailboxes );
+
+ // MEmailMailbox::Release() called for each array element and then
+ // mailboxes.Reset() is called
+ CleanupStack::PopAndDestroy();
+ @endcode
+ */
+template
+NONSHARABLE_CLASS( CleanupResetAndRelease )
+{
+public:
+ /**
+ * Cleanup for elements containing Release() method
+ */
+ inline static void PushL( RPointerArray& aItem );
+
+ /**
+ * Releases array elements and resets array.
+ */
+ inline static void ResetAndRelease( TAny* aPtr );
+};
+
+#include "emailinterfacefactory.inl"
+
+} // namespace EmailInterface
+
+#endif // CEMAILINTERFACEFACTORY_H
diff -r 780f926bc26c -r f83bd4ae1fe3 email_plat/email_client_api/emailinterfacefactory.inl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/emailinterfacefactory.inl Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,90 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: ECom interface for email interface factory inline implementation
+*
+*/
+
+#include "emailclientapi.hrh"
+
+// LOCAL FUNCTIONS
+
+inline void ResetAndDestroyCleanup( TAny* aAny )
+ {
+ RImplInfoPtrArray* ptrArray = reinterpret_cast( aAny );
+ ptrArray->ResetAndDestroy();
+ }
+
+inline void CleanupResetAndDestroyPushL( RImplInfoPtrArray& aArray )
+ {
+ TCleanupItem item( &ResetAndDestroyCleanup, &aArray );
+ CleanupStack::PushL( item );
+ }
+
+// ============================= MEMBER FUNCTIONS =============================
+
+// ----------------------------------------------------------------------------
+// CEmailInterfaceFactory::NewL
+// Two-phased constructor
+// ----------------------------------------------------------------------------
+//
+inline CEmailInterfaceFactory* CEmailInterfaceFactory::NewL( )
+ {
+ // Find implementation for our interface.
+ RImplInfoPtrArray implArray;
+ EmailInterface::CleanupResetAndDestroyPushL( implArray );
+ const TUid ifUid = {KEmailClientFactoryApiUid};
+ REComSession::ListImplementationsL(
+ ifUid,
+ implArray );
+ // there should be only one impl so take first
+ TAny* interface = NULL;
+ if ( implArray.Count() )
+ {
+ const TUid uid = implArray[0]->ImplementationUid();
+ interface = REComSession::CreateImplementationL(
+ uid, _FOFF( CEmailInterfaceFactory, iDtor_ID_Key ) );
+ }
+ CleanupStack::PopAndDestroy(); // implArray
+
+ return reinterpret_cast( interface );
+ }
+
+// ----------------------------------------------------------------------------
+// CEmailInterfaceFactory::~CEmailInterfaceFactory
+// Destructor
+// ----------------------------------------------------------------------------
+//
+inline CEmailInterfaceFactory::~CEmailInterfaceFactory()
+ {
+ REComSession::DestroyedImplementation( iDtor_ID_Key );
+ }
+
+template
+inline void CleanupResetAndRelease::PushL( RPointerArray& aItem ) {
+ TCleanupItem item( &CleanupResetAndRelease::ResetAndRelease, &aItem );
+ CleanupStack::PushL( item );
+ }
+template
+inline void CleanupResetAndRelease::ResetAndRelease( TAny* aPtr )
+ {
+ RPointerArray* array = reinterpret_cast* >( aPtr );
+ for ( TInt i = 0; i < array->Count(); i++ )
+ {
+ T* item = (*array)[i];
+ item->Release();
+ }
+ array->Reset();
+ }
+
+// End Of File
diff -r 780f926bc26c -r f83bd4ae1fe3 email_plat/email_client_api/emailsorting.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/emailsorting.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,61 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Email Client sort criteria definition
+*
+*/
+
+#ifndef EMAILSORTING
+#define EMAILSORTING
+
+#include
+
+namespace EmailInterface {
+
+/**
+* Sort criteria used in searching messages with MEmailMessageSearchAsync
+* declared in memailmessagesearch.h.
+*/
+class TEmailSortCriteria
+{
+public:
+ /**
+ * Fields for sort criteria
+ */
+ enum TSortField {
+ EDontCare,
+ EByDate,
+ EBySender,
+ EByRecipient,
+ EBySubject,
+ EByPriority,
+ EByFlagStatus,
+ EByUnread,
+ EBySize,
+ EByAttachment,
+ };
+
+ // is ascending sort order
+ TBool iAscending;
+
+ // sort by field
+ TSortField iField;
+
+ inline TEmailSortCriteria() : iAscending( ETrue ), iField( EDontCare ) {}
+};
+
+typedef RArray RSortCriteriaArray;
+
+} // EmailInterface
+
+#endif // EMAILSORTING
diff -r 780f926bc26c -r f83bd4ae1fe3 email_plat/email_client_api/memailaddress.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/memailaddress.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,91 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Email address in Email Client API
+*
+*/
+
+#ifndef MEMAILADDRESS_H
+#define MEMAILADDRESS_H
+
+#include
+
+namespace EmailInterface {
+
+/**
+ * Email address that is used as recipient or sender in MEmailMessage and
+ * mailbox address in MEmailMailbox.
+ * @since S60 v5.0
+ */
+class MEmailAddress : public MEmailInterface
+{
+public:
+ /**
+ * Association role of the address in message/mailbox.
+ */
+ enum TRole {
+ // role is undefined
+ EUndefined,
+ // reply-to address in a message
+ EReplyTo,
+ // sender of a message
+ ESender,
+ // to-recipient of a message
+ ETo,
+ // cc-recipient of a message
+ ECc,
+ // bcc-recipient of a message
+ EBcc };
+
+ /**
+ * Sets email address
+ * @param email address
+ */
+ virtual void SetAddressL( const TDesC& aAddress ) = 0;
+
+ /**
+ * Returns email address
+ * @return email address
+ */
+ virtual TPtrC Address() const = 0;
+
+ /**
+ * Sets display name for the address
+ * @param display name
+ */
+ virtual void SetDisplayNameL( const TDesC& aDisplayName ) = 0;
+
+ /**
+ * Returns display name for the address
+ * @return display name
+ */
+ virtual TPtrC DisplayName() const = 0;
+
+ /**
+ * Returns role associated with the address
+ * @return role
+ */
+ virtual TRole Role() const = 0;
+
+ /**
+ * Sets role
+ * @param role
+ */
+ virtual void SetRole( const TRole aRole ) = 0;
+};
+
+typedef RPointerArray REmailAddressArray;
+
+} // namespace EmailInterface {
+
+#endif // MEMAILADDRESS_H
\ No newline at end of file
diff -r 780f926bc26c -r f83bd4ae1fe3 email_plat/email_client_api/memailclientapi.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/memailclientapi.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,78 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: ECom interface for Email Client API
+*
+*/
+
+
+#ifndef MEMAILCLIENTAPI_H
+#define MEMAILCLIENTAPI_H
+
+#include
+
+namespace EmailInterface {
+
+class MEmailMailbox;
+
+
+typedef RPointerArray RMailboxPtrArray;
+
+/**
+ * Email client main interface for accessing mailboxes and launching
+ * email editor and viewer.
+ * Use CEmailInterfaceFactory::InterfaceL( KEmailClientApiInterface )
+ * to get instance. Use Release() (from MEmailInterface) when the instance
+ * is no more needed.
+ *
+ */
+class MEmailClientApi : public MEmailInterface
+{
+public:
+
+ /** returns mailbox by id, ownership transferred */
+ virtual MEmailMailbox* MailboxL( const TMailboxId& aId ) = 0;
+
+ /**
+ * Conveninence method for accessing mailbox by own addresss.
+ */
+ virtual MEmailMailbox* MailboxL( const TPtrC& aAddress ) = 0;
+
+ /**
+ * Gets all mailboxes in pointer array. It is recommended to free other
+ * mailboxes besides needed one to optimise memory usage.
+ */
+ virtual TInt GetMailboxesL( RMailboxPtrArray& aMailboxes ) = 0;
+
+ /**
+ * Launch policy defines behavior when launching email application
+ */
+ enum TLaunchPolicy {
+ // Launch email application as from menu application by the user
+ EDefault,
+ // Shows inbox with unseen messages. If there are no unseen messages
+ // behavior is same as EDefault. This one is not currently supported.
+ EShowLastUnseenMailbox
+ };
+ /**
+ * Launches Email application with defined launch behavior
+ * The method follows "fire and forget" pattern, returns immediately.
+ * @param aPolicy defines behavior for app launch
+ */
+ virtual void LaunchEmailL( const TLaunchPolicy aPolicy ) = 0;
+
+};
+
+} // namespace EmailInterface
+
+#endif // MEMAILCLIENTAPI_H
diff -r 780f926bc26c -r f83bd4ae1fe3 email_plat/email_client_api/memailcontent.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/memailcontent.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,289 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: ECom interface for Email Client API
+*
+*/
+
+#ifndef MEMAILCONTENT_H
+#define MEMAILCONTENT_H
+
+#include
+
+namespace EmailInterface {
+
+_LIT( KContentTypeTextPlain, "text/plain" );
+_LIT( KContentTypeTextHtml, "text/html" );
+
+class MEmailOperationObserver;
+class MEmailAttachment;
+class MEmailMultipart;
+class MEmailTextContent;
+class MEmailMessageContent;
+
+/**
+* Callback interface used for content fetching asynchronously.
+* Object deriving this interface is passed to MEmailMessageContent::FetchL
+* @since S60 v5.0
+*/
+class MEmailFetchObserver
+{
+public:
+ /** Content fetched
+ * @param operation result
+ */
+ virtual void DataFetchedL( const TInt aResult ) = 0;
+};
+
+typedef RPointerArray REmailContentArray;
+
+/**
+* Base interface for mime message parts.
+* @since S60 v5.0
+*/
+class MEmailMessageContent : public MEmailInterface
+{
+public:
+ /** numeric identifier of message content */
+ virtual TMessageContentId Id() const = 0;
+
+// fields as per RFC 2045
+ /**
+ * return sContent-Type field value
+ */
+ virtual TPtrC ContentType() const = 0;
+
+ /**
+ * sets value of Content-Type field
+ * @param content type
+ */
+ virtual void SetContentType( const TDesC& aContentType ) = 0;
+
+ /**
+ /* Returns Content-ID field value.
+ * @return content id
+ */
+ virtual TPtrC ContentId() const = 0;
+
+ /**
+ * Sets value of Content-ID field
+ * @param content id
+ */
+ virtual void SetContentId( const TDesC& aContentId ) = 0;
+
+ /**
+ * Returns value of content-description field
+ * @return content description
+ */
+ virtual TPtrC ContentDescription() const = 0;
+
+ /**
+ * Sets value of content description field
+ * @param content description
+ */
+ virtual void SetContentDescription( const TDesC& aContentDescription ) = 0;
+
+ /**
+ * Returns value of content disposition field
+ * @return content disposition
+ */
+ virtual TPtrC ContentDisposition() const = 0;
+
+ /**
+ * Sets value of content-disposition field
+ * @param content disposition
+ */
+ virtual void SetContentDisposition( const TDesC& aContentDisposition ) = 0;
+
+// end of standard RFC 2045 fields
+
+ /**
+ * returns Content-class field value (non-standard)
+ */
+ virtual TPtrC ContentClass() const = 0;
+
+ /**
+ * Sets value of Content-class field (non-standard)
+ * @param content class
+ */
+ virtual void SetContentClass( const TDesC& aContentClass ) = 0;
+
+ /**
+ * Available (=fetched) size accessor. If this is less than value from
+ * TotalSize(), Fetch() should be used to retrieve more data from
+ * remote mail server.
+ * @return fetched size of the data.
+ */
+ virtual TInt AvailableSize() const = 0;
+
+ /**
+ * Total size accessor
+ * @return total size of message text.
+ */
+ virtual TInt TotalSize( ) const = 0;
+
+ /**
+ * Returns pointer descriptor to content data
+ */
+ virtual TPtrC ContentL() const = 0;
+
+ /**
+ * Sets content data.
+ */
+ virtual void SetContentL( const TDesC& aContent ) = 0;
+
+ /**
+ * Starts fetching rest of content asynchronously.
+ *
+ * If available size after fetch is smaller than total size, next chunk can
+ * be fetched with new invocatin of Fetch method.
+ *
+ * Calling Release() implicitly cancels fetching.
+ * @param aObserver called when when fetch completes.
+ * @exception KErrInUse if fetch is ongoing
+ */
+ virtual void FetchL( MEmailFetchObserver& aObserver ) = 0;
+
+ /**
+ * Cancels fetch operation, observer is not called
+ */
+ virtual void CancelFetch() = 0;
+
+ /**
+ * Stores message content to a file
+ */
+ virtual void SaveToFileL( const TDesC& aPath ) = 0;
+
+ /**
+ * Typesafe multipart accessor for obtaining MEmailMultipart pointer
+ * to this object.
+ * @param content as multipart or NULL if content is not multipart
+ */
+ virtual MEmailMultipart* AsMultipartOrNull() const = 0;
+
+ /**
+ * Typesafe text content accessor for obtaining MEmailTextContent pointer
+ * to this object.
+ * @param content as text content or NULL if content is not text
+ */
+ virtual MEmailTextContent* AsTextContentOrNull() const = 0;
+
+ /**
+ * Typesafe attachment content accessor for obtaining MEmailAttachment pointer
+ * to this object.
+ * @param content as attachment content or NULL if content is not an attachment
+ */
+ virtual MEmailAttachment* AsAttachmentOrNull() const = 0;
+};
+
+/**
+* Convenience abstraction for manipulating plain or html text content. Use
+* CEmailInterfaceFactory::InterfaceL( KEmailIFUidTextContent ) to make new
+* instance of this interface.
+* @since S60 v5.0
+*/
+class MEmailTextContent : public MEmailMessageContent
+{
+public:
+ /**
+ * Text (content) type
+ */
+ enum TTextType {
+ EPlainText, // text/plain
+ EHtmlText // text/html
+ };
+
+ /**
+ * Tells if content has specified type of text.
+ */
+ virtual TTextType TextType() const = 0;
+
+ /**
+ * Sets (replaces) text to message content. Possible old content is
+ * deleted. Content type is set to "text/plain" or "text/html" based on
+ * specified text type.
+ * @param aPlainOrHtml sub-type of the text
+ * @param aText content of the message part
+ */
+ virtual void SetTextL(
+ const TTextType aPlainOrHtml,
+ const TDesC& aText ) = 0;
+};
+
+/**
+* Message part with multiple sub parts. If MEmailMessage::ContentL returns
+* content with type "multipart/*" (where '*' is a character sequence) it can
+* safely be casted to MEmailMultipart
+* @since S60 v5.0
+*/
+class MEmailMultipart : public MEmailMessageContent
+{
+public:
+ /**
+ * Returns number of child parts
+ */
+ virtual TInt PartCountL() = 0;
+
+ /**
+ * Returns a child part, ownership is transferred.
+ * @param aIndex part to return, leaves KErrArgument if out of bounds
+ */
+ virtual MEmailMessageContent* PartByIndexL( const TUint aIndex ) const = 0;
+
+ /**
+ * Deletes part by index.
+ * @param aIndex part to delete, leaves KErrArgument if out of bounds
+ */
+ virtual void DeletePartL( const TUint aIndex ) = 0;
+
+ /**
+ * Adds message part, ownership is transferred.
+ * @param aPart any object derived from MEmailMessageContent
+ * @param aPos position among child parts
+ */
+ virtual void AddPartL(
+ const MEmailMessageContent& aPart,
+ const TUint aPos ) = 0;
+};
+
+typedef RPointerArray REmailAttachmentArray;
+
+/**
+* Email attachment interface
+* Attachment is created with MEmailMessage::AddAttachmentL()
+* @since S60 v5.0
+*/
+class MEmailAttachment : public MEmailMessageContent
+{
+public:
+ /**
+ * Returns file handle of this attachment. If the attachment is
+ * not associated with a file, null file handle is returned.
+ */
+ virtual RFile FileL() const = 0;
+
+ /**
+ * Sets file name field
+ */
+ virtual void SetFileNameL( const TDesC& aFileName ) = 0;
+
+ /**
+ * Returns file name or null pointer descriptor if attachment
+ * is not associated with any file
+ */
+ virtual TPtrC FileNameL() const = 0;
+};
+
+} // namespace EmailInterface
+
+#endif // MEMAILCONTENT_H
diff -r 780f926bc26c -r f83bd4ae1fe3 email_plat/email_client_api/memailfolder.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/memailfolder.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,107 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Email message API
+*
+*/
+
+#ifndef _M_EMAILFOLDER
+#define _M_EMAILFOLDER
+
+#include
+#include
+
+namespace EmailInterface {
+
+class MEmailFolder;
+class MMessageIterator;
+
+typedef RPointerArray RFolderArray;
+
+/**
+* folder types
+*/
+enum TFolderType
+ {
+ EInbox,
+ EOutbox,
+ EDrafts,
+ EDeleted,
+ ESent,
+ EOther
+ };
+
+/**
+* Email folder interface
+* This is used for accessing folder information and included messages.
+* Operations affecting folder itself are not provided.
+*
+* Use case: for accessing messages in specific folder use MEmailMessageQuery
+* and set folder id with MEmailMessageQuery::SetFolderIdL()
+*
+* @since S60 v5.0
+*/
+class MEmailFolder : public MEmailInterface
+{
+public:
+ /**
+ * Returns folder id.
+ * @return folder type
+ */
+ virtual TFolderId FolderId() const = 0;
+
+ /**
+ * Returns parent folder id.
+ * @return parent folder id
+ */
+ virtual TFolderId ParentFolderId() const = 0;
+
+ /**
+ * Returns folder type.
+ * @return folder type
+ */
+ virtual TFolderType FolderType() const = 0;
+
+ /**
+ * Returns folder name.
+ * @return folder name pointer descriptor
+ */
+ virtual TPtrC Name() const = 0;
+
+ /**
+ * Returns direct children of this folder, i.e. this is not recursive.
+ * @return number of subfolders or an error code
+ */
+ virtual TInt GetSubfoldersL(
+ RFolderArray& aSubfolders ) const = 0;
+
+ /**
+ * Returns message iterator for iterating messages in the folder
+ * @param aSortCriteria sort criteria
+ * @return message iterator
+ */
+ virtual EmailInterface::MMessageIterator* MessagesL(
+ const RSortCriteriaArray& aCriteria ) = 0;
+
+ /**
+ * Deletes messages in this folder
+ * @param aMessageIds messages to delete. This method is no-op if
+ * array is empty. It is expected that messages in the array are
+ * located in same folder or KErrArgument exception is raised.
+ */
+ virtual void DeleteMessagesL( const REmailMessageIdArray& aMessageIds ) = 0;
+};
+
+} // namespace EmailInterface
+
+#endif // _M_EMAILFOLDER
diff -r 780f926bc26c -r f83bd4ae1fe3 email_plat/email_client_api/memailmailbox.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/memailmailbox.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,159 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Email message API
+*
+*/
+
+#ifndef MEMAILMAILBOX_H
+#define MEMAILMAILBOX_H
+
+#include
+
+namespace EmailInterface {
+
+class MEmailAddress;
+class MEmailMessage;
+class MMailboxContentObserver;
+class MEmailMessageSearchAsync;
+class MMailboxSyncObserver;
+
+/**
+* Email mailbox interface.
+* MEmailMailbox cannot be instantiated with factory method. Use
+* MEmailClientApi::MailboxL to obtain a configured mailbox.
+* @since S60 v5.0
+*/
+class MEmailMailbox : public MEmailInterface
+{
+public:
+ /**
+ * Returns mailbox identifier
+ * @return mailbox id
+ */
+ virtual TMailboxId MailboxId() const = 0;
+
+ /**
+ * Returns own address of the mailbox. Role is set to ESender
+ * @return address, ownership not transferred
+ */
+ virtual MEmailAddress* AddressL() const = 0;
+
+ /**
+ * Returns mailbox name
+ * @return mailbox name
+ */
+ virtual TPtrC MailboxName() const = 0;
+
+ /** returns root level folders of this mailbox, to get subfolders of specific
+ * folder, use MEmailFolder::GetSubfolders
+ * @param aFolders pointer array of folders, ownership of folders is
+ * transferred
+ * @return number of folders in aFolders or Symbian OS error code
+ */
+ virtual TInt GetFoldersL( RFolderArray& aFolders ) const = 0;
+
+ /**
+ * Returns folder by folder id
+ * @param folder id
+ * @return pointer to folder, ownership is transferred
+ */
+ virtual MEmailFolder* FolderL( const TFolderId& aFolderId ) const = 0;
+
+ /**
+ * Returns folder by type
+ * @param type other than EOther because it is ambiguous
+ * @return pointer to folder, ownership is transferred
+ * @exception KErrNotFound if folder of requested type is not found
+ */
+ virtual MEmailFolder* FolderByTypeL(
+ const TFolderType aFolderType ) const = 0;
+
+ /**
+ * Returns existing message in this mailbox.
+ * @param aMessageId a message id returned by GetMessagesIdsL()
+ * @return new message object, ownership transferred.
+ * @exception
+ */
+ virtual MEmailMessage* MessageL( const TMessageId& aMessageId ) = 0;
+
+ /**
+ * Creates new message in 'drafts' folder. Ownership is transferred
+ * @return new draft message
+ */
+ virtual MEmailMessage* CreateDraftMessageL() const = 0;
+
+ /**
+ * Creates reply message. Ownership is transferred
+ * @param aMessageId original message
+ * @param aReplyToAll If ETrue, all recipients of the original message are
+ * added to reply message.
+ * @return new draft message
+ */
+ virtual MEmailMessage* CreateReplyMessageL(
+ const TMessageId& aMessageId,
+ const TBool aReplyToAll = ETrue ) const = 0;
+
+ /**
+ * Creates forward message. Ownership is transferred
+ * @param aMessageId original message
+ * @return new draft message
+ */
+ virtual MEmailMessage* CreateForwardMessageL(
+ const TMessageId& aMessageId ) const = 0;
+
+ /**
+ * Starts synchronising this mailbox
+ * @param aObserver observer called back when sync is complete
+ */
+ virtual void SynchroniseL( MMailboxSyncObserver& aObserver ) = 0;
+
+ /**
+ * Cancels mailbox synchronisation.
+ */
+ virtual void CancelSynchronise() = 0;
+
+ /**
+ * Returns interface for searching messages from this mailbox. Ownership
+ * is transferred.
+ * @return message search interface pointer
+ */
+ virtual MEmailMessageSearchAsync* MessageSearchL() = 0;
+
+ /**
+ * Launches Email application and shows inbox.
+ * The method follows "fire and forget" pattern, returns immediately.
+ */
+ virtual void ShowInboxL() = 0;
+
+ /** Launches email editor and returns immediately.
+ * The method follows "fire and forget" pattern, returns immediately.
+ */
+ virtual void EditNewMessageL() = 0;
+
+ /** Register mailbox observer
+ * @param aObserver observer called back when changes in mailbox (new message,
+ * messages changes or messages deleted).
+ * */
+ virtual void RegisterObserverL( MMailboxContentObserver& aObserver ) = 0;
+
+ /**
+ * Unregister mailbox observe.r
+ */
+ virtual void UnregisterObserver( MMailboxContentObserver& aObserver ) = 0;
+
+};
+
+} // namespace EmailInterface
+
+#endif // MEMAILMAILBOX_H
diff -r 780f926bc26c -r f83bd4ae1fe3 email_plat/email_client_api/memailmessage.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/memailmessage.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,262 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Email message API
+*
+*/
+
+#ifndef MEMAILMESSAGE_H
+#define MEMAILMESSAGE_H
+
+#include
+#include
+#include
+
+namespace EmailInterface {
+
+class MEmailMessageContent;
+class MEmailAttachment;
+
+/** message flags */
+enum TMsgFlag
+ {
+ EFlag_Read = 1, // Message is read (or "seen") on the server
+ EFlag_Read_Locally = 2, // Message is read on the client
+ EFlag_Low = 4, // Message has low priority
+ EFlag_Important = 8, // Message has high priority
+ EFlag_FollowUpComplete = 16, // The message follow-up is complete
+ EFlag_FollowUp = 32, // Message is flagged (a flag is showing next to msg in Outlook)
+ EFlag_Attachments = 64, // Message has attachments
+ EFlag_Multiple = 128, // Message has more than one recipient
+ EFlag_CalendarMsg = 256, // Message is a calendar message
+ EFlag_Answered = 512, // The message was replied to
+ EFlag_Forwarded = 1024, // The message was forwarded
+ EFlag_OnlyToMe = 2048, // The message was sent only to this user
+ EFlag_RemoteDeleted = 4096, // The message has been deleted on the server
+ EFlag_HasMsgSender = 8192, // The message has one or more senders
+ };
+/**
+ * MEmailMessage is email message abstraction
+ * @since S60 v5.0
+ @code
+ Create and send a message with attachment:
+
+ using namespace EmailInterface;
+ CEmailInterfaceFactory* factory = CEmailInterfaceFactory::NewL();
+ CleanupStack::PushL( factory );
+ MEmailClientApi* emailAPI = factory->InterfaceL( KEmailTypeClientAPI );
+ CleanupReleasePushL( *emailAPI );
+ RMailboxPtrArray mailboxes;
+ // Cleanup for array containing mailbox pointers,
+ // calls MEmailMailbox::Release() on cleanup.
+ CleanupResetAndRelease::PushL( mailboxes );
+ if ( emailAPI->GetMailboxesL( mailboxes ) > 0 ) // at least one found
+ {
+ MEmailMailbox* mailbox = mailboxes[0];
+ MEmailMessage* message = mailbox->CreateDraftMessageL();
+ CleanupReleasePushL( *message );
+ message->SetPlainTextBodyL( _L("So say we all!") );
+ message->AddAttachmentL( _L( "BSG.png" ) );
+ message->SendL();
+ CleanupStack::PopAndDestroy(); // message
+ }
+ CleanupStack::PopAndDestroy( 3 ); // mailboxes, emailAPI, factory
+ @endcode
+ *
+ */
+class MEmailMessage : public MEmailInterface
+{
+public:
+ /**
+ * Returns message id
+ * @return message id
+ */
+ virtual const TMessageId& MessageId() const = 0;
+
+ /**
+ * Returns sender address, ownership is not transferred
+ * Setting role to MEmailAddress::EUndefined marks sender field "undefined"
+ */
+ virtual MEmailAddress* SenderAddressL() const = 0;
+
+ /**
+ * Returns reply-to address (NULL for newly created draft message).
+ * Ownership is not transferred. Setting role to MEmailAddress::EUndefined
+ * marks reply-to field "undefined".
+ */
+ virtual MEmailAddress* ReplyToAddressL() const = 0;
+
+ /**
+ * Sets reply-to address, note that role of the address is ignored.
+ * Ownership is not transferred.
+ */
+ virtual void SetReplyToAddressL( const MEmailAddress& aSender ) = 0;
+
+ /**
+ * Returns recipients. Ownership is transferred.
+ * @param aRole, if EUndefined - returns to,cc and bcc recipients in that order
+ * @return number of recipients returned in array
+ * @exception returns KErrArgument if aRole is EReplyTo or ESender
+ */
+ virtual TInt GetRecipientsL( const MEmailAddress::TRole aRole,
+ REmailAddressArray& aRecipients ) const = 0;
+
+ /**
+ * Sets and replaces recipients of specific type.
+ * @param aRole to, cc or bcc, for other types leave KErrArgument
+ * @return recipient added to this message. Ownership is not transferred.
+ */
+ virtual void SetRecipientsL( const MEmailAddress::TRole aRole, REmailAddressArray& aRecipients ) = 0;
+
+ /** removes recipient from the message
+ * @param aRecipient that has been obtained by GetRecipients().
+ * Comparison of recipients and aRecipient is done based on
+ * MEmailAddress::Address() and MEmailAddress::Role().
+ * @exception KErrNotFound if aRecipient doesn't match with existing
+ * recipients.
+ */
+ virtual void RemoveRecipientL( const MEmailAddress& aRecipient ) = 0;
+
+ /**
+ * Returns subject
+ * @return subject of the message
+ */
+ virtual TPtrC Subject() const = 0;
+
+ /**
+ * Sets subject
+ * @param subject of the message
+ */
+ virtual void SetSubjectL( const TPtrC& aSubject) = 0;
+
+ /**
+ * Returns date and time of the message.
+ * @return message date/time
+ */
+ virtual TTime Date() const = 0;
+
+ /**
+ * Returns message flags
+ * @return message flags
+ */
+ virtual TInt Flags() const = 0;
+
+ /**
+ * Sets a message flag
+ * @param flag to set
+ */
+ virtual void SetFlag( const TUint aFlag ) = 0;
+
+ /**
+ * Resets a message flag to zero
+ * @param flag to reset
+ */
+ virtual void ResetFlag( const TUint aFlag ) = 0;
+
+// content
+ /**
+ * Returns message body
+ * Returns pointer to message content, ownership not transferred.
+ * Actual type is MEmailTextContent, or MEmailMultipart (see memailcontent.h)
+ * @return content of the message or NULL if content has not been set
+ */
+ virtual MEmailMessageContent* ContentL() const = 0;
+
+ /**
+ * Sets content to this message. First create content object, e.g.
+ * CEmailInterfaceFactory::InterfaceL( KEmailIFUidTextContent ), i.e. text/plain
+ * @param aContent content to set in the message, ownership is transferred.
+ * possible old content is destroyed if setting new content succeeds.
+ */
+ virtual void SetContentL( const MEmailMessageContent* aContent ) = 0;
+
+ /**
+ * Convenience method for setting plain text as message body.
+ * @param aPlainText text/plain content of message body. Old content
+ * is destroyed.
+ */
+ virtual void SetPlainTextBodyL( const TDesC& aPlainText ) = 0;
+
+ /**
+ * Adds attachment to message. This may affect previously set content, e.g.
+ * if SetContentL with MEmailTextContent argument was called, a new multipart
+ * content is created with MEmailTextContent and attachment as child parts.
+ * @param aFullpath path to file
+ * @return created attachment, ownership is not transferred
+ */
+ virtual MEmailAttachment* AddAttachmentL( const TDesC& aFullPath ) = 0;
+
+ /**
+ * Adds attachment to message. This may affect previously set content, e.g.
+ * if SetContentL with MEmailTextContent argument was called, a new multipart
+ * content is created with MEmailTextContent and attachment as child parts.
+ * @param file handle to file to be attached. Handle remains open.
+ * @return created attachment, ownership is not transferred
+ */
+ virtual MEmailAttachment* AddAttachmentL( RFile& aFile ) = 0;
+
+ /**
+ * Returns attachments, ownership is transferred
+ * @return number of attachments in aAttachments
+ */
+ virtual TInt GetAttachmentsL( REmailAttachmentArray& aAttachments ) = 0;
+
+ /**
+ * Remove an attachment, ownership is not transferred.
+ * @param attachment object obtained with GetAttachmentsL
+ */
+ virtual void RemoveAttachmentL( const MEmailAttachment& aAttachment ) = 0;
+
+ /**
+ * Returns id of parent folder of the message
+ * @return parent folder id
+ */
+ virtual const TFolderId& ParentFolderId() const = 0;
+
+ /**
+ * Saves changes done with any mutator to persistent store.
+ */
+ virtual void SaveChangesL() = 0;
+
+ /**
+ * Moves message to outbox, sending may not happen immediately but
+ * after next mailbox synchronization. Changes done to the message
+ * are first saved before sending as if SaveChangesL was called.
+ * For immediate sending use MEmailMailbox::SynchronizeL()
+ */
+ virtual void SendL() = 0;
+
+ /**
+ * Launches Email application and opens message in viewer
+ * The method follows "fire and forget" pattern, returns immediately.
+ */
+ virtual void ShowMessageViewerL( ) = 0;
+
+ /**
+ * Launches Email application and new reply message in editor.
+ * The method follows "fire and forget" pattern, returns immediately.
+ * @param boolean indicating if reply-to message is sent to all recipients.
+ */
+ virtual void ReplyToMessageL( const TBool aReplyToAll = ETrue ) = 0;
+
+ /**
+ * Launches Email application and new forward message in editor
+ * The method follows "fire and forget" pattern, returns immediately.
+ */
+ virtual void ForwardMessageL() = 0;
+
+};
+
+} // namespace EmailInterface
+
+#endif // MEMAILMESSAGE_H
diff -r 780f926bc26c -r f83bd4ae1fe3 email_plat/email_client_api/memailmessagesearch.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/memailmessagesearch.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,133 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: ECom interface for Email Client API
+*
+*/
+
+#ifndef __MEMAILACTIONS
+#define __MEMAILACTIONS
+
+#include
+#include
+
+namespace EmailInterface {
+
+class MMessageIterator;
+class TEmailSortCriteria;
+
+/**
+* Observer interface for handling email search results.
+*/
+class MEmailSearchObserver
+{
+public:
+ /**
+ * Called when search has next message available.
+ * This callback is called several times until all results
+ * have been delivered.
+ *
+ * @param message found in search, ownership is transferred.
+ *
+ */
+ virtual void HandleResultL(
+ MEmailMessage* aMessage ) = 0;
+
+ /**
+ * Notifies that the search has completed and no more results are expected.
+ */
+ virtual void SearchCompletedL() = 0;
+};
+
+/**
+ * Search interface for messages. Results are provided asynchronoysly.
+ * By default all found mailboxes are included in search.
+ * @code
+
+ MEmailMailbox* mailbox = NULL;
+ // obtain mailbox here...
+ // ...and now get search interface
+ MEmailMessageSearchAsync* search = mailbox->MessageSearchL();
+ CleanupReleasePushL( *search );
+ TEmailSortCriteria criteria;
+ criteria.iAscending = ETrue;
+ criteria.iField = TEmailSortCriteria::EByDate;
+ search->SetSortCriteriaL( criteria );
+ search->StartSearchL( *this ); // this implements MEmailSearchObserver
+ search->Cancel(); // cancel search
+ CleanupStack::PopAndDestroy(); // search
+
+ @endcode
+
+ * @since S60 v5.0
+ */
+class MEmailMessageSearchAsync : public MEmailInterface
+{
+public:
+
+ /**
+ * Sets sort order for search results.
+ * Leaves KErrNotReady if search is ongoing.
+ */
+ virtual void SetSortCriteriaL( const TEmailSortCriteria& aCriteria ) = 0;
+
+ /**
+ * Adds a search key. Leaves KErrNotReady if search is ongoing.
+ */
+ virtual void AddSearchKeyL( const TDesC& aSearchKey ) = 0;
+
+ /**
+ * Enables/disables search from remote email server.
+ * Leaves KErrNotReady if search is ongoing.
+ */
+ virtual void SetRemoteSearchL( TBool aRemote ) = 0;
+
+ /**
+ * Indicates whether remote search is enabled.
+ */
+ virtual TBool IsRemoteSearch() const = 0;
+
+ /**
+ * Starts search, all methods affecting search attribures leave
+ * KErrNotReady while search is ongoing.
+ * @param aObserver called when results are available.
+ */
+ virtual void StartSearchL( MEmailSearchObserver& aObserver ) = 0;
+
+ /**
+ * Cancels search.
+ */
+ virtual void Cancel() = 0;
+
+ /** returns search status
+ * @return search status:
+ * < 0 : Search has failed
+ * KRequestPending : search is ongoing. note that status may be
+ * KRequestPending after HandleResultL callback because results
+ * may be given in chunks of results. Size of chunk depends on
+ * implementation and may vary.
+ * KErrNone : initial state, or search has finished
+ */
+ virtual TInt Status() const = 0;
+
+ /**
+ * Resets all search attribures. Cancels search if ongoing.
+ */
+ virtual void Reset() = 0;
+};
+
+} //EmailInterface
+
+#endif // __MEMAILACTIONS
+
+// End of file.
diff -r 780f926bc26c -r f83bd4ae1fe3 email_plat/email_client_api/mmailboxcontentobserver.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/mmailboxcontentobserver.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,37 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Observer interface for mailbox events.
+*
+*/
+
+#ifndef MMAILBOXCONTENTOBSERVER_H
+#define MMAILBOXCONTENTOBSERVER_H
+
+#include
+
+namespace EmailInterface {
+
+class MMailboxContentObserver
+{
+public:
+ virtual void NewMessageEventL( const TMailboxId& aMailbox, const REmailMessageIdArray aNewMessages, const TFolderId& aParentFolderId ) = 0;
+
+ virtual void MessageChangedEventL( const TMailboxId& aMailbox, const REmailMessageIdArray aChangedMessages, const TFolderId& aParentFolderId ) = 0;
+
+ virtual void MessageDeletedEventL( const TMailboxId& aMailbox, const REmailMessageIdArray aDeletedMessages, const TFolderId& aParentFolderId ) = 0;
+};
+
+} // namespace EmailInterface
+
+#endif // MMAILBOXCONTENTOBSERVER_H
diff -r 780f926bc26c -r f83bd4ae1fe3 email_plat/email_client_api/mmailboxsyncobserver.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/mmailboxsyncobserver.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,33 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Observer interface for mailbox synchronisation.
+*
+*/
+
+#ifndef MEMAILSYNCOBSERVER_H
+#define MEMAILSYNCOBSERVER_H
+
+#include
+
+namespace EmailInterface {
+
+class MMailboxSyncObserver
+{
+public:
+ virtual void MailboxSynchronisedL( TInt aResult ) = 0;
+};
+
+} // namespace EmailInterface
+
+#endif // MEMAILSYNCOBSERVER_H
diff -r 780f926bc26c -r f83bd4ae1fe3 email_plat/email_client_api/mmessageiterator.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/email_client_api/mmessageiterator.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,56 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Message iterator interface
+*
+*/
+
+#ifndef MMESSAGEITERATOR_H
+#define MMESSAGEITERATOR_H
+
+#include
+
+namespace EmailInterface {
+
+class MEmailMessage;
+
+/**
+ * Iterator for email messages.
+ * @since S60 v5.0
+ */
+class MMessageIterator : public MEmailInterface
+{
+public:
+ /**
+ * Returns next message. When all messages are iterated, returns NULL
+ * @return next message. Ownership is not transferred.
+ */
+ virtual MEmailMessage* NextL() = 0;
+
+ /**
+ * Returns previous message. When first message is reached, returns NULL
+ * @return previous message. Ownership not is transferred.
+ */
+ virtual MEmailMessage* PreviousL() = 0;
+
+ /**
+ * Returns amount of messages accessible from the iterator.
+ * @return message count
+ */
+ virtual TUint Count() const = 0;
+
+};
+
+} // EmailInterface
+
+#endif // MMESSAGEITERATOR_H
diff -r 780f926bc26c -r f83bd4ae1fe3 email_plat/email_plat.pro
--- a/email_plat/email_plat.pro Fri Jun 11 16:42:02 2010 +0300
+++ b/email_plat/email_plat.pro Thu Jun 24 14:32:18 2010 +0300
@@ -19,6 +19,7 @@
symbian*: {
include(email_services_api/email_services_api.pri)
-
+ include(nmail_settings_api/nmail_settings_api.pri)
include(nmail_client_api/nmail_client_api.pri)
+ include(email_client_api/email_client_api.pri)
}
diff -r 780f926bc26c -r f83bd4ae1fe3 email_plat/nmail_client_api/nmapimessagemanager.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/nmail_client_api/nmapimessagemanager.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,84 @@
+/*
+ * 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * Email message related operations
+ */
+
+#ifndef NMAPIMESSAGEMANAGER_H_
+#define NMAPIMESSAGEMANAGER_H_
+
+#include
+#include
+
+#include
+
+struct NmApiMessage;
+class NmApiEmailMessage;
+
+namespace EmailClientApi {
+
+class NmApiFolder;
+class NmApiMessageManagerPrivate;
+
+class NMAPI_EXPORT NmApiMessageManager : public QObject
+{
+ Q_OBJECT
+
+public:
+ NmApiMessageManager(quint64 mailboxId,QObject *parent = 0);
+
+ virtual ~NmApiMessageManager();
+
+public slots:
+ bool createDraftMessage(const QVariant *initData);
+
+ bool createForwardMessage(const QVariant *initData);
+
+ bool createReplyMessage(const QVariant *initData,bool replyAll);
+
+ bool moveMessages(const QList messageIds,
+ quint64 sourceFolderId,quint64 targetFolderId);
+
+ bool copyMessages(const QList messageIds,
+ quint64 sourceFolder,
+ quint64 targetFolder);
+
+ bool saveMessage(const ::NmApiMessage &message);
+
+ bool deleteMessages(const QList messageIds);
+
+ bool fetch(const NmApiMessage &message);
+
+ bool send(const NmApiMessage &message);
+
+ bool createAttachment(NmApiEmailMessage &message,const QVariant &attachmenSpec);
+
+ bool removeAttachment(NmApiEmailMessage &message,quint64 attachmentId);
+
+signals:
+ void messagesCopied(int result);
+
+ void messagesCreated(int result);
+
+ void messagesMoved(int result);
+
+ void messagesDeleted(int result);
+
+private:
+ NmApiMessageManagerPrivate *d;
+};
+
+}
+
+#endif
diff -r 780f926bc26c -r f83bd4ae1fe3 email_plat/nmail_settings_api/nmail_settings_api.pri
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/nmail_settings_api/nmail_settings_api.pri Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,24 @@
+#
+# 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"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+#
+
+symbian*: {
+ # Build.inf rules
+ BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include " \
+ "nmail_settings_api/nmapimailboxsettingsdata.h APP_LAYER_PLATFORM_EXPORT_PATH(nmapimailboxsettingsdata.h)" \
+ "nmail_settings_api/nmapimailboxsettings.h APP_LAYER_PLATFORM_EXPORT_PATH(nmapimailboxsettings.h)"
+
+}
diff -r 780f926bc26c -r f83bd4ae1fe3 email_plat/nmail_settings_api/nmapimailboxsettings.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/nmail_settings_api/nmapimailboxsettings.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,55 @@
+/*
+ * 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef NMAPIMAILBOXSETTINGS_H_
+#define NMAPIMAILBOXSETTINGS_H_
+
+#include
+#include
+
+#include
+
+namespace EmailClientApi
+{
+
+class NmApiMailboxSettingsData;
+class NmApiMailboxSettingsPrivate;
+class NMAPI_EXPORT NmApiMailboxSettings : public QObject
+{
+ Q_OBJECT
+public:
+ NmApiMailboxSettings(QObject *parent = 0);
+ ~NmApiMailboxSettings();
+
+ bool listMailboxIds(QList &idList);
+ bool loadSettings(quint64 mailboxId, NmApiMailboxSettingsData &data);
+ bool saveSettings(const NmApiMailboxSettingsData &data);
+ bool createMailbox(const QString &mailboxType, NmApiMailboxSettingsData &data);
+ bool deleteMailbox(quint64 mailboxId);
+ bool populateDefaultSettings(const QString &mailboxType, NmApiMailboxSettingsData &data);
+
+signals:
+ void mailboxDeleted(int result = 0);
+
+protected:
+ NmApiMailboxSettingsPrivate *d;
+
+};
+
+}
+
+#endif /* NMAPIMAILBOXSETTINGS_H_ */
diff -r 780f926bc26c -r f83bd4ae1fe3 email_plat/nmail_settings_api/nmapimailboxsettingsdata.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/email_plat/nmail_settings_api/nmapimailboxsettingsdata.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,129 @@
+/*
+ * 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef NMAPIMAILBOXSETTINGSDATA_H_
+#define NMAPIMAILBOXSETTINGSDATA_H_
+
+#include
+#include
+
+namespace EmailClientApi
+{
+
+const QString NmApiMailboxTypeImap = "imap";
+const QString NmApiMailboxTypePop = "pop";
+
+const QString NmApiAuthNone = "none";
+const QString NmApiAuthSameAsIncoming = "SameAsIncoming";
+const QString NmApiAuthUserAuthentication = "UserAuthentication";
+
+const QString NmApiAutomatic = "automatic";
+const QString NmApiAlways = "always";
+const QString NmApiHomeOnly = "homeOnly";
+const QString NmApiOff = "off";
+
+const QString NmApiStartTls = "StartTls";
+const QString NmApiSSLTls = "SSLTls";
+const QString NmApiSecurityOff = NmApiOff;
+
+const QString NmApiKeepUpToDate = "Keep-Up-To-Date";
+const QString NmApiSaveEnergy = "Save-Energy";
+const QString NmApiFetchManually = "Manual-Fetch";
+const QString NmApiUserDefined = "User-Defined";
+
+enum NmApiWeekDays
+{
+ Mon = 0x01, Tue = 0x02, Wed = 0x04, Thu = 0x08, Fri = 0x10,
+ Sat = 0x20, Sun = 0x40
+};
+
+enum NmApiRefreshPeriods
+{
+ WhenMailboxOpens = 0, Every5minutes = 5, Every15minutes = 15,
+ EveryHour = 60, Every4Hours = 240
+};
+
+enum NmApiMailboxSettingKey
+{
+ IncomingLoginName = 0, // String
+ IncomingPassword, // String
+ MailboxName, // String
+ EmailAddress, // String
+ ReplyAddress, // String
+ EmailAlias, // String
+ MyName, // String
+ DownloadPictures, // Integer: 0=Off, 1=On
+ MessageDivider, // Integer: 0=Off, 1=On
+ ReceptionActiveProfile, // String: Reception profile
+ ReceptionUserDefinedProfile, // Integer: 0=Disabled, 1=Enabled
+ ReceptionInboxSyncWindow, // Integer: 0=All messages
+ ReceptionGenericSyncWindowInMessages, // Integer: 0=All messages
+ ReceptionWeekDays, // Integer bitmask of weekdays
+ ReceptionDayStartTime, // Integer: 0-23
+ ReceptionDayEndTime, // Integer: 0-23
+ ReceptionRefreshPeriodDayTime, // Integer: 5,15,60,240,0="When open mailbox"
+ ReceptionRefreshPeriodOther, // Integer: 5,15,60,240,0="When open mailbox"
+ UserNameHidden, // Integer: 0=Off, 1=On
+ IncomingMailServer, // String
+ IncomingMailUsesAuthentication, // String "none", "UserAuthentication"
+ IncomingMailSecurityType, // String "StartTls", "SSLTls", "none"
+ OutgoingMailServer, // String
+ OutgoingMailUsesAuthentication, // String "none", "SameAsIncoming", "UserAuthentication"
+ OutgoingMailSecurityType, // String "StartTls", "SSLTls", "none"
+ IncomingPort, // Integer
+ OutgoingPort, // Integer
+ FolderPath, // String: Empty string means 'Default'
+ AlwaysOnlineState, // string "always", "homeOnly", "off"
+ EmailNotificationState, // string "automatic", "homeOnly", "off"
+ FirstEmnReceived, // Integer: 0=false,1=true
+ EmnReceivedNotSynced, // Integer: 0=false,1=true
+ AoLastSuccessfulUpdate, // QDateTime
+ AoLastUpdateFailed, // Integer: 0=false, 1=true
+ AoUpdateSuccessfulWithCurSettings, // Integer: 0=false, 1=true
+ IncomingSecureSockets, // Boolean
+ IncomingSSLWrapper, // Boolean
+ OutgoingLoginName, // String
+ OutgoingPassword, // String
+ UseOutgoingAuthentication, // Boolean
+ OutgoingSecureSockets, // Boolean
+ OutgoingSSLWrapper // Boolean
+};
+
+class NmApiMailboxSettingsDataPrivate;
+class NMAPI_EXPORT NmApiMailboxSettingsData
+{
+
+public:
+ NmApiMailboxSettingsData();
+ ~NmApiMailboxSettingsData();
+
+ void setMailboxId(quint64 mailboxId);
+ quint64 mailboxId() const;
+ void setValue(int key, const QVariant &settingValue);
+ bool getValue(int key, QVariant &settingValue) const;
+ bool validateData() const;
+ void clearSettings();
+ QList listSettings() const;
+
+protected:
+ NmApiMailboxSettingsDataPrivate *d;
+
+};
+
+}//end namespace
+
+#endif /* NMAPIMAILBOXSETTINGSDATA_H_ */
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/bwins/emailclientapiu.def
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/bwins/emailclientapiu.def Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,3 @@
+EXPORTS
+ ?ImplementationGroupProxy@@YAPBUTImplementationProxy@@AAH@Z @ 1 NONAME ; struct TImplementationProxy const * ImplementationGroupProxy(int &)
+
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/data/emailclientapi.rss
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/data/emailclientapi.rss Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,52 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Declares ECom registration information for email client api
+*
+*
+*/
+
+#include //REGISTRY_INFO
+#include "emailclientapiimpl.hrh"
+
+/** ECom version number to be used in Cmail related ECom registeration
+ * resource files.
+ * NOTE: Version number in ECom registeration resource file is saved as one
+ * byte, so 255 is the maximum version number.
+ */
+#define KEmailEcomVersionNumber 7
+
+RESOURCE REGISTRY_INFO theInfo
+ {
+ dll_uid = 0x20022D63;
+ resource_format_version = RESOURCE_FORMAT_VERSION_2;
+ interfaces =
+ {
+ INTERFACE_INFO
+ {
+ interface_uid = 0x20022D62;
+ implementations =
+ {
+ IMPLEMENTATION_INFO
+ {
+ implementation_uid = 0x20022D61;
+ version_no = KEmailEcomVersionNumber;
+ display_name = "email client api";
+ default_data = "";
+ opaque_data = "";
+ rom_only=0;
+ }
+ };
+ }
+ };
+ }
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/eabi/emailclientapiu.def
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/eabi/emailclientapiu.def Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,3 @@
+EXPORTS
+ _Z24ImplementationGroupProxyRi @ 1 NONAME
+
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/emailclientapi.pro
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/emailclientapi.pro Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,107 @@
+#
+# 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"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Nokia Corporation - initial contribution.
+#
+# Contributors:
+#
+# Description:
+#
+#
+
+TEMPLATE = lib
+TARGET = emailclientapi
+DEPENDPATH += . inc src
+INCLUDEPATH += . \
+ ../../inc \
+ ../emailframework/inc
+INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
+
+HEADERS += inc/emailclientapiimpl.h \
+ inc/emailinterfacefactoryimpl.h \
+ inc/emailapiutils.h \
+ inc/emailmailbox.h \
+ inc/emailaddress.h \
+ inc/emailfolder.h \
+ inc/emailmessage.h \
+ inc/emailmailboxcache.h \
+ inc/messageiterator.h \
+ inc/emailcontent.h \
+ inc/emailmessagesearch.h \
+ inc/emailattachment.h \
+ inc/emailtextcontent.h \
+ inc/emailmultipart.h
+
+SOURCES += src/emailclientapiimpl.cpp \
+ src/emailinterfacefactoryimpl.cpp \
+ src/implproxy.cpp \
+ src/emailapiutils.cpp \
+ src/emailmailbox.cpp \
+ src/emailaddress.cpp \
+ src/emailfolder.cpp \
+ src/emailmessage.cpp \
+ src/emailmailboxcache.cpp \
+ src/messageiterator.cpp \
+ src/emailcontent.cpp \
+ src/emailmessagesearch.cpp \
+ src/emailattachment.cpp \
+ src/emailtextcontent.cpp \
+ src/emailmultipart.cpp
+
+
+LIBS += -lbafl \
+ -lcone \
+ -leuser \
+ -lECom \
+ -lFSFWCommonLib \
+ -lFSMailFramework \
+ -lefsrv \
+ -lviewcli \
+ -lestor \
+ -lcentralrepository
+
+symbian*: {
+
+ INCLUDEPATH += /sf/mw/qtextensions/qthighway/inc
+ LIBS += -lxqservice
+
+ TARGET.EPOCALLOWDLLDATA = 1
+ TARGET.CAPABILITY = CAP_ECOM_PLUGIN
+
+ TARGET.UID2 = 0x10009D8D
+ TARGET.UID3 = 0x20022D63
+
+ ecomPluginRegisterationFile = \
+ "SOURCEPATH data" \
+ "START RESOURCE emailclientapi.rss" \
+ "END"
+
+ MMP_RULES += "SYSTEMINCLUDE /epoc32/include/ecom"
+ MMP_RULES += ecomPluginRegisterationFile
+ MMP_RULES += "TARGETTYPE PLUGIN"
+
+ defBlock = \
+ "$${LITERAL_HASH}if defined(MARM)" \
+ "DEFFILE eabi/emailclientapi.def" \
+ "$${LITERAL_HASH}else" \
+ "DEFFILE bwins/emailclientapi.def" \
+ "$${LITERAL_HASH}endif"
+
+ MMP_RULES += defBlock
+
+ BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include " \
+ "rom/emailclientapi.iby CORE_APP_LAYER_IBY_EXPORT_PATH(emailclientapi.iby)"
+
+ # Prevents C2874W warnings
+ QMAKE_CXXFLAGS.ARMCC += --diag_suppress 2874
+}
+
+win32 {
+ DESTDIR = ../../../../bin
+}
\ No newline at end of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/inc/emailaddress.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailaddress.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,61 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: mail address implementation definition
+*
+*/
+
+#ifndef EMAILADDRESS_H
+#define EMAILADDRESS_H
+
+#include
+#include "emailapiutils.h"
+
+using namespace EmailInterface;
+
+NONSHARABLE_CLASS( CEmailAddress ) : public CBase, public MEmailAddress
+ {
+public:
+ static CEmailAddress* NewL( const TRole aRole, const TDataOwner aOwner );
+ static CEmailAddress* NewLC( const TRole aRole, const TDataOwner aOwner );
+
+ ~CEmailAddress();
+
+public: // from MEmailInterface
+ TEmailTypeId InterfaceId() const;
+
+ void Release();
+
+public: // from MEmailAddress
+ void SetAddressL( const TDesC& aAddress );
+ TPtrC Address() const;
+
+ void SetDisplayNameL( const TDesC& aDisplayName );
+ TPtrC DisplayName() const;
+
+ TRole Role() const;
+ void SetRole( const TRole aRole );
+
+private:
+ CEmailAddress( const TRole aRole, const TDataOwner aOwner );
+
+private:
+ RBuf iAddress;
+ RBuf iDisplayName;
+ TRole iRole;
+ TDataOwner iOwner;
+ };
+
+#endif // EMAILADDRESS_H
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/inc/emailapiutils.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailapiutils.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,157 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: This file implements utilities like CPluginData.
+*
+*/
+
+#ifndef EMAILAPIUTILS_H
+#define EMAILAPIUTILS_H
+
+#include
+#include "cfsmailcommon.h"
+#include
+
+//using namespace EmailInterface;
+
+class CFSMailPlugin;
+
+enum TDataOwner
+ {
+ EClientOwns,
+ EAPIOwns
+ };
+
+
+/**
+* Helper container class for storing plugin pointer and implementation UID
+* @since S60 v5.2
+*/
+NONSHARABLE_CLASS( TPluginData )
+ {
+ public:
+
+ inline TPluginData( TUid aUid ) : iPlugin( NULL ), iUid( TUid::Uid( aUid.iUid ) ) {}
+
+ CFSMailPlugin* iPlugin;
+
+ const TUid iUid;
+ };
+
+/**
+* Plugin data is a utility for protocol plugin creation and book
+* keeping. Objects using the plugin should access it via this
+* class for optimised reference counting.
+*/
+NONSHARABLE_CLASS( CPluginData ) : public CBase
+{
+public:
+ /**
+ * returns plugin instance or null if failed to instantiate.
+ * LoadResult() will return error code in instantiation
+ */
+ CFSMailPlugin* ClaimInstance();
+
+ /**
+ * returns plugin instance or leaves if failed to instantiate.
+ */
+ CFSMailPlugin* ClaimInstanceL();
+
+ /**
+ * Decreases access count of the plugin and deletes if reaches zero.
+ * Note! this should be called only aftre succesful ClaimInstance or
+ * ClaimInstanceL.
+ */
+ void ReleaseInstance();
+
+ /**
+ * Adds cleanup operation calling ReleaseInstance to cleanup stack
+ */
+ void ReleasePushL();
+ /**
+ * Cleanup operation for CleanupReleasePluginPushL
+ */
+ static void CleanupOperation( TAny* aAny );
+
+ TUid Uid() const;
+
+ TInt LoadResult() const;
+
+private:
+ /* only CEmailClientApi owns instances of this, it should make sure that
+ * no duplicates exist, otherwise reference counting of plugins fail
+ * (this is not singleton class)
+ */
+ friend class CEmailClientApi;
+ friend class CEmailMailboxCache;
+
+ CPluginData( TUid aUid );
+ ~CPluginData();
+
+private:
+ // plugin pointer and uid
+ TPluginData iData;
+
+ TInt iPluginLoadError;
+
+ // >0 when iPlugin is instantiated
+ TUint iRefCount;
+
+ // EFalse if shared from Email Framework (CFSMailClient). If true,
+ // ReleaseInstance() doesn't delete plugin
+ TBool iOwned;
+};
+
+/**
+* Constructs internal message id type from plugin data and mailbox/folder/message id
+*/
+TFSMailMsgId FsMsgId( const CPluginData& aPluginData, const EmailInterface::TBaseId& aId );
+
+/**
+* Cleanup support for pointer arrays
+*/
+template
+class CleanupResetAndDestroy
+{
+public:
+ inline static void PushL( T& aItem );
+
+private:
+ inline static void ResetAndDestroy( TAny *aPtr );
+} ;
+
+template
+inline void CleanupResetAndDestroyPushL( T& aRef )
+ {
+ CleanupResetAndDestroy::PushL( aRef );
+ }
+
+/**
+* Cleanup support for email interface objects.
+*/
+class CleanupReleasePush
+{
+public:
+ static void PushL( EmailInterface::MEmailInterface& aItem );
+
+private:
+ static void Release( TAny *aPtr );
+} ;
+
+
+#include "emailapiutils.inl"
+
+
+#endif // EMAILAPIUTILS_H
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/inc/emailapiutils.inl
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailapiutils.inl Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,31 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: This file implements class CEmailMailbox.
+*
+*/
+
+template
+inline void CleanupResetAndDestroy::PushL( T& aItem )
+ {
+ TCleanupItem item( &CleanupResetAndDestroy::ResetAndDestroy, &aItem );
+ CleanupStack::PushL( item );
+ }
+
+template
+inline void CleanupResetAndDestroy::ResetAndDestroy( TAny *aPtr )
+ {
+ reinterpret_cast( aPtr )->ResetAndDestroy();
+ }
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/inc/emailattachment.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailattachment.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,162 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Definition of Email attachment.
+*
+*/
+
+
+#ifndef EMAILATTACHMENT_H
+#define EMAILATTACHMENT_H
+
+// INCLUDES
+#include
+#include
+
+#include "cfsmailclient.h"
+#include
+#include "emailapiutils.h"
+
+using namespace EmailInterface;
+
+class CEmailMessageContent;
+// CLASS DECLARATION
+
+/**
+ * CEmailAttachment
+ *
+ */
+
+NONSHARABLE_CLASS(CEmailAttachment) : public CBase, public MEmailAttachment
+ {
+public:
+ // Constructors and destructor
+
+ /**
+ * Destructor.
+ */
+ ~CEmailAttachment();
+
+ /**
+ * Two-phased constructor.
+ */
+ static CEmailAttachment* NewL(
+ CPluginData& aPluginData,
+ const TMessageContentId& aMsgContentId,
+ CFSMailMessagePart *aAtt,
+ const TDataOwner aOwner );
+
+ /**
+ * Two-phased constructor.
+ */
+ static CEmailAttachment* NewLC(
+ CPluginData& aPluginData,
+ const TMessageContentId& aMsgContentId,
+ CFSMailMessagePart *aAtt,
+ const TDataOwner aOwner );
+
+public: // from MEmailInterface
+ TEmailTypeId InterfaceId() const;
+
+ void Release();
+
+public: // from MEmailAttachment
+ /**
+ * Returns file handle of this attachment. If the attachment is
+ * not associated with a file, null file handle is returned.
+ */
+ RFile FileL() const;
+
+ /**
+ * Sets file name field
+ */
+ void SetFileNameL( const TDesC& aFileName );
+
+ /**
+ * Returns file name or null pointer descriptor if attachment
+ * is not associated with any file
+ */
+ TPtrC FileNameL() const;
+
+
+public: // from MEmailMessageContent
+
+ TMessageContentId Id() const;
+
+ TPtrC ContentType() const;
+
+ void SetContentType( const TDesC& aContentType );
+
+ TPtrC ContentId() const;
+
+ void SetContentId( const TDesC& aContentId );
+
+ TPtrC ContentDescription() const;
+
+ void SetContentDescription( const TDesC& aContentDescription );
+
+ TPtrC ContentDisposition() const;
+
+ void SetContentDisposition( const TDesC& aContentDisposition );
+
+ TPtrC ContentClass() const;
+
+ void SetContentClass( const TDesC& aContentClass );
+
+ TInt AvailableSize() const;
+
+ TInt TotalSize() const;
+
+ TPtrC ContentL() const;
+
+ void SetContentL( const TDesC& aContent );
+
+ void FetchL( MEmailFetchObserver& aObserver );
+
+ void CancelFetch();
+
+ void SaveToFileL( const TDesC& aPath );
+
+ MEmailMultipart* AsMultipartOrNull() const;
+
+ MEmailTextContent* AsTextContentOrNull() const;
+
+ MEmailAttachment* AsAttachmentOrNull() const;
+
+private:
+
+ /**
+ * Constructor for performing 1st stage construction
+ */
+ CEmailAttachment( const TDataOwner aOwner );
+
+ /**
+ * EPOC default constructor for performing 2nd stage construction
+ */
+ void ConstructL(
+ CPluginData& aPluginData,
+ const TMessageContentId& aMsgContentId );
+
+ void ConstructL(
+ CPluginData& aPluginData,
+ const TMessageContentId& aMsgContentId,
+ CFSMailMessagePart *aPart);
+
+private:
+ CEmailMessageContent* iEmailMsgContent;
+ TDataOwner iOwner;
+ };
+
+#endif // EMAILATTACHMENT_H
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/inc/emailclientapiimpl.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailclientapiimpl.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,232 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Definition of Email API main interface.
+*
+*/
+
+#ifndef EMAILCLIENTAPIIMPL_H
+#define EMAILCLIENTAPIIMPL_H
+
+
+#include
+#include "emailapiutils.h"
+#include "cfsmailcommon.h"
+#include "mfsmaileventobserver.h"
+#include
+#include "emailclientpluginmanager.h"
+
+
+using namespace EmailInterface;
+
+class CFSMailBox;
+class MEmailEventObserver;
+class CVwsSessionWrapper;
+class CFSMailPlugin;
+class TFSMailMsgId;
+class CEmailMailboxCache;
+class CFSMailClient;
+
+/**
+* "Framework" class including plugin management
+* @since S60 v5.2
+*/
+NONSHARABLE_CLASS( CEmailClientApi ) : public CBase, public MEmailClientApi
+{
+public:
+ /**
+ * Constructor
+ * @return
+ */
+ static CEmailClientApi* NewL();
+
+ /**
+ *
+ */
+ CEmailClientApi();
+
+public: // from MEmailInterface
+ TEmailTypeId InterfaceId() const;
+
+ void Release();
+
+public: // from MEmailClientApi
+
+ /** @see MEmailClientApi */
+ MEmailMailbox* MailboxL( const TMailboxId& aId );
+
+ /** @see MEmailClientApi */
+ MEmailMailbox* MailboxL( const TPtrC& aAddress );
+
+ /**
+ * Gets all mailboxes in pointer array. It is recommended to free other
+ * mailboxes besides needed one to optimise memory usage.
+ */
+ TInt GetMailboxesL( RMailboxPtrArray& aMailboxes );
+
+ /**
+ */
+ void LaunchEmailL( const TLaunchPolicy aPolicy );
+
+public: // new methods
+
+ /**
+ * Gets array of mailbox ids
+ * @param aMailboxes mailbox ids from all plugins
+ * @return number of mailboxes returned in aMailboxes
+ */
+ TInt GetMailboxIdsL( REmailMailboxIdArray& aMailboxes );
+
+private:
+
+ /**
+ * Constructor
+ */
+ void ConstructL();
+
+ /**
+ * Destructor
+ */
+ ~CEmailClientApi();
+
+ /**
+ * Push ECom implementation info to cleanup operation to cleanup stack
+ */
+ void CleanupImplInfoPushL( RPointerArray& aArray );
+
+ /**
+ * Cleanup operation for ECom implementation info
+ */
+ static void CleanupImplInfo( TAny* aAny );
+
+
+ // Group of methods for book keeping of loaded protocol plugins by this object.
+ // In certain situations it is preferable to have a plugin in memory
+ // instead of loading/unloading frequently.
+
+ /** Increases plugin reference count if CEmailClientApi already doesn't
+ * have active instance. When plugin is needed internally, this method
+ * should be accessor to a plugin. Counterpart is ReleasePlugin() when
+ * CEmailClientApi doesn't itself need plugin any more.
+ */
+ CFSMailPlugin* UsePlugin( CPluginData& aPluginData );
+
+ /**
+ * For finding plugin data
+ */
+ TInt IndexOfLoadedPluginData( const TPluginData& aPluginData ) const;
+
+ /**
+ * Used in comparing plugin data in array (part of find algorithm)
+ */
+ static TBool PluginDataEquals( const TPluginData& a1, const TPluginData& a2 );
+
+ /**
+ * This object doesn't need related protocol plugin
+ */
+ void ReleasePlugin( CPluginData& aPluginData );
+
+ /**
+ * This object doesn't need any protocol plugin
+ */
+ void ReleaseAllPlugins();
+
+ /**
+ * Return mailbox cache, creates it when called first time
+ */
+ CEmailMailboxCache& MailboxInfoCacheL();
+
+ /**
+ * Caches mailbox ids and their mapping to related plugin data for quick
+ * lookup. When a mailbox with specific id is next time asked, related
+ * protocol plugin is already known.
+ */
+ void UpdateMailboxInfoCacheL();
+
+ /**
+ * Internal, used from UpdateMailboxInfoCacheL
+ */
+ TBool CachePluginMailboxesL(
+ CPluginData& aPluginData,
+ CFSMailPlugin& aPlugin );
+
+private:
+ typedef RPointerArray RPluginDataArray;
+
+ /**
+ * Iterator for CPluginData elements in an array
+ */
+ class TPluginIterator
+ {
+ public:
+ // constructor
+ inline TPluginIterator( RPluginDataArray& aArray ) :
+ iArray( aArray ), iIndex( 0 ) {}
+
+ /**
+ * return next element
+ */
+ CPluginData* Next();
+ private:
+ // iterator array
+ RPluginDataArray& iArray;
+ // current iterator index
+ TInt iIndex;
+ };
+
+private:
+ // plugin data array for all protocol plugins
+ RPluginDataArray iPluginDataArray;
+
+ // singleton instance counter
+ TInt iInstanceCounter;
+
+ // book keeping of loaded plugins
+ RArray iLoadedPluginsArray;
+
+ // Mailbox ids are cached when first time listed. Related plugin uid
+ // is include in the cache.
+ CEmailMailboxCache* iMailboxCache;
+
+ CFSMailClient* iMailClient;
+
+};
+
+/**
+* Email application launcher.
+*/
+NONSHARABLE_CLASS( CEmailLauncher ) : public CBase
+{
+public:
+ static CEmailLauncher* NewL();
+
+ ~CEmailLauncher();
+
+ /**
+ *
+ */
+ void LaunchL( const TMailboxId& aMailboxId );
+private:
+
+ CEmailLauncher();
+
+ void ConstructL();
+
+ // Owned window server session.
+ CVwsSessionWrapper* iViewSrvSession;
+};
+
+
+#endif // EMAILCLIENTAPIIMPL_H
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/inc/emailclientapiimpl.hrh
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailclientapiimpl.hrh Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,25 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: email client api internal definitions
+*
+*/
+#ifndef _EMAILCLIENTAPIIMPL_HRH
+#define _EMAILCLIENTAPIIMPL_HRH
+
+#define KEmailClientApiDllUid 0x20022D63
+#define KEmailClientApiImplUid 0x20022D61
+
+#endif // _EMAILCLIENTAPIIMPL_HRH
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/inc/emailclientapiimpldefs.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailclientapiimpldefs.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,30 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: .
+*
+*/
+
+#ifndef _EMAILCLIENTAPIIMPLDEFS_H
+#define _EMAILCLIENTAPIIMPLDEFS_H
+
+enum TEmailImplPanic {
+ EMailPanicPluginNotReleased,
+ EMailPanicSortMapIndexOutOfBounds
+};
+
+void Panic( TEmailImplPanic aPanic );
+
+#endif // _EMAILCLIENTAPIIMPLDEFS_H
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/inc/emailclientpluginmanager.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailclientpluginmanager.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,32 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors: Definition for plugin manager interface
+*
+* Description:
+*
+*/
+
+#ifndef MEMAILPLUGINMANAGER_H_
+#define MEMAILPLUGINMANAGER_H_
+
+#include "cfsmailcommon.h"
+
+class MEmailClientPluginManager
+ {
+public:
+ virtual CFSMailPlugin* GetPluginByUid(TUid aUid) = 0;
+ };
+
+#endif // MEMAILPLUGINMANAGER_H_
+
+// End of file
+
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/inc/emailcontent.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailcontent.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,129 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: mail content implementation definition
+*
+*/
+
+#ifndef EMAILCONTENT_H
+#define EMAILCONTENT_H
+
+#include
+
+#include "cfsmailclient.h"
+#include "emailapiutils.h"
+
+using namespace EmailInterface;
+
+class CFSMailPlugin;
+class CFSMailRequestObserver;
+
+NONSHARABLE_CLASS( CEmailMessageContent ) : public CBase,
+ public MEmailMessageContent
+{
+public:
+ static CEmailMessageContent* NewL(
+ CPluginData& aPluginData,
+ const TMessageContentId& aMsgContentId,
+ CFSMailMessagePart* aPart);
+
+ ~CEmailMessageContent();
+
+public: // from MEmailInterface
+ TEmailTypeId InterfaceId() const;
+
+ void Release();
+
+public: // from MEmailMessageContent
+ TMessageContentId Id() const;
+
+ TPtrC ContentType() const;
+
+ void SetContentType( const TDesC& aContentType );
+
+ TPtrC ContentId() const;
+
+ void SetContentId( const TDesC& aContentId );
+
+ TPtrC ContentDescription() const;
+
+ void SetContentDescription( const TDesC& aContentDescription );
+
+ TPtrC ContentDisposition() const;
+
+ void SetContentDisposition( const TDesC& aContentDisposition );
+
+ TPtrC ContentClass() const;
+
+ void SetContentClass( const TDesC& aContentClass );
+
+ TInt AvailableSize() const;
+
+ TInt TotalSize() const;
+
+ TPtrC ContentL() const;
+
+ void SetContentL( const TDesC& aContent );
+
+ void FetchL( MEmailFetchObserver& aObserver );
+
+ void CancelFetch();
+
+ void SaveToFileL( const TDesC& aPath );
+
+ MEmailMultipart* AsMultipartOrNull() const;
+
+ MEmailTextContent* AsTextContentOrNull() const;
+
+ MEmailAttachment* AsAttachmentOrNull() const;
+
+public:
+ CFSMailMessagePart& Part();
+ void SetPart( CFSMailMessagePart *aPart );
+
+ CPluginData& PluginData();
+
+protected:
+ CEmailMessageContent( CPluginData& aPluginData, const TMessageContentId& aMsgContentId, CFSMailMessagePart* aPart );
+
+private:
+ class CContentRequestObserver: public CBase,
+ public MFSMailRequestObserver
+ {
+ public:
+ CContentRequestObserver( CEmailMessageContent &aParent);
+
+ virtual void RequestResponseL( TFSProgress aEvent, TInt aRequestId );
+ void SetObserverL( MEmailFetchObserver* aObserver );
+ private:
+ MEmailFetchObserver* iObserver;
+ CEmailMessageContent& iParent;
+ };
+
+private:
+ void ConstructL();
+
+private:
+ CPluginData& iPluginData;
+ CFSMailPlugin* iPlugin;
+ CFSMailMessagePart* iPart;
+ TMessageContentId iMsgContentId;
+ mutable HBufC* iBuf;
+ mutable TUint iUsed;
+ CContentRequestObserver *iFetchObserver;
+ TInt iRequestId;
+};
+
+#endif // EMAILCONTENT_H
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/inc/emailfolder.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailfolder.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,103 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: CEmailMailbox.
+*
+*/
+
+#ifndef CEMAILFOLDER_H
+#define CEMAILFOLDER_H
+
+#include
+#include "cfsmailcommon.h"
+#include
+#include "mfsmaileventobserver.h"
+
+using namespace EmailInterface;
+
+class CFSMailPlugin;
+class CPluginData;
+class CFSMailFolder;
+class EmailInterface::MMessageIterator;
+
+NONSHARABLE_CLASS( CEmailFolder ) :
+ public CBase,
+ public MEmailFolder
+{
+public:
+
+ static CEmailFolder* NewLC(
+ CPluginData& aPluginData,
+ const TFolderId& aFolderId,
+ CFSMailFolder *aFolder );
+
+ static CEmailFolder* NewL(
+ CPluginData& aPluginData,
+ const TFolderId& aFolderId,
+ CFSMailFolder *aFolder );
+
+ ~CEmailFolder();
+
+public: // from MEmailInterface
+ TEmailTypeId InterfaceId() const;
+
+ void Release();
+
+public: // from MEmailFolder
+ TFolderId FolderId() const;
+
+ TFolderId ParentFolderId() const;
+
+ TFolderType FolderType() const;
+
+ TPtrC Name() const;
+
+ /**
+ * Returns direct childs of this folder, i.e. this is not recursive.
+ * @return number of subfolders or an error code
+ */
+ TInt GetSubfoldersL(
+ RFolderArray& aSubfolders ) const;
+
+ EmailInterface::MMessageIterator* MessagesL(
+ const RSortCriteriaArray& aCriteria );
+
+ void DeleteMessagesL( const REmailMessageIdArray& aMessageIds );
+
+private: // constructors
+ CEmailFolder( CPluginData& aPluginData, const TFolderId& aFolderId, CFSMailFolder *aFolder );
+
+ void ConstructL();
+
+private: // Internal methods
+ static void ToFsSortCriteriaL(
+ const RSortCriteriaArray& aSortCriteria,
+ RArray& aFsCriteria );
+
+private:
+ CPluginData& iPluginData;
+
+ CFSMailPlugin* iPlugin;
+
+ TFolderType iFolderType;
+
+ TFolderId iFolderId;
+
+ TFolderId iParentId;
+
+ CFSMailFolder *iFolder;
+};
+
+#endif // CEMAILFOLDER_H
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/inc/emailinterfacefactoryimpl.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailinterfacefactoryimpl.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,69 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Interface factory implementation class definition
+*
+*/
+
+#ifndef EMAILINTERFACEFACTORY_H
+#define EMAILINTERFACEFACTORY_H
+
+#include
+
+using namespace EmailInterface;
+
+/**
+* Implements CEmailInterfaceFactory ECom interface
+*
+*/
+NONSHARABLE_CLASS( CEmailInterfaceFactoryImpl ) : public CEmailInterfaceFactory
+{
+public:
+
+ /**
+ * Creates interface factory
+ * @return interface factory
+ */
+ static CEmailInterfaceFactoryImpl* NewL();
+
+ // destructor
+ ~CEmailInterfaceFactoryImpl();
+
+ /** @see CEmailInterfaceFactory::InterfaceL */
+ MEmailInterface* InterfaceL( const TInt aInterfaceId );
+
+private:
+ enum TEmailUidAppendRemoveMode
+ {
+ EEmailUidModeAppend,
+ EEmailUidModeRemove,
+ };
+
+ /**
+ * Registers/removes application UID to/from P&S so that the application
+ * can be shutdown during Email IAD update. Update may fail if any
+ * application is using some Email services during the update.
+ * Application UID is removed from the list in destructor.
+ * @param aMode Is the current process UID added or removed from the list
+ */
+ void AppendOrRemoveUidL( const TEmailUidAppendRemoveMode aMode );
+
+private:
+ // c++ constructor and 2nd phase constructor
+ CEmailInterfaceFactoryImpl();
+ void ConstructL();
+};
+
+#endif // EMAILINTERFACEFACTORY_H
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/inc/emailmailbox.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailmailbox.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,181 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: This file implements class CEmailMailbox.
+*
+*/
+
+#ifndef EMAILMAILBOX_H
+#define EMAILMAILBOX_H
+
+#include "cfsmailcommon.h"
+#include
+#include "mfsmaileventobserver.h"
+#include "mfsmailrequestobserver.h"
+#include "mmailboxcontentobserver.h"
+
+using namespace EmailInterface;
+
+class CFSMailBox;
+class CFSMailAddress;
+class CFSMailPlugin;
+class CPluginData;
+class CEmailAddress;
+
+NONSHARABLE_CLASS( CEmailMailbox ) :
+ public CBase,
+ public MEmailMailbox
+{
+public:
+
+ static CEmailMailbox* NewL(
+ CPluginData& aPluginData,
+ const TMailboxId& aMailboxId );
+
+ ~CEmailMailbox();
+
+public: // from MEmailInterface
+ TEmailTypeId InterfaceId() const;
+
+ void Release();
+
+public: // from MEmailMailbox
+ /**@see MEmailMailbox */
+ TMailboxId MailboxId() const;
+
+ /**@see MEmailMailbox */
+ MEmailAddress* AddressL() const;
+
+ /**@see MEmailMailbox */
+ TPtrC MailboxName() const;
+
+ /**@see MEmailMailbox */
+ TInt GetFoldersL( RFolderArray& aFolders ) const;
+
+ /**@see MEmailMailbox */
+ MEmailFolder* FolderL( const TFolderId& aFolderId ) const;
+
+ /**@see MEmailMailbox */
+ MEmailFolder* FolderByTypeL(
+ const TFolderType aFolderType ) const;
+
+ /**@see MEmailMailbox */
+ MEmailMessage* MessageL( const TMessageId& aMessageId );
+
+ /**@see MEmailMailbox */
+ MEmailMessage* CreateDraftMessageL() const;
+
+ /**@see MEmailMailbox */
+ MEmailMessage* CreateReplyMessageL( const TMessageId& aMessageId, const TBool aReplyToAll = ETrue ) const;
+
+ /**@see MEmailMailbox */
+ MEmailMessage* CreateForwardMessageL( const TMessageId& aMessageId ) const;
+
+ /**@see MEmailMailbox */
+ void SynchroniseL( MMailboxSyncObserver& aObserver );
+
+ /**@see MEmailMailbox */
+ void CancelSynchronise();
+
+ /**@see MEmailMailbox */
+ void RegisterObserverL( MMailboxContentObserver& aObserver );
+
+ /**@see MEmailMailbox */
+ void UnregisterObserver( MMailboxContentObserver& aObserver );
+
+ /**@see MEmailMailbox */
+ MEmailMessageSearchAsync* MessageSearchL();
+
+ /**@see MEmailMailbox */
+ void ShowInboxL();
+
+ /**@see MEmailMailbox */
+ void EditNewMessageL();
+
+
+public: // new methods
+
+private:
+ TFSMailMsgId FsMailboxId() const;
+
+private: // constructors
+ CEmailMailbox( CPluginData& aPluginData, const TMailboxId& aPlugin );
+
+ void ConstructL();
+
+private: // inner class for mailbox event handling
+ class TObserverEventMapper : public MFSMailEventObserver
+ {
+ public:
+ TObserverEventMapper( CFSMailPlugin* aPlugin, TUid aPluginUid, const TMailboxId& aMailboxId );
+ ~TObserverEventMapper();
+ void AddObserverL( MMailboxContentObserver& aObserver );
+ void RemoveObserver( MMailboxContentObserver& aObserver );
+ public: // from MFSMailEventObserver
+ virtual void EventL( TFSMailEvent aEvent, TFSMailMsgId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3 );
+ typedef void ( CEmailMailbox::TObserverEventMapper::*TEventMapFunc)( TMailboxId, TAny*, TAny*, TAny* );
+ private: // mappers, so say we all!
+ void ConvertParamsL( TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, REmailMessageIdArray& aMessageIds, TFolderId& aFolderId );
+ void IgnoreEventL( TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3 );
+ void NewMessageL( TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3 );
+ void MessageChangedL( TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3 );
+ void MessageDeletedL( TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3 );
+ void MessageMoved( TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3 );
+ void MessageCopiedL( TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3 );
+ void NewFolderL( TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3 );
+ void FolderChangeL( TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3 );
+ void FoldersDeletedL( TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3 );
+ void FoldersMovedL( TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3 );
+ void ExceptionL( TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3 );
+
+ private:
+ static TBool Equals( const MMailboxContentObserver& a1, const MMailboxContentObserver& a2 );
+ private:
+ CFSMailPlugin* iPlugin;
+ TFSMailMsgId iFsMailboxId;
+ RPointerArray iClientObservers;
+ };
+ class CEmailRequestObserver: public CBase,
+ public MFSMailRequestObserver
+ {
+ public:
+ CEmailRequestObserver();
+
+ void RequestResponseL( TFSProgress aEvent, TInt aRequestId );
+ void SetObserverL( MMailboxSyncObserver* aObserver );
+ private:
+ MMailboxSyncObserver* iObserver;
+ };
+
+private:
+
+ CPluginData& iPluginData;
+
+ CFSMailPlugin* iPlugin;
+
+ TMailboxId iMailboxId;
+
+ TObserverEventMapper* iEventMapper;
+
+ mutable CEmailAddress* iAddress;
+
+ CFSMailBox* iFsMailbox;
+
+ CEmailRequestObserver* iSyncObserver;
+
+ TInt iRequestId;
+};
+
+#endif // EMAILMAILBOX_H
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/inc/emailmailboxcache.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailmailboxcache.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,138 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Definition for mailbox cache
+*
+*/
+
+#ifndef EMAILMAILBOXCACHE_H
+#define EMAILMAILBOXCACHE_H
+
+#include
+#include
+
+using namespace EmailInterface;
+
+class CPluginData;
+
+
+/**
+* Cache associating mailbox with a protocol plugin. Improves performance by
+* removing need to load protocol plugins every time a mailbox needs to be
+* accessed (and keeping plugin loaded when it is not needed)
+* @since s60 v5.2
+*/
+NONSHARABLE_CLASS( CEmailMailboxCache ) : public CBase
+{
+public:
+ /**
+ * Cache entry to access plugin by mailbox id
+ */
+ class TCacheEntry
+ {
+ public:
+ inline TCacheEntry(
+ CPluginData* aPluginData,
+ TMailboxId aId ) :
+ iPluginData( aPluginData ),
+ iMailboxId( aId ) {}
+ CPluginData* iPluginData;
+ TMailboxId iMailboxId;
+ };
+
+ /**
+ * Constructor
+ */
+ static CEmailMailboxCache* NewL();
+
+ /** destructor */
+ ~CEmailMailboxCache();
+
+ /**
+ * Clears cache and indicates that one or more AddMailboxL calls will
+ * follow.
+ * Cleanup support invalidates cache if leave occurs before EndCachingPop()
+ * is called
+ */
+ void StartCachingPushL();
+
+ /**
+ * Marks caching fully complete for all mailboxes (call when no more
+ * AddMailboxL will follow) and pops cleanup item.
+ */
+ void EndCachingPop();
+
+ /**
+ * Returns if mailboxes are cached
+ */
+ TBool IsCached() const;
+
+ /**
+ * Adds mailbox to cache.
+ * @param aPluginData mailbox associated with plugin(data)
+ * @param aMailboxId mailbox id
+ * @precondition: StartCaching must have been called.
+ */
+ void AddMailboxL( CPluginData& aPluginData, const TMailboxId& aMailboxId );
+
+ /**
+ * Returns plugin data by mailbox id
+ * @param aMailboxId
+ * @return plugin data associated with specified mailbox
+ */
+ CPluginData* PluginDataL( const TMailboxId& aMailboxId ) const;
+
+ /**
+ * Returns plugin data by plugin id
+ * @param aPluginId
+ * @return plugin data associated with specified plugin
+ */
+ CPluginData* PluginDataL( const TUid& aPluginId ) const;
+
+ /**
+ * Gets all mailbox ids in all protocol plugins
+ */
+ void GetIdsL( REmailMailboxIdArray& aIdArray ) const;
+
+private:
+
+ TInt FindById( const TMailboxId& aMailboxId ) const;
+ TInt FindByPluginIdL( const TUid& aPluginId ) const;
+ static TBool Equals( const TCacheEntry& a1, const TCacheEntry& a2 );
+ static TBool PluginEquals( const TCacheEntry& a1, const TCacheEntry& a2 );
+
+ static void CleanupOp( TAny* aAny );
+
+private:
+
+ CEmailMailboxCache();
+
+ void ConstructL();
+
+ enum TCacheState {
+ EEmpty,
+ ECaching,
+ EComplete
+ };
+private:
+ // empty, caching or caching complete
+ TCacheState iState;
+
+ // cached mailbox id with associated plugin data
+ RArray iEntries;
+};
+
+
+#endif // EMAILMAILBOXCACHE_H
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/inc/emailmessage.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailmessage.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,200 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: mail message implementation definition
+*
+*/
+
+#ifndef EMAILMESSAGE_H
+#define EMAILMESSAGE_H
+
+#include
+#include "cfsmailcommon.h"
+#include "emailapiutils.h"
+#include "MFSMailRequestObserver.h"
+#include
+
+using namespace EmailInterface;
+
+class CFSMailMessagePart;
+class CFSMailMessage;
+class CFSMailAddress;
+class CFSMailPlugin;
+class CPluginData;
+class CEmailAddress;
+class CEmailAttachment;
+class CEmailTextContent;
+class CEmailMultipart;
+
+NONSHARABLE_CLASS( CEmailMessage ) : public CBase, public MEmailMessage, public MFSMailRequestObserver
+ {
+public:
+ /**
+ * Creates email message from plugin message
+ */
+ static CEmailMessage* NewL( CPluginData& aPluginData,
+ CFSMailMessage* aFsMessage,
+ const TDataOwner aOwner );
+
+ ~CEmailMessage();
+
+public: // from MEmailInterface
+ TEmailTypeId InterfaceId() const;
+
+ void Release();
+
+public: // from MEmailMessage
+ /**@see MEmailMessage */
+ const TMessageId& MessageId() const;
+
+ /**@see MEmailMessage */
+ MEmailAddress* SenderAddressL() const;
+
+ /**@see MEmailMessage */
+ MEmailAddress* ReplyToAddressL() const;
+
+ /**@see MEmailMessage */
+ void SetReplyToAddressL( const MEmailAddress& aSender );
+
+ /**@see MEmailMessage */
+ TInt GetRecipientsL( const MEmailAddress::TRole aRole,
+ REmailAddressArray& aRecipients ) const;
+
+ /**@see MEmailMessage */
+ void SetRecipientsL( const MEmailAddress::TRole aRole, REmailAddressArray& aRecipients );
+
+ /**@see MEmailMessage */
+ void RemoveRecipientL( const MEmailAddress& aRecipient );
+
+ /**@see MEmailMessage */
+ TPtrC Subject() const;
+
+ /**@see MEmailMessage */
+ void SetSubjectL( const TPtrC& aSubject );
+
+ /**@see MEmailMessage */
+ TTime Date() const;
+
+ /**@see MEmailMessage */
+ TInt Flags() const;
+
+ /**@see MEmailMessage */
+ void SetFlag( const TUint aFlag );
+
+ /**@see MEmailMessage */
+ void ResetFlag( const TUint aFlag );
+
+ /**@see MEmailMessage */
+ MEmailMessageContent* ContentL() const;
+
+ /**@see MEmailMessage */
+ void SetContentL( const MEmailMessageContent* aContent );
+
+ /**@see MEmailMessage */
+ void SetPlainTextBodyL( const TDesC& aPlainText );
+
+ /**@see MEmailMessage */
+ MEmailAttachment* AddAttachmentL( const TDesC& aFullPath );
+
+ /**@see MEmailMessage */
+ MEmailAttachment* AddAttachmentL( RFile& aFile );
+
+ /**@see MEmailMessage */
+ TInt GetAttachmentsL( REmailAttachmentArray& aAttachments );
+
+ /**@see MEmailMessage */
+ void RemoveAttachmentL( const MEmailAttachment& aAttachment );
+
+ /**@see MEmailMessage */
+ const TFolderId& ParentFolderId() const;
+
+ /**@see MEmailMessage */
+ void SaveChangesL();
+
+ /**@see MEmailMessage */
+ void SendL();
+
+ /**@see MEmailMessage */
+ void ShowMessageViewerL();
+
+ /**@see MEmailMessage */
+ void ReplyToMessageL( const TBool aReplyToAll = ETrue );
+
+ /**@see MEmailMessage */
+ void ForwardMessageL();
+
+protected: // From MFSMailRequestObserver
+ void RequestResponseL( TFSProgress aEvent, TInt aRequestId );
+
+private:
+
+ // Copies/moves flag values from iPluginMessage's flags to local flag member variable
+ void InitializeFlagValues();
+
+ CEmailMessage( CPluginData& aPluginData, CFSMailMessage* aMessage, const TDataOwner aOwner );
+
+ void ConstructL();
+
+ void ConvertAddressArrayL( const MEmailAddress::TRole aRole,
+ const RPointerArray& aSrc,
+ REmailAddressArray& aDst ) const;
+ CEmailAddress* CreateAddressLC( const MEmailAddress::TRole aRole, CFSMailAddress& aFsAddress ) const;
+ TUint MapFlags( const TUint& aFlag );
+
+ TMessageContentId MessageContentId( TEntryId aContentId ) const;
+
+private:
+ CPluginData& iPluginData;
+
+ CFSMailPlugin* iPlugin;
+
+ TMessageId iMessageId;
+
+ TMessageContentId iMsgContentId;
+
+ mutable CEmailAddress* iSender;
+
+ mutable CEmailAddress* iReplyTo;
+
+ REmailAddressArray iRecipients;
+
+ CFSMailMessage* iPluginMessage;
+
+ TUint iFlags;
+
+ mutable CEmailTextContent *iTextContent;
+ mutable CEmailMultipart* iContent;
+ RPointerArray iAttachments;
+ TDataOwner iOwner;
+ QEventLoop iEventLoop;
+ TInt iError;
+
+ };
+//Class for compare email content type
+class TContentType
+{
+public:
+ TContentType( const TDesC& aContentType );
+ // Returns ETrue iff the content type represented by this object
+ // (after parameters have been removed) is equal to the given content type.
+ TBool Equals( const TDesC& aContentType );
+
+private:
+ // Content type (without parameters)
+ TPtrC iContentType;
+};
+
+
+#endif // EMAILMESSAGE_H
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/inc/emailmessagesearch.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailmessagesearch.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,170 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Definition of Email message search API.
+*
+*/
+
+#ifndef EMAILMESSAGESEARCHASYNCIMPL_H_
+#define EMAILMESSAGESEARCHASYNCIMPL_H_
+
+#include
+#include
+#include
+
+#include "cfsmailclient.h"
+#include "mfsmailboxsearchobserver.h"
+#include "emailapiutils.h"
+
+using namespace EmailInterface;
+
+
+NONSHARABLE_CLASS( CEmailMessageSearchAsync) :
+ public CBase,
+ public MEmailMessageSearchAsync,
+ public MFSMailBoxSearchObserver
+
+{
+public:
+ /**
+ * Constructor
+ * @return
+ */
+ static CEmailMessageSearchAsync* NewL(
+ CPluginData& aPluginData,
+ const TMailboxId& aMailboxId );
+
+ /**
+ * Destructor
+ */
+ ~CEmailMessageSearchAsync();
+
+public: // from MEmailInterface
+ TEmailTypeId InterfaceId() const;
+
+ void Release();
+
+
+public: // from MEmailMessageSearchAsync
+ /**
+ * Sets sort order for search results.
+ * Leaves KErrNotReady if search is ongoing.
+ */
+ void SetSortCriteriaL( const TEmailSortCriteria& aCriteria );
+
+ /**
+ * Adds a search key. Leaves KErrNotReady if search is ongoing.
+ */
+ void AddSearchKeyL( const TDesC& aSearchKey );
+
+ /**
+ * Enables/disables search from remote email server.
+ * Leaves KErrNotReady if search is ongoing.
+ */
+ void SetRemoteSearchL( TBool aRemote );
+
+ /**
+ * Indicates whether remote search is enabled.
+ */
+ TBool IsRemoteSearch() const;
+
+ /**
+ * Starts search, all methods affecting search attribures leave
+ * KErrNotReady while search is ongoing.
+ * @param aObserver called when results are available.
+ */
+ void StartSearchL( MEmailSearchObserver& aObserver );
+
+ /**
+ * Cancels search.
+ */
+ void Cancel();
+
+ /** returns search status
+ * @return search status:
+ * < 0 : Search has failed
+ * KRequestPending : search is ongoing. note that status may be
+ * KRequestPending after HandleResultL callback because results
+ * may be given in chunks of results. Size of chunk depends on
+ * implementation and may vary.
+ * KErrNone : initial state, or search has finished
+ */
+ TInt Status() const;
+
+ /**
+ * Resets all search attribures. Cancels search if ongoing.
+ */
+ void Reset();
+
+public: // From MFSMailBoxSearchObserver
+ /**
+ * Notifies the email search API client that a match has been found
+ *
+ * @param aMatchMessage contains a pointer to the matched message.
+ * Ownership is transfered to the observer.
+ *
+ */
+ void MatchFoundL( CFSMailMessage* aMatchMessage );
+
+ /**
+ * Notifies the email search API client that the search has completed
+ *
+ */
+ void SearchCompletedL();
+
+//
+ /**
+ * Asks client if search engine should change search priority
+ */
+ void ClientRequiredSearchPriority(TInt *apRequiredSearchPriority);
+//
+
+
+private:
+ /**
+ * Constructor
+ */
+ CEmailMessageSearchAsync(
+ CPluginData& aPluginData,
+ const TMailboxId& aMailboxId );
+
+ void ConstructL();
+
+ /**
+ * Function leaves if search is going on. Otherwise it doesn't do anything.
+ */
+ inline void IsSearchGoingOnL() const;
+
+private:
+
+ CPluginData& iPluginData;
+
+ CFSMailPlugin* iPlugin;
+
+ TMailboxId iMailboxId;
+
+ TFSMailSortCriteria iCriteria;
+
+ RPointerArray iSearchStrings;
+
+ MEmailSearchObserver* iObserver;
+
+ mutable RSemaphore iGate;
+
+ TBool iRemote;
+};
+
+#endif // EMAILMESSAGESEARCHASYNCIMPL_H_
+
+// End of file
+
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/inc/emailmultipart.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailmultipart.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,123 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Definition of Email text content.
+*
+*/
+
+
+#ifndef EMAILMULTIPART_H_
+#define EMAILMULTIPART_H_
+// INCLUDES
+#include "cfsmailclient.h"
+#include
+#include "emailapiutils.h"
+
+using namespace EmailInterface;
+
+class CEmailMessageContent;
+
+
+// CLASS DECLARATION
+
+NONSHARABLE_CLASS( CEmailMultipart ) : public CBase,
+ public MEmailMultipart
+{
+public:
+ static CEmailMultipart* NewL( CPluginData& aPluginData,
+ const TMessageContentId& aMsgContentId,
+ CFSMailMessagePart* aPart,
+ const TDataOwner aOwner );
+
+ ~CEmailMultipart();
+
+public: // from MEmailInterface
+ TEmailTypeId InterfaceId() const;
+
+ void Release();
+
+public: // from MEmailMessageContent
+
+ TMessageContentId Id() const;
+
+ TPtrC ContentType() const;
+
+ void SetContentType( const TDesC& aContentType );
+
+ TPtrC ContentId() const;
+
+ void SetContentId( const TDesC& aContentId );
+
+ TPtrC ContentDescription() const;
+
+ void SetContentDescription( const TDesC& aContentDescription );
+
+ TPtrC ContentDisposition() const;
+
+ void SetContentDisposition( const TDesC& aContentDisposition );
+
+ TPtrC ContentClass() const;
+
+ void SetContentClass( const TDesC& aContentClass );
+
+ TInt AvailableSize() const;
+
+ TInt TotalSize() const;
+
+ TPtrC ContentL() const;
+
+ void SetContentL( const TDesC& aContent );
+
+ void FetchL( MEmailFetchObserver& aObserver );
+
+ void CancelFetch();
+
+ void SaveToFileL( const TDesC& aPath );
+
+ MEmailMultipart* AsMultipartOrNull() const;
+
+ MEmailTextContent* AsTextContentOrNull() const;
+
+ MEmailAttachment* AsAttachmentOrNull() const;
+
+public: // from MEmailMultipart
+ TInt PartCountL();
+
+ MEmailMessageContent* PartByIndexL( const TUint aIndex ) const;
+
+ void DeletePartL( const TUint aIndex );
+
+ void AddPartL(
+ const MEmailMessageContent& aPart,
+ const TUint aPos );
+
+public: // for internal usage
+ void SetOwner( const TDataOwner aOwner );
+
+
+private:
+ CEmailMultipart( const TDataOwner aOwner );
+
+ void ConstructL( CPluginData& aPluginData, const TMessageContentId& aMsgContentId, CFSMailMessagePart* aPart );
+
+private: // Private data
+ CEmailMessageContent* iEmailMsgContent;
+ RArray iChildParts;
+ TUint iChildPartCount;
+ TDataOwner iOwner;
+};
+
+#endif // EMAILMULTIPART_H_
+
+// End of file
+
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/inc/emailtextcontent.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/emailtextcontent.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,121 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Definition of Email text content.
+*
+*/
+
+
+#ifndef EMAILTEXTCONTENT_H_
+#define EMAILTEXTCONTENT_H_
+
+// INCLUDES
+#include "cfsmailclient.h"
+#include
+#include "emailapiutils.h"
+
+using namespace EmailInterface;
+
+class CEmailMessageContent;
+// CLASS DECLARATION
+
+/**
+ * CEmailTextContent
+ *
+ */
+NONSHARABLE_CLASS( CEmailTextContent ) : public CBase,
+ public MEmailTextContent
+{
+public:
+ static CEmailTextContent* NewL( CPluginData& aPluginData,
+ const TMessageContentId& aMsgContentId,
+ CFSMailMessagePart* aPart,
+ const TDataOwner aOwner );
+
+ ~CEmailTextContent();
+
+public: // from MEmailInterface
+ TEmailTypeId InterfaceId() const;
+
+ void Release();
+
+public: // from MEmailTextContent
+ TTextType TextType() const;
+
+ void SetTextL(
+ const TTextType aPlainOrHtml,
+ const TDesC& aText );
+
+public: // from MEmailMessageContent
+
+ TMessageContentId Id() const;
+
+ TPtrC ContentType() const;
+
+ void SetContentType( const TDesC& aContentType );
+
+ TPtrC ContentId() const;
+
+ void SetContentId( const TDesC& aContentId );
+
+ TPtrC ContentDescription() const;
+
+ void SetContentDescription( const TDesC& aContentDescription );
+
+ TPtrC ContentDisposition() const;
+
+ void SetContentDisposition( const TDesC& aContentDisposition );
+
+ TPtrC ContentClass() const;
+
+ void SetContentClass( const TDesC& aContentClass );
+
+ TInt AvailableSize() const;
+
+ TInt TotalSize() const;
+
+ TPtrC ContentL() const;
+
+ void SetContentL( const TDesC& aContent );
+
+ void FetchL( MEmailFetchObserver& aObserver );
+
+ void CancelFetch();
+
+ void SaveToFileL( const TDesC& aPath );
+
+ MEmailMultipart* AsMultipartOrNull() const;
+
+ MEmailTextContent* AsTextContentOrNull() const;
+
+ MEmailAttachment* AsAttachmentOrNull() const;
+
+public: // for internal usage
+ void SetOwner( const TDataOwner aOwner );
+
+
+private:
+ CEmailTextContent( const TDataOwner aOwner );
+
+ void ConstructL( CPluginData& aPluginData, const TMessageContentId& aMsgContentId, CFSMailMessagePart* aPart);
+
+private:
+ TTextType iTextType;
+ CEmailMessageContent* iEmailMsgContent;
+ TDataOwner iOwner;
+};
+
+#endif // EMAILTEXTCONTENT_H_
+
+// End of file
+
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/inc/messageiterator.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/inc/messageiterator.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,135 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: Email message iterator
+*
+*/
+
+#ifndef CMESSAGEITERATOR_H
+#define CMESSAGEITERATOR_H
+
+#include
+#include "emailapidefs.h"
+#include "cfsmailcommon.h"
+
+using namespace EmailInterface;
+
+class MFSMailIterator;
+class CPluginData;
+class CFSMailMessage;
+class CEmailMessage;
+/**
+ * Iterator for email messages
+ * @since S60 v5.2
+ */
+NONSHARABLE_CLASS( CMessageIterator ) : public CBase, public MMessageIterator
+{
+public:
+ /**
+ * Constructor
+ * @param aIterator
+ * @param aPluginData
+ * @return new iterator
+ */
+ static CMessageIterator* NewL( MFSMailIterator* aIterator,
+ CPluginData& aPluginData,
+ TUint aCount );
+
+ ~CMessageIterator();
+
+private:
+ CMessageIterator( MFSMailIterator* aIterator, CPluginData& aPluginData, TUint aCount );
+
+ void ConstructL();
+
+public: // from MEmailInterface
+
+ TEmailTypeId InterfaceId() const;
+
+ void Release();
+
+public: // from MMessageIterator
+
+ /** @see MMessageIterator */
+ MEmailMessage* NextL();
+
+ /** @see MMessageIterator
+ (not implemented) */
+
+ MEmailMessage* PreviousL();
+
+ TUint Count() const;
+
+
+private:
+ // Reads next chunk of messages from protocol plugin
+ TBool ReadNextChunkL();
+ TBool ReadPreviousChunkL();
+ MEmailMessage* ReadFromChunkL();
+ void CleanCache();
+ void AddToCacheL( CFSMailMessage* aFsMsg );
+private: // data
+
+ /**
+ * Iterator internal states. "Consuming" in state names mean getting and
+ * returning next message from the iterator.
+ */
+ enum TState {
+ // No messages available in iterator, read them from protocl plugin.
+ // NextL returns a message from chunk (or NULL if folder is empty)
+ // This is initial state.
+ EReadNextMessageChunk,
+ EReadPreviousMessageChunk,
+
+ // Message(s) are available (retrieved from plugin). No remaining
+ // messages excepted from the plugin. NextL returns a message from chunk.
+ EConsumeFromChunk,
+
+ // Message(s) are available in chunk and more in protocol plugin.
+ EConsumeFromChunkWithMoreChunksToFollow,
+
+ // Iterator is iterated throuh and NextL would return NULL.
+ EIteratorConsumed
+ };
+
+ // plugin iterator, owned
+ MFSMailIterator* iIterator;
+
+ // reference to plugin data
+ CPluginData& iPluginData;
+
+ CFSMailPlugin* iPlugin;
+
+ // message id used for reading messages from plugin
+ TFSMailMsgId iStartMsgId;
+
+ // Internal state
+ TState iState;
+
+ // pointer array of messages read from protocol plugin (aka message chunk)
+ RPointerArray iFsMessageArray;
+ RPointerArray iMessageArray;
+
+ TUint iCount;
+
+ TInt iCursor;
+
+ TFSMailMsgId iFirstMsgId;
+
+ TBool iHasMoreNextItems;
+ TBool iHasMorePrevItems;
+};
+
+#endif // CMESSAGEITERATOR_H
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/rom/emailclientapi.iby
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/rom/emailclientapi.iby Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,22 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: (ROM) Image description file for emailclientapi
+*
+*/
+#include
+#ifdef FF_EMAIL_FRAMEWORK
+
+ECOM_PLUGIN( emailclientapi.dll, emailclientapi.rsc )
+
+#endif
\ No newline at end of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/src/emailaddress.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailaddress.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,129 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: This file implements class CEmailAddress.
+*
+*/
+
+#include "emailaddress.h"
+#include "cfsmailclient.h"
+#include "emailclientapi.hrh"
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailAddress* CEmailAddress::NewL( const TRole aRole, const TDataOwner aOwner )
+ {
+ CEmailAddress* self = new ( ELeave ) CEmailAddress( aRole, aOwner );
+
+ return self;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailAddress* CEmailAddress::NewLC( const TRole aRole, const TDataOwner aOwner )
+ {
+ CEmailAddress* self = CEmailAddress::NewL( aRole, aOwner );
+ CleanupStack::PushL( self );
+ return self;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailAddress::~CEmailAddress()
+ {
+ iAddress.Close();
+ iDisplayName.Close();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailAddress::CEmailAddress( const TRole aRole, const TDataOwner aOwner ) :
+ iRole( aRole ),
+ iOwner( aOwner )
+ {
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TEmailTypeId CEmailAddress::InterfaceId() const
+ {
+ return KEmailIFUidAddress;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAddress::Release()
+ {
+ if ( iOwner == EClientOwns )
+ {
+ delete this;
+ }
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAddress::SetAddressL( const TDesC& aAddress )
+ {
+ iAddress.Close();
+ iAddress.CreateL( aAddress );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailAddress::Address() const
+ {
+ return iAddress;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAddress::SetDisplayNameL( const TDesC& aDisplayName )
+ {
+ iDisplayName.Close();
+ iDisplayName.CreateL( aDisplayName );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailAddress::DisplayName() const
+ {
+ return iDisplayName;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailAddress::TRole CEmailAddress::Role() const
+ {
+ return iRole;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAddress::SetRole( const TRole aRole )
+ {
+ iRole = aRole;
+ }
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/src/emailapiutils.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailapiutils.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,144 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: This file implements class CEmailApiUtils.
+*
+*/
+
+#include
+#include "cfsmailplugin.h"
+#include "emailapidefs.h"
+#include "emailclientapiimpldefs.h"
+#include "emailapiutils.h"
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+CPluginData::CPluginData( TUid aUid ) :
+ iData( aUid ),
+ iPluginLoadError( KErrNotReady )
+ {
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+CPluginData::~CPluginData()
+ {
+ // panic if a user of plugin has not called ReleaseInstance after ClaimInstance
+ __ASSERT_ALWAYS( iOwned || !iRefCount, Panic( EMailPanicPluginNotReleased ) );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+CFSMailPlugin* CPluginData::ClaimInstance()
+ {
+ if ( !iData.iPlugin )
+ {
+ TRAP( iPluginLoadError, iData.iPlugin = CFSMailPlugin::NewL( iData.iUid ) );
+ }
+ if ( !iPluginLoadError )
+ {
+ iRefCount++;
+ }
+ return iData.iPlugin;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+CFSMailPlugin* CPluginData::ClaimInstanceL()
+ {
+ ClaimInstance();
+ User::LeaveIfError( iPluginLoadError );
+ return iData.iPlugin;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+void CPluginData::ReleaseInstance()
+ {
+ if ( iData.iPlugin )
+ {
+ iRefCount--;
+ if ( !iRefCount )
+ {
+ delete iData.iPlugin;
+ iData.iPlugin = NULL;
+ }
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+void CPluginData::ReleasePushL()
+ {
+ TCleanupItem item( &CPluginData::CleanupOperation, this );
+ CleanupStack::PushL( item );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+void CPluginData::CleanupOperation( TAny* aAny )
+ {
+ CPluginData* pdata = reinterpret_cast( aAny );
+ pdata->ReleaseInstance();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+TUid CPluginData::Uid() const
+ {
+ return iData.iUid;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+TInt CPluginData::LoadResult() const
+ {
+ return iPluginLoadError;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+TFSMailMsgId FsMsgId( const CPluginData& aPluginData, const EmailInterface::TBaseId& aId )
+ {
+ TFSMailMsgId id( aPluginData.Uid(), aId.iId );
+ return id;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+void CleanupReleasePush::PushL( EmailInterface::MEmailInterface& aItem )
+ {
+ TCleanupItem item( &CleanupReleasePush::Release, &aItem );
+ CleanupStack::PushL( item );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+void CleanupReleasePush::Release( TAny *aPtr )
+ {
+ reinterpret_cast( aPtr )->Release();
+ }
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/src/emailattachment.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailattachment.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,292 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: This file implements class CEmailAttachment.
+*
+*/
+
+#include "emailattachment.h"
+#include "emailcontent.h"
+#include "emailclientapi.hrh"
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------/
+CEmailAttachment::CEmailAttachment( const TDataOwner aOwner ) : iOwner( aOwner )
+ {
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailAttachment::~CEmailAttachment()
+ {
+ delete iEmailMsgContent;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailAttachment* CEmailAttachment::NewLC(
+ CPluginData& aPluginData,
+ const TMessageContentId& aMsgContentId,
+ CFSMailMessagePart *aAtt,
+ const TDataOwner aOwner )
+ {
+ CEmailAttachment* self = new (ELeave) CEmailAttachment( aOwner );
+ CleanupStack::PushL( self );
+ self->ConstructL( aPluginData, aMsgContentId, aAtt );
+
+ return self;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailAttachment* CEmailAttachment::NewL(
+ CPluginData& aPluginData,
+ const TMessageContentId& aMsgContentId,
+ CFSMailMessagePart *aAtt,
+ const TDataOwner aOwner )
+ {
+ CEmailAttachment* self = CEmailAttachment::NewLC( aPluginData, aMsgContentId, aAtt, aOwner );
+ CleanupStack::Pop( self );
+
+ return self;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAttachment::ConstructL(
+ CPluginData& aPluginData,
+ const TMessageContentId& aMsgContentId,
+ CFSMailMessagePart *aAtt)
+ {
+ iEmailMsgContent = CEmailMessageContent::NewL( aPluginData, aMsgContentId, aAtt );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TInt CEmailAttachment::AvailableSize() const
+{
+ return iEmailMsgContent->AvailableSize();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAttachment::CancelFetch()
+{
+ iEmailMsgContent->CancelFetch();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailAttachment::ContentL() const
+{
+ User::Leave(KErrNotSupported);
+ return iEmailMsgContent->ContentL();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailAttachment::ContentClass() const
+{
+ return iEmailMsgContent->ContentClass();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailAttachment::ContentDescription() const
+{
+ return iEmailMsgContent->ContentDescription();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailAttachment::ContentDisposition() const
+{
+ return iEmailMsgContent->ContentDisposition();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailAttachment::ContentId() const
+{
+ return iEmailMsgContent->ContentId();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailAttachment::ContentType() const
+{
+ return iEmailMsgContent->ContentType();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAttachment::FetchL( MEmailFetchObserver & aObserver )
+{
+ iEmailMsgContent->FetchL( aObserver );
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TMessageContentId CEmailAttachment::Id() const
+{
+ return iEmailMsgContent->Id();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TEmailTypeId CEmailAttachment::InterfaceId() const
+ {
+ return KEmailIFUidAttachment;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAttachment::Release()
+ {
+ if ( iOwner == EClientOwns )
+ {
+ delete this;
+ }
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAttachment::SaveToFileL( const TDesC& aPath )
+{
+ iEmailMsgContent->SaveToFileL( aPath );
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAttachment::SetContentClass( const TDesC& aContentClass )
+{
+ iEmailMsgContent->SetContentClass( aContentClass );
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAttachment::SetContentDescription( const TDesC& aContentDescription )
+{
+ iEmailMsgContent->SetContentDescription(aContentDescription);
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAttachment::SetContentDisposition( const TDesC& aContentDisposition )
+{
+ iEmailMsgContent->SetContentDisposition( aContentDisposition );
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAttachment::SetContentId( const TDesC &aContentId )
+{
+ iEmailMsgContent->SetContentId( aContentId );
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAttachment::SetContentL( const TDesC &aContent )
+{
+ iEmailMsgContent->SetContentL( aContent );
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailAttachment::SetContentType( const TDesC &aContentType )
+{
+ iEmailMsgContent->SetContentType( aContentType );
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TInt CEmailAttachment::TotalSize() const
+{
+ return iEmailMsgContent->TotalSize();
+}
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailMultipart* CEmailAttachment::AsMultipartOrNull() const
+ {
+ return NULL;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailTextContent* CEmailAttachment::AsTextContentOrNull() const
+ {
+ return NULL;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailAttachment* CEmailAttachment::AsAttachmentOrNull() const
+ {
+ const MEmailAttachment* ptr = this;
+ return const_cast( ptr );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+RFile CEmailAttachment::FileL() const
+ {
+ return iEmailMsgContent->Part().GetContentFileL();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------/
+void CEmailAttachment::SetFileNameL( const TDesC& aFileName )
+ {
+ iEmailMsgContent->Part().SetAttachmentNameL( aFileName );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailAttachment::FileNameL() const
+ {
+ return iEmailMsgContent->Part().AttachmentNameL();
+ }
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/src/emailclientapiimpl.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailclientapiimpl.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,425 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: This file implements class CEmailClientApi.
+*
+*/
+
+
+
+#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
+#include
+#include
+#else
+#include
+#include
+#endif // SYMBIAN_ENABLE_SPLIT_HEADERS
+#include
+#include "emailclientapiimpl.h"
+#include "emailapiutils.h"
+#include "emailmailbox.h"
+#include
+#include "cfsmailplugin.h"
+#include "cfsmailclient.h"
+#include "emailclientapiimpldefs.h"
+#include "emailmailboxcache.h"
+#include "emailclientapi.hrh"
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+MEmailMailbox* CEmailClientApi::MailboxL( const TMailboxId& aId )
+ {
+ UpdateMailboxInfoCacheL();
+ CPluginData* pluginData = MailboxInfoCacheL().PluginDataL( aId );
+ MEmailMailbox* mailbox = NULL;
+ if ( pluginData )
+ {
+ mailbox = CEmailMailbox::NewL( *pluginData, aId );
+ }
+ return mailbox;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailMailbox* CEmailClientApi::MailboxL( const TPtrC& aAddress )
+ {
+ MEmailMailbox* mailbox = NULL;
+ REmailMailboxIdArray mailboxes;
+ CleanupClosePushL( mailboxes );
+ TInt count( GetMailboxIdsL( mailboxes ) );
+ while ( count-- )
+ {
+ const TMailboxId mailboxId = mailboxes[count];
+ MEmailMailbox* refMailbox = MailboxL( mailboxId );
+ if ( refMailbox )
+ {
+ TPtrC address( refMailbox->AddressL()->Address() );
+ if ( !address.Compare( aAddress ) )
+ {
+ mailbox = refMailbox; // addresses match
+ count = 0;
+ }
+ else
+ {
+ refMailbox->Release();
+ }
+ }
+ }
+ CleanupStack::PopAndDestroy( &mailboxes );
+ // find mailbox or leave KErrNotFound
+ if ( !mailbox )
+ {
+ User::Leave( KErrNotFound );
+ }
+ return mailbox;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TInt CEmailClientApi::GetMailboxIdsL(
+ REmailMailboxIdArray& aMailboxes )
+ {
+ UpdateMailboxInfoCacheL();
+
+ aMailboxes.Reset();
+ CEmailMailboxCache& mbcache = MailboxInfoCacheL();
+ mbcache.GetIdsL( aMailboxes );
+
+ const TInt mailboxesFound( aMailboxes.Count() );
+ return mailboxesFound;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TInt CEmailClientApi::GetMailboxesL( RMailboxPtrArray& aMailboxes )
+ {
+ REmailMailboxIdArray mailboxIdArray;
+ CleanupClosePushL( mailboxIdArray );
+
+ // GetMailboxIdsL loads plugin and keeps loaded if it contains at
+ // least one mailbox
+ TInt count = GetMailboxIdsL( mailboxIdArray );
+ while ( count-- )
+ {
+ // mailbox creation increases plugin ref count by one
+ MEmailMailbox* mailbox = MailboxL( mailboxIdArray[count] );
+ CleanupReleasePushL( *mailbox );
+ aMailboxes.AppendL( mailbox );
+ CleanupStack::Pop( mailbox );
+ }
+ // Created mailboxes still hold plugin references so we can decrease
+ // ref count.
+ ReleaseAllPlugins();
+
+ CleanupStack::PopAndDestroy( &mailboxIdArray );
+ return aMailboxes.Count();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailClientApi::LaunchEmailL( const TLaunchPolicy /*aPolicy*/ )
+ {
+ User::Leave(KErrNotSupported);
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CPluginData* CEmailClientApi::TPluginIterator::Next()
+ {
+ CPluginData* item = NULL;
+ if ( iIndex < iArray.Count() )
+ {
+ item = iArray[ iIndex++ ];
+ }
+ return item;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailClientApi* CEmailClientApi::NewL()
+ {
+ CEmailClientApi* instance = static_cast( Dll::Tls() );
+
+ if ( !instance )
+ {
+ instance = new ( ELeave ) CEmailClientApi();
+ CleanupStack::PushL( instance );
+ instance->ConstructL();
+ User::LeaveIfError( Dll::SetTls( instance ) );
+ CleanupStack::Pop( instance );
+ }
+
+ instance->iInstanceCounter++;
+
+ return instance;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailClientApi::~CEmailClientApi()
+ {
+ // ensure this doesn't held plugin references
+ ReleaseAllPlugins();
+
+ // ResetAndDestroy doesn't work because ~CPluginData is private
+ TInt count( iPluginDataArray.Count() );
+ while ( count-- )
+ {
+ delete iPluginDataArray[count];
+ }
+ iPluginDataArray.Close();
+ iLoadedPluginsArray.Close();
+ delete iMailboxCache;
+
+ Dll::FreeTls();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailClientApi::CEmailClientApi() : iInstanceCounter( 0 )
+ {
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailClientApi::CleanupImplInfoPushL( RPointerArray& aArray )
+ {
+ TCleanupItem item( &CEmailClientApi::CleanupImplInfo, &aArray );
+ CleanupStack::PushL( item );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailClientApi::CleanupImplInfo( TAny* aAny )
+ {
+ RPointerArray* array =
+ reinterpret_cast*>( aAny );
+ array->ResetAndDestroy();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailClientApi::ConstructL()
+ {
+ RPointerArray implInfoArray;
+ REComSession::ListImplementationsL( KFSMailPluginInterface, implInfoArray );
+ CleanupImplInfoPushL( implInfoArray );
+ TInt err = KErrNone;
+ TInt count( implInfoArray.Count() );
+ // add implementation UIDs to plugin info array, no instantiation at this
+ // phase
+ while ( count-- )
+ {
+ const CImplementationInformation* info = implInfoArray[count];
+ CPluginData* pluginData = new ( ELeave ) CPluginData( info->ImplementationUid() );
+ err = iPluginDataArray.Append( pluginData );
+ if ( err != KErrNone )
+ {
+ // failed to append, give up
+ delete pluginData;
+ count = 0;
+ }
+ }
+ iMailClient = CFSMailClient::NewL();
+ CleanupStack::PopAndDestroy( &implInfoArray );
+ User::LeaveIfError( err );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TEmailTypeId CEmailClientApi::InterfaceId() const
+ {
+ return KEmailClientApiInterface;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailClientApi::Release()
+ {
+ if( this->iInstanceCounter == 1 )
+ {
+ delete this;
+ }
+ else
+ {
+ this->iInstanceCounter--;
+ }
+ }
+
+// -----------------------------------------------------------------------------
+// Returns plugin instance from plugin data. If we already have "claimed"
+// instance once, prevent increment of reference count
+// -----------------------------------------------------------------------------
+CFSMailPlugin* CEmailClientApi::UsePlugin( CPluginData& aPluginData )
+ {
+ // use 'data' as search key for IndexOfLoadedPluginData()
+ TPluginData data( aPluginData.Uid() );
+ TPluginData* pluginDataPtr = &data;
+ // check if we have plugin already "in use".
+ const TInt index( IndexOfLoadedPluginData( data ) );
+ if ( index == KErrNotFound )
+ { // we don't have plugin instance so take it and add to loaded plugins
+ data.iPlugin = aPluginData.ClaimInstance();
+ if ( data.iPlugin && iLoadedPluginsArray.Append( data ) != KErrNone )
+ {
+ aPluginData.ReleaseInstance(); // failed to append, don't proceed..
+ data.iPlugin = NULL; // but return null
+ }
+ }
+ else
+ {
+ // already in use, obtain plugin pointer from the array
+ pluginDataPtr = &iLoadedPluginsArray[index];
+ }
+ return pluginDataPtr->iPlugin;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailClientApi::ReleasePlugin( CPluginData& aPluginData )
+ {
+ // release plugin but only if it is not already claimed
+ TPluginData data( aPluginData.Uid() );
+ const TInt index( IndexOfLoadedPluginData( data ) );
+ if ( index != KErrNotFound )
+ {
+ aPluginData.ReleaseInstance();
+ iLoadedPluginsArray.Remove( index );
+ }
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailClientApi::ReleaseAllPlugins()
+ {
+ for ( TInt i = 0; i < iPluginDataArray.Count(); i++ )
+ {
+ CPluginData* pdata = iPluginDataArray[i];
+ ReleasePlugin( *pdata );
+ }
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailMailboxCache& CEmailClientApi::MailboxInfoCacheL()
+ {
+ if ( !iMailboxCache)
+ {
+ iMailboxCache = CEmailMailboxCache::NewL();
+ }
+ return *iMailboxCache;
+ }
+
+// -----------------------------------------------------------------------------
+// Lists all mailboxes in protocol plugins and adds them to cache. Plugins may
+// not be loaded so loading is done. The plugin is kept in memory if it contains
+// at least one mailbox to avoid loading again later as typical use case is
+// creation of a mailbox object => the plugin is again needed
+//( see ::GetMailboxesL which calls ReleaseAllPlugins()
+// -----------------------------------------------------------------------------
+void CEmailClientApi::UpdateMailboxInfoCacheL()
+ {
+ CEmailMailboxCache& mbcache = MailboxInfoCacheL();
+ if ( !mbcache.IsCached() )
+ {
+ // cache update needed
+ mbcache.StartCachingPushL();
+ TPluginIterator iter( iPluginDataArray );
+ CPluginData* pluginData = iter.Next();
+ while ( pluginData )
+ {
+ TBool containsMailbox( EFalse );
+ // loads plugin if needed
+ CFSMailPlugin* plugin = UsePlugin( *pluginData );
+ if ( plugin )
+ {
+ // if one plugin fails, it should not block other plugins
+ // ==> trap it
+
+ TRAPD( err, containsMailbox = CachePluginMailboxesL(
+ *pluginData,
+ *plugin ) );
+ if ( !containsMailbox || err )
+ {
+ // plugins with no mailboxes (or failed to cache) is
+ // released (unloaded) to optimize RAM usage.
+ ReleasePlugin( *pluginData );
+ }
+ }
+ else if ( pluginData->iPluginLoadError == KErrNoMemory )
+ {
+ // don't continue if OOM
+ User::Leave( KErrNoMemory );
+ }
+ pluginData = iter.Next();
+ }
+ mbcache.EndCachingPop();
+ }
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TBool CEmailClientApi::CachePluginMailboxesL( CPluginData& aPluginData, CFSMailPlugin& aPlugin )
+ {
+ TBool containsMailbox( EFalse );
+ RArray pluginMailboxes;
+ CleanupClosePushL( pluginMailboxes );
+ aPlugin.ListMailBoxesL( pluginMailboxes );
+ TInt mailboxCount = pluginMailboxes.Count();
+ while ( mailboxCount-- )
+ {
+ const TFSMailMsgId& mailboxId = pluginMailboxes[mailboxCount];
+ TMailboxId id( mailboxId.Id() );
+ MailboxInfoCacheL().AddMailboxL( aPluginData, id );
+ containsMailbox = ETrue;
+ }
+ CleanupStack::PopAndDestroy( &pluginMailboxes );
+ return containsMailbox;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TInt CEmailClientApi::IndexOfLoadedPluginData( const TPluginData& aPluginData ) const
+ {
+ TIdentityRelation relation( CEmailClientApi::PluginDataEquals );
+ return iLoadedPluginsArray.Find( aPluginData, relation );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TBool CEmailClientApi::PluginDataEquals( const TPluginData& a1, const TPluginData& a2 )
+ {
+ return ( a1.iUid == a2.iUid );
+ }
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/src/emailcontent.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailcontent.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,412 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: This file implements class CEmailContent.
+*
+*/
+
+#include
+
+#include "emailcontent.h"
+#include "cfsmailclient.h"
+#include "emailclientapi.hrh"
+#include "emailapiutils.h"
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+CEmailMessageContent* CEmailMessageContent::NewL(
+ CPluginData& aPluginData,
+ const TMessageContentId& aMsgContentId,
+ CFSMailMessagePart* aPart )
+ {
+
+ CEmailMessageContent* self = new ( ELeave )
+ CEmailMessageContent( aPluginData, aMsgContentId, aPart );
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop( self );
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+CFSMailMessagePart& CEmailMessageContent::Part()
+ {
+ return *iPart;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::SetPart( CFSMailMessagePart* aPart )
+ {
+ iPart = aPart;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+CPluginData& CEmailMessageContent::PluginData()
+ {
+ return iPluginData;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::ConstructL()
+ {
+ iPlugin = iPluginData.ClaimInstanceL();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+CEmailMessageContent::~CEmailMessageContent()
+ {
+ iPluginData.ReleaseInstance();
+ delete iPart;
+ delete iBuf;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+CEmailMessageContent::CEmailMessageContent(
+ CPluginData& aPluginData,
+ const TMessageContentId& aMsgContentId,
+ CFSMailMessagePart* aPart):
+ iPluginData( aPluginData ),
+ iPart( aPart ),
+ iMsgContentId( aMsgContentId ),
+ iBuf( NULL ),
+ iUsed( 0 )
+ {
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+TEmailTypeId CEmailMessageContent::InterfaceId() const
+ {
+ return KEmailIFUidMessageContent;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::Release()
+ {
+ delete this;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+TMessageContentId CEmailMessageContent::Id() const
+ {
+ return iMsgContentId;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+TPtrC CEmailMessageContent::ContentType() const
+ {
+ if (iPart)
+ {
+ return iPart->GetContentType();
+ }
+ else
+ {
+ return TPtrC(0,0);
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::SetContentType( const TDesC& aContentType )
+ {
+ if (iPart)
+ iPart->SetContentType( aContentType );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+TPtrC CEmailMessageContent::ContentId() const
+ {
+ if (iPart)
+ {
+ return iPart->ContentID();
+ }
+ else
+ {
+ return TPtrC(0,0);
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::SetContentId( const TDesC& aContentId )
+ {
+ if (iPart)
+ TRAP_IGNORE( iPart->SetContentIDL( aContentId ) );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+TPtrC CEmailMessageContent::ContentDescription() const
+ {
+ if (iPart)
+ {
+ return iPart->ContentDescription();
+ }
+ else
+ {
+ return TPtrC(0,0);
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::SetContentDescription(
+ const TDesC& aContentDescription )
+ {
+ if (iPart)
+ iPart->SetContentDescription( aContentDescription );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+TPtrC CEmailMessageContent::ContentDisposition() const
+ {
+ if (iPart)
+ {
+ return iPart->ContentDisposition();
+ }
+ else
+ {
+ return TPtrC(0,0);
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::SetContentDisposition(
+ const TDesC& aContentDisposition )
+ {
+ if (iPart)
+ iPart->SetContentDisposition( aContentDisposition );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+TPtrC CEmailMessageContent::ContentClass() const
+ {
+ if (iPart)
+ {
+ return iPart->GetContentClass();
+ }
+ else
+ {
+ return TPtrC(0,0);
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::SetContentClass( const TDesC& aContentClass )
+ {
+ if (iPart)
+ iPart->SetContentClass( aContentClass );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+TInt CEmailMessageContent::AvailableSize() const
+ {
+ if (iPart)
+ {
+ return iPart->FetchedContentSize();
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+TInt CEmailMessageContent::TotalSize() const
+ {
+ if (iPart)
+ {
+ return iPart->ContentSize();
+ }
+ else
+ {
+ return 0;
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+TPtrC CEmailMessageContent::ContentL() const
+ {
+ TInt size = AvailableSize();
+ TPtr16 ptr( 0, size );
+ if ( size != 0 )
+ {
+ if ( !iBuf )
+ {
+ iBuf = HBufC::NewL( size );
+ }
+
+ if ( size > ptr.MaxLength() )
+ {
+ iBuf = iBuf->ReAlloc( size );
+ }
+ ptr.Set( iBuf->Des() );
+ 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 ) );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::FetchL( MEmailFetchObserver& aObserver )
+ {
+ User::LeaveIfNull( iPart );
+ const TFSMailMsgId fsId = FsMsgId(iPluginData, iMsgContentId);
+ if ( !iFetchObserver )
+ {
+ iFetchObserver = new ( ELeave ) CContentRequestObserver( *this );
+ }
+ iFetchObserver->SetObserverL( &aObserver );
+ iRequestId = iPart->FetchMessagePartL( fsId, *iFetchObserver, TUint( 0 ) );
+
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::CancelFetch()
+ {
+ 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 ),
+ aPath );
+ }
+
+/* Dummy implementations, not ever called */
+MEmailMultipart* CEmailMessageContent::AsMultipartOrNull() const
+ {
+ return NULL;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+MEmailTextContent* CEmailMessageContent::AsTextContentOrNull() const
+ {
+ return NULL;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+MEmailAttachment* CEmailMessageContent::AsAttachmentOrNull() const
+ {
+ return NULL;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+CEmailMessageContent::CContentRequestObserver::CContentRequestObserver(
+ CEmailMessageContent& aParent ) : iObserver( NULL ), iParent( aParent )
+ {
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::CContentRequestObserver::RequestResponseL(
+ TFSProgress aEvent, TInt /* aRequestId */ )
+ {
+ if ( aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete )
+ {
+ delete iParent.iPart;
+ iParent.iPart = NULL;
+ CFSMailMessagePart *part = iParent.iPlugin->MessagePartL(
+ FsMsgId( iParent.iPluginData, iParent.iMsgContentId.iMessageId.iFolderId.iMailboxId ),
+ FsMsgId( iParent.iPluginData, iParent.iMsgContentId.iMessageId.iFolderId ),
+ FsMsgId( iParent.iPluginData, iParent.iMsgContentId.iMessageId ),
+ FsMsgId( iParent.iPluginData, iParent.iMsgContentId ) );
+ iParent.SetPart( part );
+
+ if ( iObserver )
+ iObserver->DataFetchedL( aEvent.iError );
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+void CEmailMessageContent::CContentRequestObserver::SetObserverL( MEmailFetchObserver* aObserver )
+ {
+ iObserver = aObserver;
+ }
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/src/emailfolder.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailfolder.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,278 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: This file implements class CEmailFolder.
+*
+*/
+
+#include "emailfolder.h"
+#include "emailmailbox.h"
+#include "emailapiutils.h"
+#include "messageiterator.h"
+#include "emailsorting.h"
+#include "cfsmailfolder.h"
+#include "cfsmailplugin.h"
+#include "emailclientapi.hrh"
+#include "emailclientapiimpldefs.h"
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailFolder* CEmailFolder::NewLC(
+ CPluginData& aPluginData,
+ const TFolderId& aFolderId,
+ CFSMailFolder *aFolder )
+ {
+ CEmailFolder* self = new ( ELeave )
+ CEmailFolder( aPluginData, aFolderId, aFolder );
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ return self;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailFolder* CEmailFolder::NewL(
+ CPluginData& aPluginData,
+ const TFolderId& aFolderId,
+ CFSMailFolder *aFolder )
+ {
+ CEmailFolder* self = CEmailFolder::NewLC( aPluginData, aFolderId, aFolder);
+ CleanupStack::Pop( self );
+ return self;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailFolder::CEmailFolder(
+ CPluginData& aPluginData,
+ const TFolderId& aFolderId,
+ CFSMailFolder* aFolder) :
+ iPluginData( aPluginData ),
+ iFolderType( EOther ),
+ iFolderId( aFolderId ),
+ iFolder( aFolder )
+ {
+ }
+
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailFolder::ConstructL()
+ {
+ iPlugin = iPluginData.ClaimInstance();
+
+ User::LeaveIfNull( iFolder );
+
+ const TFSFolderType fsType = iFolder->GetFolderType();
+ switch ( fsType )
+ {
+ case EFSInbox:
+ iFolderType = EInbox;
+ break;
+ case EFSOutbox:
+ iFolderType = EOutbox;
+ break;
+ case EFSDraftsFolder:
+ iFolderType = EDrafts;
+ break;
+ case EFSSentFolder:
+ iFolderType = ESent;
+ break;
+ case EFSDeleted:
+ iFolderType = EDeleted;
+ break;
+ case EFSOther:
+ default:
+ iFolderType = EOther;
+ break;
+ }
+ iParentId = TFolderId(
+ iFolder->GetParentFolderId().Id(),
+ iFolderId.iMailboxId );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailFolder::~CEmailFolder()
+ {
+ iPluginData.ReleaseInstance();
+ delete iFolder;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TEmailTypeId CEmailFolder::InterfaceId() const
+ {
+ return KEmailIFUidFolder;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailFolder::Release()
+ {
+ delete this;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TFolderId CEmailFolder::FolderId() const
+ {
+ return iFolderId;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TFolderId CEmailFolder::ParentFolderId() const
+ {
+ return iParentId;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TFolderType CEmailFolder::FolderType() const
+ {
+ return iFolderType;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailFolder::Name() const
+ {
+ if ( !iFolder )
+ return KNullDesC();
+ return TPtrC ( iFolder->GetFolderName() );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TInt CEmailFolder::GetSubfoldersL( RFolderArray& aSubfolders ) const
+ {
+ User::LeaveIfNull( iFolder );
+
+ RPointerArray folders;
+ CleanupResetAndDestroy >::PushL( folders );
+
+ iFolder->GetSubFoldersL( folders );
+
+ TInt res( folders.Count() );
+
+ for ( TInt i = 0; i < res; i++ )
+ {
+ const CFSMailFolder* fsfolder = folders[i];
+ const TEntryId id = fsfolder->GetFolderId().Id();
+ const TFolderId folderId( id, iFolderId.iMailboxId.iId );
+ MEmailFolder* folder = CEmailFolder::NewL( iPluginData, folderId, folders[i] );
+ aSubfolders.AppendL( folder );
+ }
+ CleanupStack::Pop( &folders );
+ folders.Close();
+ return res;
+ }
+
+// -----------------------------------------------------------------------------
+// CEmailFolder::MessagesL
+// -----------------------------------------------------------------------------
+MMessageIterator* CEmailFolder::MessagesL(
+ const RSortCriteriaArray& aCriteria )
+ {
+ RArray sortCriterias;
+ CleanupClosePushL( sortCriterias );
+ CEmailFolder::ToFsSortCriteriaL( aCriteria, sortCriterias );
+
+ MFSMailIterator* fsIter = iFolder->ListMessagesL( EFSMsgDataEnvelope, sortCriterias );
+ TUint count = iFolder->GetMessageCount();
+
+ CleanupStack::PopAndDestroy( &sortCriterias );
+ CMessageIterator* iter = CMessageIterator::NewL(
+ fsIter, iPluginData, count );
+
+ return iter;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailFolder::DeleteMessagesL( const REmailMessageIdArray& aMessageIds )
+ {
+ RArray fsArray;
+ CleanupClosePushL( fsArray );
+ const TInt count( aMessageIds.Count() );
+ for ( TInt i = 0; i < count; i++ )
+ {
+ TMessageId msgId = aMessageIds[i];
+ if ( iFolderId != msgId.iFolderId )
+ {
+ // not all messages in the same folder, plugin API doesn't accept this.
+ User::Leave( KErrArgument );
+ }
+ fsArray.AppendL( FsMsgId( iPluginData, msgId ) );
+ }
+ iPlugin->DeleteMessagesByUidL(
+ FsMsgId( iPluginData, iFolderId.iMailboxId ),
+ FsMsgId( iPluginData, iFolderId ),
+ fsArray );
+ CleanupStack::PopAndDestroy( &fsArray );
+ }
+
+// -----------------------------------------------------------------------------
+// Maps email api sort criteria to sort criteria type that protocol plugin
+// accepts.
+// -----------------------------------------------------------------------------
+void CEmailFolder::ToFsSortCriteriaL(
+ const RSortCriteriaArray& aSortCriteria,
+ RArray& aFsCriteria )
+ {
+ const TFSMailSortField fieldValues[] = {
+ EFSMailDontCare,
+ EFSMailSortByDate,
+ EFSMailSortBySender,
+ EFSMailSortByRecipient,
+ EFSMailSortBySubject,
+ EFSMailSortByPriority,
+ EFSMailSortByFlagStatus,
+ EFSMailSortByUnread,
+ EFSMailSortBySize,
+ EFSMailSortByAttachment };
+
+ for ( TInt i=0; i < aSortCriteria.Count(); i++ )
+ {
+ const TEmailSortCriteria& criteria = aSortCriteria[i];
+ __ASSERT_ALWAYS( criteria.iField < sizeof( fieldValues ) / sizeof (fieldValues [i] ),
+ Panic( EMailPanicSortMapIndexOutOfBounds ) );
+ TFSMailSortCriteria fsCriteria;
+ fsCriteria.iField = fieldValues[ criteria.iField ];
+ if ( criteria.iAscending )
+ {
+ fsCriteria.iOrder = EFSMailAscending;
+ }
+ else
+ {
+ fsCriteria.iOrder = EFSMailDescending;
+ }
+ aFsCriteria.AppendL( fsCriteria );
+ }
+ }
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/src/emailinterfacefactoryimpl.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailinterfacefactoryimpl.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,216 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: This file implements class CEmailInterfaceFactoryImpl.
+*
+*/
+
+#include // RProperty
+#include // RDesRead/WriteStream
+
+#include "emailinterfacefactoryimpl.h"
+#include "emailcontent.h"
+#include "cfsmailclient.h"
+#include "emailclientapiimpldefs.h"
+#include "emailclientapiimpl.h"
+#include "emailaddress.h"
+#include "emailmessagesearch.h"
+#include "emailshutdownconst.h"
+
+_LIT( KEmailImplPanic, "Email client API" );
+const TInt KEmailUidExtraBuffer = 2 * KEmailPlatformApiUidItemSize;
+
+// ---------------------------------------------------------------------------
+// Email client API panic wrapper
+// ---------------------------------------------------------------------------
+void Panic( TEmailImplPanic aPanic )
+ {
+ User::Panic( KEmailImplPanic(), aPanic );
+ }
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CEmailInterfaceFactoryImpl::NewL
+// ---------------------------------------------------------------------------
+CEmailInterfaceFactoryImpl* CEmailInterfaceFactoryImpl::NewL()
+ {
+ CEmailInterfaceFactoryImpl* self = new (ELeave) CEmailInterfaceFactoryImpl();
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop( self );
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+// CEmailInterfaceFactoryImpl::~CEmailInterfaceFactoryImpl
+// ---------------------------------------------------------------------------
+CEmailInterfaceFactoryImpl::~CEmailInterfaceFactoryImpl()
+ {
+ TRAP_IGNORE( AppendOrRemoveUidL( EEmailUidModeRemove ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CEmailInterfaceFactoryImpl::CEmailInterfaceFactoryImpl
+// ---------------------------------------------------------------------------
+CEmailInterfaceFactoryImpl::CEmailInterfaceFactoryImpl() :
+ CEmailInterfaceFactory()
+ {
+ }
+
+// ---------------------------------------------------------------------------
+// CEmailInterfaceFactoryImpl::ConstructL
+// ---------------------------------------------------------------------------
+void CEmailInterfaceFactoryImpl::ConstructL()
+ {
+ // This leaves if related P&S keys are not defined by EmailServerMonitor,
+ // so EmailServerMonitor need to be started before using client API.
+ // TRAP_IGNORE should be removed after EmailServerMonitor is added to
+ // starter list.
+ TRAP_IGNORE( AppendOrRemoveUidL( EEmailUidModeAppend ) );
+ }
+
+// ---------------------------------------------------------------------------
+// CEmailInterfaceFactoryImpl::InterfaceL
+// ---------------------------------------------------------------------------
+MEmailInterface* CEmailInterfaceFactoryImpl::InterfaceL( const TInt aInterfaceId )
+ {
+ MEmailInterface* interface = NULL;
+ switch ( aInterfaceId )
+ {
+ case KEmailClientApiInterface:
+ interface = CEmailClientApi::NewL();
+ break;
+ case KEmailIFUidAddress:
+ interface = CEmailAddress::NewL( MEmailAddress::EUndefined, EClientOwns );
+ break;
+ case KEmailIFUidTextContent:
+ default:
+ break;
+ }
+ if ( !interface )
+ {
+ User::Leave( KErrNotSupported );
+ }
+ return interface;
+ }
+
+// ---------------------------------------------------------------------------
+// CEmailInterfaceFactoryImpl::AppendOrRemoveUidL
+// ---------------------------------------------------------------------------
+void CEmailInterfaceFactoryImpl::AppendOrRemoveUidL(
+ const TEmailUidAppendRemoveMode aMode )
+ {
+ // Read buffer length
+ TInt bufLength( 0 );
+ User::LeaveIfError( RProperty::Get( KEmailShutdownPsCategory,
+ EEmailPsKeyPlatformApiAppsToCloseLength,
+ bufLength ) );
+
+ // Allocate buffer for reading and then read the list of UIDs from P&S.
+ // Adding some extra buffer just in case the size key and actual list
+ // are out of sync. This shouldn't happen, but you never know.
+ HBufC8* readBuf = HBufC8::NewLC( bufLength + KEmailUidExtraBuffer );
+ TPtr8 readPtr = readBuf->Des();
+
+ User::LeaveIfError( RProperty::Get( KEmailShutdownPsCategory,
+ EEmailPsKeyPlatformApiAppsToClose,
+ readPtr ) );
+
+ // For writing get the size of the original buffer + room for our own UID
+ // if needed
+ TInt writeBufSize = readPtr.Length();
+ if( aMode == EEmailUidModeAppend )
+ {
+ writeBufSize += KEmailPlatformApiUidItemSize;
+ }
+
+ HBufC8* writeBuf = HBufC8::NewLC( writeBufSize );
+ TPtr8 writePtr = writeBuf->Des();
+
+ // Read and write streams used to read/write the UIDs from/to descriptors
+ RDesReadStream readStream( readPtr );
+ CleanupClosePushL( readStream );
+
+ RDesWriteStream writeStream( writePtr );
+ CleanupClosePushL( writeStream );
+
+ // Get our own process UID
+ RProcess ownProcess;
+ TUid ownUid = ownProcess.SecureId();
+ ownProcess.Close();
+
+ TInt itemsCount = readPtr.Length() / KEmailPlatformApiUidItemSize;
+
+ TBool ownUidFound = EFalse;
+ TInt writeLength = 0;
+ for ( TInt ii = 0;ii < itemsCount; ++ii )
+ {
+ // Read next UID from the stream
+ TUid item = TUid::Uid( readStream.ReadInt32L() );
+
+ // We can skip our own UID. If we are removing, then we don't want
+ // our UID to be written. If we are adding, we don't need to set
+ // the new values as our UID already exists in the list.
+ if( item == ownUid )
+ {
+ ownUidFound = ETrue;
+ if( aMode == EEmailUidModeAppend )
+ {
+ // Our own UID is already in the list, so no need to update
+ // the list. Hence we can quit here.
+ break;
+ }
+ }
+ else
+ {
+ writeStream.WriteInt32L( item.iUid );
+ writeLength += KEmailPlatformApiUidItemSize;
+ }
+ }
+
+ // If we are appending our UID and it wasn't found from the list,
+ // write it to the stream
+ if( aMode == EEmailUidModeAppend && !ownUidFound )
+ {
+ writeStream.WriteInt32L( ownUid.iUid );
+ writeLength += KEmailPlatformApiUidItemSize;
+ }
+
+ // Set correct length for the write ptr buffer as it might not be
+ // updated correctly by the write stream
+ writePtr.SetLength( writeLength );
+
+ // Set new values to P&S only if something has changed, so either:
+ // 1) We are appending our UID and it didn't exist before
+ // 2) We are removing our UID and it did exist before
+ if( ( aMode == EEmailUidModeAppend && !ownUidFound ) ||
+ ( aMode == EEmailUidModeRemove && ownUidFound ) )
+ {
+ // Write first the UID list as it is more probable to fail, writing
+ // plain integer value shouldn't fail in any case. This way these
+ // values stay in sync also in case of error, as the list length
+ // gets updated only if the list itself is updated succesfully.
+ User::LeaveIfError( RProperty::Set( KEmailShutdownPsCategory,
+ EEmailPsKeyPlatformApiAppsToClose,
+ writePtr ) );
+
+ User::LeaveIfError( RProperty::Set( KEmailShutdownPsCategory,
+ EEmailPsKeyPlatformApiAppsToCloseLength,
+ writeLength ) );
+ }
+
+ CleanupStack::PopAndDestroy( 4, readBuf );
+ }
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/src/emailmailbox.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailmailbox.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,662 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: This file implements class CEmailMailbox.
+*
+*/
+
+#include
+#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
+#include
+#include
+#else
+#include
+#include
+#endif // SYMBIAN_ENABLE_SPLIT_HEADERS
+
+#include
+#include "emailmailbox.h"
+#include "emailapiutils.h"
+#include "emailaddress.h"
+#include "emailfolder.h"
+#include "emailmessage.h"
+#include "emailmessagesearch.h"
+#include "cfsmailclient.h"
+#include "emailclientapiimpl.h"
+#include "cfsmailplugin.h"
+#include "cfsmailbox.h"
+#include "cfsmailfolder.h"
+#include "emailclientapi.hrh"
+
+#include
+#include "email_services_api.h"
+
+// Constants
+
+#include
+
+_LIT( KNewLine, "\n" );
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailMailbox* CEmailMailbox::NewL(
+ CPluginData& aPluginData,
+ const TMailboxId& aMailboxId )
+ {
+ CEmailMailbox* self = new ( ELeave ) CEmailMailbox( aPluginData, aMailboxId );
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop( self );
+ return self;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailMailbox::CEmailMailbox(
+ CPluginData& aPluginData,
+ const TMailboxId& aMailboxId )
+ : iPluginData( aPluginData ),
+ iMailboxId( aMailboxId.iId )
+ {
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::ConstructL()
+ {
+ iPlugin = iPluginData.ClaimInstanceL();
+ iEventMapper = new ( ELeave ) TObserverEventMapper(
+ iPlugin, iPluginData.Uid(), iMailboxId );
+ iFsMailbox = iPlugin->GetMailBoxByUidL( FsMailboxId() );
+ iSyncObserver = new ( ELeave ) CEmailMailbox::CEmailRequestObserver();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailMailbox::~CEmailMailbox()
+ {
+ delete iFsMailbox;
+ delete iEventMapper;
+ delete iAddress;
+ iPluginData.ReleaseInstance();
+ delete iSyncObserver;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TEmailTypeId CEmailMailbox::InterfaceId() const
+ {
+ return KEmailIFUidMailbox;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::Release()
+ {
+ delete this;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TMailboxId CEmailMailbox::MailboxId() const
+ {
+ return iMailboxId;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailAddress* CEmailMailbox::AddressL() const
+ {
+ if ( !iAddress )
+ {
+ iAddress = CEmailAddress::NewL(
+ MEmailAddress::ESender, EAPIOwns );
+ iAddress->SetDisplayNameL( iFsMailbox->GetName() );
+ iAddress->SetAddressL( iFsMailbox->OwnMailAddress().GetEmailAddress() );
+ }
+ return iAddress;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailMailbox::MailboxName() const
+ {
+ return iFsMailbox->GetName();
+ }
+
+// -----------------------------------------------------------------------------
+// Constructs and returns type mailbox id of internal data type TFSMailMsgId
+// -----------------------------------------------------------------------------
+TFSMailMsgId CEmailMailbox::FsMailboxId() const
+ {
+ return FsMsgId( iPluginData, iMailboxId );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TInt CEmailMailbox::GetFoldersL( RFolderArray& aFolders ) const
+ {
+ TFSMailMsgId rootId = TFSMailMsgId();
+ RPointerArray folders;
+ CleanupResetAndDestroyPushL( folders );
+ iPlugin->ListFoldersL( FsMailboxId(), rootId, folders );
+ TInt res( folders.Count() );
+ for ( TInt i = 0; i < res; i++ )
+ {
+ const CFSMailFolder* fsfolder = folders[i];
+ const TEntryId id = fsfolder->GetFolderId().Id();
+ const TFolderId folderId( id, iMailboxId );
+ CEmailFolder* folder = CEmailFolder::NewLC( iPluginData, folderId, folders[i] );
+ aFolders.AppendL( folder );
+ CleanupStack::Pop( folder );
+ }
+ CleanupStack::Pop( &folders );
+ folders.Close(); // close but don't delete folders because they are
+ // owned by CEmailFolder
+ return res;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailFolder* CEmailMailbox::FolderL( const TFolderId& aFolderId ) const
+ {
+ CFSMailFolder* fsFolder = iPlugin->GetFolderByUidL(
+ FsMsgId( iPluginData, iMailboxId ),
+ FsMsgId( iPluginData, aFolderId ) );
+ CleanupStack::PushL( fsFolder );
+
+ CEmailFolder* folder = CEmailFolder::NewL( iPluginData,
+ aFolderId, fsFolder );
+ CleanupStack::Pop( fsFolder );
+
+ return folder;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailFolder* CEmailMailbox::FolderByTypeL(
+ const TFolderType aFolderType ) const
+ {
+ TFSMailMsgId fsFolderId;
+
+ switch ( aFolderType )
+ {
+ case EInbox:
+ fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSInbox );
+ break;
+ case EOutbox:
+ fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSOutbox );
+ break;
+ case EDrafts:
+ fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSDraftsFolder );
+ break;
+ case EDeleted:
+ fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSDeleted );
+ break;
+ case ESent:
+ fsFolderId = iPlugin->GetStandardFolderIdL( FsMailboxId(), EFSSentFolder );
+ break;
+ case EOther:
+ default:
+ User::Leave( KErrNotFound );
+ break;
+ }
+
+ const TFolderId folderId( fsFolderId.Id(), iMailboxId );
+
+ CFSMailFolder* fsFolder = iPlugin->GetFolderByUidL(
+ FsMsgId( iPluginData, iMailboxId ),
+ fsFolderId );
+ CleanupStack::PushL( fsFolder );
+
+ CEmailFolder* folder = CEmailFolder::NewL( iPluginData,
+ folderId,
+ fsFolder );
+
+ CleanupStack::Pop( fsFolder );
+
+ return folder;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailMessage* CEmailMailbox::MessageL( const TMessageId& aMessageId )
+ {
+ CFSMailMessage *fsMessage = iPlugin->GetMessageByUidL(
+ FsMsgId( iPluginData, aMessageId.iFolderId.iMailboxId ),
+ FsMsgId( iPluginData, aMessageId.iFolderId ),
+ FsMsgId( iPluginData, aMessageId ),
+ EFSMsgDataEnvelope );
+
+ CleanupStack::PushL( fsMessage );
+ CEmailMessage* message = CEmailMessage::NewL( iPluginData, fsMessage, EClientOwns );
+ CleanupStack::Pop( fsMessage );
+
+ return message;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailMessage* CEmailMailbox::CreateDraftMessageL() const
+ {
+ CFSMailMessage* fsMessage = iFsMailbox->CreateMessageToSend();
+ User::LeaveIfNull( fsMessage );
+ CleanupStack::PushL( fsMessage );
+ MEmailMessage* message = CEmailMessage::NewL( iPluginData, fsMessage, EClientOwns );
+ CleanupStack::Pop( fsMessage );
+
+ return message;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailMessage* CEmailMailbox::CreateReplyMessageL(
+ const TMessageId& aMessageId, const TBool aReplyToAll ) const
+ {
+ CFSMailMessage* fsMessage = iFsMailbox->CreateReplyMessage(
+ FsMsgId( iPluginData, aMessageId ), aReplyToAll );
+ User::LeaveIfNull( fsMessage );
+ CleanupStack::PushL( fsMessage );
+ MEmailMessage* message = CEmailMessage::NewL( iPluginData, fsMessage, EClientOwns );
+ CleanupStack::Pop( fsMessage );
+
+ return message;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailMessage* CEmailMailbox::CreateForwardMessageL( const TMessageId& aMessageId ) const
+ {
+ CFSMailMessage* fsMessage = iFsMailbox->CreateForwardMessage(
+ FsMsgId( iPluginData, aMessageId ), KNewLine() );
+ User::LeaveIfNull( fsMessage );
+ CleanupStack::PushL( fsMessage );
+ MEmailMessage* message = CEmailMessage::NewL( iPluginData, fsMessage, EClientOwns );
+ CleanupStack::Pop( fsMessage );
+
+ return message;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::SynchroniseL( MMailboxSyncObserver& aObserver )
+ {
+ iSyncObserver->SetObserverL( &aObserver );
+ iRequestId = iFsMailbox->RefreshNowL( *iSyncObserver );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::CancelSynchronise()
+ {
+ iFsMailbox->CancelSearch();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::RegisterObserverL( MMailboxContentObserver& aObserver )
+ {
+ iEventMapper->AddObserverL( aObserver );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::UnregisterObserver( MMailboxContentObserver& aObserver )
+ {
+ iEventMapper->RemoveObserver( aObserver );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailMessageSearchAsync* CEmailMailbox::MessageSearchL()
+ {
+ MEmailMessageSearchAsync* searchAPI =
+ CEmailMessageSearchAsync::NewL( iPluginData, iMailboxId );
+ return searchAPI;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::ShowInboxL()
+ {
+ User::Leave( KErrNotSupported );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::EditNewMessageL()
+ {
+ bool syncronous;
+
+ XQServiceRequest request( emailInterfaceNameSend,
+ emailOperationSendMail,
+ syncronous );
+
+ QVariant returnValue;
+ if ( !request.send( returnValue ) )
+ User::Leave( KErrGeneral );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailMailbox::TObserverEventMapper::TObserverEventMapper(
+ CFSMailPlugin* aPlugin,
+ TUid aPluginUid, const TMailboxId& aMailboxId )
+ : iPlugin( aPlugin ),
+ iFsMailboxId( aPluginUid.iUid, aMailboxId.iId )
+ {
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailMailbox::TObserverEventMapper::~TObserverEventMapper()
+ {
+ iClientObservers.Close();
+ }
+
+// -----------------------------------------------------------------------------
+// Adds mailbox observer and subscribes to plugin mailbox events if there
+// were no previous observers.
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::AddObserverL(
+ MMailboxContentObserver& aObserver )
+ {
+ TIdentityRelation relation(
+ &CEmailMailbox::TObserverEventMapper::Equals );
+ if ( iClientObservers.Find( &aObserver, relation ) == KErrNotFound )
+ {
+ const TInt count( iClientObservers.Count() );
+ if ( !count )
+ {
+ iPlugin->SubscribeMailboxEventsL( iFsMailboxId, *this );
+ }
+ iClientObservers.AppendL( &aObserver );
+ }
+ }
+
+// -----------------------------------------------------------------------------
+// Removes an observer and removes event subscription if the observer was
+// last in observer array.
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::RemoveObserver(
+ MMailboxContentObserver& aObserver )
+ {
+ TIdentityRelation relation(
+ &CEmailMailbox::TObserverEventMapper::Equals );
+ const TInt index( iClientObservers.Find( &aObserver, relation ) );
+ if ( index != KErrNotFound )
+ {
+ iClientObservers.Remove( index );
+ const TInt count( iClientObservers.Count() );
+ if ( !count )
+ {
+ iPlugin->UnsubscribeMailboxEvents( iFsMailboxId, *this );
+ }
+ }
+ }
+
+// -----------------------------------------------------------------------------
+// Maps protocol a plugin event to client event
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::EventL(
+ TFSMailEvent aEvent,
+ TFSMailMsgId aMailbox,
+ TAny* aParam1,
+ TAny* aParam2,
+ TAny* aParam3 )
+ {
+ const TEventMapFunc KMailboxEventHandlers[] = {
+ &CEmailMailbox::TObserverEventMapper::IgnoreEventL,
+ &CEmailMailbox::TObserverEventMapper::IgnoreEventL,
+ &CEmailMailbox::TObserverEventMapper::IgnoreEventL,
+ &CEmailMailbox::TObserverEventMapper::IgnoreEventL,
+ &CEmailMailbox::TObserverEventMapper::IgnoreEventL,
+ &CEmailMailbox::TObserverEventMapper::IgnoreEventL,
+ &CEmailMailbox::TObserverEventMapper::IgnoreEventL,
+ &CEmailMailbox::TObserverEventMapper::IgnoreEventL,
+ &CEmailMailbox::TObserverEventMapper::IgnoreEventL,
+ &CEmailMailbox::TObserverEventMapper::IgnoreEventL,
+ &CEmailMailbox::TObserverEventMapper::IgnoreEventL,
+ &CEmailMailbox::TObserverEventMapper::NewMessageL,
+ &CEmailMailbox::TObserverEventMapper::MessageChangedL,
+ &CEmailMailbox::TObserverEventMapper::MessageDeletedL,
+ &CEmailMailbox::TObserverEventMapper::MessageMoved,
+ &CEmailMailbox::TObserverEventMapper::MessageCopiedL,
+ &CEmailMailbox::TObserverEventMapper::NewFolderL,
+ &CEmailMailbox::TObserverEventMapper::FolderChangeL,
+ &CEmailMailbox::TObserverEventMapper::FoldersDeletedL,
+ &CEmailMailbox::TObserverEventMapper::FoldersMovedL,
+ &CEmailMailbox::TObserverEventMapper::ExceptionL
+ };
+
+ TMailboxId id( aMailbox.Id() );
+ // boundary check
+ const TInt index( aEvent );
+ if ( index < sizeof( KMailboxEventHandlers ) / sizeof( KMailboxEventHandlers[ index ] ) )
+ {
+ // call event handler function
+ TEventMapFunc method = KMailboxEventHandlers[ index ];
+ (this->*method)(id, aParam1,aParam2,aParam3 );
+ }
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::ConvertParamsL(
+ TMailboxId aMailbox, TAny* aParam1, TAny* aParam2,
+ REmailMessageIdArray& aMessageIds, TFolderId& aFolderId )
+ {
+ RArray* newEntries( static_cast< RArray* >( aParam1 ) );
+ CleanupClosePushL( *newEntries );
+ TFSMailMsgId* parentFolder = static_cast( aParam2 );
+ aFolderId = TFolderId( parentFolder->Id(), aMailbox );
+
+ for ( TInt j = 0; j < newEntries->Count(); j++ )
+ {
+ TFSMailMsgId fsId(( *newEntries )[j] );
+ TMessageId messageId( fsId.Id(), aFolderId.iId, aMailbox );
+ aMessageIds.Append( messageId );
+ }
+
+ CleanupStack::PopAndDestroy( newEntries );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::IgnoreEventL(
+ TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
+ {
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::NewMessageL(
+ TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* /*aParam3*/ )
+ {
+ REmailMessageIdArray messageIds;
+ TFolderId folderId;
+ ConvertParamsL( aMailbox, aParam1, aParam2, messageIds, folderId );
+ CleanupClosePushL( messageIds );
+
+ for ( TInt i = 0; i < iClientObservers.Count(); i++ )
+ {
+ MMailboxContentObserver* observer = iClientObservers[i];
+ if (observer)
+ observer->NewMessageEventL( aMailbox, messageIds, folderId );
+ }
+
+ CleanupStack::PopAndDestroy( &messageIds );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::MessageChangedL(
+ TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* /*aParam3*/ )
+ {
+ REmailMessageIdArray messageIds;
+ TFolderId folderId;
+ ConvertParamsL( aMailbox, aParam1, aParam2, messageIds, folderId );
+ CleanupClosePushL( messageIds );
+
+ for ( TInt i = 0; i < iClientObservers.Count(); i++ )
+ {
+ MMailboxContentObserver* observer = iClientObservers[i];
+ if (observer)
+ observer->MessageChangedEventL( aMailbox, messageIds, folderId );
+ }
+ CleanupStack::PopAndDestroy( &messageIds );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::MessageDeletedL(
+ TMailboxId aMailbox, TAny* aParam1, TAny* aParam2, TAny* /*aParam3*/ )
+ {
+ REmailMessageIdArray messageIds;
+ TFolderId folderId;
+ ConvertParamsL( aMailbox, aParam1, aParam2, messageIds, folderId );
+ CleanupClosePushL( messageIds );
+
+ for ( TInt i = 0; i < iClientObservers.Count(); i++ )
+ {
+ MMailboxContentObserver* observer = iClientObservers[i];
+ if (observer)
+ observer->MessageDeletedEventL( aMailbox, messageIds, folderId );
+ }
+
+ CleanupStack::PopAndDestroy( &messageIds );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::MessageMoved(
+ TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
+ {
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::MessageCopiedL(
+ TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
+ {
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::NewFolderL(
+ TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
+ {
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::FolderChangeL(
+ TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
+ {
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::FoldersDeletedL(
+ TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
+ {
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::FoldersMovedL(
+ TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
+ {
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::TObserverEventMapper::ExceptionL(
+ TMailboxId /*aMailbox*/, TAny* /*aParam1*/, TAny* /*aParam2*/, TAny* /*aParam3*/ )
+ {
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TBool CEmailMailbox::TObserverEventMapper::Equals(
+ const MMailboxContentObserver& a1, const MMailboxContentObserver& a2 )
+ {
+ return ( &a1 == &a2 );
+ }
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailMailbox::CEmailRequestObserver::CEmailRequestObserver() : iObserver( NULL )
+ {
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::CEmailRequestObserver::RequestResponseL(
+ TFSProgress aEvent, TInt /* aRequestId */ )
+ {
+ if ( iObserver && aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete )
+ {
+ iObserver->MailboxSynchronisedL(aEvent.iError);
+ }
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMailbox::CEmailRequestObserver::SetObserverL( MMailboxSyncObserver* aObserver )
+ {
+ iObserver = aObserver;
+ }
+
+// End of file
+
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/src/emailmailboxcache.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailmailboxcache.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,194 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: This file implements class CEmailMailboxCache.
+*
+*/
+
+#include "emailmailboxcache.h"
+#include "emailapiutils.h"
+
+static const TInt KCacheGranularity = 2;
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+CEmailMailboxCache* CEmailMailboxCache::NewL()
+ {
+ CEmailMailboxCache* cache = new ( ELeave ) CEmailMailboxCache();
+ return cache;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+CEmailMailboxCache::~CEmailMailboxCache()
+ {
+ iEntries.Close();
+ }
+
+// ---------------------------------------------------------------------------
+// Start of cache transaction with clenanup support
+// ---------------------------------------------------------------------------
+void CEmailMailboxCache::StartCachingPushL()
+ {
+ TCleanupItem item( &CEmailMailboxCache::CleanupOp, this );
+ CleanupStack::PushL( item );
+ iState = ECaching;
+ iEntries.Reset();
+ }
+
+// ---------------------------------------------------------------------------
+// End of cache transaction
+// ---------------------------------------------------------------------------
+void CEmailMailboxCache::EndCachingPop()
+ {
+ iState = EComplete;
+ CleanupStack::Pop();
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+TBool CEmailMailboxCache::IsCached() const
+ {
+ return iState == EComplete;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+void CEmailMailboxCache::AddMailboxL(
+ CPluginData& aPluginData,
+ const TMailboxId& aMailboxId )
+ {
+ if ( iState != ECaching )
+ {
+ User::Leave( KErrNotReady );
+ }
+ if ( FindById( aMailboxId ) == KErrNotFound )
+ {
+ TCacheEntry entry( &aPluginData, aMailboxId );
+ iEntries.AppendL( entry );
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+CPluginData* CEmailMailboxCache::PluginDataL( const TMailboxId& aMailboxId ) const
+ {
+ CPluginData* pdata = NULL;
+ const TInt index( FindById( aMailboxId ) );
+ if ( index != KErrNotFound )
+ {
+ const TCacheEntry& entry = iEntries[ index ];
+ pdata = entry.iPluginData;
+ }
+ return pdata;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+CPluginData* CEmailMailboxCache::PluginDataL( const TUid& aPluginId ) const
+ {
+ CPluginData* pdata = NULL;
+ const TInt index( FindByPluginIdL( aPluginId ) );
+ if ( index != KErrNotFound )
+ {
+ const TCacheEntry& entry = iEntries[ index ];
+ pdata = entry.iPluginData;
+ }
+ return pdata;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+void CEmailMailboxCache::GetIdsL( REmailMailboxIdArray& aIdArray ) const
+ {
+ if ( iState != EComplete )
+ {
+ // cache not up to date
+ User::Leave( KErrNotReady );
+ }
+ for ( TInt i=0; i < iEntries.Count(); i++ )
+ {
+ TMailboxId id = iEntries[i].iMailboxId;
+ aIdArray.AppendL( id );
+ }
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+TInt CEmailMailboxCache::FindById( const TMailboxId& aMailboxId ) const
+ {
+ TIdentityRelation rel( CEmailMailboxCache::Equals );
+
+ // don't care about plugin data because this is seach key only and
+ // mailbox id is used for search
+ TCacheEntry entry( NULL, aMailboxId );
+ return iEntries.Find( entry, rel );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+TInt CEmailMailboxCache::FindByPluginIdL( const TUid& aPluginId ) const
+ {
+ TIdentityRelation rel( CEmailMailboxCache::PluginEquals );
+ CPluginData* key = new ( ELeave ) CPluginData( aPluginId );
+ TCacheEntry entry( key, TMailboxId() );
+ TInt index = iEntries.Find( entry, rel );
+ delete key;
+ return index;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+TBool CEmailMailboxCache::Equals( const TCacheEntry& a1, const TCacheEntry& a2 )
+ {
+ return ( a1.iMailboxId == a2.iMailboxId );
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+TBool CEmailMailboxCache::PluginEquals( const TCacheEntry& a1, const TCacheEntry& a2 )
+ {
+ return ( a1.iPluginData->Uid() == a2.iPluginData->Uid() );
+ }
+
+// ---------------------------------------------------------------------------
+// Cleanup
+// ---------------------------------------------------------------------------
+void CEmailMailboxCache::CleanupOp( TAny* aAny )
+ {
+ CEmailMailboxCache* cache = reinterpret_cast( aAny );
+ cache->iEntries.Reset();
+ cache->iState = EEmpty;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+CEmailMailboxCache::CEmailMailboxCache() :
+ iState( EEmpty ),
+ iEntries( KCacheGranularity )
+ {
+ }
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/src/emailmessage.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailmessage.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,912 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: This file implements class CEmailMessage.
+*
+*/
+
+#ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
+#include
+#include
+#else
+#include
+#include
+#endif // SYMBIAN_ENABLE_SPLIT_HEADERS
+
+#include "emailmessage.h"
+#include "emailaddress.h"
+#include "emailapiutils.h"
+#include "emailclientapi.hrh"
+#include "emailapiutils.h"
+#include "emailinterfacefactoryimpl.h"
+#include "emailcontent.h"
+#include "emailtextcontent.h"
+#include "emailmultipart.h"
+#include "emailattachment.h"
+#include "cfsmailplugin.h"
+#include "cfsmailclient.h"
+
+#include
+#include "email_services_api.h"
+
+const TInt KSendMessageRequestId = 100;
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailMessage* CEmailMessage::NewL( CPluginData& aPluginData,
+ CFSMailMessage* aFsMessage,
+ const TDataOwner aOwner )
+ {
+ CEmailMessage* message = new ( ELeave ) CEmailMessage( aPluginData, aFsMessage, aOwner );
+ CleanupStack::PushL( message );
+ message->ConstructL();
+ CleanupStack::Pop( message );
+ return message;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailMessage::CEmailMessage(
+ CPluginData& aPluginData,
+ CFSMailMessage *aFsMessage,
+ const TDataOwner aOwner)
+ : iPluginData( aPluginData ), iPluginMessage( aFsMessage ), iOwner( aOwner )
+ {
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMessage::ConstructL()
+ {
+ User::LeaveIfNull( iPluginMessage );
+ iPlugin = iPluginData.ClaimInstanceL();
+ if ( iPluginMessage )
+ {
+ iMessageId = TMessageId(
+ iPluginMessage->GetMessageId().Id(),
+ iPluginMessage->GetFolderId().Id(),
+ iPluginMessage->GetMailBoxId().Id() );
+
+ // Copy the message flags
+ InitializeFlagValues();
+ }
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailMessage::~CEmailMessage()
+ {
+ delete iPluginMessage;
+ delete iSender;
+ delete iReplyTo;
+ delete iTextContent;
+ delete iContent;
+ iPluginData.ReleaseInstance();
+ iAttachments.ResetAndDestroy();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TEmailTypeId CEmailMessage::InterfaceId() const
+ {
+ return KEmailIFUidMessage;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMessage::Release()
+ {
+ if ( iOwner == EClientOwns )
+ {
+ delete this;
+ }
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+const TMessageId& CEmailMessage::MessageId() const
+ {
+ return iMessageId;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailAddress* CEmailMessage::SenderAddressL() const
+ {
+ User::LeaveIfNull( iPluginMessage );
+
+ CFSMailAddress* fsAddress = iPluginMessage->GetSender();
+ if ( fsAddress )
+ {
+ if ( !iSender )
+ {
+ iSender = CEmailAddress::NewL( MEmailAddress::ESender, EAPIOwns );
+ }
+ iSender->SetAddressL(fsAddress->GetEmailAddress());
+ iSender->SetDisplayNameL(fsAddress->GetDisplayName());
+ }
+ else
+ {
+ // Sender address not defined. Delete client object as well
+ delete iSender;
+ iSender = NULL;
+ }
+ return iSender;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailAddress* CEmailMessage::ReplyToAddressL() const
+ {
+ User::LeaveIfNull( iPluginMessage );
+
+ const CFSMailAddress& fsAddress = iPluginMessage->GetReplyToAddress();
+ if ( &fsAddress )
+ {
+ if ( !iReplyTo )
+ {
+ iReplyTo = CEmailAddress::NewL( MEmailAddress::EReplyTo, EAPIOwns );
+ }
+ iReplyTo->SetAddressL( fsAddress.GetEmailAddress() );
+ iReplyTo->SetDisplayNameL( fsAddress.GetDisplayName() );
+ }
+ else
+ {
+ delete iReplyTo;
+ iReplyTo = NULL;
+ }
+ return iReplyTo;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMessage::SetReplyToAddressL( const MEmailAddress& aSender )
+ {
+ User::LeaveIfNull( iPluginMessage );
+
+ CFSMailAddress *fsAddress = CFSMailAddress::NewLC();
+ if ( !iReplyTo )
+ {
+ iReplyTo = CEmailAddress::NewL( MEmailAddress::EReplyTo, EAPIOwns );
+ }
+ fsAddress->SetDisplayName( aSender.DisplayName() );
+ fsAddress->SetEmailAddress( aSender.Address() );
+ iPluginMessage->SetReplyToAddress( fsAddress );
+ iReplyTo->SetAddressL( fsAddress->GetEmailAddress() );
+ iReplyTo->SetDisplayNameL( fsAddress->GetDisplayName() );
+ CleanupStack::Pop();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TInt CEmailMessage::GetRecipientsL( const MEmailAddress::TRole aRole,
+ REmailAddressArray& aRecipients ) const
+ {
+ if( aRole == MEmailAddress::EReplyTo ||
+ aRole == MEmailAddress::ESender )
+ {
+ User::Leave( KErrArgument );
+ }
+ else
+ {
+ User::LeaveIfNull( iPluginMessage );
+
+ if( aRole == MEmailAddress::ETo ||
+ aRole == MEmailAddress::EUndefined )
+ {
+ const RPointerArray& toRecipients =
+ iPluginMessage->GetToRecipients();
+ ConvertAddressArrayL(
+ MEmailAddress::ETo,
+ toRecipients, aRecipients );
+ }
+ if( aRole == MEmailAddress::ECc ||
+ aRole == MEmailAddress::EUndefined )
+ {
+ const RPointerArray& ccRecipients =
+ iPluginMessage->GetCCRecipients();
+ ConvertAddressArrayL(
+ MEmailAddress::ECc,
+ ccRecipients, aRecipients );
+ }
+ if( aRole == MEmailAddress::EBcc ||
+ aRole == MEmailAddress::EUndefined )
+ {
+ const RPointerArray& bccRecipients =
+ iPluginMessage->GetBCCRecipients();
+ ConvertAddressArrayL(
+ MEmailAddress::EBcc,
+ bccRecipients, aRecipients );
+ }
+ }
+ return aRecipients.Count();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMessage::SetRecipientsL( const MEmailAddress::TRole aRole,
+ REmailAddressArray& aRecipients )
+ {
+ TInt count( aRecipients.Count() );
+
+ for( TInt i=0;iSetEmailAddress( address->Address() );
+ fsAddress->SetDisplayName( address->DisplayName() );
+
+ User::LeaveIfNull( iPluginMessage );
+
+ if( aRole == MEmailAddress::ETo )
+ {
+ iPluginMessage->AppendToRecipient( fsAddress );
+ }
+ else if( aRole == MEmailAddress::ECc )
+ {
+ iPluginMessage->AppendCCRecipient( fsAddress );
+ }
+ else if( aRole == MEmailAddress::EBcc )
+ {
+ iPluginMessage->AppendBCCRecipient( fsAddress );
+ }
+ else
+ {
+ User::Leave( KErrArgument );
+ }
+ CleanupStack::Pop( fsAddress );
+ }
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMessage::RemoveRecipientL( const MEmailAddress& /*aRecipient*/ )
+ {
+ User::Leave( KErrNotSupported );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailMessage::Subject() const
+ {
+ if ( !iPluginMessage )
+ return KNullDesC();
+ return iPluginMessage->GetSubject();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMessage::SetSubjectL( const TPtrC& aSubject )
+ {
+ User::LeaveIfNull( iPluginMessage );
+ iPluginMessage->SetSubject( aSubject );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TTime CEmailMessage::Date() const
+ {
+ TTime time;
+
+ if ( iPluginMessage ) {
+ time = iPluginMessage->GetDate();
+ }
+
+ return time;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TInt CEmailMessage::Flags() const
+ {
+ return iFlags;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMessage::SetFlag( const TUint aFlag )
+ {
+ iFlags |= aFlag;
+ TUint flag = MapFlags( aFlag );
+ if ( iPluginMessage )
+ iPluginMessage->SetFlag( flag );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMessage::ResetFlag( const TUint aFlag )
+ {
+ iFlags &= ~aFlag;
+ TUint flag = MapFlags( aFlag );
+ if ( iPluginMessage )
+ iPluginMessage->ResetFlag( flag );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMessage::InitializeFlagValues()
+ {
+ if ( !iPluginMessage )
+ return;
+ // 1st reset member value, then start copying different flags
+ iFlags = 0;
+
+ // EFlag_Read
+ if ( iPluginMessage->IsFlagSet( EFSMsgFlag_Read ) )
+ {
+ iFlags |= EFlag_Read;
+ }
+ else
+ {
+ iFlags &= ~EFlag_Read;
+ }
+ // EFlag_Read_Locally
+ if ( iPluginMessage->IsFlagSet( EFSMsgFlag_Read_Locally ) )
+ {
+ iFlags |= EFlag_Read_Locally;
+ }
+ else
+ {
+ iFlags &= ~EFlag_Read_Locally;
+ }
+ // EFlag_Low
+ if ( iPluginMessage->IsFlagSet( EFSMsgFlag_Low ) )
+ {
+ iFlags |= EFlag_Low;
+ }
+ else
+ {
+ iFlags &= ~EFlag_Low;
+ }
+ // EFlag_Important
+ if ( iPluginMessage->IsFlagSet( EFSMsgFlag_Important ) )
+ {
+ iFlags |= EFlag_Important;
+ }
+ else
+ {
+ iFlags &= ~EFlag_Important;
+ }
+ // EFlag_FollowUpComplete
+ if ( iPluginMessage->IsFlagSet( EFSMsgFlag_FollowUpComplete ) )
+ {
+ iFlags |= EFlag_FollowUpComplete;
+ }
+ else
+ {
+ iFlags &= ~EFlag_FollowUpComplete;
+ }
+ // EFlag_FollowUp
+ if ( iPluginMessage->IsFlagSet( EFSMsgFlag_FollowUp ) )
+ {
+ iFlags |= EFlag_FollowUp;
+ }
+ else
+ {
+ iFlags &= ~EFlag_FollowUp;
+ }
+ // EFlag_Attachments
+ if ( iPluginMessage->IsFlagSet( EFSMsgFlag_Attachments ) )
+ {
+ iFlags |= EFlag_Attachments;
+ }
+ else
+ {
+ iFlags &= ~EFlag_Attachments;
+ }
+ // EFlag_Multiple
+ if ( iPluginMessage->IsFlagSet( EFSMsgFlag_Multiple ) )
+ {
+ iFlags |= EFlag_Multiple;
+ }
+ else
+ {
+ iFlags &= ~EFlag_Multiple;
+ }
+ // EFlag_CalendarMsg
+ if ( iPluginMessage->IsFlagSet( EFSMsgFlag_CalendarMsg ) )
+ {
+ iFlags |= EFlag_CalendarMsg;
+ }
+ else
+ {
+ iFlags &= ~EFlag_CalendarMsg;
+ }
+ // EFlag_Answered
+ if ( iPluginMessage->IsFlagSet( EFSMsgFlag_Answered ) )
+ {
+ iFlags |= EFlag_Answered;
+ }
+ else
+ {
+ iFlags &= ~EFlag_Answered;
+ }
+ // EFlag_Forwarded
+ if ( iPluginMessage->IsFlagSet( EFSMsgFlag_Forwarded ) )
+ {
+ iFlags |= EFlag_Forwarded;
+ }
+ else
+ {
+ iFlags &= ~EFlag_Forwarded;
+ }
+ // EFlag_OnlyToMe
+ if ( iPluginMessage->IsFlagSet( EFSMsgFlag_OnlyToMe ) )
+ {
+ iFlags |= EFlag_OnlyToMe;
+ }
+ else
+ {
+ iFlags &= ~EFlag_OnlyToMe;
+ }
+ // EFlag_RemoteDeleted
+ if ( iPluginMessage->IsFlagSet( EFSMsgFlag_RemoteDeleted ) )
+ {
+ iFlags |= EFlag_RemoteDeleted;
+ }
+ else
+ {
+ iFlags &= ~EFlag_RemoteDeleted;
+ }
+ // EFlag_HasMsgSender
+ if ( iPluginMessage->IsFlagSet( EFSMsgFlag_HasMsgSender ) )
+ {
+ iFlags |= EFlag_HasMsgSender;
+ }
+ else
+ {
+ iFlags &= ~EFlag_HasMsgSender;
+ }
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailMessageContent* CEmailMessage::ContentL() const
+ {
+ if ( iTextContent )
+ {
+ return iTextContent;
+ }
+ if ( iContent )
+ {
+ return iContent;
+ }
+
+ User::LeaveIfNull( iPluginMessage );
+
+ RPointerArray parts;
+ CleanupResetAndDestroyPushL( parts );
+ iPluginMessage->ChildPartsL( parts );
+ TInt count( parts.Count() );
+ if( count == 0 )
+ {
+ /* No content, return NULL */
+ CleanupStack::PopAndDestroy( &parts ); // in case heap allocated but not used
+ return NULL;
+ }
+ CFSMailMessagePart* part = parts[0];
+ TContentType contentType( part->GetContentType() );
+ TMessageContentId msgContentId = TMessageContentId(
+ part->GetPartId().Id(),
+ iMessageId.iId,
+ iMessageId.iFolderId.iId,
+ iMessageId.iFolderId.iMailboxId );
+
+ if ( contentType.Equals( KFSMailContentTypeTextPlain ) ||
+ contentType.Equals( KFSMailContentTypeTextHtml ) )
+ {
+ iTextContent = CEmailTextContent::NewL(iPluginData, msgContentId, part, EAPIOwns );
+ parts[0] = NULL; // ownership of part transferred
+ }
+ else if ( contentType.Equals( KFSMailContentTypeMultipartMixed ) ||
+ contentType.Equals( KFSMailContentTypeMultipartAlternative ) ||
+ contentType.Equals( KFSMailContentTypeMultipartDigest ) ||
+ contentType.Equals( KFSMailContentTypeMultipartRelated ) ||
+ contentType.Equals( KFSMailContentTypeMultipartParallel ) )
+ {
+ iContent = CEmailMultipart::NewL(iPluginData, msgContentId, part, EAPIOwns);
+ parts[0] = NULL; // ownership of part transferred
+ }
+
+ CleanupStack::PopAndDestroy( &parts ); // parts
+
+ if (iTextContent)
+ {
+ return iTextContent;
+ }
+ return iContent;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMessage::SetContentL( const MEmailMessageContent* aContent )
+ {
+ User::LeaveIfNull( aContent );
+ MEmailTextContent* textContent = aContent->AsTextContentOrNull();
+ if ( textContent )
+ {
+ if ( iTextContent )
+ {
+ delete iTextContent; // Destroy old content
+ }
+ iTextContent = dynamic_cast( textContent );
+ if ( iTextContent )
+ {
+ iTextContent->SetOwner( EAPIOwns );
+ }
+ return;
+ }
+ MEmailMultipart* mPart = aContent->AsMultipartOrNull();
+ if ( mPart )
+ {
+ if ( iContent )
+ {
+ delete iContent;
+ }
+ iContent = dynamic_cast( mPart );
+ if ( iContent )
+ {
+ iContent->SetOwner( EAPIOwns );
+ }
+ }
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMessage::SetPlainTextBodyL( const TDesC& aPlainText )
+ {
+ if ( iTextContent )
+ {
+ iTextContent->SetTextL( MEmailTextContent::EPlainText, aPlainText );
+ return;
+ }
+
+ User::LeaveIfNull( iPluginMessage );
+
+ CFSMailMessagePart* msgTextPart = iPluginMessage->PlainTextBodyPartL();
+
+ if( !msgTextPart )
+ {
+ msgTextPart = iPluginMessage->NewChildPartL( TFSMailMsgId(), KFSMailContentTypeTextPlain );
+ }
+ CleanupStack::PushL( msgTextPart );
+
+ TMessageContentId msgContentId = MessageContentId( msgTextPart->GetPartId().Id() );
+
+ msgTextPart->SetContentType( KFSMailContentTypeTextPlain );
+ iTextContent = CEmailTextContent::NewL( iPluginData, msgContentId, msgTextPart, EAPIOwns );
+ if (iTextContent)
+ {
+ iTextContent->SetTextL( MEmailTextContent::EPlainText, aPlainText );
+ }
+ CleanupStack::Pop( msgTextPart );
+
+ return;
+
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailAttachment* CEmailMessage::AddAttachmentL( const TDesC& aFullPath )
+ {
+ User::LeaveIfNull( iPluginMessage );
+
+ CFSMailMessagePart* part = iPluginMessage->AddNewAttachmentL( aFullPath, TFSMailMsgId() );
+ CleanupStack::PushL( part );
+ CEmailAttachment* att = CEmailAttachment::NewLC( iPluginData, iMsgContentId, part, EAPIOwns );
+ iAttachments.AppendL( att );
+ CleanupStack::Pop( 2, part );
+
+ return att;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailAttachment* CEmailMessage::AddAttachmentL( RFile& aFile )
+ {
+ User::LeaveIfNull( iPluginMessage );
+ TBufC8 <1> mime;
+ CFSMailMessagePart* part = iPluginMessage->AddNewAttachmentL( aFile, mime );
+ CleanupStack::PushL( part );
+ CEmailAttachment* att = CEmailAttachment::NewLC( iPluginData, iMsgContentId, part, EAPIOwns );
+ iAttachments.AppendL( att );
+
+ CleanupStack::Pop( 2, part );
+
+ return att;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TInt CEmailMessage::GetAttachmentsL( REmailAttachmentArray& aAttachments )
+ {
+ User::LeaveIfNull( iPluginMessage );
+
+ RPointerArray attachments;
+ CleanupResetAndDestroyPushL( attachments );
+ iPluginMessage->AttachmentListL( attachments );
+ const TInt count( attachments.Count() );
+ for (TInt i = 0; i < count; i++)
+ {
+ TMessageContentId msgContentId = MessageContentId( attachments[i]->GetPartId().Id() );
+
+ CEmailAttachment* att = CEmailAttachment::NewL(
+ iPluginData, msgContentId, attachments[i], EClientOwns );
+
+ aAttachments.AppendL( att );
+ }
+ CleanupStack::Pop( &attachments );
+ return count;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMessage::RemoveAttachmentL( const MEmailAttachment& /*aAttachment*/ )
+ {
+ User::Leave( KErrNotSupported );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+const TFolderId& CEmailMessage::ParentFolderId() const
+ {
+ return iMessageId.iFolderId;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMessage::SaveChangesL()
+ {
+ User::LeaveIfNull( iPluginMessage );
+
+ TFSMailMsgId mailboxId(
+ FsMsgId( iPluginData, iMessageId.iFolderId.iMailboxId ) );
+
+ iPlugin->StoreMessageL( mailboxId, *iPluginMessage );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMessage::SendL()
+ {
+ User::LeaveIfNull( iPluginMessage );
+
+ if ( iEventLoop.isRunning() )
+ User::Leave( KErrInUse );
+
+ SaveChangesL();
+ iError = KErrNone;
+ iPlugin->SendMessageL( *iPluginMessage, *this, KSendMessageRequestId );
+ iEventLoop.exec();
+
+ User::LeaveIfError( iError );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMessage::RequestResponseL( TFSProgress aEvent, TInt aRequestId )
+ {
+ iError = aEvent.iError;
+
+ if ( aRequestId == KSendMessageRequestId &&
+ aEvent.iProgressStatus == TFSProgress::EFSStatus_RequestComplete )
+ iEventLoop.quit();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMessage::ConvertAddressArrayL(
+ const MEmailAddress::TRole aRole,
+ const RPointerArray& aSrc,
+ REmailAddressArray& aDst ) const
+ {
+ for ( TInt i=0; iSetAddressL( temp1 );
+ }
+ TDesC& temp2 = aFsAddress.GetDisplayName();
+ if ( &temp2 )
+ {
+ address->SetDisplayNameL( temp2 );
+ }
+ return address;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TUint CEmailMessage::MapFlags( const TUint& aFlag )
+ {
+ TUint flag = 0;
+ switch( aFlag )
+ {
+ case EFlag_Read:
+ flag = EFSMsgFlag_Read;
+ break;
+ case EFlag_Read_Locally:
+ flag = EFSMsgFlag_Read_Locally;
+ break;
+ case EFlag_Low:
+ flag = EFSMsgFlag_Low;
+ break;
+ case EFlag_Important:
+ flag = EFSMsgFlag_Important;
+ break;
+ case EFlag_FollowUpComplete:
+ flag = EFSMsgFlag_FollowUpComplete;
+ break;
+ case EFlag_FollowUp:
+ flag = EFSMsgFlag_FollowUp;
+ break;
+ case EFlag_Attachments:
+ flag = EFSMsgFlag_Attachments;
+ break;
+ case EFlag_Multiple:
+ flag = EFSMsgFlag_Multiple;
+ break;
+ case EFlag_CalendarMsg:
+ flag = EFSMsgFlag_CalendarMsg;
+ break;
+ case EFlag_Answered:
+ flag = EFSMsgFlag_Answered;
+ break;
+ case EFlag_Forwarded:
+ flag = EFSMsgFlag_Forwarded;
+ break;
+ case EFlag_OnlyToMe:
+ flag = EFSMsgFlag_OnlyToMe;
+ break;
+ case EFlag_RemoteDeleted:
+ flag = EFSMsgFlag_RemoteDeleted;
+ break;
+ case EFlag_HasMsgSender:
+ flag = EFSMsgFlag_HasMsgSender;
+ break;
+ default:
+ break;
+ }
+ return flag;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMessage::ShowMessageViewerL()
+ {
+ bool syncronous;
+
+ XQServiceRequest request(
+ emailInterfaceNameMessage,
+ emailOperationViewMessage,
+ syncronous );
+
+ TFSMailMsgId mailboxId = FsMsgId( iPluginData, iMessageId.iFolderId.iMailboxId );
+ TFSMailMsgId folderId = FsMsgId( iPluginData, iMessageId.iFolderId );
+ TFSMailMsgId messageId = FsMsgId( iPluginData, iMessageId );
+
+ QList list;
+ list.append( mailboxId.Id() );
+ list.append( folderId.Id() );
+ list.append( messageId.Id() );
+ request.setArguments( list );
+
+ QVariant returnValue;
+ if ( !request.send( returnValue ) )
+ User::Leave( KErrGeneral );
+ }
+
+// -----------------------------------------------------------------------------
+// Launches Email application and new reply message in editor.
+// The method follows "fire and forget" pattern, returns immediately.
+// -----------------------------------------------------------------------------
+void CEmailMessage::ReplyToMessageL( const TBool /*aReplyToAll*/ )
+ {
+ User::Leave( KErrNotSupported );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMessage::ForwardMessageL()
+ {
+ User::Leave( KErrNotSupported );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TMessageContentId CEmailMessage::MessageContentId( TEntryId aContentId ) const
+ {
+ TMessageContentId msgContentId = TMessageContentId(
+ aContentId,
+ iMessageId.iId,
+ iMessageId.iFolderId.iId,
+ iMessageId.iFolderId.iMailboxId );
+ return msgContentId;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TContentType::TContentType( const TDesC& aContentType ) : iContentType( aContentType )
+ {
+ _LIT( KSeparator, ";" );
+ TInt end = aContentType.Find( KSeparator );
+ if ( end != KErrNotFound )
+ {
+ iContentType.Set( aContentType.Left( end ) );
+ }
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TBool TContentType::Equals( const TDesC& aContentType )
+ {
+ TBool ret = iContentType.CompareF( aContentType );
+ if ( ret == 0 )
+ return ETrue;
+ else
+ return EFalse;
+ }
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/src/emailmessagesearch.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailmessagesearch.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,362 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: This file implements class CEmailMessageSearchAsync
+*
+*/
+
+#include
+#include "emailmessagesearch.h"
+#include "emailmessage.h"
+
+/**
+ * Global semaphore name. Semaphore blocks parallel service access.
+ */
+_LIT( KGlobalSemaphoreToPreventParallelCall, "12mymessaging.nokia.com34" );
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// CEmailMessageSearchAsync::NewL
+// ---------------------------------------------------------------------------
+CEmailMessageSearchAsync* CEmailMessageSearchAsync::NewL(
+ CPluginData& aPluginData,
+ const TMailboxId& aMailboxId )
+ {
+ CEmailMessageSearchAsync* self =
+ new ( ELeave ) CEmailMessageSearchAsync( aPluginData, aMailboxId );
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop( self );
+ return self;
+ }
+
+// ---------------------------------------------------------------------------
+//
+// ---------------------------------------------------------------------------
+void CEmailMessageSearchAsync::ConstructL()
+ {
+ iPlugin = iPluginData.ClaimInstanceL();
+ // Open existing semaphore, or create a new one
+ if ( KErrNone != iGate.OpenGlobal( KGlobalSemaphoreToPreventParallelCall, EOwnerProcess ) )
+ {
+ User::LeaveIfError(
+ iGate.CreateGlobal( KGlobalSemaphoreToPreventParallelCall, 1, EOwnerProcess ) );
+ }
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailMessageSearchAsync::CEmailMessageSearchAsync(
+ CPluginData& aPluginData,
+ const TMailboxId& aMailboxId )
+ : iPluginData( aPluginData ), iMailboxId( aMailboxId.iId ),
+ iCriteria(), iObserver( NULL ), iRemote( EFalse )
+ {
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailMessageSearchAsync::~CEmailMessageSearchAsync()
+ {
+ iSearchStrings.Close();
+ iPluginData.ReleaseInstance();
+ iGate.Close();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TEmailTypeId CEmailMessageSearchAsync::InterfaceId() const
+ {
+ return KEmailIFUidSearch;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMessageSearchAsync::Release()
+ {
+ if (KErrNone != iGate.Wait(1))
+ {
+ this->Cancel();
+ }
+ delete this;
+ }
+
+// -----------------------------------------------------------------------------
+// Sets sort order for search results.
+// Leaves KErrNotReady if search is ongoing.
+// -----------------------------------------------------------------------------
+void CEmailMessageSearchAsync::SetSortCriteriaL( const TEmailSortCriteria& aCriteria )
+ {
+ IsSearchGoingOnL();
+
+ switch (aCriteria.iField)
+ {
+ case TEmailSortCriteria::EDontCare:
+ iCriteria.iField = EFSMailDontCare;
+ break;
+
+ case TEmailSortCriteria::EByDate:
+ iCriteria.iField = EFSMailSortByDate;
+ break;
+
+ case TEmailSortCriteria::EBySender:
+ iCriteria.iField = EFSMailSortBySender;
+ break;
+
+ case TEmailSortCriteria::EByRecipient:
+ iCriteria.iField = EFSMailSortByRecipient;
+ break;
+
+ case TEmailSortCriteria::EBySubject:
+ iCriteria.iField = EFSMailSortBySubject;
+ break;
+
+ case TEmailSortCriteria::EByPriority:
+ iCriteria.iField = EFSMailSortByPriority;
+ break;
+
+ case TEmailSortCriteria::EByFlagStatus:
+ iCriteria.iField = EFSMailSortByFlagStatus;
+ break;
+
+ case TEmailSortCriteria::EByUnread:
+ iCriteria.iField = EFSMailSortByUnread;
+ break;
+
+ case TEmailSortCriteria::EBySize:
+ iCriteria.iField = EFSMailSortBySize;
+ break;
+
+ case TEmailSortCriteria::EByAttachment:
+ iCriteria.iField = EFSMailSortByAttachment;
+ break;
+
+ default:
+ User::Leave( KErrNotSupported );
+ break;
+
+ }
+ if (aCriteria.iAscending)
+ {
+ iCriteria.iOrder = EFSMailAscending;
+ }
+ else
+ {
+ iCriteria.iOrder = EFSMailDescending;
+ }
+ // Release gate
+ iGate.Signal();
+ }
+
+// -----------------------------------------------------------------------------
+// Adds a search key. Leaves KErrNotReady if search is ongoing.
+// -----------------------------------------------------------------------------
+void CEmailMessageSearchAsync::AddSearchKeyL( const TDesC& aSearchKey )
+ {
+ IsSearchGoingOnL();
+
+ iSearchStrings.AppendL(&aSearchKey);
+ // Release gate
+ iGate.Signal();
+ }
+
+/// -----------------------------------------------------------------------------
+// Enables/disables search from remote email server.
+// Leaves KErrNotReady if search is ongoing.
+// -----------------------------------------------------------------------------
+void CEmailMessageSearchAsync::SetRemoteSearchL( TBool aRemote )
+ {
+ IsSearchGoingOnL();
+
+ iRemote = aRemote;
+ // Release gate
+ iGate.Signal();
+ // Currently plugins do not support this function
+ User::Leave( KErrNotSupported );
+ }
+
+// -----------------------------------------------------------------------------
+// Indicates whether remote search is enabled.
+// -----------------------------------------------------------------------------
+TBool CEmailMessageSearchAsync::IsRemoteSearch() const
+ {
+ // Currently plugins do not support this function
+ return EFalse;
+ }
+
+// -----------------------------------------------------------------------------
+// Starts search, all methods affecting search attribures leave
+// KErrNotReady while search is ongoing.
+// @param aObserver called when results are available.
+//
+void CEmailMessageSearchAsync::StartSearchL( MEmailSearchObserver& aObserver )
+ {
+ IsSearchGoingOnL();
+
+ iObserver = &aObserver;
+ const TFSMailMsgId fsMailboxId( iPluginData.Uid(), iMailboxId.iId );
+ RArray folderIds;
+
+ /** Search API */
+
+ /**
+ * Asyncronous call for starting search for given string. Only one search can be
+ * performed at a time.
+ *
+ *
+ * This function will search for message's containing the given search string.
+ * The search will be performed on the all message fields: To, Cc, Bcc, subject, body.
+ * The search client will be notified of each found message,
+ * and upon completion of the search. Only one search can be performed at a time.
+ *
+ * To change the sort order in the search result, use the same search string in the
+ * but change the aSortCriteria parameter. The store "caches" the search
+ * results generated by the same search string.
+ *
+ * The function will leave with KErrInUse if a search is already in progress.
+ *
+ * /note Only works if the store is in an authenticated state,
+ * otherwise this function leaves with KErrNotReady
+ *
+ * @paran aMailBoxId id of the mailbox where messages are to be searched
+ * @param aFolderIds list of folders where messages are to be searched
+ * global or folder specific search depends on the size of array is 0 or not.
+ * @param aSearchStrings text strings that will be searched from different message fields.
+ * @param aSortCriteria sort criteria for the results
+ * @param aSearchObserver client observer that will be notified about search status.
+ *
+ */
+ iPlugin->SearchL( fsMailboxId,
+ folderIds,
+ iSearchStrings,
+ iCriteria,
+ *this );
+ // Gate is kept closed as search is asynchronous. Gate will be reopen after search is completed, i.e.
+ // CEmailMessageSearchAsync::SearchCompleted.
+ }
+
+// -----------------------------------------------------------------------------
+// Cancels search.
+// -----------------------------------------------------------------------------
+void CEmailMessageSearchAsync::Cancel()
+ {
+ if (KErrNone != iGate.Wait(1))
+ {
+
+ /**
+ * Cancels current search. Does nothing if there is not any search.
+ * The search client will not be called back after this function is called.
+ *
+ */
+ const TFSMailMsgId fsMailboxId( iPluginData.Uid(), iMailboxId.iId );
+ iPlugin->CancelSearch( fsMailboxId );
+ }
+ else
+ {
+ // Release gate
+ iGate.Signal();
+ }
+ }
+
+// -----------------------------------------------------------------------------
+// * @return search status:
+// * < 0 : Search has failed
+// * KRequestPending : search is ongoing. note that status may be
+// * KRequestPending after HandleResultL callback because results
+// * may be given in chunks of results. Size of chunk depends on
+// * implementation and may vary.
+// * KErrNone : initial state, or search has finished
+// -----------------------------------------------------------------------------
+TInt CEmailMessageSearchAsync::Status() const
+ {
+ if (KErrNone != iGate.Wait(1))
+ {
+ // Search is going on
+ return KRequestPending;
+ }
+ else
+ {
+ // Release gate
+ iGate.Signal();
+ }
+
+ return KErrNone;
+ }
+
+// -----------------------------------------------------------------------------
+// Resets all search attribures. Cancels search if ongoing.
+// -----------------------------------------------------------------------------
+void CEmailMessageSearchAsync::Reset()
+ {
+ if ( KErrNone != iGate.Wait( 1 ) )
+ {
+ this->Cancel();
+ }
+
+ iCriteria = TFSMailSortCriteria();
+ iSearchStrings.Reset();
+
+ // Release gate
+ iGate.Signal();
+
+ };
+
+// -----------------------------------------------------------------------------
+// Notifies the email search API client that a match has been found
+//
+// @param aMatchMessage contains a pointer to the matched message.
+// Ownership is transfered to the observer.
+// -----------------------------------------------------------------------------
+void CEmailMessageSearchAsync::MatchFoundL( CFSMailMessage* aMatchMessage )
+{
+ User::LeaveIfNull( iObserver );
+ CEmailMessage *result = CEmailMessage::NewL(iPluginData, aMatchMessage, EClientOwns );
+ iObserver->HandleResultL( result );
+}
+
+// -----------------------------------------------------------------------------
+// Notifies the email search API client that the search has completed
+// -----------------------------------------------------------------------------
+ void CEmailMessageSearchAsync::SearchCompletedL()
+{
+ User::LeaveIfNull( iObserver );
+ iObserver->SearchCompletedL();
+ // Search is now complete, release gate.
+ iGate.Signal();
+}
+
+// -----------------------------------------------------------------------------
+// Asks client if search engine should change search priority
+// -----------------------------------------------------------------------------
+void CEmailMessageSearchAsync::ClientRequiredSearchPriority(TInt* /*apRequiredSearchPriority*/)
+ {
+ }
+
+// -----------------------------------------------------------------------------
+// Function leaves if search is going on. Otherwise it doesn't do anything.
+// -----------------------------------------------------------------------------
+void CEmailMessageSearchAsync::IsSearchGoingOnL() const
+ {
+ if ( KErrNone != iGate.Wait( 1 ) )
+ {
+ // Leave now, search is going on
+ User::Leave( KErrNotReady );
+ }
+ }
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/src/emailmultipart.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailmultipart.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,378 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: This file implements class CEmailAttachment.
+*
+*/
+
+#include "emailcontent.h"
+#include "emailtextcontent.h"
+#include "emailattachment.h"
+#include "emailmultipart.h"
+#include "emailmessage.h"
+#include "emailclientapi.hrh"
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailMultipart* CEmailMultipart::NewL(
+ CPluginData& aPluginData,
+ const TMessageContentId& aMsgContentId,
+ CFSMailMessagePart* aPart,
+ const TDataOwner aOwner )
+ {
+ CEmailMultipart* self = new ( ELeave ) CEmailMultipart( aOwner );
+ CleanupStack::PushL( self );
+ self->ConstructL( aPluginData, aMsgContentId, aPart );
+ CleanupStack::Pop( self );
+ return self;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMultipart::ConstructL(
+ CPluginData& aPluginData,
+ const TMessageContentId& aMsgContentId,
+ CFSMailMessagePart* aPart )
+ {
+ iEmailMsgContent = CEmailMessageContent::NewL( aPluginData, aMsgContentId, aPart );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailMultipart::~CEmailMultipart()
+ {
+ delete iEmailMsgContent;
+ iChildParts.Reset();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailMultipart::CEmailMultipart( const TDataOwner aOwner ) : iOwner( aOwner )
+ {
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TInt CEmailMultipart::PartCountL()
+ {
+ iChildParts.Reset();
+ RPointerArray childParts;
+ CleanupResetAndDestroyPushL( childParts );
+ iEmailMsgContent->Part().ChildPartsL( childParts );
+ iChildPartCount = childParts.Count();
+
+ for ( TInt i = 0; i < iChildPartCount; i++ )
+ {
+ TFSMailMsgId id = childParts[i]->GetPartId();
+ iChildParts.AppendL( id );
+ }
+ CleanupStack::PopAndDestroy( &childParts );
+ return iChildPartCount;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailMessageContent* CEmailMultipart::PartByIndexL( const TUint aIndex ) const
+ {
+ if ( aIndex >= iChildPartCount )
+ {
+ User::Leave( KErrArgument );
+ }
+ MEmailMessageContent* content = NULL;
+ TFSMailMsgId partId = iChildParts[aIndex];
+ CFSMailMessagePart* copy = iEmailMsgContent->Part().ChildPartL( partId );
+ if ( !copy )
+ return content;
+
+ TContentType contentType( copy->GetContentType() );
+ TMessageContentId msgContentId = TMessageContentId(
+ copy->GetPartId().Id(),
+ Id().iMessageId.iId,
+ Id().iMessageId.iFolderId.iId,
+ Id().iMessageId.iFolderId.iMailboxId );
+
+ if ( contentType.Equals( KFSMailContentTypeTextPlain ) ||
+ contentType.Equals( KFSMailContentTypeTextHtml ) )
+ {
+ content = CEmailTextContent::NewL(
+ iEmailMsgContent->PluginData(), msgContentId, copy, EClientOwns );
+ }
+ else if ( contentType.Equals( KFSMailContentTypeMultipartMixed ) ||
+ contentType.Equals( KFSMailContentTypeMultipartAlternative ) ||
+ contentType.Equals( KFSMailContentTypeMultipartDigest ) ||
+ contentType.Equals( KFSMailContentTypeMultipartRelated ) ||
+ contentType.Equals( KFSMailContentTypeMultipartParallel ) )
+ {
+ content = CEmailMultipart::NewL(
+ iEmailMsgContent->PluginData(), msgContentId, copy, EClientOwns );
+ }
+ else
+ {
+ content = CEmailAttachment::NewL(
+ iEmailMsgContent->PluginData(), msgContentId, copy, EClientOwns );
+ }
+ return content;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMultipart::DeletePartL( const TUint aIndex )
+ {
+ if ( aIndex >= iChildPartCount )
+ {
+ User::Leave( KErrArgument );
+ }
+
+ TFSMailMsgId partId = iChildParts[aIndex];
+ iEmailMsgContent->Part().RemoveChildPartL( partId );
+ iChildParts.Remove( aIndex );
+ iChildPartCount--;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMultipart::AddPartL(
+ const MEmailMessageContent& aPart,
+ const TUint aPos )
+ {
+ if ( aPos > iChildPartCount )
+ {
+ User::Leave( KErrArgument );
+ }
+
+ TFSMailMsgId insertBefore = TFSMailMsgId();
+ if ( aPos < iChildPartCount )
+ {
+ insertBefore = iChildParts[aPos];
+ }
+ const TDesC& contentType = aPart.ContentType();
+
+ CFSMailMessagePart* newPart =
+ iEmailMsgContent->Part().NewChildPartL( insertBefore, contentType );
+ CleanupStack::PushL( newPart );
+ TFSMailMsgId newPartId = newPart->GetPartId();
+ iChildParts.InsertL( newPartId, aPos );
+ iChildPartCount = iChildParts.Count();
+ CleanupStack::Pop( newPart );
+
+
+
+ return;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TEmailTypeId CEmailMultipart::InterfaceId() const
+ {
+ return KEmailIFUidMultipart;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMultipart::Release()
+ {
+ if ( iOwner == EClientOwns )
+ {
+ delete this;
+ }
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TMessageContentId CEmailMultipart::Id() const
+ {
+ return iEmailMsgContent->Id();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailMultipart::ContentType() const
+ {
+ return iEmailMsgContent->ContentType();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMultipart::SetContentType( const TDesC& aContentType )
+ {
+ iEmailMsgContent->SetContentType( aContentType );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailMultipart::ContentId() const
+ {
+ return iEmailMsgContent->ContentId();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMultipart::SetContentId( const TDesC& aContentId )
+ {
+ iEmailMsgContent->SetContentId( aContentId );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailMultipart::ContentDescription() const
+ {
+ return iEmailMsgContent->ContentDescription();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMultipart::SetContentDescription( const TDesC& aContentDescription )
+ {
+ iEmailMsgContent->SetContentDescription( aContentDescription );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailMultipart::ContentDisposition() const
+ {
+ return iEmailMsgContent->ContentDisposition();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMultipart::SetContentDisposition( const TDesC& aContentDisposition )
+ {
+ iEmailMsgContent->SetContentDisposition( aContentDisposition );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailMultipart::ContentClass() const
+ {
+ return iEmailMsgContent->ContentClass();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMultipart::SetContentClass( const TDesC& aContentClass )
+ {
+ iEmailMsgContent->SetContentClass( aContentClass );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TInt CEmailMultipart::AvailableSize() const
+ {
+ return iEmailMsgContent->AvailableSize();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TInt CEmailMultipart::TotalSize() const
+ {
+ return iEmailMsgContent->TotalSize();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailMultipart::ContentL() const
+ {
+ User::Leave(KErrNotSupported);
+ return iEmailMsgContent->ContentL();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMultipart::SetContentL( const TDesC& aContent )
+ {
+ iEmailMsgContent->SetContentL( aContent );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMultipart::FetchL( MEmailFetchObserver& aObserver )
+ {
+ iEmailMsgContent->FetchL( aObserver );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMultipart::CancelFetch()
+ {
+ iEmailMsgContent->CancelFetch();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMultipart::SaveToFileL( const TDesC& aPath )
+ {
+ iEmailMsgContent->SaveToFileL( aPath );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailMultipart* CEmailMultipart::AsMultipartOrNull() const
+ {
+ const MEmailMultipart* ptr = this;
+ return const_cast( ptr );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailTextContent* CEmailMultipart::AsTextContentOrNull() const
+ {
+ return NULL;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailAttachment* CEmailMultipart::AsAttachmentOrNull() const
+ {
+ return NULL;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailMultipart::SetOwner( const TDataOwner aOwner )
+ {
+ iOwner = aOwner;
+ }
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/src/emailtextcontent.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/emailtextcontent.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,298 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: This file implements class CEmailAttachment.
+*
+*/
+
+#include "emailcontent.h"
+#include "emailtextcontent.h"
+#include "emailmessage.h"
+#include "emailclientapi.hrh"
+
+// CEmailTextContent
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailTextContent* CEmailTextContent::NewL(
+ CPluginData& aPluginData,
+ const TMessageContentId& aMsgContentId,
+ CFSMailMessagePart* aPart,
+ const TDataOwner aOwner )
+ {
+ CEmailTextContent* self = new ( ELeave ) CEmailTextContent( aOwner );
+ CleanupStack::PushL( self );
+ self->ConstructL( aPluginData, aMsgContentId, aPart );
+ CleanupStack::Pop( self );
+ return self;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailTextContent::ConstructL(
+ CPluginData& aPluginData,
+ const TMessageContentId& aMsgContentId,
+ CFSMailMessagePart* aPart )
+ {
+ iEmailMsgContent = CEmailMessageContent::NewL( aPluginData, aMsgContentId, aPart );
+ TContentType contentType( aPart->GetContentType() );
+ if ( contentType.Equals( KFSMailContentTypeTextHtml ) )
+ {
+ iTextType = EHtmlText;
+ }
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailTextContent::~CEmailTextContent()
+ {
+ delete iEmailMsgContent;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CEmailTextContent::CEmailTextContent( TDataOwner aOwner ) :
+ iTextType( EPlainText ),
+ iOwner( aOwner )
+ {
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TEmailTypeId CEmailTextContent::InterfaceId() const
+ {
+ return KEmailIFUidTextContent;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailTextContent::Release()
+ {
+ if ( iOwner == EClientOwns )
+ {
+ delete this;
+ }
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailTextContent::TTextType CEmailTextContent::TextType() const
+ {
+ return iTextType;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailTextContent::SetTextL(
+ const TTextType aPlainOrHtml,
+ const TDesC& aText )
+ {
+ iTextType = aPlainOrHtml;
+
+ if( aPlainOrHtml == EPlainText )
+ {
+ SetContentType( KContentTypeTextPlain );
+ }
+ else if( aPlainOrHtml == EHtmlText )
+ {
+ SetContentType( KContentTypeTextHtml );
+ }
+ SetContentL( aText );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TMessageContentId CEmailTextContent::Id() const
+ {
+ return iEmailMsgContent->Id();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailTextContent::ContentType() const
+ {
+ return iEmailMsgContent->ContentType();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailTextContent::SetContentType( const TDesC& aContentType )
+ {
+ iEmailMsgContent->SetContentType( aContentType );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailTextContent::ContentId() const
+ {
+ return iEmailMsgContent->ContentId();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailTextContent::SetContentId( const TDesC& aContentId )
+ {
+ iEmailMsgContent->SetContentId( aContentId );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailTextContent::ContentDescription() const
+ {
+ return iEmailMsgContent->ContentDescription();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailTextContent::SetContentDescription( const TDesC& aContentDescription )
+ {
+ iEmailMsgContent->SetContentDescription( aContentDescription );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailTextContent::ContentDisposition() const
+ {
+ return iEmailMsgContent->ContentDisposition();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailTextContent::SetContentDisposition( const TDesC& aContentDisposition )
+ {
+ iEmailMsgContent->SetContentDisposition( aContentDisposition );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailTextContent::ContentClass() const
+ {
+ return iEmailMsgContent->ContentClass();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailTextContent::SetContentClass( const TDesC& aContentClass )
+ {
+ iEmailMsgContent->SetContentClass( aContentClass );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TInt CEmailTextContent::AvailableSize() const
+ {
+ return iEmailMsgContent->AvailableSize();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TInt CEmailTextContent::TotalSize() const
+ {
+ return iEmailMsgContent->TotalSize();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TPtrC CEmailTextContent::ContentL() const
+ {
+ return iEmailMsgContent->ContentL();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailTextContent::SetContentL( const TDesC& aContent )
+ {
+ iEmailMsgContent->SetContentL( aContent );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailTextContent::FetchL( MEmailFetchObserver& aObserver )
+ {
+ iEmailMsgContent->FetchL( aObserver );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailTextContent::CancelFetch()
+ {
+ iEmailMsgContent->CancelFetch();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailTextContent::SaveToFileL( const TDesC& aPath )
+ {
+ iEmailMsgContent->SaveToFileL( aPath );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailMultipart* CEmailTextContent::AsMultipartOrNull() const
+ {
+ return NULL;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailTextContent* CEmailTextContent::AsTextContentOrNull() const
+ {
+ const MEmailTextContent* ptr = this;
+ return const_cast(ptr);
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailAttachment* CEmailTextContent::AsAttachmentOrNull() const
+ {
+ return NULL;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CEmailTextContent::SetOwner( const TDataOwner aOwner )
+ {
+ iOwner = aOwner;
+ }
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/src/implproxy.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/implproxy.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,44 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: ECom impementation proxy for Email client API
+*
+*/
+
+#include "emailclientapiimpl.hrh"
+#include "emailclientapiimpl.h"
+#include "emailinterfacefactoryimpl.h"
+#include //TImplementationProxy
+
+// -----------------------------------------------------------------------------
+// Defines the pairing required by the ECOM framework to correctly identify the
+// instantiation method pointer for client's request.
+// -----------------------------------------------------------------------------
+const TImplementationProxy ImplementationTable[] =
+ {
+ IMPLEMENTATION_PROXY_ENTRY(
+ KEmailClientApiImplUid,
+ CEmailInterfaceFactoryImpl::NewL )
+ };
+
+// -----------------------------------------------------------------------------
+// Returns the TImplementationProxy for email client api implementation
+// -----------------------------------------------------------------------------
+EXPORT_C const TImplementationProxy* ImplementationGroupProxy( TInt& aTableCount )
+ {
+ aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy );
+
+ return ImplementationTable;
+ }
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailclientapi/src/messageiterator.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/emailclientapi/src/messageiterator.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,319 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: This file implements class CMessageIterator.
+*
+*/
+
+#include "emailmessage.h"
+#include "messageiterator.h"
+#include "emailapiutils.h"
+#include "cfsmailplugin.h"
+#include "emailapiutils.h"
+#include "emailclientapi.hrh"
+#include "mfsmailiterator.h"
+
+// number of messages in chunk to retrive from protocol plugin. Actual chunk
+// size is one less because last element is used for reference to next chunk
+// retrieval. See ReadNextChunkL() for details.
+const TInt KMessageChunkSize = 5;
+
+const TInt KUndefined = -1;
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CMessageIterator* CMessageIterator::NewL(
+ MFSMailIterator* aIterator,
+ CPluginData& aPluginData,
+ TUint aCount )
+ {
+ CMessageIterator* iter = new ( ELeave )
+ CMessageIterator( aIterator, aPluginData, aCount );
+ return iter;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CMessageIterator::~CMessageIterator()
+ {
+ iPluginData.ReleaseInstance();
+ TInt count = iMessageArray.Count();
+ iMessageArray.ResetAndDestroy();
+ for ( TInt i = count; i < iFsMessageArray.Count(); i++ )
+ {
+ delete iFsMessageArray[i];
+ }
+ iFsMessageArray.Reset();
+ delete iIterator;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TEmailTypeId CMessageIterator::InterfaceId() const
+ {
+ return KEmailIFUidMessageIterator;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CMessageIterator::Release()
+ {
+ delete this;
+ }
+
+// -----------------------------------------------------------------------------
+// Returns next message
+// Messages are retrieved from protocol plugin in chunks of x messages and
+// when NextL has be called for x times, next chunk is retrieved. This
+// is trade-off between RAM consumption and speed.
+// -----------------------------------------------------------------------------
+MEmailMessage* CMessageIterator::NextL()
+ {
+ if ( iCursor == KUndefined )
+ {
+ // Buffer empty, read the first chunk
+ if ( !ReadNextChunkL() )
+ {
+ // No messages found,
+ // Reset the cursor and return NULL
+ iCursor = KUndefined;
+ iStartMsgId = TFSMailMsgId();
+ return NULL;
+ }
+ // Items found, return the first item in the buffer
+ iCursor = 0;
+ }
+ else
+ {
+ // Iterate to the next item
+ iCursor++;
+ }
+ return ReadFromChunkL();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailMessage* CMessageIterator::PreviousL()
+ {
+ if ( iCursor == KUndefined )
+ {
+ iStartMsgId = TFSMailMsgId();
+ // Buffer empty, client should first call NextL
+ return NULL;
+ }
+ // Iterate to the previous item
+ iCursor--;
+ return ReadFromChunkL();
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TBool CMessageIterator::ReadNextChunkL()
+ {
+ User::LeaveIfNull( iIterator );
+
+ TBool chunkFound = EFalse;
+
+ // Delete previous items if exist
+ CleanCache();
+ iHasMoreNextItems = iIterator->NextL(
+ iStartMsgId,
+ KMessageChunkSize,
+ iFsMessageArray );
+ if ( iFsMessageArray.Count() > 0 )
+ {
+ chunkFound = ETrue;
+ // Set the cursor to the first item
+ iCursor = 0;
+ iHasMorePrevItems = ETrue;
+ }
+ return chunkFound;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TBool CMessageIterator::ReadPreviousChunkL()
+ {
+ User::LeaveIfNull( iIterator );
+
+ TBool chunkFound = EFalse;
+
+ // Delete previous items if exist
+ CleanCache();
+ RPointerArray tmp;
+ iHasMorePrevItems = iIterator->PreviousL(
+ iStartMsgId,
+ KMessageChunkSize,
+ tmp );
+ TInt count = tmp.Count();
+ if ( count > 0 )
+ {
+ // It seems that items have been found
+ // Set the cursor to the end of array
+ iCursor = count - 1;
+ iHasMoreNextItems = ETrue;
+ chunkFound = ETrue;
+ // Revise the order of the buffer.
+ // Create complete cache, so it is easier to iterate,
+ // as now we have to start from the end of cache
+ for ( TInt i = count; i > 0; i-- )
+ {
+ CFSMailMessage* msg = tmp[i-1];
+ iFsMessageArray.AppendL( msg );
+ AddToCacheL( msg );
+ }
+ }
+
+ return chunkFound;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+MEmailMessage* CMessageIterator::ReadFromChunkL()
+ {
+ if ( iCursor >= KMessageChunkSize )
+ {
+ if ( iHasMoreNextItems )
+ {
+ iStartMsgId = iFsMessageArray[iCursor-1]->GetMessageId();
+ if ( !ReadNextChunkL() )
+ {
+ // No more items found,
+ // set the cursor to the previous item,
+ // and return NULL.
+ iCursor--;
+ return NULL;
+ }
+ }
+ else
+ {
+ // No more items found,
+ // set the cursor to the previous item,
+ // and return NULL.
+ iCursor--;
+ return NULL;
+ }
+ }
+ else if ( iCursor < 0 )
+ {
+ iStartMsgId = iFsMessageArray[0]->GetMessageId();
+ if ( iHasMorePrevItems )
+ {
+ if ( !ReadPreviousChunkL() )
+ {
+ // Buffer is empty now, client should call nextL,
+ // and start reading from the start of the buffer
+ iCursor = KUndefined;
+ return NULL;
+ }
+ }
+ else
+ {
+ // Buffer is empty now, client should call nextL,
+ // and start reading from the start of the buffer
+ iCursor = KUndefined;
+ return NULL;
+ }
+ }
+
+ if ( iCursor < iFsMessageArray.Count() )
+ {
+ /* There are items to read in the cache */
+ if ( iCursor >= iMessageArray.Count() )
+ {
+ AddToCacheL( iFsMessageArray[iCursor] );
+ }
+ return iMessageArray[iCursor];
+ }
+ else
+ {
+ // No more items found,
+ // set the cursor to the previous item,
+ // and return NULL.
+ iCursor--;
+ return NULL;
+ }
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CMessageIterator::AddToCacheL( CFSMailMessage* aFsMsg )
+ {
+ CEmailMessage* message = CEmailMessage::NewL( iPluginData, aFsMsg, EAPIOwns );
+ iMessageArray.AppendL( message );
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CMessageIterator::CleanCache()
+ {
+ // This is strange loop indeed
+ // Both arrays has items that are deleted, iMessageArray has objects that point to iFsMessageArray
+ // Index in both arrays goes syncronously
+ // To prevent double destruction, first delete iMessageArray onjects and then the rest of the iFsMessageArray
+ TInt count = iMessageArray.Count();
+ iMessageArray.ResetAndDestroy();
+ for ( TInt i = count; i < iFsMessageArray.Count(); i++ )
+ {
+ iFsMessageArray.Remove( count );
+ }
+ iFsMessageArray.Reset();
+ }
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+TUint CMessageIterator::Count() const
+ {
+ return iCount;
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+void CMessageIterator::ConstructL()
+ {
+ iPlugin = iPluginData.ClaimInstanceL();
+
+ }
+
+// -----------------------------------------------------------------------------
+//
+// -----------------------------------------------------------------------------
+CMessageIterator::CMessageIterator(
+ MFSMailIterator* aIterator,
+ CPluginData& aPluginData,
+ TUint aCount ) :
+ iIterator( aIterator ),
+ iPluginData( aPluginData ),
+ iStartMsgId( TFSMailMsgId() ),
+ iState( EReadNextMessageChunk ),
+ iFsMessageArray( KMessageChunkSize ),
+ iCount( aCount ),
+ iCursor ( KUndefined ),
+ iFirstMsgId( TFSMailMsgId() ),
+ iHasMoreNextItems( ETrue ),
+ iHasMorePrevItems( ETrue )
+ {
+ }
+
+// End of file
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emaildebug/inc/emailtrace.h
--- a/emailservices/emaildebug/inc/emailtrace.h Fri Jun 11 16:42:02 2010 +0300
+++ b/emailservices/emaildebug/inc/emailtrace.h Thu Jun 24 14:32:18 2010 +0300
@@ -18,47 +18,43 @@
#ifndef EMAILTRACE_H
#define EMAILTRACE_H
-#include
-#include
-#include
-
-/*
- * The NM_TRACING_SYSTEM macro can be used to enable and disable the tracing
- * system in debug mode. The tracing system can be disabled in a specific
- * source file by defining the macro "NM_TRACING_SYSTEM 0" before this file
- * is included.
- */
-#ifndef NM_TRACING_SYSTEM
-#define NM_TRACING_SYSTEM 1
-#endif
+#include
+#include
+#include
+#include
/*
* The macros NM_COMMENT_TRACES, NM_ERROR_TRACES, and NM_FUNCTION_TRACES
* control which debug messages are printed. The trace logging is controlled
- * with the NM_LOG_TO_FILE macro, whereas the NM_LOG_FILE macro defines which
- * file is to be used in logging. The print_trace() helper function implements
- * printing. If NM_LOG_TO_FILE is zero or the NM_LOG_FILE cannot be opened,
- * the messages are printed to qDebug().
+ * with the NM_LOG_TO_FILE macro, whereas the NM_LOG_DIRECTORY macro defines
+ * which directory is to be used to store the log files. The print_trace()
+ * helper function implements printing. Log files are named according to
+ * process and thread IDs. If NM_LOG_TO_FILE is zero or a log file cannot be
+ * opened, the messages are printed to qDebug(). The DSC2STR() function can
+ * be used to convert Symbian descriptors to QString objects.
*/
-#if NM_TRACING_SYSTEM && (defined(DEBUG) || defined(_DEBUG))
+#if defined(DEBUG) || defined(_DEBUG)
-#define NM_COMMENT_TRACES 1
-#define NM_ERROR_TRACES 1
-#define NM_FUNCTION_TRACES 1
+#define NM_COMMENT_TRACES 0
+#define NM_ERROR_TRACES 0
+#define NM_FUNCTION_TRACES 0
#if NM_COMMENT_TRACES || NM_ERROR_TRACES || NM_FUNCTION_TRACES
-#define NM_LOG_TO_FILE 0
-#define NM_LOG_FILE "c:/data/logs/nmail_trace.log"
+#define NM_LOG_TO_FILE 1
+#define NM_LOG_DIRECTORY "c:/data/logs/"
inline void print_trace(const QString& msg)
{
- static QFile file(NM_LOG_FILE);
+ static QFile file(NM_LOG_DIRECTORY+
+ QString("nmail_p%1_t%2.log").
+ arg(QCoreApplication::applicationPid()).
+ arg(QThread::currentThreadId()));
if (NM_LOG_TO_FILE && !file.isOpen()) {
file.open(QIODevice::Append | QIODevice::Text);
}
if (file.isWritable()) {
- QDebug(&file).nospace() << "[Nmail] " << msg << '\n';
+ QDebug(&file).nospace() << msg << '\n';
} else {
qDebug().nospace() << "[Nmail] " << msg;
}
@@ -66,6 +62,16 @@
#endif
+inline QString DSC2STR(const TDesC& dsc)
+{
+ return QString::fromRawData(reinterpret_cast(dsc.Ptr()),
+ dsc.Length());
+}
+
+#else
+
+#define DSC2STR(dsc)
+
#endif /* DEBUG */
/*
@@ -142,7 +148,7 @@
#define ERROR_3(err,msg,arg1,arg2,arg3)\
do {\
QString __msg;\
- __msg.sprintf(msg,arg1,srg2,arg3);\
+ __msg.sprintf(msg,arg1,arg2,arg3);\
NM_ERROR(err,__msg);\
} while(0)
#define ERROR_GEN(msg) ERROR(KErrGeneral,msg)
@@ -162,10 +168,12 @@
/*
* The macro NM_FUNCTION, when used inside a function body, enables tracing
- * for a function. ENTER and RETURN messages are printed when entering into
+ * for a function. If used, it should be placed on the first line of the
+ * function body. ENTER and RETURN messages are printed when entering into
* and returning from a function, respectively. In case of an exception,
- * UNWIND (for stack unwinding) is printed. The FUNC_LOG macro is provided
- * for legacy compatibility. It is deprecated and should not be used.
+ * UNWIND (for stack unwinding) is printed instead of RETURN. The FUNC_LOG
+ * macro is provided for legacy compatibility. It is deprecated and should
+ * not be used.
*/
#if NM_FUNCTION_TRACES
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailframework/src/CFSMailClient.cpp
--- a/emailservices/emailframework/src/CFSMailClient.cpp Fri Jun 11 16:42:02 2010 +0300
+++ b/emailservices/emailframework/src/CFSMailClient.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -188,7 +188,7 @@
{
NM_FUNCTION;
- CFSMailPlugin* plugin = iFWImplementation->GetPluginManager().GetPluginByUid(aFolderId);
+ CFSMailPlugin* plugin = iFWImplementation->GetPluginManager().GetPluginByUid(aMailBoxId);
if(plugin)
{
plugin->DeleteMessagesByUidL(aMailBoxId,aFolderId,aMessages);
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailstore/base_plugin/inc/BasePlugin.h
--- a/emailservices/emailstore/base_plugin/inc/BasePlugin.h Fri Jun 11 16:42:02 2010 +0300
+++ b/emailservices/emailstore/base_plugin/inc/BasePlugin.h Thu Jun 24 14:32:18 2010 +0300
@@ -50,6 +50,7 @@
class CMailboxInfo;
class CSearchHandler;
class HMailIterator;
+class CDelayedOp;
class CDelayedOpsManager;
class MDelayedOpsManager;
@@ -831,6 +832,7 @@
RPointerArray iObservers;
//async fetch reqs.
RPointerArray iReqs;
+ RPointerArray iDelayedOpReqs;
TCacheLine iCacheLine;
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailstore/base_plugin/inc/baseplugindelayedops.h
--- a/emailservices/emailstore/base_plugin/inc/baseplugindelayedops.h Fri Jun 11 16:42:02 2010 +0300
+++ b/emailservices/emailstore/base_plugin/inc/baseplugindelayedops.h Thu Jun 24 14:32:18 2010 +0300
@@ -108,6 +108,10 @@
MDelayedOpsManager* iManager; //not owned
CBasePlugin* iPlugin; //not owned
+public:
+ TInt iRequestId;
+ MFSMailRequestObserver* iOperationObserver;
+
__LOG_DECLARATION
};
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailstore/base_plugin/inc/baseplugindelayedopsprivate.h
--- a/emailservices/emailstore/base_plugin/inc/baseplugindelayedopsprivate.h Fri Jun 11 16:42:02 2010 +0300
+++ b/emailservices/emailstore/base_plugin/inc/baseplugindelayedopsprivate.h Thu Jun 24 14:32:18 2010 +0300
@@ -231,8 +231,6 @@
TFSMailMsgId iMailBox;
RPointerArray iMessages;
RPointerArray iMessageParts;
- MFSMailRequestObserver& iOperationObserver;
- TInt iRequestId;
TInt iType;
// Data buffer for async operations
HBufC8* iDataBuffer;
@@ -273,8 +271,6 @@
private:
CBasePlugin& iBasePlugin;
TFSMailMsgId iMailBox;
- MFSMailRequestObserver& iOperationObserver;
- TInt iRequestId;
__LOG_DECLARATION
};
@@ -342,8 +338,6 @@
TFSMailMsgId iPartId;
HBufC* iContentType;
HBufC* iFilePath;
- MFSMailRequestObserver& iOperationObserver;
- TInt iRequestId;
TInt iActionType;
__LOG_DECLARATION
};
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailstore/base_plugin/src/BasePlugin.cpp
--- a/emailservices/emailstore/base_plugin/src/BasePlugin.cpp Fri Jun 11 16:42:02 2010 +0300
+++ b/emailservices/emailstore/base_plugin/src/BasePlugin.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -131,6 +131,8 @@
iReqs.ResetAndDestroy();
iReqs.Close();
+ iDelayedOpReqs.ResetAndDestroy();
+ iDelayedOpReqs.Close();
ResetCache();
__LOG_DESTRUCT
@@ -800,6 +802,7 @@
CDelayedMessageToSendOp* delayedOp = CDelayedMessageToSendOp::NewLC(
*this,aMailBoxId,aOperationObserver,aRequestId);
iDelayedOpsManager->EnqueueOpL( delayedOp );
+ iDelayedOpReqs.AppendL(delayedOp);
CleanupStack::Pop( delayedOp );
}
//
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailstore/base_plugin/src/baseplugindelayedops.cpp
--- a/emailservices/emailstore/base_plugin/src/baseplugindelayedops.cpp Fri Jun 11 16:42:02 2010 +0300
+++ b/emailservices/emailstore/base_plugin/src/baseplugindelayedops.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -613,10 +613,12 @@
MFSMailRequestObserver& aOperationObserver,
const TInt aRequestId)
: iMailBox( aMailBox ),
- iOperationObserver( aOperationObserver ),
- iRequestId( aRequestId ),
iType(EHeaders)
{
+
+ CDelayedOp::iOperationObserver = &aOperationObserver ;
+ CDelayedOp::iRequestId = aRequestId ;
+
for(TInt i=0; i < messages.Count(); i++)
{
iMessages.Append(messages[i]);
@@ -630,10 +632,12 @@
RPointerArray& aMessageParts,
MFSMailRequestObserver& aOperationObserver,
const TInt aRequestId)
- :iOperationObserver( aOperationObserver ),
- iRequestId( aRequestId ),
- iType(EParts)
+ :iType(EParts)
{
+
+ CDelayedOp::iOperationObserver = &aOperationObserver ;
+ CDelayedOp::iRequestId = aRequestId ;
+
for(TInt i=0; i < aMessageParts.Count(); i++)
{
iMessageParts.Append(aMessageParts[i]);
@@ -704,8 +708,12 @@
progress.iError = KErrNone;
progress.iProgressStatus = TFSProgress::EFSStatus_RequestComplete;
}
-
- iOperationObserver.RequestResponseL( progress, iRequestId );
+
+ if(iOperationObserver)
+ {
+ iOperationObserver->RequestResponseL( progress, iRequestId );
+ }
+
__LOG_EXIT;
}
@@ -714,35 +722,39 @@
/**
*
*/
-void CDelayedMessageStorerOp::StorePartL(
- CFSMailMessagePart* aPart)
+void CDelayedMessageStorerOp::StorePartL(CFSMailMessagePart* aPart)
{
User::LeaveIfNull(aPart);
-
+
// Text buffer for html text content
HBufC* data16 = aPart->GetLocalTextContentLC();
- TPtrC8 ptr8(reinterpret_cast( data16->Ptr() ),
- data16->Size() );
-
+ // Convert from 16 to 8 bit data -
+ HBufC8* dataBuffer = HBufC8::NewLC((data16->Length() * 2) + 1);
+ TPtr8 ptr8(dataBuffer->Des());
+ CnvUtfConverter::ConvertFromUnicodeToUtf8(ptr8, *data16);
+
//get msgstore part
- CMailboxInfo& mailBox = GetPlugin().GetMailboxInfoL( aPart->GetMailBoxId().Id() );
-
+ CMailboxInfo& mailBox = GetPlugin().GetMailboxInfoL(
+ aPart->GetMailBoxId().Id());
+
CMsgStoreMessage* msg = mailBox().FetchMessageL(
- aPart->GetMessageId().Id(), KMsgStoreInvalidId );
- CleanupStack::PushL( msg );
-
- CMsgStoreMessagePart* part= msg->ChildPartL( aPart->GetPartId().Id(), ETrue );
-
- CleanupStack::PopAndDestroy( msg );
- CleanupStack::PushL( part );
+ aPart->GetMessageId().Id(), KMsgStoreInvalidId);
+ CleanupStack::PushL(msg);
+
+ CMsgStoreMessagePart* part = msg->ChildPartL(aPart->GetPartId().Id(),
+ ETrue);
+
+ CleanupStack::PopAndDestroy(msg);
+ CleanupStack::PushL(part);
//replace content
part->ReplaceContentL(ptr8);
-
- CleanupStack::PopAndDestroy( part );
- CleanupStack::PopAndDestroy( data16 );
-
+
+ CleanupStack::PopAndDestroy(part);
+ CleanupStack::PopAndDestroy(dataBuffer);
+ CleanupStack::PopAndDestroy(data16);
+
}
@@ -794,10 +806,11 @@
MFSMailRequestObserver& aOperationObserver,
const TInt aRequestId)
: iBasePlugin(aPlugin),
- iMailBox( aMailBox ),
- iOperationObserver( aOperationObserver ),
- iRequestId( aRequestId )
+ iMailBox( aMailBox )
{
+
+ CDelayedOp::iOperationObserver = &aOperationObserver ;
+ CDelayedOp::iRequestId = aRequestId ;
}
@@ -821,7 +834,10 @@
progress.iProgressStatus = TFSProgress::EFSStatus_RequestComplete;
}
- iOperationObserver.RequestResponseL( progress, iRequestId );
+ if(iOperationObserver)
+ {
+ iOperationObserver->RequestResponseL( progress, iRequestId );
+ }
__LOG_EXIT;
}
@@ -885,10 +901,10 @@
iParentFolderId( aParentFolderId ),
iMessageId( aMessageId ),
iParentPartId( aParentPartId ),
- iOperationObserver( aOperationObserver ),
- iRequestId( aRequestId ),
iActionType( AddNewChild)
{
+ CDelayedOp::iOperationObserver = &aOperationObserver ;
+ CDelayedOp::iRequestId = aRequestId ;
}
/**
@@ -907,10 +923,10 @@
iMessageId( aMessageId ),
iParentPartId( aParentPartId ),
iPartId( aPartId ),
- iOperationObserver( aOperationObserver ),
- iRequestId( aRequestId ),
iActionType( RemoveChild)
{
+ CDelayedOp::iOperationObserver = &aOperationObserver ;
+ CDelayedOp::iRequestId = aRequestId ;
}
/**
@@ -978,7 +994,10 @@
progress.iProgressStatus = TFSProgress::EFSStatus_RequestComplete;
}
- iOperationObserver.RequestResponseL( progress, iRequestId );
+ if(iOperationObserver)
+ {
+ iOperationObserver->RequestResponseL( progress, iRequestId );
+ }
__LOG_EXIT;
}
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/emailstore/base_plugin/src/basepluginmisc.cpp
--- a/emailservices/emailstore/base_plugin/src/basepluginmisc.cpp Fri Jun 11 16:42:02 2010 +0300
+++ b/emailservices/emailstore/base_plugin/src/basepluginmisc.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -384,6 +384,23 @@
break;
}
}
+ count = iDelayedOpReqs.Count();
+ for ( TInt i = 0; i < count; i++ )
+ {
+ if ( iDelayedOpReqs[i]->iRequestId == aRequestId )
+ {
+ CDelayedOp* request = iDelayedOpReqs[i];
+ TFSProgress progress = TFSProgress();
+ progress.iProgressStatus = TFSProgress::EFSStatus_RequestCancelled;
+ progress.iCounter = progress.iMaxCount = 1;
+ progress.iError = KErrNone;
+ request->iOperationObserver->RequestResponseL( progress, aRequestId );
+ iDelayedOpsManager->DequeueOp(*request);
+ iDelayedOpReqs.Remove( i );
+ delete request;
+ break;
+ }
+ }
}
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/nmailagent/nmailagent.pro
--- a/emailservices/nmailagent/nmailagent.pro Fri Jun 11 16:42:02 2010 +0300
+++ b/emailservices/nmailagent/nmailagent.pro Thu Jun 24 14:32:18 2010 +0300
@@ -51,13 +51,14 @@
"conf/2002C326.txt /epoc32/release/winscw/urel/z/private/10202BE9/2002C326.txt" \
"conf/2002C326.txt /epoc32/data/z/private/10202BE9/2002C326.txt"
+ RSS_RULES += "hidden = KAppIsHidden;"
TARGET.EPOCHEAPSIZE = 0x1000 0x100000 // MAX 1MB
LIBS += -ldomaincli
LIBS += -lxqservice
LIBS += -lxqsettingsmanager
- #LIBS += -lxqsystemtoneservice
+ LIBS += -lxqsystemtoneservice
LIBS += -lhwrmvibraclient
TARGET.UID2 = 0x100039CE
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/nmailagent/src/nmmailagent.cpp
--- a/emailservices/nmailagent/src/nmmailagent.cpp Fri Jun 11 16:42:02 2010 +0300
+++ b/emailservices/nmailagent/src/nmmailagent.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -31,7 +31,7 @@
const int NmAgentIndicatorNotSet = -1;
const int NmAgentAlertToneTimer = 60000; // 60s
const int NmAgentDefaultVibraDuration = 1000; // 1 second
-static const quint32 NmRepositoryId = 0x2002C326;
+static const quint32 NmRepositoryId = 0x2002C326;
static const QString NmMailboxIndicatorType = "com.nokia.nmail.indicatorplugin_%1/1.0";
static const QString NmSendIndicatorName = "com.nokia.nmail.indicatorplugin.send/1.0";
static const QString NmUnreadIndicatorName = "com.nokia.nmail.indicatorplugin.unread/1.0";
@@ -99,8 +99,8 @@
return false;
}
- //mSystemTone = new XQSystemToneService();
-
+ mSystemTone = new XQSystemToneService();
+
mIndicator = new HbIndicator();
connect(mIndicator,SIGNAL(userActivated(const QString &, const QVariantMap&)),
this, SLOT(indicatorActivated(const QString&, const QVariantMap&)));
@@ -144,11 +144,10 @@
NM_FUNCTION;
delete mVibra;
- //delete mSystemTone;
+ delete mSystemTone;
qDeleteAll(mMailboxes);
- //delete mSystemTone;
NmDataPluginFactory::releaseInstance(mPluginFactory);
}
@@ -332,10 +331,10 @@
bool changed = false;
if (mailboxInfo->mActive != active ||
refreshAlways) {
-
+
// store the new state to permanent storage
storeMailboxActive(mailboxId, active);
-
+
mailboxInfo->mActive = active;
changed = true;
if (active) {
@@ -428,17 +427,20 @@
{
NM_FUNCTION;
+ bool ok(false);
XQApplicationManager appManager;
XQAiwRequest *request = appManager.create(
XQI_EMAIL_INBOX_VIEW, XQOP_EMAIL_INBOX_VIEW, false);
-
- QList list;
- list.append(QVariant(mailboxId));
- request->setArguments(list);
-
- bool ok = request->send();
- NM_COMMENT(QString("Launch ok=%1 error=%2").arg(ok).arg(request->lastError()));
- delete request;
+ // Instance might be NULL if the service is not available.
+ if (request) {
+ QList list;
+ list.append(QVariant(mailboxId));
+ request->setArguments(list);
+
+ ok = request->send();
+ NM_COMMENT(QString("Launch ok=%1 error=%2").arg(ok).arg(request->lastError()));
+ delete request;
+ }
return ok;
}
@@ -479,7 +481,7 @@
case NmMailboxCreated:
foreach (NmId mailboxId, mailboxIds) {
getMailboxInfo(mailboxId); // create a new mailbox if needed
-
+
// make sure the mailbox activity data is reseted
deleteStoredMailboxActivity(mailboxId);
}
@@ -511,7 +513,7 @@
foreach (NmId mailboxId, mailboxIds) {
// Will hide also the indicator
removeMailboxInfo(mailboxId);
-
+
// make sure the mailbox activity data is deleted
deleteStoredMailboxActivity(mailboxId);
}
@@ -551,7 +553,7 @@
{
NM_FUNCTION;
Q_UNUSED(data);
-
+
// map the indicator type to mailbox
NmMailboxInfo *info = getMailboxByType(type);
if (info) {
@@ -583,45 +585,44 @@
switch (event) {
case NmMessageCreated: {
+ // Check the new messages to make the indicator appear earlier
NmMailboxInfo *mailboxInfo = getMailboxInfo(mailboxId);
+
+ // Inbox folder ID may be still unknown
+ if (mailboxInfo->mInboxFolderId.id() == 0) {
+ NmDataPluginInterface *plugin =
+ mPluginFactory->interfaceInstance(mailboxId);
- // Check the new messages to make the indicator appear earlier
- if (mailboxInfo->mSyncState == Synchronizing) {
-
- // Inbox folder ID may be still unknown
- if (mailboxInfo->mInboxFolderId.id()==0) {
- NmDataPluginInterface *plugin = mPluginFactory->interfaceInstance(mailboxId);
- if (plugin) {
- mailboxInfo->mInboxFolderId =
- plugin->getStandardFolderId(mailboxId, NmFolderInbox);
- }
+ if (plugin) {
+ mailboxInfo->mInboxFolderId =
+ plugin->getStandardFolderId(mailboxId, NmFolderInbox);
}
-
- if (folderId == mailboxInfo->mInboxFolderId) {
- foreach (NmId messageId, messageIds) {
- bool messageUnread = false;
+ }
+
+ if (folderId == mailboxInfo->mInboxFolderId) {
+ foreach (NmId messageId, messageIds) {
+ bool messageUnread = false;
- // Check the message if we can either play a tone or if the "@" is
- // not visible at the moment
- if (mAlertToneAllowed || !mUnreadIndicatorActive) {
- if (getMessageUnreadInfo(folderId, messageId, mailboxId, messageUnread)) {
- if (messageUnread) {
- mailboxInfo->mUnreadMailIdList.append(messageId);
- mailboxInfo->mInboxActive = true;
- updateMailboxState(mailboxId, true, false);
+ // Check the message if we can either play a tone or if the "@" is
+ // not visible at the moment
+ if (mAlertToneAllowed || !mUnreadIndicatorActive) {
+ if (getMessageUnreadInfo(folderId, messageId, mailboxId, messageUnread)) {
+ if (messageUnread) {
+ mailboxInfo->mUnreadMailIdList.append(messageId);
+ mailboxInfo->mInboxActive = true;
+ updateMailboxState(mailboxId, true, false);
- // make the "@" appear immediatelly
- updateUnreadIndicator(true);
+ // make the "@" appear immediatelly
+ updateUnreadIndicator(true);
- // Play the tone as well
- playAlertTone();
- }
+ // Play the tone as well
+ playAlertTone();
}
}
}
}
}
-
+
if (folderId==mailboxInfo->mInboxFolderId) {
mailboxInfo->mInboxCreatedMessages += messageIds.count();
}
@@ -635,7 +636,7 @@
// Always activate the indicator
activate = true;
updateNeeded = true;
-
+
mailboxInfo->mOutboxMails += messageIds.count();
updateSendIndicator();
}
@@ -681,13 +682,21 @@
// The last mail was now deleted
if (mailboxInfo->mOutboxMails == 0) {
NM_COMMENT("NmMailAgent: last mail deleted from outbox");
- // Keep it active if there is unread mails and inbox is still active
- if (mailboxInfo->mInboxActive &&
+ updateNeeded = true;
+
+ // Keep it active if there is unread mails and inbox is still active
+ if (mailboxInfo->mInboxActive &&
mailboxInfo->mUnreadMailIdList.count() > 0) {
activate = true;
- }
- updateNeeded = true;
- }
+ }
+ }
+ else {
+ // Also update the indicator status if it is already shown
+ if (mailboxInfo->mActive) {
+ activate = true;
+ updateNeeded = true;
+ }
+ }
updateSendIndicator();
}
break;
@@ -913,13 +922,15 @@
bool played = false;
if (mAlertToneAllowed) {
- //mSystemTone->playTone(XQSystemToneService::EmailAlertTone);
-
+ if (mSystemTone) {
+ mSystemTone->playTone(XQSystemToneService::EmailAlertTone);
+ }
+
// Execute the vibra effect.
if (mVibra) {
TRAP_IGNORE(mVibra->StartVibraL(NmAgentDefaultVibraDuration));
}
-
+
// play alert only once per minute
mAlertToneAllowed = false;
QTimer::singleShot(NmAgentAlertToneTimer, this, SLOT(enableAlertTone()));
@@ -973,7 +984,7 @@
XQCentralRepositorySettingsKey key(NmRepositoryId, mailboxId.id());
XQSettingsManager mgr;
XQCentralRepositoryUtils utils(mgr);
-
+
if (active) {
// when mailbox is active, key can be deleted
utils.deleteKey(key);
@@ -984,7 +995,7 @@
}
/*!
- Get the mailbox activity state.
+ Get the mailbox activity state.
\param mailboxId id of the mailbox
\return true if the mailbox is active or no information was stored earlier
*/
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/nmclientapi/bwins/nmailclientapiu.def
--- a/emailservices/nmclientapi/bwins/nmailclientapiu.def Fri Jun 11 16:42:02 2010 +0300
+++ b/emailservices/nmclientapi/bwins/nmailclientapiu.def Thu Jun 24 14:32:18 2010 +0300
@@ -187,4 +187,59 @@
?setParentFolderId@NmApiFolder@EmailClientApi@@QAEX_K@Z @ 186 NONAME ; void EmailClientApi::NmApiFolder::setParentFolderId(unsigned long long)
?start@NmApiFolderListing@EmailClientApi@@UAE_NXZ @ 187 NONAME ; bool EmailClientApi::NmApiFolderListing::start(void)
?cancel@NmApiFolderListing@EmailClientApi@@UAEXXZ @ 188 NONAME ; void EmailClientApi::NmApiFolderListing::cancel(void)
+ ?metaObject@NmApiMessageManager@EmailClientApi@@UBEPBUQMetaObject@@XZ @ 189 NONAME ; struct QMetaObject const * EmailClientApi::NmApiMessageManager::metaObject(void) const
+ ?tr@NmApiMessageManager@EmailClientApi@@SA?AVQString@@PBD0H@Z @ 190 NONAME ; class QString EmailClientApi::NmApiMessageManager::tr(char const *, char const *, int)
+ ?createReplyMessage@NmApiMessageManager@EmailClientApi@@QAE_NPBVQVariant@@_N@Z @ 191 NONAME ; bool EmailClientApi::NmApiMessageManager::createReplyMessage(class QVariant const *, bool)
+ ?saveMessage@NmApiMessageManager@EmailClientApi@@QAE_NABUNmApiMessage@@@Z @ 192 NONAME ; bool EmailClientApi::NmApiMessageManager::saveMessage(struct NmApiMessage const &)
+ ?messagesCopied@NmApiMessageManager@EmailClientApi@@IAEXH@Z @ 193 NONAME ; void EmailClientApi::NmApiMessageManager::messagesCopied(int)
+ ??_ENmApiMessageManager@EmailClientApi@@UAE@I@Z @ 194 NONAME ; EmailClientApi::NmApiMessageManager::~NmApiMessageManager(unsigned int)
+ ?tr@NmApiMailboxSettings@EmailClientApi@@SA?AVQString@@PBD0H@Z @ 195 NONAME ; class QString EmailClientApi::NmApiMailboxSettings::tr(char const *, char const *, int)
+ ?loadSettings@NmApiMailboxSettings@EmailClientApi@@QAE_N_KAAVNmApiMailboxSettingsData@2@@Z @ 196 NONAME ; bool EmailClientApi::NmApiMailboxSettings::loadSettings(unsigned long long, class EmailClientApi::NmApiMailboxSettingsData &)
+ ?removeAttachment@NmApiMessageManager@EmailClientApi@@QAE_NAAVNmApiEmailMessage@@_K@Z @ 197 NONAME ; bool EmailClientApi::NmApiMessageManager::removeAttachment(class NmApiEmailMessage &, unsigned long long)
+ ?copyMessages@NmApiMessageManager@EmailClientApi@@QAE_NV?$QList@_K@@_K1@Z @ 198 NONAME ; bool EmailClientApi::NmApiMessageManager::copyMessages(class QList, unsigned long long, unsigned long long)
+ ??1NmApiMessageManager@EmailClientApi@@UAE@XZ @ 199 NONAME ; EmailClientApi::NmApiMessageManager::~NmApiMessageManager(void)
+ ?tr@NmApiMessageManager@EmailClientApi@@SA?AVQString@@PBD0@Z @ 200 NONAME ; class QString EmailClientApi::NmApiMessageManager::tr(char const *, char const *)
+ ?listSettings@NmApiMailboxSettingsData@EmailClientApi@@QBE?AV?$QList@H@@XZ @ 201 NONAME ; class QList EmailClientApi::NmApiMailboxSettingsData::listSettings(void) const
+ ?trUtf8@NmApiMessageManager@EmailClientApi@@SA?AVQString@@PBD0@Z @ 202 NONAME ; class QString EmailClientApi::NmApiMessageManager::trUtf8(char const *, char const *)
+ ?mailboxDeleted@NmApiMailboxSettings@EmailClientApi@@IAEXH@Z @ 203 NONAME ; void EmailClientApi::NmApiMailboxSettings::mailboxDeleted(int)
+ ?staticMetaObject@NmApiMailboxSettings@EmailClientApi@@2UQMetaObject@@B @ 204 NONAME ; struct QMetaObject const EmailClientApi::NmApiMailboxSettings::staticMetaObject
+ ?messagesDeleted@NmApiMessageManager@EmailClientApi@@IAEXH@Z @ 205 NONAME ; void EmailClientApi::NmApiMessageManager::messagesDeleted(int)
+ ??0NmApiMailboxSettingsData@EmailClientApi@@QAE@XZ @ 206 NONAME ; EmailClientApi::NmApiMailboxSettingsData::NmApiMailboxSettingsData(void)
+ ?trUtf8@NmApiMessageManager@EmailClientApi@@SA?AVQString@@PBD0H@Z @ 207 NONAME ; class QString EmailClientApi::NmApiMessageManager::trUtf8(char const *, char const *, int)
+ ?metaObject@NmApiMailboxSettings@EmailClientApi@@UBEPBUQMetaObject@@XZ @ 208 NONAME ; struct QMetaObject const * EmailClientApi::NmApiMailboxSettings::metaObject(void) const
+ ?messagesMoved@NmApiMessageManager@EmailClientApi@@IAEXH@Z @ 209 NONAME ; void EmailClientApi::NmApiMessageManager::messagesMoved(int)
+ ?saveSettings@NmApiMailboxSettings@EmailClientApi@@QAE_NABVNmApiMailboxSettingsData@2@@Z @ 210 NONAME ; bool EmailClientApi::NmApiMailboxSettings::saveSettings(class EmailClientApi::NmApiMailboxSettingsData const &)
+ ?fetch@NmApiMessageManager@EmailClientApi@@QAE_NABUNmApiMessage@@@Z @ 211 NONAME ; bool EmailClientApi::NmApiMessageManager::fetch(struct NmApiMessage const &)
+ ?createMailbox@NmApiMailboxSettings@EmailClientApi@@QAE_NABVQString@@AAVNmApiMailboxSettingsData@2@@Z @ 212 NONAME ; bool EmailClientApi::NmApiMailboxSettings::createMailbox(class QString const &, class EmailClientApi::NmApiMailboxSettingsData &)
+ ?qt_metacast@NmApiMessageManager@EmailClientApi@@UAEPAXPBD@Z @ 213 NONAME ; void * EmailClientApi::NmApiMessageManager::qt_metacast(char const *)
+ ??0NmApiMessageManager@EmailClientApi@@QAE@_KPAVQObject@@@Z @ 214 NONAME ; EmailClientApi::NmApiMessageManager::NmApiMessageManager(unsigned long long, class QObject *)
+ ?getValue@NmApiMailboxSettingsData@EmailClientApi@@QBE_NHAAVQVariant@@@Z @ 215 NONAME ; bool EmailClientApi::NmApiMailboxSettingsData::getValue(int, class QVariant &) const
+ ?tr@NmApiMailboxSettings@EmailClientApi@@SA?AVQString@@PBD0@Z @ 216 NONAME ; class QString EmailClientApi::NmApiMailboxSettings::tr(char const *, char const *)
+ ?moveMessages@NmApiMessageManager@EmailClientApi@@QAE_NV?$QList@_K@@_K1@Z @ 217 NONAME ; bool EmailClientApi::NmApiMessageManager::moveMessages(class QList, unsigned long long, unsigned long long)
+ ??1NmApiMailboxSettingsData@EmailClientApi@@QAE@XZ @ 218 NONAME ; EmailClientApi::NmApiMailboxSettingsData::~NmApiMailboxSettingsData(void)
+ ?validateData@NmApiMailboxSettingsData@EmailClientApi@@QBE_NXZ @ 219 NONAME ; bool EmailClientApi::NmApiMailboxSettingsData::validateData(void) const
+ ?trUtf8@NmApiMailboxSettings@EmailClientApi@@SA?AVQString@@PBD0H@Z @ 220 NONAME ; class QString EmailClientApi::NmApiMailboxSettings::trUtf8(char const *, char const *, int)
+ ?createForwardMessage@NmApiMessageManager@EmailClientApi@@QAE_NPBVQVariant@@@Z @ 221 NONAME ; bool EmailClientApi::NmApiMessageManager::createForwardMessage(class QVariant const *)
+ ?listMailboxIds@NmApiMailboxSettings@EmailClientApi@@QAE_NAAV?$QList@_K@@@Z @ 222 NONAME ; bool EmailClientApi::NmApiMailboxSettings::listMailboxIds(class QList &)
+ ??_ENmApiMailboxSettings@EmailClientApi@@UAE@I@Z @ 223 NONAME ; EmailClientApi::NmApiMailboxSettings::~NmApiMailboxSettings(unsigned int)
+ ?getStaticMetaObject@NmApiMailboxSettings@EmailClientApi@@SAABUQMetaObject@@XZ @ 224 NONAME ; struct QMetaObject const & EmailClientApi::NmApiMailboxSettings::getStaticMetaObject(void)
+ ?deleteMessages@NmApiMessageManager@EmailClientApi@@QAE_NV?$QList@_K@@@Z @ 225 NONAME ; bool EmailClientApi::NmApiMessageManager::deleteMessages(class QList)
+ ?createDraftMessage@NmApiMessageManager@EmailClientApi@@QAE_NPBVQVariant@@@Z @ 226 NONAME ; bool EmailClientApi::NmApiMessageManager::createDraftMessage(class QVariant const *)
+ ??0NmApiMailboxSettings@EmailClientApi@@QAE@PAVQObject@@@Z @ 227 NONAME ; EmailClientApi::NmApiMailboxSettings::NmApiMailboxSettings(class QObject *)
+ ?qt_metacast@NmApiMailboxSettings@EmailClientApi@@UAEPAXPBD@Z @ 228 NONAME ; void * EmailClientApi::NmApiMailboxSettings::qt_metacast(char const *)
+ ?qt_metacall@NmApiMessageManager@EmailClientApi@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 229 NONAME ; int EmailClientApi::NmApiMessageManager::qt_metacall(enum QMetaObject::Call, int, void * *)
+ ??1NmApiMailboxSettings@EmailClientApi@@UAE@XZ @ 230 NONAME ; EmailClientApi::NmApiMailboxSettings::~NmApiMailboxSettings(void)
+ ?deleteMailbox@NmApiMailboxSettings@EmailClientApi@@QAE_N_K@Z @ 231 NONAME ; bool EmailClientApi::NmApiMailboxSettings::deleteMailbox(unsigned long long)
+ ?send@NmApiMessageManager@EmailClientApi@@QAE_NABUNmApiMessage@@@Z @ 232 NONAME ; bool EmailClientApi::NmApiMessageManager::send(struct NmApiMessage const &)
+ ?trUtf8@NmApiMailboxSettings@EmailClientApi@@SA?AVQString@@PBD0@Z @ 233 NONAME ; class QString EmailClientApi::NmApiMailboxSettings::trUtf8(char const *, char const *)
+ ?createAttachment@NmApiMessageManager@EmailClientApi@@QAE_NAAVNmApiEmailMessage@@ABVQVariant@@@Z @ 234 NONAME ; bool EmailClientApi::NmApiMessageManager::createAttachment(class NmApiEmailMessage &, class QVariant const &)
+ ?messagesCreated@NmApiMessageManager@EmailClientApi@@IAEXH@Z @ 235 NONAME ; void EmailClientApi::NmApiMessageManager::messagesCreated(int)
+ ?setMailboxId@NmApiMailboxSettingsData@EmailClientApi@@QAEX_K@Z @ 236 NONAME ; void EmailClientApi::NmApiMailboxSettingsData::setMailboxId(unsigned long long)
+ ?populateDefaultSettings@NmApiMailboxSettings@EmailClientApi@@QAE_NABVQString@@AAVNmApiMailboxSettingsData@2@@Z @ 237 NONAME ; bool EmailClientApi::NmApiMailboxSettings::populateDefaultSettings(class QString const &, class EmailClientApi::NmApiMailboxSettingsData &)
+ ?clearSettings@NmApiMailboxSettingsData@EmailClientApi@@QAEXXZ @ 238 NONAME ; void EmailClientApi::NmApiMailboxSettingsData::clearSettings(void)
+ ?setValue@NmApiMailboxSettingsData@EmailClientApi@@QAEXHABVQVariant@@@Z @ 239 NONAME ; void EmailClientApi::NmApiMailboxSettingsData::setValue(int, class QVariant const &)
+ ?mailboxId@NmApiMailboxSettingsData@EmailClientApi@@QBE_KXZ @ 240 NONAME ; unsigned long long EmailClientApi::NmApiMailboxSettingsData::mailboxId(void) const
+ ?getStaticMetaObject@NmApiMessageManager@EmailClientApi@@SAABUQMetaObject@@XZ @ 241 NONAME ; struct QMetaObject const & EmailClientApi::NmApiMessageManager::getStaticMetaObject(void)
+ ?staticMetaObject@NmApiMessageManager@EmailClientApi@@2UQMetaObject@@B @ 242 NONAME ; struct QMetaObject const EmailClientApi::NmApiMessageManager::staticMetaObject
+ ?qt_metacall@NmApiMailboxSettings@EmailClientApi@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 243 NONAME ; int EmailClientApi::NmApiMailboxSettings::qt_metacall(enum QMetaObject::Call, int, void * *)
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/nmclientapi/eabi/nmailclientapiu.def
--- a/emailservices/nmclientapi/eabi/nmailclientapiu.def Fri Jun 11 16:42:02 2010 +0300
+++ b/emailservices/nmclientapi/eabi/nmailclientapiu.def Thu Jun 24 14:32:18 2010 +0300
@@ -211,4 +211,61 @@
_ZTVN14EmailClientApi19NmApiMailboxListingE @ 210 NONAME
_ZTVN14EmailClientApi20NmApiEnvelopeListingE @ 211 NONAME
_ZTVN14EmailClientApi20NmApiMessageEnvelopeE @ 212 NONAME
+ _ZN14EmailClientApi19NmApiMessageManager11qt_metacallEN11QMetaObject4CallEiPPv @ 213 NONAME
+ _ZN14EmailClientApi19NmApiMessageManager11qt_metacastEPKc @ 214 NONAME
+ _ZN14EmailClientApi19NmApiMessageManager11saveMessageERK12NmApiMessage @ 215 NONAME
+ _ZN14EmailClientApi19NmApiMessageManager12copyMessagesE5QListIyEyy @ 216 NONAME
+ _ZN14EmailClientApi19NmApiMessageManager12moveMessagesE5QListIyEyy @ 217 NONAME
+ _ZN14EmailClientApi19NmApiMessageManager13messagesMovedEi @ 218 NONAME
+ _ZN14EmailClientApi19NmApiMessageManager14deleteMessagesE5QListIyE @ 219 NONAME
+ _ZN14EmailClientApi19NmApiMessageManager14messagesCopiedEi @ 220 NONAME
+ _ZN14EmailClientApi19NmApiMessageManager15messagesCreatedEi @ 221 NONAME
+ _ZN14EmailClientApi19NmApiMessageManager15messagesDeletedEi @ 222 NONAME
+ _ZN14EmailClientApi19NmApiMessageManager16createAttachmentER17NmApiEmailMessageRK8QVariant @ 223 NONAME
+ _ZN14EmailClientApi19NmApiMessageManager16removeAttachmentER17NmApiEmailMessagey @ 224 NONAME
+ _ZN14EmailClientApi19NmApiMessageManager16staticMetaObjectE @ 225 NONAME DATA 16
+ _ZN14EmailClientApi19NmApiMessageManager18createDraftMessageEPK8QVariant @ 226 NONAME
+ _ZN14EmailClientApi19NmApiMessageManager18createReplyMessageEPK8QVariantb @ 227 NONAME
+ _ZN14EmailClientApi19NmApiMessageManager19getStaticMetaObjectEv @ 228 NONAME
+ _ZN14EmailClientApi19NmApiMessageManager20createForwardMessageEPK8QVariant @ 229 NONAME
+ _ZN14EmailClientApi19NmApiMessageManager4sendERK12NmApiMessage @ 230 NONAME
+ _ZN14EmailClientApi19NmApiMessageManager5fetchERK12NmApiMessage @ 231 NONAME
+ _ZN14EmailClientApi19NmApiMessageManagerC1EyP7QObject @ 232 NONAME
+ _ZN14EmailClientApi19NmApiMessageManagerC2EyP7QObject @ 233 NONAME
+ _ZN14EmailClientApi19NmApiMessageManagerD0Ev @ 234 NONAME
+ _ZN14EmailClientApi19NmApiMessageManagerD1Ev @ 235 NONAME
+ _ZN14EmailClientApi19NmApiMessageManagerD2Ev @ 236 NONAME
+ _ZN14EmailClientApi20NmApiMailboxSettings11qt_metacallEN11QMetaObject4CallEiPPv @ 237 NONAME
+ _ZN14EmailClientApi20NmApiMailboxSettings11qt_metacastEPKc @ 238 NONAME
+ _ZN14EmailClientApi20NmApiMailboxSettings12loadSettingsEyRNS_24NmApiMailboxSettingsDataE @ 239 NONAME
+ _ZN14EmailClientApi20NmApiMailboxSettings12saveSettingsERKNS_24NmApiMailboxSettingsDataE @ 240 NONAME
+ _ZN14EmailClientApi20NmApiMailboxSettings13createMailboxERK7QStringRNS_24NmApiMailboxSettingsDataE @ 241 NONAME
+ _ZN14EmailClientApi20NmApiMailboxSettings13deleteMailboxEy @ 242 NONAME
+ _ZN14EmailClientApi20NmApiMailboxSettings14listMailboxIdsER5QListIyE @ 243 NONAME
+ _ZN14EmailClientApi20NmApiMailboxSettings14mailboxDeletedEi @ 244 NONAME
+ _ZN14EmailClientApi20NmApiMailboxSettings16staticMetaObjectE @ 245 NONAME DATA 16
+ _ZN14EmailClientApi20NmApiMailboxSettings19getStaticMetaObjectEv @ 246 NONAME
+ _ZN14EmailClientApi20NmApiMailboxSettings23populateDefaultSettingsERK7QStringRNS_24NmApiMailboxSettingsDataE @ 247 NONAME
+ _ZN14EmailClientApi20NmApiMailboxSettingsC1EP7QObject @ 248 NONAME
+ _ZN14EmailClientApi20NmApiMailboxSettingsC2EP7QObject @ 249 NONAME
+ _ZN14EmailClientApi20NmApiMailboxSettingsD0Ev @ 250 NONAME
+ _ZN14EmailClientApi20NmApiMailboxSettingsD1Ev @ 251 NONAME
+ _ZN14EmailClientApi20NmApiMailboxSettingsD2Ev @ 252 NONAME
+ _ZN14EmailClientApi24NmApiMailboxSettingsData12setMailboxIdEy @ 253 NONAME
+ _ZN14EmailClientApi24NmApiMailboxSettingsData13clearSettingsEv @ 254 NONAME
+ _ZN14EmailClientApi24NmApiMailboxSettingsData8setValueEiRK8QVariant @ 255 NONAME
+ _ZN14EmailClientApi24NmApiMailboxSettingsDataC1Ev @ 256 NONAME
+ _ZN14EmailClientApi24NmApiMailboxSettingsDataC2Ev @ 257 NONAME
+ _ZN14EmailClientApi24NmApiMailboxSettingsDataD1Ev @ 258 NONAME
+ _ZN14EmailClientApi24NmApiMailboxSettingsDataD2Ev @ 259 NONAME
+ _ZNK14EmailClientApi19NmApiMessageManager10metaObjectEv @ 260 NONAME
+ _ZNK14EmailClientApi20NmApiMailboxSettings10metaObjectEv @ 261 NONAME
+ _ZNK14EmailClientApi24NmApiMailboxSettingsData12listSettingsEv @ 262 NONAME
+ _ZNK14EmailClientApi24NmApiMailboxSettingsData12validateDataEv @ 263 NONAME
+ _ZNK14EmailClientApi24NmApiMailboxSettingsData8getValueEiR8QVariant @ 264 NONAME
+ _ZNK14EmailClientApi24NmApiMailboxSettingsData9mailboxIdEv @ 265 NONAME
+ _ZTIN14EmailClientApi19NmApiMessageManagerE @ 266 NONAME
+ _ZTIN14EmailClientApi20NmApiMailboxSettingsE @ 267 NONAME
+ _ZTVN14EmailClientApi19NmApiMessageManagerE @ 268 NONAME
+ _ZTVN14EmailClientApi20NmApiMailboxSettingsE @ 269 NONAME
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/nmclientapi/inc/nmapimailboxsettings_p.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/inc/nmapimailboxsettings_p.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,61 @@
+/*
+ * 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#ifndef NMAPIMAILBOXSETTINGS_P_H_
+#define NMAPIMAILBOXSETTINGS_P_H_
+
+#include
+#include
+#include
+#include
+
+class NmApiDataPluginFactory;
+class NmOperation;
+
+namespace EmailClientApi
+{
+class NmApiMailboxSettingsData;
+
+class NmApiMailboxSettingsPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ NmApiMailboxSettingsPrivate(QObject *parent = 0);
+ ~NmApiMailboxSettingsPrivate();
+
+ bool listMailboxIds(QList &idList);
+ bool loadSettings(quint64 mailboxId, NmApiMailboxSettingsData &data);
+ bool saveSettings(const NmApiMailboxSettingsData &data);
+ bool createMailbox(const QString &mailboxType, NmApiMailboxSettingsData &data);
+ bool deleteMailbox(quint64 mailboxId);
+ bool populateDefaultSettings(const QString &mailboxType, NmApiMailboxSettingsData &data);
+
+signals:
+ void mailboxDeleted(int result = 0);
+
+private:
+ void createPopImapMailbox(const QString &type, NmApiMailboxSettingsData &data);
+
+
+private:
+ NmApiDataPluginFactory *mFactory;
+ QPointer mDeleteMailboxOperation; // not owned
+};
+
+}
+
+#endif /* NMAPIMAILBOXSETTINGS_P_H_ */
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/nmclientapi/inc/nmapimailboxsettingsdata_p.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/inc/nmapimailboxsettingsdata_p.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,63 @@
+/*
+ * 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+#ifndef _NMAPI_MAILBOX_SETTINGS_DATA_PRIVATE_
+#define _NMAPI_MAILBOX_SETTINGS_DATA_PRIVATE_
+
+#include
+#include
+#include
+
+namespace EmailClientApi
+{
+class NmApiMailboxSettingsDataPrivate
+{
+public:
+ NmApiMailboxSettingsDataPrivate();
+ virtual ~NmApiMailboxSettingsDataPrivate();
+ void setMailboxId(quint64 mailboxId);
+ quint64 mailboxId() const;
+ void setValue(int key, const QVariant &settingValue);
+ bool getValue(int key, QVariant &settingValue) const;
+ bool validateData() const;
+ QList listSettings() const;
+ void clearSettings();
+
+private:
+ bool validateString(int key, QVariant& val, bool& validated) const;
+ bool validateStringValue(int key, QString& val) const;
+ bool validateStringGeneral(int key, QString& val, bool& handled) const;
+ bool validateEmailAddress(int key, QString& val, bool& handled) const;
+ bool validateUsesAuthentication(int key, QString& val, bool& handled) const;
+ bool validateSecurityType(int key, QString& val, bool& handled) const;
+ bool validateAOLState(int key, QString& val, bool& handled) const;
+ bool validateInteger(int key, QVariant& val, bool& validated) const;
+ bool validateIntVal(int key, int val) const;
+ bool validateIntGeneral(int key, int val, bool& handled) const;
+ bool validateOnOffValue(int key, int val, bool& handled) const;
+ bool validateWeekdayMask(int key, int val, bool& handled) const;
+ bool validateHoursInDay(int key, int val, bool& handled) const;
+ bool validateBool(int key, QVariant& val, bool& validated) const;
+ bool validateDateTime(int key, QVariant& val, bool& validated) const;
+
+private:
+ quint64 mId;
+ QScopedPointer > mSettings;
+
+};
+}//end namespace
+
+#endif //_NMAPI_MAILBOX_SETTINGS_DATA_PRIVATE_
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/nmclientapi/inc/nmapimessagemanager_p.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/inc/nmapimessagemanager_p.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,82 @@
+/*
+ * 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * Email message related operations
+ */
+
+#ifndef NMAPIMESSAGEMANAGER_P_H_
+#define NMAPIMESSAGEMANAGER_P_H_
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+
+class NmApiEmailMessage;
+
+namespace EmailClientApi
+{
+
+class NmApiMessageManagerPrivate : public QObject
+{
+ Q_OBJECT
+public:
+ NmApiMessageManagerPrivate(quint64 mailboxId,QObject *parent = 0);
+ virtual ~NmApiMessageManagerPrivate();
+
+private:
+ enum EState {
+ EIdle = 0,
+ ECopyPending,
+ EMovePending,
+ EDeletePending
+ };
+
+public slots:
+ bool moveMessages(const QList messageIds,
+ quint64 sourceFolderId,
+ quint64 targetFolderId);
+
+ bool copyMessages(const QList messageIds,
+ quint64 sourceFolder,
+ quint64 targetFolder);
+
+ void messageEventHandler(NmMessageEvent event,
+ const NmId &folder,
+ const QList &messages,
+ const NmId &mailBox);
+
+signals:
+ void messagesCopied(int result);
+ void messagesCreated(int result);
+ void messagesMoved(int result);
+ void messagesDeleted(int result);
+
+
+private:
+ NmApiMessageManagerPrivate::EState mState;
+ QList mMessages;
+ NmId mTarget;
+ NmId mMailboxId;
+ NmApiDataPluginFactory *mFactory;
+ QObject *mPlugin;
+};
+
+}
+
+#endif /*NMAPIMESSAGEMANAGER_P_H_ */
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/nmclientapi/inc/nmapipopimapsettingsmanager.h
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/inc/nmapipopimapsettingsmanager.h Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,39 @@
+/*
+* 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"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description:
+*
+*/
+
+#ifndef NMAPIPOPIMAPSETTINGSMANAGER_H
+#define NMAPIPOPIMAPSETTINGSMANAGER_H
+
+#include
+
+namespace EmailClientApi {
+
+class NmApiPopImapSettingsManager
+{
+public:
+ NmApiPopImapSettingsManager();
+ virtual ~NmApiPopImapSettingsManager();
+ bool populateDefaults(const QString &mailboxType, NmApiMailboxSettingsData &data);
+
+private:
+ void populateImapDefs(NmApiMailboxSettingsData &data);
+ void populatePopDefs(NmApiMailboxSettingsData &data);
+
+};
+}//namespace
+
+#endif // NMAPIPOPIMAPSETTINGSMANAGER_H
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/nmclientapi/nmclientapi.pro
--- a/emailservices/nmclientapi/nmclientapi.pro Fri Jun 11 16:42:02 2010 +0300
+++ b/emailservices/nmclientapi/nmclientapi.pro Thu Jun 24 14:32:18 2010 +0300
@@ -44,7 +44,9 @@
nmapidatapluginfactory.h \
nmapiengine.h \
nmmessagepart.h \
- nmapicommon.h
+ nmapicommon.h \
+ nmapimessagemanager.h \
+ nmoperation.h
#headers and sources from api
SOURCES += nmapitypesconverter.cpp \
@@ -52,8 +54,6 @@
nmapiemailservice.cpp \
nmapiengine.cpp
-
-
HEADERS += nmapicommonheader.h \
nmapiemailservice.h \
nmapimessagetask.h \
@@ -63,18 +63,24 @@
nmapifolderlisting.h \
nmapienvelopelisting_p.h \
nmapienvelopelisting.h \
- nmapiemailaddress_p.h \
- nmapiemailaddress.h \
- nmapieventnotifier_p.h \
- nmapieventnotifier.h \
- nmapifolder_p.h \
- nmapifolder.h \
- nmapimailbox_p.h \
- nmapimailbox.h \
- nmapimessagebody_p.h \
- nmapimessagebody.h \
- nmapimessageenvelope_p.h \
- nmapimessageenvelope.h
+ nmapiemailaddress_p.h \
+ nmapiemailaddress.h \
+ nmapieventnotifier_p.h \
+ nmapieventnotifier.h \
+ nmapifolder_p.h \
+ nmapifolder.h \
+ nmapimailbox_p.h \
+ nmapimailbox.h \
+ nmapimessagebody_p.h \
+ nmapimessagebody.h \
+ nmapimessageenvelope_p.h \
+ nmapimessageenvelope.h \
+ nmapimailboxsettingsdata_p.h \
+ nmapimailboxsettingsdata.h \
+ ../inc/nmapimailboxsettings_p.h \
+ ../../email_plat/nmail_settings_api/nmapimailboxsettings.h \
+ ../inc/nmapipopimapsettingsmanager.h \
+ ../inc/nmapimessagemanager_p.h
LIBS += -leuser
LIBS += -llibc
@@ -87,17 +93,24 @@
nmapifolderlisting.cpp \
nmapienvelopelisting_p.cpp \
nmapienvelopelisting.cpp \
- nmapiemailaddress.cpp \
- nmapieventnotifier_p.cpp \
- nmapieventnotifier.cpp \
- nmapifolder.cpp \
- nmapimailbox.cpp \
- nmapimessagebody.cpp \
- nmapimessageenvelope.cpp
+ nmapiemailaddress.cpp \
+ nmapieventnotifier_p.cpp \
+ nmapieventnotifier.cpp \
+ nmapifolder.cpp \
+ nmapimailbox.cpp \
+ nmapimessagebody.cpp \
+ nmapimessageenvelope.cpp \
+ nmapimailboxsettingsdata_p.cpp \
+ nmapimailboxsettingsdata.cpp \
+ ../src/nmapimailboxsettings_p.cpp \
+ ../src/nmapimailboxsettings.cpp \
+ nmapipopimapsettingsmanager.cpp \
+ ../src/nmapimessagemanager_p.cpp \
+ ../src/nmapimessagemanager.cpp
-
-
+
+
symbian*: {
TARGET.EPOCALLOWDLLDATA = 1
@@ -107,8 +120,14 @@
TARGET.UID3 = 0x2002C366
INCLUDEPATH += $$APP_LAYER_SYSTEMINCLUDE
+ DEPENDPATH += $$APP_LAYER_SYSTEMINCLUDE
+
- LIBS += -lnmailbase
+ LIBS += -lnmailbase \
+ -limcm \
+ -lxqsettingsmanager \
+ -lxqutils \
+ -lnmailuiengine
defBlock = \
"$${LITERAL_HASH}if defined(MARM)" \
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/nmclientapi/src/nmapimailboxsettings.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/src/nmapimailboxsettings.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,95 @@
+/*
+ * 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+#include
+#include "nmapimailboxsettings_p.h"
+#include
+
+namespace EmailClientApi {
+
+
+NmApiMailboxSettings::NmApiMailboxSettings(QObject *parent)
+ :QObject(parent)
+{
+ d = new NmApiMailboxSettingsPrivate(this);
+ connect(d, SIGNAL(mailboxDeleted(int)),this,SIGNAL(mailboxDeleted(int)));
+}
+
+NmApiMailboxSettings::~NmApiMailboxSettings()
+{
+ delete d;
+}
+
+/*!
+ \fn listMailboxIds
+ \param idList - QList consists of ids as quint64.
+ \return true is successful, otherwise return false
+
+ Lists ids of mailboxes
+ */
+bool NmApiMailboxSettings::listMailboxIds(QList &idList)
+{
+ return d->listMailboxIds(idList);
+}
+
+bool NmApiMailboxSettings::loadSettings(quint64 mailboxId, NmApiMailboxSettingsData &data)
+{
+ return d->loadSettings(mailboxId, data);
+}
+
+bool NmApiMailboxSettings::saveSettings(const NmApiMailboxSettingsData &data)
+{
+ return d->saveSettings(data);
+}
+
+/*!
+ \fn createMailbox
+ \param mailboxType - mailbox type as QString
+ \param data - mailbox settings data
+
+ Creates a mailbox
+ */
+bool NmApiMailboxSettings::createMailbox(const QString &mailboxType, NmApiMailboxSettingsData &data)
+{
+ return d->createMailbox(mailboxType, data);
+}
+
+/*!
+ \fn deleteMailbox
+ \param mailboxId - mailbox id.
+ \return quint64 - the mailbox id.
+
+ Deletes mailbox with specific id.
+ */
+bool NmApiMailboxSettings::deleteMailbox(quint64 mailboxId)
+{
+ return d->deleteMailbox(mailboxId);
+}
+
+/*!
+ \fn populateDefaultSettings
+ \param mailboxType - mailbox type as QString
+ \param data - mailbox settings data, on return contains dafault settings for mailbox protocol
+ \return true if default settings are set, otherwise false
+
+ Populates NmApiMailboxSettingsData with protocol specific settings data.
+ */
+bool NmApiMailboxSettings::populateDefaultSettings(const QString &mailboxType, NmApiMailboxSettingsData &data)
+{
+ return d->populateDefaultSettings(mailboxType, data);
+}
+
+}//end namespace
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/nmclientapi/src/nmapimailboxsettings_p.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/src/nmapimailboxsettings_p.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,148 @@
+/*
+ * 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include "nmapimailboxsettings_p.h"
+
+#include "nmdataplugininterface.h"
+#include "nmapidatapluginfactory.h"
+//#include "nmapipopimapsettingsmanager.h"
+#include "emailtrace.h"
+
+#include
+#include
+
+#include
+#include
+#include
+#include
+
+namespace EmailClientApi
+{
+NmApiMailboxSettingsPrivate::NmApiMailboxSettingsPrivate(QObject *parent) :
+ QObject(parent),
+ mFactory(NULL),
+ mDeleteMailboxOperation(NULL)
+{
+ NM_FUNCTION;
+ mFactory = NmApiDataPluginFactory::instance();
+ Q_CHECK_PTR(mFactory);
+}
+
+NmApiMailboxSettingsPrivate::~NmApiMailboxSettingsPrivate()
+{
+ NM_FUNCTION;
+ NmApiDataPluginFactory::releaseInstance(mFactory);
+ if(mDeleteMailboxOperation && mDeleteMailboxOperation->isRunning()) {
+ mDeleteMailboxOperation->cancelOperation();
+ }
+}
+
+bool NmApiMailboxSettingsPrivate::listMailboxIds(QList &idList)
+{
+ NM_FUNCTION;
+ QList mailboxIds;
+ bool ret = false;
+ idList.clear();
+
+ NmDataPluginInterface *instance = mFactory->interfaceInstance();
+ if (instance) {
+ if (instance->listMailboxIds(mailboxIds) == KErrNone) {
+
+ foreach (NmId boxId, mailboxIds) {
+ idList.append(boxId.id());
+ }
+
+ ret = true;
+ }
+ }
+
+ return ret;
+}
+
+bool NmApiMailboxSettingsPrivate::loadSettings(quint64 mailboxId, NmApiMailboxSettingsData &data)
+{
+ NM_FUNCTION;
+ Q_UNUSED(mailboxId);
+ Q_UNUSED(data);
+ return false;
+}
+
+bool NmApiMailboxSettingsPrivate::saveSettings(const NmApiMailboxSettingsData &data)
+{
+ NM_FUNCTION;
+ Q_UNUSED(data);
+ return false;
+}
+
+bool NmApiMailboxSettingsPrivate::createMailbox(
+ const QString &mailboxType,
+ NmApiMailboxSettingsData &data)
+{
+ NM_FUNCTION;
+
+ bool ret = false;
+
+ /*QT_TRY {
+ if (mailboxType==NmApiMailboxTypePop || mailboxType==NmApiMailboxTypeImap) {
+ QScopedPointer popImapManager(new NmApiPopImapSettingsManager());
+ popImapManager->createMailbox(mailboxType, data);
+ ret = true;
+ }
+ else {
+ ret = false;
+ }
+ //TODO store cenrep stuff here
+ }
+ QT_CATCH(...){
+ ret = false;
+ }*/
+
+ return ret;
+}
+
+bool NmApiMailboxSettingsPrivate::deleteMailbox(quint64 mailboxId)
+{
+ NM_FUNCTION;
+ bool ret = false;
+ NmDataPluginInterface *instance = mFactory->interfaceInstance();
+ if (instance) {
+ if (mDeleteMailboxOperation && mDeleteMailboxOperation->isRunning()) {
+ mDeleteMailboxOperation->cancelOperation();
+ }
+ mDeleteMailboxOperation = instance->deleteMailboxById(NmId(mailboxId));
+
+ if (mDeleteMailboxOperation) {
+ ret = true;
+ connect(mDeleteMailboxOperation,
+ SIGNAL(operationCompleted(int)),
+ this,
+ SIGNAL(mailboxDeleted(int)));
+ }
+ }
+ return ret;
+}
+
+bool NmApiMailboxSettingsPrivate::populateDefaultSettings(
+ const QString &mailboxType, NmApiMailboxSettingsData &data)
+{
+ NM_FUNCTION;
+ /*QScopedPointer popImapManager(new NmApiPopImapSettingsManager());
+ return popImapManager->populateDefaults(mailboxType, data);*/
+ return true;
+}
+
+}// namespace
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/nmclientapi/src/nmapimailboxsettingsdata.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/src/nmapimailboxsettingsdata.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,113 @@
+/*
+ * 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+#include
+#include "NmApiMailboxSettingsData_p.h"
+
+namespace EmailClientApi
+{
+
+NmApiMailboxSettingsData::NmApiMailboxSettingsData()
+{
+ d = new NmApiMailboxSettingsDataPrivate();
+ Q_CHECK_PTR(d);
+}
+
+NmApiMailboxSettingsData::~NmApiMailboxSettingsData()
+{
+ delete d;
+}
+
+/*!
+ \fn setMailboxId
+ \param mailboxId - valid mailbox id as quint64.
+
+ Sets the mailbox id
+ */
+void NmApiMailboxSettingsData::setMailboxId(quint64 mailboxId)
+{
+ d->setMailboxId(mailboxId);
+}
+
+/*!
+ \fn mailboxId
+ \return quint64 - the mailbox id.
+
+ Gets the mailbox id.
+ */
+quint64 NmApiMailboxSettingsData::mailboxId() const
+{
+ return d->mailboxId();
+}
+
+/*!
+ \fn setValue
+ \param key - setting data to be set.
+ \param settingValue - Value to be set as QVariant.
+
+ Sets individual setting value.
+ */
+void NmApiMailboxSettingsData::setValue(int key, const QVariant &settingValue)
+{
+ d->setValue(key, settingValue);
+}
+
+/*!
+ \fn getValue
+ \param key - setting data to get.
+ \param settingValue - On return holds as QVariant.
+ \return true if successfull, false otherwise.
+
+ Get individual setting value.
+ */
+bool NmApiMailboxSettingsData::getValue(int key, QVariant &settingValue) const
+{
+ return d->getValue(key, settingValue);
+}
+
+/*!
+ \fn validateData
+ \return boolean - true, everything validated OK, false otherwise
+
+ Validates data in this container.
+ */
+bool NmApiMailboxSettingsData::validateData() const
+{
+ return d->validateData();
+}
+
+/*!
+ \fn listSettings
+ \return QList - ,on return contains use key values for settingsdata
+
+ Validates data in this container.
+ */
+QList NmApiMailboxSettingsData::listSettings() const
+{
+ return d->listSettings();
+}
+
+/*!
+ \fn clearSettings
+
+ Resets data in this container.
+ */
+void NmApiMailboxSettingsData::clearSettings()
+{
+ d->clearSettings();
+}
+
+}//end namespace
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/nmclientapi/src/nmapimailboxsettingsdata_p.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/src/nmapimailboxsettingsdata_p.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,761 @@
+/*
+ * 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ *
+ */
+
+#include "nmapimailboxsettingsdata_p.h"
+
+#include
+#include
+#include
+#include
+#include
+#include "emailtrace.h"
+
+namespace EmailClientApi
+{
+
+NmApiMailboxSettingsDataPrivate::NmApiMailboxSettingsDataPrivate() :
+ mId(0), mSettings(new QHash())
+{
+ NM_FUNCTION;
+ Q_CHECK_PTR( mSettings );
+}
+
+NmApiMailboxSettingsDataPrivate::~NmApiMailboxSettingsDataPrivate()
+{
+ NM_FUNCTION;
+}
+
+/*!
+ \fn setMailboxId
+ \param mailboxId - valid mailbox id as quint64.
+
+ Sets the mailbox id
+ */
+void NmApiMailboxSettingsDataPrivate::setMailboxId(quint64 mailboxId)
+{
+ NM_FUNCTION;
+ mId = mailboxId;
+}
+
+/*!
+ \fn mailboxId
+ \return quint64 - the mailbox id.
+
+ Gets the mailbox id.
+ */
+quint64 NmApiMailboxSettingsDataPrivate::mailboxId() const
+{
+ NM_FUNCTION;
+ return mId;
+}
+
+/*!
+ \fn setValue
+ \param key - setting data to be set.
+ \param settingValue - Value to be set as QVariant.
+
+ Sets individual setting value.
+ */
+void NmApiMailboxSettingsDataPrivate::setValue(int key, const QVariant &settingValue)
+{
+ NM_FUNCTION;
+ (*mSettings)[key] = settingValue;
+}
+
+/*!
+ \fn getValue
+ \param key - setting data to get.
+ \param settingValue - On return holds as QVariant.
+ \return true if succesfull, false otherwise.
+
+ Get individual setting value.
+ */
+bool NmApiMailboxSettingsDataPrivate::getValue(int key, QVariant &settingValue) const
+{
+ NM_FUNCTION;
+ if (mSettings->contains(key)) {
+ settingValue = (*mSettings)[key];
+ return true;
+ }
+ return false;
+}
+
+/*!
+ \fn validateString
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param validated - if this key was validated by the method
+ \return true if valid value, false otherwise.
+
+ validates individual string type value.
+ */
+bool NmApiMailboxSettingsDataPrivate::validateString(int key, QVariant& val, bool& validated) const
+{
+ NM_FUNCTION;
+ bool ret = true;
+ switch (key) {
+ case OutgoingPassword:
+ case IncomingPassword:
+ case FolderPath:
+ case IncomingLoginName:
+ case MailboxName:
+ case MyName:
+ case ReceptionActiveProfile:
+ case IncomingMailServer:
+ case OutgoingMailServer:
+ case OutgoingLoginName:
+ case EmailAddress:
+ case ReplyAddress:
+ case EmailAlias:
+ case IncomingMailUsesAuthentication:
+ case OutgoingMailUsesAuthentication:
+ case IncomingMailSecurityType:
+ case OutgoingMailSecurityType:
+ case EmailNotificationState:
+ case AlwaysOnlineState:{
+ validated=true;
+ if (val.type() != QVariant::String) {
+ ret = false;
+ break;
+ }
+
+ QString sz = val.toString();
+ ret = validateStringValue(key, sz);
+ break;
+ }
+
+ default: {
+ validated = false;
+ ret = false;
+ break;
+ }
+ }
+ return ret;
+}
+
+/*!
+ \fn validateStringValue
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \return true if valid value, false otherwise.
+
+ validates individual string type value.
+ */
+bool NmApiMailboxSettingsDataPrivate::validateStringValue(int key, QString& val) const
+{
+ NM_FUNCTION;
+ int ret = true;
+ bool valid = true, validated = false;
+
+ valid = validateStringGeneral(key ,val, validated);
+ if (validated && !valid) {
+ ret = false;
+ }
+
+ if( !validated ) {
+ valid = validateEmailAddress(key ,val, validated);
+ if (validated && !valid) {
+ ret = false;
+ }
+ }
+
+ if( !validated ) {
+ valid = validateUsesAuthentication(key ,val, validated);
+ if (validated && !valid) {
+ ret = false;
+ }
+ }
+
+ if( !validated ) {
+ valid = validateSecurityType(key ,val, validated);
+ if (validated && !valid) {
+ ret = false;
+ }
+ }
+
+ if( !validated ) {
+ valid = validateAOLState(key ,val, validated);
+ if (validated && !valid) {
+ ret = false;
+ }
+ }
+ return ret;
+}
+
+/*!
+ \fn validateStringGeneral
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param handled - true if method value was handled by method.
+ \return true if valid value, false otherwise.
+
+ validates individual string type value.
+ */
+bool NmApiMailboxSettingsDataPrivate::validateStringGeneral(int key, QString& /*val*/, bool& handled) const
+{
+ NM_FUNCTION;
+ int ret = true;
+ switch (key) {
+ case OutgoingPassword:
+ case IncomingPassword:
+ case FolderPath:
+ case IncomingLoginName:
+ case MailboxName:
+ case MyName:
+ case ReceptionActiveProfile:
+ case IncomingMailServer:
+ case OutgoingMailServer:
+ case OutgoingLoginName: {
+ // Allready validated that values are string,
+ // otherwise method is not called
+ handled = true;
+ break;
+ }
+ default: {
+ handled = false;
+ ret = false;
+ break;
+ }
+ }
+ return ret;
+}
+
+/*!
+ \fn validateEmailAddress
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param handled - true if value was validated by the method
+ \return true if valid value, false otherwise.
+
+ validates individual string type value.
+ */
+bool NmApiMailboxSettingsDataPrivate::validateEmailAddress(int key, QString& val, bool& handled) const
+{
+ NM_FUNCTION;
+ int ret = true;
+ switch (key) {
+ case EmailAddress:
+ case ReplyAddress: {
+ handled = true;
+ if (val.size() == 0) {
+ ret = false;
+ break;
+ }
+ if (!(val.contains("@"))) {
+ ret = false;
+ }
+ break;
+ }
+ case EmailAlias: {
+ handled = true;
+ break;
+ }
+ default: {
+ handled = false;
+ ret = false;
+ break;
+ }
+ }
+ return ret;
+}
+
+/*!
+ \fn validateUsesAuthentication
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param handled - true if value was validated by the method
+ \return true if valid value, false otherwise.
+
+ validates individual string type value.
+ */
+bool NmApiMailboxSettingsDataPrivate::validateUsesAuthentication(int key, QString& val, bool& handled) const
+{
+ NM_FUNCTION;
+ int ret = true;
+ switch (key) {
+ case IncomingMailUsesAuthentication:
+ case OutgoingMailUsesAuthentication: {
+ handled = true;
+ if (val.size() == 0) {
+ ret = false;
+ break;
+ }
+ if (!(val.contains("none") ||
+ val.contains("UserAuthentication") ||
+ (key == OutgoingMailUsesAuthentication &&
+ val.contains("SameAsIncoming")) )) {
+ ret = false;
+ }
+ break;
+ }
+ default: {
+ handled = false;
+ ret = false;
+ break;
+ }
+ }
+ return ret;
+}
+
+/*!
+ \fn validateSecurityType
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param validated - true if value was validated by the method
+ \return true if valid value, false otherwise.
+
+ validates individual string type value.
+ */
+bool NmApiMailboxSettingsDataPrivate::validateSecurityType(int key, QString& val, bool& handled) const
+{
+ NM_FUNCTION;
+ int ret = true;
+ switch (key) {
+ case IncomingMailSecurityType:
+ case OutgoingMailSecurityType: {
+ handled = true;
+ if (val.size() == 0) {
+ ret = false;
+ break;
+ }
+ if (!(val.contains("StartTls") ||
+ val.contains("SSLTls") ||
+ val.contains("none"))) {
+ ret = false;
+ }
+ break;
+ }
+ default: {
+ handled = false;
+ ret = false;
+ break;
+ }
+ }
+ return ret;
+}
+
+/*!
+ \fn validateAOLState
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param validated - true if value was validated by the method
+ \return true if valid value, false otherwise.
+
+ validates individual string type value.
+ */
+bool NmApiMailboxSettingsDataPrivate::validateAOLState(int key, QString& val, bool& handled) const
+{
+ NM_FUNCTION;
+ int ret = true;
+ switch (key) {
+ case EmailNotificationState:
+ case AlwaysOnlineState:{
+ handled = true;
+ if (val.size() == 0) {
+ ret = false;
+ break;
+ }
+ if (!( (val.contains("always") && key == AlwaysOnlineState) ||
+ (val.contains("automatic") && key == EmailNotificationState) ||
+ val.contains("homeOnly") ||
+ val.contains("off"))) {
+ ret = false;
+ }
+ break;
+ }
+ default: {
+ handled = false;
+ ret = false;
+ break;
+ }
+ }
+ return ret;
+}
+
+/*!
+ \fn validateInteger
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param validated - true if value was validated by the method
+ \return true if valid value, false otherwise.
+
+ validates individual integer type value.
+ */
+bool NmApiMailboxSettingsDataPrivate::validateInteger(int key, QVariant& val, bool& validated) const
+{
+ NM_FUNCTION;
+ bool ret = true;
+ switch (key) {
+ case DownloadPictures:
+ case MessageDivider:
+ case UserNameHidden:
+ case FirstEmnReceived:
+ case EmnReceivedNotSynced:
+ case AoLastUpdateFailed:
+ case AoUpdateSuccessfulWithCurSettings:
+ case ReceptionUserDefinedProfile:
+ case ReceptionInboxSyncWindow:
+ case ReceptionGenericSyncWindowInMessages:
+ case IncomingPort:
+ case OutgoingPort:
+ case ReceptionWeekDays:
+ case ReceptionDayStartTime:
+ case ReceptionDayEndTime:
+ case ReceptionRefreshPeriodDayTime:
+ case ReceptionRefreshPeriodOther: {
+ validated = true;
+ if (!(val.type() == QVariant::Int ||
+ val.type() == QVariant::UInt ||
+ val.type() == QVariant::LongLong ||
+ val.type() == QVariant::ULongLong ||
+ val.type() == QVariant::Double)) {
+ ret = false;
+ break;
+ }
+ int ival = val.toInt();
+ ret = validateIntVal(key,ival);
+ break;
+ }
+ default: {
+ validated = false;
+ ret = false;
+ break;
+ }
+ }
+ return ret;
+}
+
+/*!
+ \fn validateIntVal
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \return true if valid value, false otherwise.
+
+ validates individual integer type value.
+ */
+bool NmApiMailboxSettingsDataPrivate::validateIntVal(int key, int val) const
+{
+ NM_FUNCTION;
+ int ret = true;
+ bool valid = true, validated = false;
+
+ valid = validateIntGeneral(key ,val, validated);
+ if (validated && !valid) {
+ ret = false;
+ }
+
+ if( !validated ) {
+ valid = validateOnOffValue(key ,val, validated);
+ if (validated && !valid) {
+ ret = false;
+ }
+ }
+
+ if( !validated ) {
+ valid = validateWeekdayMask(key ,val, validated);
+ if (validated && !valid) {
+ ret = false;
+ }
+ }
+
+ if( !validated ) {
+ valid = validateHoursInDay(key ,val, validated);
+ if (validated && !valid) {
+ ret = false;
+ }
+ }
+ return ret;
+}
+
+/*!
+ \fn validateOnOffValue
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param validated - true if value was validated by the method
+ \return true if valid value, false otherwise.
+
+ validates individual integer type value.
+ */
+bool NmApiMailboxSettingsDataPrivate::validateOnOffValue(int key, int val, bool& handled) const
+{
+ NM_FUNCTION;
+ bool ret = true;
+ switch (key) {
+ // Integer: 0=Off, 1=On
+ case DownloadPictures:
+ case MessageDivider:
+ case UserNameHidden:
+
+ // Integer: 0=false,1=true
+ case FirstEmnReceived:
+ case EmnReceivedNotSynced:
+ case AoLastUpdateFailed:
+ case AoUpdateSuccessfulWithCurSettings:
+
+ // Integer: 0=Disabled, 1=Enabled
+ case ReceptionUserDefinedProfile: {
+ handled = true;
+ if (!(0 <= val && val <= 1)) {
+ ret = false;
+ }
+ break;
+ }
+ default: {
+ handled = false;
+ ret = false;
+ break;
+ }
+ }
+ return ret;
+}
+
+/*!
+ \fn validateIntGeneral
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param validated - true if value was validated by the method
+ \return true if valid value, false otherwise.
+
+ validates individual integer type value.
+ */
+bool NmApiMailboxSettingsDataPrivate::validateIntGeneral(int key, int /*val*/, bool& handled) const
+{
+ NM_FUNCTION;
+ bool ret = true;
+ switch (key) {
+ // Integer: 5,15,60,240,0="When open mailbox"
+ case ReceptionRefreshPeriodDayTime:
+ case ReceptionRefreshPeriodOther:
+
+ // Integer: 0=All messages
+ case ReceptionInboxSyncWindow:
+ case ReceptionGenericSyncWindowInMessages:
+
+ // Integer
+ case IncomingPort:
+ case OutgoingPort: {
+ // Allready valid thate these are integers
+ handled = true;
+ break;
+ }
+ default: {
+ handled = false;
+ ret = false;
+ break;
+ }
+ }
+ return ret;
+}
+
+/*!
+ \fn validateWeekDayMask
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param validated - true if value was validated by the method
+ \return true if valid value, false otherwise.
+
+ validates individual integer type value.
+ */
+bool NmApiMailboxSettingsDataPrivate::validateWeekdayMask(int key, int val, bool& handled) const
+{
+ NM_FUNCTION;
+ bool ret = true;
+ switch (key) {
+ // Integer bitmask of weekdays: 0x01=Mon,0x02=Tue,0x04=Wed,0x08=Thu,0x10=Fri,0x20=Sat,0x40=Sun
+ case ReceptionWeekDays: {
+ handled = true;
+ int wkdmask = Mon | Tue | Wed | Thu | Fri | Sat | Sun;
+ if ((val & wkdmask) != val) {
+ ret = false;
+ }
+ break;
+ }
+ default: {
+ handled = false;
+ ret = false;
+ break;
+ }
+ }
+ return ret;
+}
+
+/*!
+ \fn validateHoursInDay
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param validated - true if value was validated by the method
+ \return true if valid value, false otherwise.
+
+ validates individual integer type value.
+ */
+bool NmApiMailboxSettingsDataPrivate::validateHoursInDay(int key, int val, bool& handled) const
+{
+ NM_FUNCTION;
+ bool ret = true;
+ switch (key) {
+ // Integer: 0-23
+ case ReceptionDayStartTime:
+ case ReceptionDayEndTime: {
+ handled = true;
+ if (!(0 <= val && val <= 23)) {
+ ret = false;
+ }
+ break;
+ }
+ default: {
+ handled = false;
+ ret = false;
+ break;
+ }
+ }
+ return ret;
+}
+
+/*!
+ \fn validateBool
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param validated - true if value was validated by the method
+ \return true if valid value, false otherwise.
+
+ validates individual bool type value.
+ */
+bool NmApiMailboxSettingsDataPrivate::validateBool(int key, QVariant& val, bool& validated) const
+{
+ NM_FUNCTION;
+ bool ret = true;
+ switch (key) {
+
+ // Boolean
+ case IncomingSecureSockets:
+ case IncomingSSLWrapper:
+ case UseOutgoingAuthentication:
+ case OutgoingSecureSockets:
+ case OutgoingSSLWrapper: {
+ validated = true;
+ if (val.type() != QVariant::Bool)
+ ret = false;
+ break;
+ }
+ default: {
+ validated = false;
+ ret = false;
+ break;
+ }
+ }
+ return ret;
+}
+
+/*!
+ \fn validateDateTime
+ \param key - setting data to validate.
+ \param val - value to validate.
+ \param validated - true if value was validated by the method
+ \return true if valid value, false otherwise.
+
+ validates individual QDateTime type value.
+ */
+bool NmApiMailboxSettingsDataPrivate::validateDateTime(int key, QVariant& val, bool& validated) const
+{
+ NM_FUNCTION;
+ switch(key) {
+ case AoLastSuccessfulUpdate: {
+ if (val.type() != QVariant::DateTime) {
+ validated = true;
+ return false;
+ }
+ return true;
+ }
+ default: {
+ validated = false;
+ return false;
+ }
+ }
+}
+
+/*!
+ \fn validateData
+ \return boolean - true, everything validated OK, false otherwise
+
+ Validates data in this container.
+ */
+bool NmApiMailboxSettingsDataPrivate::validateData() const
+{
+ NM_FUNCTION;
+ QHash::const_iterator i = mSettings->constBegin();
+ while (i != mSettings->constEnd()) {
+
+ bool validated = false;
+ bool valid = false;
+
+ int key = i.key();
+ QVariant val = i.value();
+
+ ++i;
+
+ valid = validateString(key ,val, validated);
+ if (validated) {
+ if (!valid){
+ return valid;
+ }
+ continue;
+ }
+
+ valid = validateInteger(key ,val, validated);
+ if (validated) {
+ if (!valid){
+ return valid;
+ }
+ continue;
+ }
+
+ valid = validateBool(key ,val, validated);
+ if (validated) {
+ if (!valid){
+ return valid;
+ }
+ continue;
+ }
+
+ valid = validateDateTime(key ,val, validated);
+ if (validated) {
+ if (!valid){
+ return valid;
+ }
+ continue;
+ }
+ }
+ return true;
+}
+
+QList NmApiMailboxSettingsDataPrivate::listSettings() const
+{
+ NM_FUNCTION;
+ return mSettings->keys();
+}
+
+/*!
+ \fn clearSettings
+
+ Resets data in this container.
+ */
+void NmApiMailboxSettingsDataPrivate::clearSettings()
+{
+ mSettings->clear();
+}
+
+}//end namespace
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/nmclientapi/src/nmapimessagemanager.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/src/nmapimessagemanager.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,167 @@
+/*
+ * 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * Email message related operations
+ */
+#include
+#include
+#include
+#include "nmapimessagemanager_p.h"
+
+
+/*!
+ \class NmApiMessageManager
+ \brief A class for performing various operations on messages.
+ */
+
+
+namespace EmailClientApi
+{
+
+ NmApiMessageManager::NmApiMessageManager(quint64 mailboxId,QObject *parent)
+ :QObject(parent)
+{
+ d = new NmApiMessageManagerPrivate(mailboxId,this);
+ connect(d, SIGNAL(messagesCopied(int)),this,SIGNAL(messagesCopied(int)));
+ connect(d, SIGNAL(messagesCreated(int)),this,SIGNAL(messagesCreated(int)));
+ connect(d, SIGNAL(messagesMoved(int)),this,SIGNAL(messagesMoved(int)));
+ connect(d, SIGNAL(messagesDeleted(int)),this,SIGNAL(messagesDeleted(int)));
+}
+
+NmApiMessageManager::~NmApiMessageManager()
+{
+ delete d;
+}
+
+
+ // creates a new email message
+ // signaled with draftMessageCreated(NmApiMessage *message,int result)
+ // * ownership transferred
+bool NmApiMessageManager::createDraftMessage(const QVariant *initData)
+{
+ NM_FUNCTION;
+ Q_UNUSED(initData);
+ return false;
+}
+
+ // creates fw message
+ // signaled with forwardMessageCreated(NmApiMessage *message,int result)
+ // * ownership transferred
+ bool NmApiMessageManager::createForwardMessage(const QVariant *initData)
+ {
+ NM_FUNCTION;
+ Q_UNUSED(initData);
+ return false;
+ }
+
+ // creates reply message
+ // signaled with replyMessageCreated(NmApiMessage *message,int result)
+ // * ownership transferred
+bool NmApiMessageManager::createReplyMessage(const QVariant *initData,
+ bool replyAll)
+{
+ NM_FUNCTION;
+ Q_UNUSED(initData);
+ Q_UNUSED(replyAll);
+ return false;
+}
+
+/*!
+ \fn moveMessages
+ \param messageIds Id list of source messages.
+ \param sourceFolderId Id of the source folder.
+ \param targetFolderId Id of the target folder.
+ \return true if operation was successfully started.
+
+ Starts async move operation for given messages.
+ Completion signalled with messagesMoved(int result).
+ */
+bool NmApiMessageManager::moveMessages(const QList messageIds,
+ quint64 sourceFolderId,
+ quint64 targetFolderId)
+{
+ return d->moveMessages(messageIds,sourceFolderId,targetFolderId);
+}
+
+/*!
+ \fn copyMessages
+ \param messageIds Id list of source messages.
+ \param sourceFolder Id of the source folder.
+ \param targetFolder Id of the target folder.
+ \return true if operation was successfully started.
+
+ Starts async copy operation for given messages.
+ Completion signalled with messagesCopied(int result).
+ */
+bool NmApiMessageManager::copyMessages(const QList messageIds,
+ quint64 sourceFolder,
+ quint64 targetFolder)
+{
+ return d->copyMessages(messageIds, sourceFolder, targetFolder);
+}
+
+// signaled with messageSaved(quint64 messageId, int result)
+bool NmApiMessageManager::saveMessage(const NmApiMessage &message)
+{
+ Q_UNUSED(message);
+ return false;
+}
+
+// deletes message
+// signaled with messagesDeleted(int result)
+bool NmApiMessageManager::deleteMessages(const QList messageIds)
+{
+ Q_UNUSED(messageIds);
+ return false;
+}
+
+ // starts fetching rest of message body from server
+ // signaled with messageFetched(quint64 messageId, int result)
+bool NmApiMessageManager::fetch(const NmApiMessage &message)
+{
+ Q_UNUSED(message);
+ return false;
+}
+
+ // moves message to outbox. Actual sending time may be immediate or scheduled
+ // signaled with messageSent(quint64 messageId, int result)
+bool NmApiMessageManager::send(const NmApiMessage &message)
+{
+ Q_UNUSED(message);
+ return false;
+}
+
+// creates new attachment for a message. Currently attachment can be specified as file name (attachmentSpec is QString)
+// signaled with attachmentCreated(quint64 attachemntId)
+// *
+bool NmApiMessageManager::createAttachment(NmApiEmailMessage &message,
+ const QVariant &attachmenSpec)
+{
+ Q_UNUSED(message);
+ Q_UNUSED(attachmenSpec);
+ return false;
+}
+
+// removes attachment from a message
+// signaled with attachmentRemoved(int result)
+bool NmApiMessageManager::removeAttachment(NmApiEmailMessage &message,
+quint64 /*attachmentId*/)
+{
+ Q_UNUSED(message);
+ return false;
+}
+
+} // namespace EmailClientApi
+
+
diff -r 780f926bc26c -r f83bd4ae1fe3 emailservices/nmclientapi/src/nmapimessagemanager_p.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/emailservices/nmclientapi/src/nmapimessagemanager_p.cpp Thu Jun 24 14:32:18 2010 +0300
@@ -0,0 +1,170 @@
+/*
+ * 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:
+ * Email message related operations
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include "nmapimessagemanager_p.h"
+#include "emailtrace.h"
+
+namespace EmailClientApi
+{
+
+NmApiMessageManagerPrivate::NmApiMessageManagerPrivate(quint64 mailboxId,QObject *parent)
+: QObject(parent),
+ mState(NmApiMessageManagerPrivate::EIdle), mMailboxId(mailboxId)
+{
+ NM_FUNCTION;
+
+ mFactory = NmApiDataPluginFactory::instance();
+ mPlugin = mFactory->plugin();
+ if(mPlugin) {
+ connect(mPlugin,
+ SIGNAL(messageEvent(NmMessageEvent,
+ const NmId&,
+ const QList