emailservices/emailclientapi/inc/emailclientapiimpl.h
branchRCL_3
changeset 64 3533d4323edc
parent 63 d189ee25cf9d
equal deleted inserted replaced
63:d189ee25cf9d 64:3533d4323edc
     1 /*
     1 /*
     2 * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). 
     2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    17 
    17 
    18 #ifndef EMAILCLIENTAPIIMPL_H
    18 #ifndef EMAILCLIENTAPIIMPL_H
    19 #define EMAILCLIENTAPIIMPL_H
    19 #define EMAILCLIENTAPIIMPL_H
    20 
    20 
    21 
    21 
    22 #include <implementationinformation.h> 
    22 #include <ecom/implementationinformation.h> 
    23 #include "emailapiutils.h"
    23 #include "emailapiutils.h"
    24 #include "CFSMailCommon.h"
    24 #include "cfsmailcommon.h"
    25 #include "MFSMailEventObserver.h"    
    25 #include "mfsmaileventobserver.h"    
    26 #include <memailclientapi.h>
    26 #include <memailclientapi.h>
    27 #include "emailclientpluginmanager.h"
    27 #include "emailclientpluginmanager.h"
    28 
    28 
    29 
    29 
    30 using namespace EmailInterface;
    30 using namespace EmailInterface;
    33 class MEmailEventObserver;
    33 class MEmailEventObserver;
    34 class CVwsSessionWrapper;
    34 class CVwsSessionWrapper;
    35 class CFSMailPlugin;
    35 class CFSMailPlugin;
    36 class TFSMailMsgId;
    36 class TFSMailMsgId;
    37 class CEmailMailboxCache;
    37 class CEmailMailboxCache;
    38 class CFSMailClient;
    38 class CFSClientAPI;
    39 
    39 
    40 /**
    40 /**
    41 *  "Framework" class including plugin management
    41 *  "Framework" class including plugin management
    42 * @since S60 v5.2
    42 * @since S60 v5.2
    43 */
    43 */
    44 NONSHARABLE_CLASS( CEmailClientApi ) : public CBase, public MEmailClientApi
    44 NONSHARABLE_CLASS( CEmailClientApi ) : public CBase, public MEmailClientApi, public MEmailClientPluginManager
    45 {
    45 {
    46 public:
    46 public:
    47     /**
    47     /**
    48     * Constructor
    48     * Constructor
    49     * @return
    49     * @return
    54      *
    54      *
    55      */
    55      */
    56      CEmailClientApi();       
    56      CEmailClientApi();       
    57 
    57 
    58 public: // from MEmailInterface
    58 public: // from MEmailInterface
    59     TEmailTypeId InterfaceId() const;
    59     virtual TEmailTypeId InterfaceId() const;
    60     
    60     
    61     void Release();
    61     virtual void Release();
    62     
    62     
    63 public: // from MEmailClientApi
    63 public: // from MEmailClientApi
    64 
    64 
    65     /** @see MEmailClientApi */   
    65     /** @see MEmailClientApi */   
    66     MEmailMailbox* MailboxL( const TMailboxId& aId );
    66     virtual MEmailMailbox* MailboxL( const TMailboxId& aId );
    67    
    67    
    68     /** @see MEmailClientApi */   
    68     /** @see MEmailClientApi */   
    69     MEmailMailbox* MailboxL( const TPtrC& aAddress );
    69     virtual MEmailMailbox* MailboxL( const TPtrC& aAddress );
    70            
    70            
    71     /**
    71     /**
    72     * Gets all mailboxes in pointer array. It is recommended to free other
    72     * Gets all mailboxes in pointer array. It is recommended to free other
    73     * mailboxes besides needed one to optimise memory usage.
    73     * mailboxes besides needed one to optimise memory usage.
    74     */    
    74     */    
    75     TInt GetMailboxesL( RMailboxPtrArray& aMailboxes );
    75     virtual TInt GetMailboxesL( RMailboxPtrArray& aMailboxes );
    76     
    76     
    77     /**
    77     /**
    78     */
    78     */
    79     void LaunchEmailL( const TLaunchPolicy aPolicy );
    79     virtual void LaunchEmailL( const TLaunchPolicy aPolicy );
       
    80     
       
    81 public: // from MEmailPluginManager
       
    82     virtual CFSMailPlugin* GetPluginByUid(TUid aUid);    
    80 
    83 
    81 public: // new methods
    84 public: // new methods
    82 
    85 
    83     /**
    86     /**
    84      * Gets array of mailbox ids
    87      * Gets array of mailbox ids
   181         // iterator array
   184         // iterator array
   182         RPluginDataArray& iArray;
   185         RPluginDataArray& iArray;
   183         // current iterator index
   186         // current iterator index
   184         TInt iIndex;
   187         TInt iIndex;
   185     };
   188     };
       
   189 #if 0 // Not supported    
       
   190     /**
       
   191      * Internal helper class for handling events related to mailboxes
       
   192      *(adding/removal/rename).
       
   193      */
       
   194     class CObserverHandler : public CBase, public MFSMailEventObserver
       
   195     {
       
   196     public:
       
   197         static CObserverHandler* NewL( const RPluginDataArray& aArray  );
       
   198         ~CObserverHandler();
       
   199         CObserverHandler( const RPluginDataArray& aArray );
       
   200         void ConstructL();
       
   201         void AddObserverL( MMailboxEventObserver& aObserver );
       
   202         void RemoveObserver( MMailboxEventObserver& aObserver );
       
   203         
       
   204     public: // from MFSMailEventObserver
       
   205 
       
   206         virtual void EventL(TFSMailEvent aEvent, TFSMailMsgId aMailbox, TAny* aParam1, TAny* aParam2, TAny* aParam3);
       
   207     
       
   208     private: // new methods
       
   209         
       
   210         // used for finding oberver
       
   211         static TBool Equals( const MMailboxEventObserver& a1, const MMailboxEventObserver& a2 );
       
   212         
       
   213         // Plugins needed when first observer subscribes events
       
   214         void ClaimPluginsAndStartObservingL();
       
   215         
       
   216         // plugins can be released when last observer removed
       
   217         void ReleasePlugins();
       
   218                 
       
   219     private: // data
       
   220 
       
   221         // Plugin refCount is incremented by one while any observer is 
       
   222         // registered. This prevents plugin unloading if no other entity uses 
       
   223         // the plugin. 
       
   224         class TEntry
       
   225         {
       
   226         public:
       
   227             inline TEntry( CPluginData& aData ) : iData( aData ), iPlugin( NULL ) {}
       
   228             CPluginData& iData;    
       
   229             
       
   230             // claimed from same object where iData refers to
       
   231             CFSMailPlugin* iPlugin;
       
   232         };
       
   233         
       
   234         // plugin entry array
       
   235         RArray<CObserverHandler::TEntry>     iEntryArray;
       
   236         
       
   237         // reference to CEmailClientApi::iPluginDataArray
       
   238         const RPluginDataArray&              iPluginDataArray;
       
   239         
       
   240         // registered observers
       
   241         RPointerArray<MMailboxEventObserver> iMailboxObservers;
       
   242     };
       
   243 #endif    
       
   244     /**
       
   245      * Returns reference to observer handler.
       
   246      */
       
   247 #if 0 // Not supported    
       
   248     CEmailClientApi::CObserverHandler& ObserverHandlerL();
       
   249 #endif    
   186     
   250     
   187 private:
   251 private:
   188     // plugin data array for all protocol plugins
   252     // plugin data array for all protocol plugins
   189     RPluginDataArray    iPluginDataArray;
   253     RPluginDataArray    iPluginDataArray;
   190 
   254 
   191     // singleton instance counter    
   255     // singleton instance counter    
   192     TInt iInstanceCounter;
   256     TInt iInstanceCounter;
   193     
   257     
   194     // book keeping of loaded plugins
   258     // book keeping of loaded plugins
   195     RArray<TPluginData> iLoadedPluginsArray;
   259     RArray<TPluginData> iLoadedPluginsArray;
   196        
   260     
       
   261 #if 0 // Not supported    
       
   262     // orchestrates event monitoring and related plugin references
       
   263     CEmailClientApi::CObserverHandler*   iObserverHandler;
       
   264     
       
   265 #endif
       
   266     
   197     // Mailbox ids are cached when first time listed. Related plugin uid
   267     // Mailbox ids are cached when first time listed. Related plugin uid
   198     // is include in the cache.
   268     // is include in the cache.
   199     CEmailMailboxCache* iMailboxCache;
   269     CEmailMailboxCache* iMailboxCache;
   200 
   270 
   201     CFSMailClient* iMailClient;
   271     CFSClientAPI* iClientAPI;
   202     
   272     
   203 };
   273 };
   204 
   274 
   205 /**
   275 /**
   206 * Email application launcher. 
   276 * Email application launcher. 
   227 };
   297 };
   228 
   298 
   229 
   299 
   230 #endif // EMAILCLIENTAPIIMPL_H
   300 #endif // EMAILCLIENTAPIIMPL_H
   231 
   301 
   232 // End of file
   302 // End of file.