S60 3rd Edition SDK for Symbian OS
Example Applications Guide

SIPExResolverPlugin.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : SIPExResolverPlugin.cpp
00004 *  Part of     : SIPExResolverPlugin
00005 *  Interface   : 
00006 *  Description : 
00007 *  Version     : 
00008 *
00009 *  Copyright (c) 2005-2006 Nokia Corporation.
00010 *  This material, including documentation and any related 
00011 *  computer programs, is protected by copyright controlled by 
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 #include "SIPExResolverPlugin.h"
00017 
00018 #include <apacmdln.h>
00019 
00020 // SIPEx capabilities - could be also defined in resource of this plugin
00021 // but then length of capablities text is in resource file limited to 
00022 // 255 characters. However, defining capabilities in resource file's opaque_data 
00023 // field is more efficient way.
00024 _LIT8(KCapabilities,
00025 "<SIP_CLIENT ALLOW_STARTING=\"YES\">\
00026 <SIP_HEADERS>\
00027 <ACCEPT value=\"application/sdp\"/>\
00028 <ACCEPT value=\"SIPEx/InstantMessage\"/>\
00029 </SIP_HEADERS>\
00030 <SDP_LINES>\
00031 <LINE name=\"m\" value=\"application 0 TCP SIPEx\"/>\
00032 </SDP_LINES>\
00033 </SIP_CLIENT>");
00034 
00035 // -----------------------------------------------------------------------------
00036 // CTTCNResolverPlugin1::NewL
00037 // -----------------------------------------------------------------------------
00038 //
00039 CSIPExResolverPlugin* CSIPExResolverPlugin::NewL()
00040         {
00041         CSIPExResolverPlugin* self = new ( ELeave ) CSIPExResolverPlugin;
00042         CleanupStack::PushL( self );
00043         self->ConstructL();
00044         CleanupStack::Pop( self );
00045         return self;
00046         }
00047 
00048 // -----------------------------------------------------------------------------
00049 // CSIPExResolverPlugin::ConstructL
00050 // -----------------------------------------------------------------------------
00051 //
00052 void CSIPExResolverPlugin::ConstructL()
00053         {
00054         const TUid KMyImplementationUid = { KSIPExResolverPluginUID };
00055 
00056         RImplInfoPtrArray infoArray;
00057         REComSession::ListImplementationsL( KSIPResolvedClientIFUid, infoArray );
00058         CleanupStack::PushL( TCleanupItem( ResetAndDestroy, &infoArray ) );
00059 
00060         TBool found = EFalse;
00061         for ( TInt i=0; !found && i < infoArray.Count(); i++ )
00062                 {
00063                 CImplementationInformation* info = infoArray[ i ];
00064                 if ( info->ImplementationUid() == KMyImplementationUid )
00065                         {
00066                         TLex8 lex( info->DataType() );
00067                         TUint value( 0 );
00068                         User::LeaveIfError( lex.Val( value, EHex ) );
00069                     iApplicationUID.iUid = value;
00070                         found = ETrue;
00071                         }
00072                 }
00073 
00074         CleanupStack::PopAndDestroy( 1 ); // infoArray
00075 
00076         if ( !found )
00077                 {
00078                 User::Leave( KErrNotFound );
00079                 }
00080                 
00081         User::LeaveIfError( iApaSession.Connect() );
00082         User::LeaveIfError( iApaSession.GetAppInfo( iAppInfo, iApplicationUID ) );              
00083         }
00084 
00085 // -----------------------------------------------------------------------------
00086 // CSIPExResolverPlugin::~CSIPExResolverPlugin
00087 // -----------------------------------------------------------------------------
00088 //
00089 CSIPExResolverPlugin::~CSIPExResolverPlugin()
00090         {
00091         iApaSession.Close();
00092         }
00093         
00094 // -----------------------------------------------------------------------------
00095 // CSIPExResolverPlugin::ChannelL
00096 // -----------------------------------------------------------------------------
00097 //      
00098 TUid CSIPExResolverPlugin::ChannelL( RStringF /*aMethod*/,
00099     const TDesC8& /*aRequestUri*/,
00100     const RPointerArray<CSIPHeaderBase>& /*aHeaders*/,
00101     const TDesC8& /*aContent*/,
00102     const CSIPContentTypeHeader* /*aContentType*/)
00103     {
00104     return iApplicationUID;
00105     }
00106 
00107 
00108 // -----------------------------------------------------------------------------
00109 // CSIPExResolverPlugin::ConnectL
00110 // -----------------------------------------------------------------------------
00111 //
00112 void CSIPExResolverPlugin::ConnectL( TUid aUid )
00113         {
00114         // Launch app based on uid passed from SIP stack
00115         //
00116         TApaAppInfo appInfo;
00117         User::LeaveIfError( iApaSession.GetAppInfo( appInfo, aUid ) );
00118         CApaCommandLine* cmdLine = CApaCommandLine::NewLC();
00119 #ifdef EKA2
00120         cmdLine->SetExecutableNameL( appInfo.iFullName );
00121 #else
00122         cmdLine->SetLibraryNameL( appInfo.iFullName );
00123 #endif
00124         User::LeaveIfError( iApaSession.StartApp( *cmdLine ) );
00125         CleanupStack::PopAndDestroy( cmdLine ); 
00126         }
00127         
00128 // -----------------------------------------------------------------------------
00129 // CTTCNResolverPlugin1::Capabilities
00130 // -----------------------------------------------------------------------------
00131 //
00132 const TDesC8& CSIPExResolverPlugin::Capabilities()
00133     {
00134     return KCapabilities;
00135     }
00136 
00137 // -----------------------------------------------------------------------------
00138 // CSIPExResolverPlugin::ResetAndDestroy
00139 // -----------------------------------------------------------------------------
00140 //
00141 void CSIPExResolverPlugin::ResetAndDestroy( TAny* anArray )
00142         {
00143     RImplInfoPtrArray* array = reinterpret_cast<RImplInfoPtrArray*>( anArray );
00144     if (array)
00145         {
00146         array->ResetAndDestroy();
00147         }
00148         }
00149 

© Nokia 2006

Back to top