convergedcallengine/cce/src/ccceextension.cpp
changeset 0 ff3b6d0fd310
child 19 7d48bed6ce0c
equal deleted inserted replaced
-1:000000000000 0:ff3b6d0fd310
       
     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:  Handles Extension interfaces
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 //  INCLUDE FILES
       
    20 #include "cccepluginmanager.h"
       
    21 #include "ccceextension.h"
       
    22 #include "cccelogger.h"
       
    23 
       
    24 
       
    25 #include "mcceextensionobserver.h"
       
    26 #include "mccpextensionprovider.h"
       
    27 
       
    28 #include "cconvergedcallprovider.h"
       
    29 
       
    30 
       
    31 // ======== MEMBER FUNCTIONS ========
       
    32 // -----------------------------------------------------------------------------
       
    33 // NewL()
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CCCEExtension* CCCEExtension::NewL( CCCEPluginManager& aPluginManager )
       
    37     {
       
    38     CCCEExtension* self = new (ELeave) CCCEExtension( aPluginManager );
       
    39     CleanupStack::PushL(self);
       
    40     self->ConstructL();
       
    41     CleanupStack::Pop(self);
       
    42     return self;
       
    43     }
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CCCEDtmf()
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 CCCEExtension::CCCEExtension( CCCEPluginManager& aPluginManager ):
       
    50     iPluginManager( aPluginManager )
       
    51     {
       
    52 
       
    53     }
       
    54 
       
    55 // -----------------------------------------------------------------------------
       
    56 // ConstructL()
       
    57 // -----------------------------------------------------------------------------
       
    58 //
       
    59 void CCCEExtension::ConstructL()
       
    60     {
       
    61 
       
    62     }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // ~CCCEExtension()
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 CCCEExtension::~CCCEExtension()
       
    69     {
       
    70     }
       
    71 
       
    72 // -----------------------------------------------------------------------------
       
    73 // AddObserverL( MCCEDtmfObserver& aObserver )
       
    74 // -----------------------------------------------------------------------------
       
    75 //
       
    76 void CCCEExtension::AddObserverL( const MCCEExtensionObserver& aObserver )
       
    77     {
       
    78     // add support for more than one observer later on. Only one is used at the moment. Last one 
       
    79     // given is used.
       
    80     iMCCEExtensionObserver = const_cast<MCCEExtensionObserver*>(&aObserver);
       
    81     }
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // RemoveObserver( MCCEDtmfObserver& aObserver )
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 TInt CCCEExtension::RemoveObserver( const MCCEExtensionObserver& /*aObserver*/ )
       
    88     {
       
    89     // add support for more than one observer later on. Only one is used at the moment. Last one 
       
    90     // given is used.
       
    91 
       
    92     if( !iMCCEExtensionObserver )
       
    93     	{
       
    94     	return KErrNotFound;
       
    95     	}
       
    96     	
       
    97 	iMCCEExtensionObserver = NULL;
       
    98     return KErrNone;
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // RequestCommand()
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 TInt CCCEExtension::RequestCommand( TUint32 aServiceId,
       
   106 									TInt aRequestId, 
       
   107 									TDesC8& aData )
       
   108     {
       
   109     CCELOGSTRING3("CCCEExtension::RequestCommand(): Service id=%d Request id=%d", aServiceId, aRequestId );
       
   110 
       
   111 	CConvergedCallProvider* plugin = GetExtIfPlugin(aServiceId);
       
   112 
       
   113 	if( !plugin )
       
   114 	    {
       
   115     	CCELOGSTRING("CCCEExtension::RequestCommand(): Plug-in for service-id was not found. Returning KErrNotFound" );
       
   116 	    return KErrNotFound;
       
   117 	    }
       
   118 
       
   119     MCCPExtensionProvider* extif = NULL;
       
   120 	TRAPD( err, extif = plugin->ExtensionProviderL(*this) );
       
   121 
       
   122 	if( err!=KErrNone )
       
   123 		{
       
   124     	CCELOGSTRING2("CCCEExtension::RequestCommand(): Plug-in was found, but extension interface get failed with error=%d", err );
       
   125 		return err;
       
   126 		}
       
   127    
       
   128     if( extif )
       
   129         {
       
   130         extif->RequestCommand(aRequestId,aData);
       
   131         }
       
   132     else
       
   133         {
       
   134     	CCELOGSTRING("CCCEExtension::RequestCommand() Plug-in extension interface was found, but extensions are not supported. Returning KErrNotSupported" );
       
   135         return KErrNotSupported;
       
   136         }
       
   137 
       
   138     return KErrNone;
       
   139     }
       
   140 
       
   141 // -----------------------------------------------------------------------------
       
   142 // CancelRequest()
       
   143 // -----------------------------------------------------------------------------
       
   144 //
       
   145 TInt CCCEExtension::CancelRequest( TUint32 aServiceId,
       
   146 								   TInt aRequestId )
       
   147     {
       
   148     CCELOGSTRING3("CCCEExtension::CancelRequest(): Service id=%d Request id=%d", aServiceId, aRequestId );
       
   149 
       
   150 	CConvergedCallProvider* plugin = GetExtIfPlugin(aServiceId);
       
   151 
       
   152 	if( !plugin )
       
   153 	    {
       
   154     	CCELOGSTRING("CCCEExtension::CancelRequest(): Plug-in for service-id was not found. Returning KErrNotFound" );
       
   155 	    return KErrNotFound;
       
   156 	    }
       
   157 
       
   158     MCCPExtensionProvider* extif = NULL;
       
   159 	TRAPD( err, extif = plugin->ExtensionProviderL(*this) );
       
   160 
       
   161 	if( err!=KErrNone )
       
   162 		{
       
   163     	CCELOGSTRING2("CCCEExtension::CancelRequest(): Plug-in was found, but extension interface get failed with error=%d", err );
       
   164 		return err;
       
   165 		}
       
   166 	
       
   167     if( extif )
       
   168         {
       
   169         extif->CancelRequest(aRequestId);
       
   170         }
       
   171     else
       
   172         {
       
   173     	CCELOGSTRING("CCCEExtension::CancelRequest() Plug-in extension interface was found, but extensions are not supported. Returning KErrNotSupported" );
       
   174         return KErrNotSupported;
       
   175         }
       
   176 
       
   177     return KErrNone;
       
   178     }
       
   179 
       
   180 // -----------------------------------------------------------------------------
       
   181 // HandleExtensionEvents()
       
   182 // -----------------------------------------------------------------------------
       
   183 //
       
   184 void CCCEExtension::HandleExtensionEvents( TUint32 aServiceId,
       
   185 										   TInt aEvent,
       
   186                                            TInt aStatus )
       
   187     {
       
   188     CCELOGSTRING3("CCCEExtension::HandleExtensionEvents(): Service id=%d Event=%d", aServiceId, aEvent );
       
   189     CCELOGSTRING2("CCCEExtension::HandleExtensionEvents(): Status=%d", aStatus );
       
   190 
       
   191     if( iMCCEExtensionObserver )
       
   192     	{
       
   193 		iMCCEExtensionObserver->HandleExtensionEvents(aServiceId,aEvent,aStatus);
       
   194     	}
       
   195    	else
       
   196    		{
       
   197     	CCELOGSTRING("CCCEExtension::HandleExtensionEvents(): No observer was set, ignoring no event was notified!" );
       
   198    		}
       
   199     }
       
   200 
       
   201 // -----------------------------------------------------------------------------
       
   202 // HandleExtensionEvents()
       
   203 // -----------------------------------------------------------------------------
       
   204 //
       
   205 CConvergedCallProvider* CCCEExtension::GetExtIfPlugin( TUint32 aServiceId )
       
   206     {
       
   207     CConvergedCallProvider* provider = NULL;
       
   208     
       
   209     TRAP_IGNORE( provider = iPluginManager.GetPluginL( aServiceId ) );
       
   210 
       
   211 	return provider;
       
   212     }
       
   213 
       
   214 
       
   215 // end of file