messagingapp/msgappfw/server/src/ccsplugininterface.cpp
changeset 23 238255e8b033
equal deleted inserted replaced
5:4697dfb2d7ad 23:238255e8b033
       
     1 /*
       
     2 * Copyright (c) 2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description:  CS Server Plugin Interface
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 // INCLUDE FILES
       
    20 #include "ccsplugin.h"
       
    21 #include "ccsserver.h"
       
    22 #include "ccsplugininterface.h"
       
    23 #include "ccsdebug.h"
       
    24 
       
    25 // ============================== MEMBER FUNCTIONS ============================
       
    26 
       
    27 // ----------------------------------------------------------------------------
       
    28 // CCsPluginInterface::NewL
       
    29 // Two Phase Construction
       
    30 // ----------------------------------------------------------------------------
       
    31 CCsPluginInterface* CCsPluginInterface::NewL()
       
    32 {
       
    33     PRINT ( _L("Enter CCsPluginInterface::NewL") );
       
    34 
       
    35     CCsPluginInterface* self = CCsPluginInterface::NewLC();
       
    36     CleanupStack::Pop( self );
       
    37 
       
    38     PRINT ( _L("End CCsPluginInterface::NewL") );
       
    39 
       
    40     return self;
       
    41 }
       
    42 
       
    43 // ----------------------------------------------------------------------------
       
    44 // CCsPluginInterface::NewLC
       
    45 // Two Phase Construction
       
    46 // ----------------------------------------------------------------------------
       
    47 CCsPluginInterface* CCsPluginInterface::NewLC()
       
    48 {
       
    49     PRINT ( _L("Enter CCsPluginInterface::NewLC") );
       
    50 
       
    51     CCsPluginInterface* self = new( ELeave ) CCsPluginInterface();
       
    52     CleanupStack::PushL( self );
       
    53     self->ConstructL();
       
    54 
       
    55     PRINT ( _L("End CCsPluginInterface::NewLC") );
       
    56 
       
    57     return self;
       
    58 }
       
    59 
       
    60 // ----------------------------------------------------------------------------
       
    61 // CCsPluginInterface::CCsPluginInterface
       
    62 // Constructor
       
    63 // ----------------------------------------------------------------------------
       
    64 CCsPluginInterface::CCsPluginInterface()
       
    65 {
       
    66 }
       
    67 
       
    68 // ----------------------------------------------------------------------------
       
    69 // CCsPluginInterface::ConstructL
       
    70 // 2nd phase constructor
       
    71 // ----------------------------------------------------------------------------
       
    72 void CCsPluginInterface::ConstructL()
       
    73 {
       
    74 }
       
    75 
       
    76 // ----------------------------------------------------------------------------
       
    77 // CCsPluginInterface::~CCsPluginInterface
       
    78 // Constructor
       
    79 // ----------------------------------------------------------------------------
       
    80 CCsPluginInterface::~CCsPluginInterface( )
       
    81 {
       
    82     PRINT ( _L("Enter CCsPluginInterface::~CCsPluginInterface") );
       
    83 
       
    84     UnloadPlugIns();
       
    85     iCsPluginInstances.ResetAndDestroy();
       
    86 
       
    87     PRINT ( _L("End CCsPluginInterface::~CCsPluginInterface") );
       
    88 }
       
    89 
       
    90 // ----------------------------------------------------------------------------
       
    91 // CCsPluginInterface::InstantiateAllPlugInsL
       
    92 // Instantiates all plugins
       
    93 // ----------------------------------------------------------------------------
       
    94 void CCsPluginInterface::InstantiatePluginL(CCsServer* aCsServer )
       
    95     {
       
    96     RImplInfoPtrArray infoArray;
       
    97 
       
    98     // Get list of all implementations
       
    99     ListAllImplementationsL( infoArray );
       
   100 
       
   101     // Instantiate plugins for all impUIds by calling
       
   102     // InstantiatePlugInFromImpUidL
       
   103     for ( TInt iloop=0; iloop<infoArray.Count(); iloop++ )
       
   104         {
       
   105         // Get imp info
       
   106         CImplementationInformation& info( *infoArray[iloop] );
       
   107 
       
   108         // Get imp UID
       
   109         TUid impUid ( info.ImplementationUid() );
       
   110 
       
   111         PRINT ( _L("------------- CS Plugin Details -----------"));
       
   112         PRINT1 ( _L("Name: %S"), &(info.DisplayName()) );
       
   113         PRINT1 ( _L("UID: %X"), impUid.iUid );
       
   114         iPluginInUse.iUid = impUid.iUid;
       
   115         PRINT ( _L("-----------------------------------------------"));
       
   116 
       
   117         CCsPlugin* plugin = NULL;
       
   118 
       
   119         //instantiate plugin for impUid
       
   120 	        plugin = InstantiatePlugInFromImpUidL( impUid, aCsServer );
       
   121         if ( plugin )
       
   122             {
       
   123             iCsPluginInstances.AppendL( plugin );
       
   124             }
       
   125         }
       
   126     infoArray.ResetAndDestroy();
       
   127     }
       
   128 
       
   129 // -----------------------------------------------------------------------------
       
   130 // CCsPluginInterface::UnloadPlugIns
       
   131 // Unloads plugins
       
   132 // -----------------------------------------------------------------------------
       
   133 void CCsPluginInterface::UnloadPlugIns()
       
   134 {
       
   135     REComSession::FinalClose();
       
   136     PRINT ( _L("CCsPluginInterface::UnloadPlugIns - Plugins Unloaded") );
       
   137 }
       
   138 
       
   139 // ----------------------------------------------------------------------------
       
   140 // CCsPluginInterface::InstantiatePlugInFromImpUidL
       
   141 // Instantiates plugin
       
   142 // ----------------------------------------------------------------------------
       
   143 CCsPlugin* CCsPluginInterface::InstantiatePlugInFromImpUidL( const TUid& aImpUid,
       
   144         CCsServer* aCsServer )
       
   145 {
       
   146     CCsPlugin* plugin = CCsPlugin::NewL(aImpUid, aCsServer );
       
   147 
       
   148     PRINT( _L("CCsPluginInterface::InstantiatePlugInFromImpUidL - Plugin created") );
       
   149 
       
   150     return plugin;
       
   151 }
       
   152 
       
   153 // ----------------------------------------------------------------------------
       
   154 // CCsPluginInterface::GetConversationsL
       
   155 // Forwards the request to the plugin instance ,
       
   156 // to get the all conversation entry list from List of plugins
       
   157 // ----------------------------------------------------------------------------
       
   158 void CCsPluginInterface::GetConversationsL()
       
   159 {
       
   160     for(TInt iloop=0 ; iloop < iCsPluginInstances.Count(); iloop++)
       
   161         iCsPluginInstances[iloop]->GetConversationsL();
       
   162 }
       
   163 
       
   164 // ----------------------------------------------------------------------------
       
   165 // CCsPluginInterface::GetPlugin
       
   166 // Get Plugins count
       
   167 // ----------------------------------------------------------------------------
       
   168 TInt CCsPluginInterface:: GetPluginsCount()
       
   169 {
       
   170     return iCsPluginInstances.Count();
       
   171 }
       
   172 
       
   173 //EOF