emailservices/emailframework/src/CFSMailPluginManager.cpp
branchRCL_3
changeset 64 3533d4323edc
parent 63 d189ee25cf9d
child 70 968773a0b6ef
equal deleted inserted replaced
63:d189ee25cf9d 64:3533d4323edc
    13 *
    13 *
    14 * Description:  common mailbox object
    14 * Description:  common mailbox object
    15 *
    15 *
    16 */
    16 */
    17 
    17 
       
    18 
    18 #include "emailtrace.h"
    19 #include "emailtrace.h"
    19 
    20 #include "cfsmailpluginmanager.h"
    20 //<qmail>
    21 #include "cfsmailrequestobserver.h"
    21 #include <nmcommonheaders.h>
    22 #include "cfsmailrequesthandler.h"
    22 //</qmail>
       
    23 #include "CFSMailPluginManager.h"
       
    24 #include "CFSMailRequestObserver.h"
       
    25 #include "CFSMailRequestHandler.h"
       
    26 
    23 
    27 // ================= MEMBER FUNCTIONS ==========================================
    24 // ================= MEMBER FUNCTIONS ==========================================
    28 // -----------------------------------------------------------------------------
    25 // -----------------------------------------------------------------------------
    29 // CFSMailPluginManager::CFSMailPluginManager
    26 // CFSMailPluginManager::CFSMailPluginManager
    30 // -----------------------------------------------------------------------------
    27 // -----------------------------------------------------------------------------
    31 CFSMailPluginManager::CFSMailPluginManager()
    28 CFSMailPluginManager::CFSMailPluginManager()
    32 {
    29 {
    33     NM_FUNCTION;
    30     FUNC_LOG;
       
    31 
    34 }
    32 }
    35 
    33 
    36 // -----------------------------------------------------------------------------
    34 // -----------------------------------------------------------------------------
    37 // CFSMailPluginManager::~CFSMailPluginManager
    35 // CFSMailPluginManager::~CFSMailPluginManager
    38 // -----------------------------------------------------------------------------
    36 // -----------------------------------------------------------------------------
    39 CFSMailPluginManager::~CFSMailPluginManager()
    37 CFSMailPluginManager::~CFSMailPluginManager()
    40 {
    38 {
    41     NM_FUNCTION;
    39     FUNC_LOG;
    42     
       
    43 	iPluginInfo.ResetAndDestroy();
    40 	iPluginInfo.ResetAndDestroy();
    44 }
    41 }
    45 
    42 
    46 
    43 
    47 // -----------------------------------------------------------------------------
    44 // -----------------------------------------------------------------------------
    48 // CFSMailPluginManager::NewLC
    45 // CFSMailPluginManager::NewLC
    49 // -----------------------------------------------------------------------------
    46 // -----------------------------------------------------------------------------
    50 CFSMailPluginManager* CFSMailPluginManager::NewLC(TInt aConfiguration)
    47 CFSMailPluginManager* CFSMailPluginManager::NewLC(TInt aConfiguration)
    51 {
    48 {
    52     NM_FUNCTION;
    49     FUNC_LOG;
    53     
    50   CFSMailPluginManager* pluginManager = new (ELeave) CFSMailPluginManager();
    54     CFSMailPluginManager* pluginManager = new (ELeave) CFSMailPluginManager();
    51   CleanupStack:: PushL(pluginManager);
    55     CleanupStack:: PushL(pluginManager);
    52   pluginManager->ConstructL(aConfiguration);
    56     pluginManager->ConstructL(aConfiguration);
    53   return pluginManager;
    57     return pluginManager;
       
    58 } 
    54 } 
    59 
    55 
    60 // -----------------------------------------------------------------------------
    56 // -----------------------------------------------------------------------------
    61 // CFSMailPluginManager::NewL
    57 // CFSMailPluginManager::NewL
    62 // -----------------------------------------------------------------------------
    58 // -----------------------------------------------------------------------------
    63 CFSMailPluginManager* CFSMailPluginManager::NewL(TInt aConfiguration)
    59 CFSMailPluginManager* CFSMailPluginManager::NewL(TInt aConfiguration)
    64 {
    60 {
    65     NM_FUNCTION;
    61     FUNC_LOG;
    66     
    62   CFSMailPluginManager* pluginManager =  CFSMailPluginManager::NewLC(aConfiguration);
    67     CFSMailPluginManager* pluginManager =  CFSMailPluginManager::NewLC(aConfiguration);
    63   CleanupStack:: Pop(pluginManager);
    68     CleanupStack:: Pop(pluginManager);
    64   return pluginManager;
    69     return pluginManager;
       
    70 }
    65 }
    71 
    66 
    72 // -----------------------------------------------------------------------------
    67 // -----------------------------------------------------------------------------
    73 // CFSMailPluginManager::ConstructL
    68 // CFSMailPluginManager::ConstructL
    74 // -----------------------------------------------------------------------------
    69 // -----------------------------------------------------------------------------
    75 void CFSMailPluginManager::ConstructL(TInt aConfiguration)
    70 void CFSMailPluginManager::ConstructL(TInt aConfiguration)
    76 {
    71 {
    77     NM_FUNCTION;
    72     FUNC_LOG;
    78 
    73 
    79 	// list plugin implementations
    74 	// list plugin implementations
    80 
    75 
    81 	iPluginInfo.Reset();
    76 	iPluginInfo.Reset();
    82 	CFSMailPlugin::ListImplementationsL(iPluginInfo);
    77 	CFSMailPlugin::ListImplementationsL(iPluginInfo);
   111 // -----------------------------------------------------------------------------
   106 // -----------------------------------------------------------------------------
   112 // CFSMailPluginManager::LoadPluginL
   107 // CFSMailPluginManager::LoadPluginL
   113 // -----------------------------------------------------------------------------
   108 // -----------------------------------------------------------------------------
   114 void CFSMailPluginManager::LoadPluginL( TUid /*aPlugin*/ )
   109 void CFSMailPluginManager::LoadPluginL( TUid /*aPlugin*/ )
   115 {
   110 {
   116     NM_FUNCTION;
   111     FUNC_LOG;
       
   112 
   117 }
   113 }
   118 	
   114 	
   119 // -----------------------------------------------------------------------------
   115 // -----------------------------------------------------------------------------
   120 // CFSMailPluginManager::GetPluginByIndex
   116 // CFSMailPluginManager::GetPluginByIndex
   121 // -----------------------------------------------------------------------------
   117 // -----------------------------------------------------------------------------
   122 CFSMailPlugin* CFSMailPluginManager::GetPluginByIndex(TUint aIndex)
   118 CFSMailPlugin* CFSMailPluginManager::GetPluginByIndex(TUint aIndex)
   123 	{
   119 	{
   124     NM_FUNCTION;
   120     FUNC_LOG;
   125     
       
   126 	return iPluginList[aIndex]->iPlugin;
   121 	return iPluginList[aIndex]->iPlugin;
   127 	}
   122 	}
   128 
   123 
   129 // -----------------------------------------------------------------------------
   124 // -----------------------------------------------------------------------------
   130 // CFSMailPluginManager::GetPluginIdByIndex
   125 // CFSMailPluginManager::GetPluginIdByIndex
   131 // -----------------------------------------------------------------------------
   126 // -----------------------------------------------------------------------------
   132 TUid CFSMailPluginManager::GetPluginIdByIndex(TUint aIndex)
   127 TUid CFSMailPluginManager::GetPluginIdByIndex(TUint aIndex)
   133 	{
   128 	{
   134     NM_FUNCTION;
   129     FUNC_LOG;
   135     
       
   136 	return iPluginList[aIndex]->iPluginId;
   130 	return iPluginList[aIndex]->iPluginId;
   137 	}
   131 	}
   138 
   132 
   139 // -----------------------------------------------------------------------------
   133 // -----------------------------------------------------------------------------
   140 // CFSMailPluginManager::GetPluginCount
   134 // CFSMailPluginManager::GetPluginCount
   141 // -----------------------------------------------------------------------------
   135 // -----------------------------------------------------------------------------
   142 TUint CFSMailPluginManager::GetPluginCount( )
   136 TUint CFSMailPluginManager::GetPluginCount( )
   143 	{
   137 	{
   144     NM_FUNCTION;
   138     FUNC_LOG;
   145     
       
   146 	return iPluginList.Count();
   139 	return iPluginList.Count();
   147 	}
   140 	}
   148 	
   141 	
       
   142 // -----------------------------------------------------------------------------
       
   143 // CFSMailPluginManager::RecheckPlugins
       
   144 // -----------------------------------------------------------------------------
   149 
   145 
   150 
   146 void CFSMailPluginManager::RecheckPlugins( )
       
   147     {
       
   148     FUNC_LOG;
       
   149     
       
   150     CFSMailPlugin* plugin = NULL;
       
   151     
       
   152     TInt tempCount = iPluginInfo.Count();
       
   153     
       
   154     for ( TInt i = 0; i < tempCount; i++ )
       
   155         {
       
   156         TUid id = iPluginInfo[i]->ImplementationUid();
       
   157         TBool found = false;
       
   158         
       
   159         // check if plugin is already in plugin list
       
   160         for ( TInt j = 0; j < iPluginList.Count(); j++)
       
   161             {
       
   162             
       
   163             if ( iPluginList[j]->iPluginId == id )
       
   164                 {
       
   165                 found = true;
       
   166                 break;
       
   167                 }
       
   168             }
       
   169         // if plugin is not found try to create it and add it to plugin list.
       
   170         if ( !found )
       
   171             {
       
   172             TRAPD(err,plugin = CFSMailPlugin::NewL( id ));
       
   173             CFSMailPlugin::Close();
       
   174             if ( err == KErrNone && plugin != NULL )
       
   175                 {
       
   176                 AddPluginL(id,plugin);
       
   177                 }
       
   178             }
       
   179         }
       
   180     }