multimediacommsengine/tsrc/MCETestUI/MCETestUIPlugin/src/MCETestUIPlugin.cpp
changeset 0 1bce908db942
equal deleted inserted replaced
-1:000000000000 0:1bce908db942
       
     1 /*
       
     2 * Copyright (c) 2002-2004 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:    Implementation of MCETestUI client resolver for incoming SIP messages
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "MCETestUIPlugin.h"
       
    23 #include "EComImplementationProxy.h"
       
    24 #include <badesca.h>
       
    25 #include <sipstrings.h>
       
    26 #include <sipstrconsts.h>
       
    27 #include <stringpool.h>
       
    28 // CONSTANTS
       
    29 const TUid KMyApplicationUid = { 0x10281F9C };
       
    30 _LIT(KCapabiliesFileName, "C:\\MCETestUICaps.xml");
       
    31 
       
    32 // -----------------------------------------------------------------------------
       
    33 // CMCETestUIPlugin::NewL
       
    34 // -----------------------------------------------------------------------------
       
    35 //
       
    36 CMCETestUIPlugin* CMCETestUIPlugin::NewL()
       
    37     {
       
    38     CMCETestUIPlugin* self = new( ELeave ) CMCETestUIPlugin;
       
    39     CleanupStack::PushL( self );
       
    40     self->ConstructL();
       
    41     CleanupStack::Pop();
       
    42     return self;
       
    43     }                      
       
    44 
       
    45 // -----------------------------------------------------------------------------
       
    46 // CMCETestUIPlugin::CMCETestUIPlugin
       
    47 // -----------------------------------------------------------------------------
       
    48 //
       
    49 CMCETestUIPlugin::CMCETestUIPlugin() 
       
    50     {                      
       
    51     }
       
    52 
       
    53 // -----------------------------------------------------------------------------
       
    54 // CMCETestUIPlugin::ConstructL
       
    55 // -----------------------------------------------------------------------------
       
    56 //
       
    57 void CMCETestUIPlugin::ConstructL()
       
    58     {
       
    59 	RImplInfoPtrArray infoArray;
       
    60 	REComSession::ListImplementationsL( KSIPResolvedClientIFUid, infoArray );
       
    61 	CleanupStack::PushL( TCleanupItem( ResetAndDestroy, &infoArray ) );
       
    62 
       
    63 	TBool found = EFalse;
       
    64 	for (TInt i=0; !found && i<infoArray.Count(); i++)
       
    65 		{
       
    66 		CImplementationInformation* info = infoArray[ i ];
       
    67 		if ( info->ImplementationUid() == KMyApplicationUid )
       
    68 			{
       
    69 			TLex8 lex( info->DataType() );
       
    70 			TUint value( 0 );
       
    71 			User::LeaveIfError( lex.Val( value, EHex ) );
       
    72 		    iApplicationUID.iUid = value;
       
    73 			found = ETrue;
       
    74 			}
       
    75 		}
       
    76 
       
    77 	CleanupStack::PopAndDestroy( 1 ); // infoArray
       
    78 
       
    79 	if ( !found )
       
    80 		{
       
    81 		User::Leave( KErrNotFound );
       
    82 		}
       
    83 		
       
    84 	iCapabilitiesFromFile = KNullDesC8().AllocL();
       
    85     }
       
    86     
       
    87 // -----------------------------------------------------------------------------
       
    88 // CMCETestUIPlugin::~CMCETestUIPlugin
       
    89 // -----------------------------------------------------------------------------
       
    90 //
       
    91 CMCETestUIPlugin::~CMCETestUIPlugin()
       
    92     {
       
    93     delete iCapabilitiesFromFile;
       
    94     }
       
    95 
       
    96 // -----------------------------------------------------------------------------
       
    97 // CMCETestUIPlugin::ChannelL
       
    98 // -----------------------------------------------------------------------------
       
    99 //
       
   100 TUid CMCETestUIPlugin::ChannelL( 
       
   101 	RStringF aMethod,
       
   102 	const TDesC8& /*aRequestUri*/,
       
   103 	const RPointerArray<CSIPHeaderBase>& /*aHeaders*/,
       
   104 	const TDesC8& /*aContent*/,
       
   105 	const CSIPContentTypeHeader* /*aContentType*/)
       
   106     {
       
   107     RDebug::Print(_L("New TestUI with KUidFCTestUI channel ID"));
       
   108 	const TUid KUidFCTestUI = { 0x10281F9B };
       
   109 	const TUid KUIOptionsUid = { 0x10123F9E };
       
   110 	if ( aMethod == SIPStrings::StringF( SipStrConsts::EOptions ) ) 
       
   111 		{
       
   112 		return KUIOptionsUid;
       
   113 		}
       
   114 	else
       
   115 		{
       
   116 		return KUidFCTestUI;	
       
   117 		}
       
   118     }
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // ChannelL::ConnectL
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 void CMCETestUIPlugin::ConnectL( TUid /*aUid*/ )
       
   125     {
       
   126     }
       
   127 
       
   128 // -----------------------------------------------------------------------------
       
   129 // CMCETestUIPlugin::Capabilities
       
   130 // -----------------------------------------------------------------------------
       
   131 //
       
   132 const TDesC8& CMCETestUIPlugin::Capabilities()
       
   133 	{
       
   134 	TRAP_IGNORE(RefreshCapabilitiesL())
       
   135 	return *iCapabilitiesFromFile;
       
   136 	}
       
   137 
       
   138 // -----------------------------------------------------------------------------
       
   139 // CMCETestUIPlugin::RefreshCapabilitiesL
       
   140 // -----------------------------------------------------------------------------
       
   141 //
       
   142 void CMCETestUIPlugin::RefreshCapabilitiesL()
       
   143     {    
       
   144    	RFs fs;
       
   145 	User::LeaveIfError( fs.Connect() );
       
   146 	CleanupClosePushL( fs );
       
   147 
       
   148 	RFile capabilitiesFile;
       
   149 	TInt err = capabilitiesFile.Open( fs, KCapabiliesFileName, EFileRead );
       
   150 	User::LeaveIfError( err );
       
   151 	
       
   152 	CleanupClosePushL( capabilitiesFile );
       
   153 
       
   154 	TInt size( 0 );
       
   155 	User::LeaveIfError( capabilitiesFile.Size( size ) );    
       
   156 	HBufC8* tmp = HBufC8::NewLC( size );
       
   157 	TPtr8 ptr( tmp->Des() );
       
   158 	User::LeaveIfError( capabilitiesFile.Read( ptr ) );
       
   159 	CleanupStack::Pop( tmp );
       
   160 	delete iCapabilitiesFromFile;
       
   161 	iCapabilitiesFromFile = tmp;   
       
   162 	    
       
   163 	CleanupStack::PopAndDestroy(); // capabilitiesFile
       
   164 	CleanupStack::PopAndDestroy(); // fs
       
   165     }
       
   166 
       
   167 // -----------------------------------------------------------------------------
       
   168 // CMCETestUIPlugin::ResetAndDestroy
       
   169 // -----------------------------------------------------------------------------
       
   170 //
       
   171 void CMCETestUIPlugin::ResetAndDestroy( TAny* anArray )
       
   172 	{
       
   173     RImplInfoPtrArray* array = reinterpret_cast<RImplInfoPtrArray*>( anArray );
       
   174     if (array)
       
   175         {
       
   176         array->ResetAndDestroy();
       
   177         }
       
   178 	}
       
   179 
       
   180 //  End of File