browserutilities/schemehandler/SchemeDispatcher/src/CtiHandler.cpp
changeset 0 dd21522fd290
child 37 cb62a4f66ebe
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     1 /*
       
     2 * Copyright (c) 2002 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 the License "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: 
       
    15 *      Implementation of Scheme handler interface implementation for wtai:// scheme
       
    16 *      
       
    17 *
       
    18 */
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 
       
    23 #include "CtiHandler.h"
       
    24 #include "SchemeDispLogger.h"
       
    25 #include <ECom.h>		// For REComSession
       
    26 #include <eikenv.h>
       
    27 #include <apparc.h>
       
    28 #include <apgcli.h>
       
    29 
       
    30 // ================= CONSTANTS =======================
       
    31 _LIT( KPattern,"cti:");
       
    32 
       
    33 // ================= MEMBER FUNCTIONS =======================
       
    34 
       
    35 // ---------------------------------------------------------
       
    36 // CCtiHandler::NewL()
       
    37 // ---------------------------------------------------------
       
    38 //
       
    39 CCtiHandler* CCtiHandler::NewL( const TDesC& aUrl )
       
    40 	{
       
    41 	CLOG_ENTERFN( "CCtiHandler::NewL()" );
       
    42 
       
    43 	CCtiHandler* self=new(ELeave) CCtiHandler();
       
    44 	CleanupStack::PushL( self );
       
    45 	self->ConstructL( aUrl );
       
    46 	CleanupStack::Pop( self );
       
    47 
       
    48 	CLOG_LEAVEFN( "CCtiHandler::NewL()" );
       
    49 	return self;
       
    50 	}
       
    51 
       
    52 // ---------------------------------------------------------
       
    53 // CCtiHandler::~CCtiHandler()
       
    54 // ---------------------------------------------------------
       
    55 //
       
    56 CCtiHandler::~CCtiHandler()
       
    57 	{
       
    58 	CLOG_ENTERFN( "CCtiHandler::~CCtiHandler()" );
       
    59 
       
    60     if( iTelService != NULL )
       
    61         {
       
    62 	    iTelService->RemoveObserver(this);
       
    63 	    delete iTelService;
       
    64         iTelService = NULL;
       
    65         }
       
    66 
       
    67 	CLOG_LEAVEFN( "CCtiHandler::~CCtiHandler()" );
       
    68 	}
       
    69 
       
    70 // ---------------------------------------------------------
       
    71 // CCtiHandler::CCtiHandler()
       
    72 // ---------------------------------------------------------
       
    73 //
       
    74 CCtiHandler::CCtiHandler() : CBaseHandler()
       
    75 	{
       
    76 	// Deliberately do nothing here : See ConstructL() for initialisation 
       
    77     // completion.
       
    78 	}
       
    79 
       
    80 // ---------------------------------------------------------
       
    81 // CCtiHandler::ConstructL()
       
    82 // ---------------------------------------------------------
       
    83 //
       
    84 void CCtiHandler::ConstructL( const TDesC& aUrl )
       
    85 	{
       
    86 	CLOG_ENTERFN( "CCtiHandler::ConstructL()" );
       
    87 
       
    88 	BaseConstructL( aUrl );
       
    89 
       
    90 	CLOG_LEAVEFN( "CCtiHandler::ConstructL()" );
       
    91 	}
       
    92 
       
    93 // ---------------------------------------------------------
       
    94 // CCtiHandler::HandleUrlEmbeddedL()
       
    95 // ---------------------------------------------------------
       
    96 //
       
    97 void CCtiHandler::HandleUrlEmbeddedL()
       
    98 	{
       
    99 	CLOG_ENTERFN( "CCtiHandler::HandleUrlEmbeddedL()" );
       
   100 
       
   101 	TPtrC path;
       
   102     TInt err;
       
   103 
       
   104 	iTelService = CBrowserTelService::NewL();
       
   105 	iTelService->AddObserver( this );
       
   106 
       
   107 	TRAP( err, path.Set( RemoveSchemeFromUrlL( KPattern ) ) );
       
   108 	if( err ==  KErrNone)
       
   109 		{
       
   110         TBool confirmDtmfValue = ReadSdConfirmDtmfValueL();
       
   111 		CLOG_WRITE_FORMAT( "CCtiHandler::HandleUrlEmbeddedL: path: %S", &path );
       
   112 		
       
   113         if( 0 != path.Length() )
       
   114             {
       
   115 			err = iTelService->MakeCall( path, confirmDtmfValue );
       
   116             }
       
   117         else
       
   118             {
       
   119             err = KErrCancel;
       
   120             }
       
   121         }
       
   122 
       
   123     NotifyClient();
       
   124 
       
   125     ErrorHandlerL( err );
       
   126 
       
   127 	CLOG_LEAVEFN( "CCtiHandler::HandleUrlEmbeddedL()" );
       
   128 
       
   129 	}
       
   130 
       
   131 // ---------------------------------------------------------
       
   132 // CCtiHandler::HandleUrlStandaloneL()
       
   133 // ---------------------------------------------------------
       
   134 //
       
   135 void CCtiHandler::HandleUrlStandaloneL()
       
   136 	{
       
   137 	CLOG_ENTERFN( "CCtiHandler::HandleUrlStandaloneL()" );
       
   138 
       
   139     LaunchSchemeAppWithCommandLineL();
       
   140 
       
   141 	CLOG_LEAVEFN( "CCtiHandler::HandleUrlStandaloneL()" );
       
   142 	}
       
   143 
       
   144 // ---------------------------------------------------------
       
   145 // CCtiHandler::BrowserTelServiceEvent()
       
   146 // ---------------------------------------------------------
       
   147 //
       
   148 void CCtiHandler::BrowserTelServiceEvent( TBrowserTelServiceState aEvent )
       
   149 	{
       
   150 	if( ( EIdle == aEvent ) && ( NULL !=iSchemeDoc ) )
       
   151 		{
       
   152         iSchemeDoc->HandleServerAppExit( KErrNone );
       
   153 		}
       
   154 	}
       
   155 
       
   156 // ---------------------------------------------------------
       
   157 // CCtiHandler::BrowserTelServiceError()
       
   158 // ---------------------------------------------------------
       
   159 //
       
   160 void CCtiHandler::BrowserTelServiceError( TBrowserTelServiceError /*aError*/)
       
   161 	{
       
   162 	}
       
   163 
       
   164 // ---------------------------------------------------------
       
   165 // CCtiHandler::BrowserTelServiceError()
       
   166 // ---------------------------------------------------------
       
   167 //
       
   168 void CCtiHandler::NotifyClient()
       
   169 	{
       
   170 	if( NULL !=iSchemeDoc )
       
   171 		{
       
   172         iSchemeDoc->HandleServerAppExit( KErrNone );
       
   173 		}
       
   174 	}