radioengine/utils/src/cradioremcontargetimp.cpp
changeset 23 a2b50a479edf
parent 19 afea38384506
child 24 6df133bd92e1
equal deleted inserted replaced
19:afea38384506 23:a2b50a479edf
     1 /*
       
     2 * Copyright (c) 2009 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:
       
    15 *
       
    16 */
       
    17 
       
    18 // System includes
       
    19 #include <RemConCallHandlingTarget.h>
       
    20 #include <remconcoreapitarget.h>
       
    21 #include <remconinterfaceselector.h>
       
    22 
       
    23 // User includes
       
    24 #include "cradioenginelogger.h"
       
    25 #include "cradioremcontargetimp.h"
       
    26 #include "mradiocontroleventobserver.h"
       
    27 #include "radioengineutils.h"
       
    28 
       
    29 // Constants
       
    30 const TInt KVRVolumeTimerInitialDelay = 1000000; // Initial timer for headset volume up/down press event should expire immediately
       
    31 
       
    32 // ================= MEMBER FUNCTIONS =======================
       
    33 
       
    34 // ---------------------------------------------------------------------------
       
    35 //
       
    36 // ---------------------------------------------------------------------------
       
    37 //
       
    38 CRadioRemConTargetImp::CRadioRemConTargetImp()
       
    39     {
       
    40     }
       
    41 
       
    42 // ---------------------------------------------------------------------------
       
    43 //
       
    44 // ---------------------------------------------------------------------------
       
    45 //
       
    46 void CRadioRemConTargetImp::ConstructL()
       
    47     {
       
    48     RadioEngineUtils::InitializeL();
       
    49     // Create interface selector.
       
    50     iInterfaceSelector = CRemConInterfaceSelector::NewL();
       
    51     // Create a new CRemConCoreApiTarget, owned by the interface selector.
       
    52     iCoreTarget = CRemConCoreApiTarget::NewL( *iInterfaceSelector, *this );
       
    53     // Create a new CRemConCallHandlingTarget, owned by the interface selector.
       
    54     iCallTarget = CRemConCallHandlingTarget::NewL( *iInterfaceSelector, *this );
       
    55     // Start being a target.
       
    56     iInterfaceSelector->OpenTargetL();
       
    57     // Create repeat timer.
       
    58     iRepeatTimer = CPeriodic::NewL( CActive::EPriorityStandard );
       
    59     }
       
    60 
       
    61 // ---------------------------------------------------------------------------
       
    62 //
       
    63 // ---------------------------------------------------------------------------
       
    64 //
       
    65 CRadioRemConTargetImp* CRadioRemConTargetImp::NewL()
       
    66     {
       
    67     CRadioRemConTargetImp* self = new ( ELeave ) CRadioRemConTargetImp();
       
    68     CleanupStack::PushL( self );
       
    69     self->ConstructL();
       
    70     CleanupStack::Pop();
       
    71     return self;
       
    72     }
       
    73 
       
    74 // ---------------------------------------------------------------------------
       
    75 //
       
    76 // ---------------------------------------------------------------------------
       
    77 //
       
    78 CRadioRemConTargetImp::~CRadioRemConTargetImp()
       
    79     {
       
    80     if ( iRepeatTimer )
       
    81         {
       
    82         iRepeatTimer->Cancel();
       
    83         }
       
    84     delete iRepeatTimer;
       
    85     delete iInterfaceSelector; //deletes also iCallTarget and iCoreTarget
       
    86     iCoreTarget = NULL;
       
    87     iCallTarget = NULL;
       
    88     RadioEngineUtils::Release();
       
    89     }
       
    90 
       
    91 // ---------------------------------------------------------------------------
       
    92 //
       
    93 // ---------------------------------------------------------------------------
       
    94 //
       
    95 void CRadioRemConTargetImp::SetControlEventObserver( MRadioControlEventObserver* aControlEventObserver )
       
    96     {
       
    97     iObserver = aControlEventObserver;
       
    98     }
       
    99 
       
   100 // ---------------------------------------------------------------------------
       
   101 //
       
   102 // ---------------------------------------------------------------------------
       
   103 //
       
   104 void CRadioRemConTargetImp::MrccatoCommand( TRemConCoreApiOperationId aOperationId,
       
   105                                          TRemConCoreApiButtonAction aButtonAct )
       
   106     {
       
   107     LOG_FORMAT( "CRadioRemConTargetImp::MrccatoCommand ( aOperationId = %d, aButtonAct = %d )", aOperationId, aButtonAct );
       
   108     //TODO: Refactor
       
   109     if ( iObserver )
       
   110         {
       
   111         switch ( aOperationId )
       
   112             {
       
   113             case ERemConCoreApiChannelUp:
       
   114                 {
       
   115                 if ( aButtonAct == ERemConCoreApiButtonClick )
       
   116                     {
       
   117                     TRAP_IGNORE( iObserver->ChannelUpL( ETrue ); iObserver->ChannelUpL( EFalse ));
       
   118                     }
       
   119                 else if ( aButtonAct == ERemConCoreApiButtonPress )
       
   120                     {
       
   121                     TRAP_IGNORE( iObserver->ChannelUpL( ETrue ));
       
   122                     }
       
   123                 else if ( aButtonAct == ERemConCoreApiButtonRelease )
       
   124                     {
       
   125                     TRAP_IGNORE( iObserver->ChannelUpL( EFalse ));
       
   126                     }
       
   127                 else {}
       
   128                 break;
       
   129                 }
       
   130             case ERemConCoreApiChannelDown:
       
   131                 {
       
   132                 if ( aButtonAct == ERemConCoreApiButtonClick )
       
   133                     {
       
   134                     TRAP_IGNORE( iObserver->ChannelDownL( ETrue ); iObserver->ChannelDownL( EFalse ));
       
   135                     }
       
   136                 else if ( aButtonAct == ERemConCoreApiButtonPress )
       
   137                     {
       
   138                     TRAP_IGNORE( iObserver->ChannelDownL( ETrue ));
       
   139                     }
       
   140                 else if ( aButtonAct == ERemConCoreApiButtonRelease )
       
   141                     {
       
   142                     TRAP_IGNORE( iObserver->ChannelDownL( EFalse ));
       
   143                     }
       
   144                 else {}
       
   145                 break;
       
   146                 }
       
   147             case ERemConCoreApiVolumeUp:
       
   148                 {
       
   149                 if ( aButtonAct == ERemConCoreApiButtonClick )
       
   150                     {
       
   151                     TRAP_IGNORE( iObserver->VolumeUpL( ETrue ); iObserver->VolumeUpL( EFalse ));
       
   152                     }
       
   153                 else if ( aButtonAct == ERemConCoreApiButtonPress )
       
   154                     {
       
   155                     iRepeatTimer->Cancel();
       
   156                     iRepeatId = ERemConCoreApiVolumeUp;
       
   157                     iRepeatTimer->Start( KVRVolumeTimerInitialDelay, KVRVolumeTimerInitialDelay, TCallBack( RepeatTimerCallback, this ));
       
   158                     TRAP_IGNORE( iObserver->VolumeUpL( ETrue ); iObserver->VolumeUpL( EFalse ));
       
   159                     }
       
   160                 else if ( aButtonAct == ERemConCoreApiButtonRelease )
       
   161                     {
       
   162                     iRepeatTimer->Cancel();
       
   163                     }
       
   164                 else {}
       
   165                 break;
       
   166                 }
       
   167             case ERemConCoreApiVolumeDown:
       
   168                 {
       
   169                 if ( aButtonAct == ERemConCoreApiButtonClick )
       
   170                     {
       
   171                     TRAP_IGNORE( iObserver->VolumeDownL( ETrue ); iObserver->VolumeDownL( EFalse ));
       
   172                     }
       
   173                 else if ( aButtonAct == ERemConCoreApiButtonPress )
       
   174                     {
       
   175                     iRepeatTimer->Cancel();
       
   176                     iRepeatId = ERemConCoreApiVolumeDown;
       
   177                     iRepeatTimer->Start( KVRVolumeTimerInitialDelay, KVRVolumeTimerInitialDelay, TCallBack( RepeatTimerCallback, this ));
       
   178                     TRAP_IGNORE( iObserver->VolumeDownL( ETrue ); iObserver->VolumeDownL( EFalse ));
       
   179                     }
       
   180                 else if ( aButtonAct == ERemConCoreApiButtonRelease )
       
   181                     {
       
   182                     iRepeatTimer->Cancel();
       
   183                     }
       
   184                 else {}
       
   185                 break;
       
   186                 }
       
   187             case ERemConCoreApiStop:
       
   188                 {
       
   189                 if ( aButtonAct == ERemConCoreApiButtonClick )
       
   190                     {
       
   191                     TRAP_IGNORE( iObserver->StopL( ETrue ); iObserver->StopL( EFalse ));
       
   192                     }
       
   193                 break;
       
   194                 }
       
   195             case ERemConCoreApiBackward:
       
   196                 {
       
   197                 if( aButtonAct == ERemConCoreApiButtonClick )
       
   198                     {
       
   199                     TRAP_IGNORE( iObserver->BackwardL( ETrue ); iObserver->BackwardL( EFalse ));
       
   200                     }
       
   201                 break;
       
   202                 }
       
   203             case ERemConCoreApiRewind:
       
   204                 {
       
   205                 if ( aButtonAct == ERemConCoreApiButtonPress )
       
   206                     {
       
   207                     LOG( "ERemConCoreApiRewind" );
       
   208                     TRAP_IGNORE( iObserver->RewindL( ETrue ));
       
   209                     }
       
   210                 else if ( aButtonAct == ERemConCoreApiButtonRelease )
       
   211                     {
       
   212                     TRAP_IGNORE( iObserver->RewindL( EFalse ));
       
   213                     }
       
   214                 else {}
       
   215                 break;
       
   216                 }
       
   217             case ERemConCoreApiForward:
       
   218                 {
       
   219                 if( aButtonAct == ERemConCoreApiButtonClick )
       
   220                     {
       
   221                     TRAP_IGNORE( iObserver->ForwardL( ETrue ); iObserver->ForwardL( EFalse ));
       
   222                     }
       
   223                 break;
       
   224                 }
       
   225             case ERemConCoreApiFastForward:
       
   226                 {
       
   227                 if ( aButtonAct == ERemConCoreApiButtonPress )
       
   228                     {
       
   229                     LOG( "ERemConCoreApiFastForward" );
       
   230                     TRAP_IGNORE( iObserver->FastForwardL( ETrue ));
       
   231                     }
       
   232                 else if ( aButtonAct == ERemConCoreApiButtonRelease )
       
   233                     {
       
   234                     TRAP_IGNORE( iObserver->FastForwardL( EFalse ));
       
   235                     }
       
   236                 else {}
       
   237                 break;
       
   238                 }
       
   239             case ERemConCoreApiPlay:
       
   240             case ERemConCoreApiPause:
       
   241             case ERemConCoreApiPausePlayFunction:
       
   242                 {
       
   243                 if ( aButtonAct == ERemConCoreApiButtonClick )
       
   244                     {
       
   245                     TRAP_IGNORE( iObserver->PausePlayL( ETrue ); iObserver->PausePlayL( EFalse ));
       
   246                     }
       
   247                 break;
       
   248                 }
       
   249             default:
       
   250                 {
       
   251                 break;
       
   252                 }
       
   253             }
       
   254         }
       
   255     }
       
   256 
       
   257 // ---------------------------------------------------------------------------
       
   258 //
       
   259 // ---------------------------------------------------------------------------
       
   260 //
       
   261 void CRadioRemConTargetImp::MrccatoPlay( TRemConCoreApiPlaybackSpeed /*aSpeed*/,
       
   262                                       TRemConCoreApiButtonAction aButtonAct )
       
   263     {
       
   264     LOG( "CRadioRemConTargetImp::MrccatoPlay" );
       
   265     if ( iObserver )
       
   266         {
       
   267         if ( aButtonAct == ERemConCoreApiButtonClick )
       
   268             {
       
   269             TRAP_IGNORE( iObserver->PlayL( ETrue ); iObserver->PlayL( EFalse ))
       
   270             }
       
   271         }
       
   272     }
       
   273 
       
   274 // ---------------------------------------------------------------------------
       
   275 //
       
   276 // ---------------------------------------------------------------------------
       
   277 //
       
   278 void CRadioRemConTargetImp::MrccatoTuneFunction( TBool /*aTwoPart*/,
       
   279                                               TUint /*aMajorChannel*/,
       
   280                                               TUint /*aMinorChannel*/,
       
   281                                               TRemConCoreApiButtonAction /*aButtonAct*/)
       
   282     {
       
   283     LOG( "CRadioRemConTargetImp::MrccatoTuneFunction ( currently unsupported in Visual Radio )" );
       
   284     }
       
   285 
       
   286 // ---------------------------------------------------------------------------
       
   287 //
       
   288 // ---------------------------------------------------------------------------
       
   289 //
       
   290 void CRadioRemConTargetImp::MrccatoSelectDiskFunction( TUint /*aDisk*/,
       
   291                                                     TRemConCoreApiButtonAction /*aButtonAct*/)
       
   292     {
       
   293     LOG( "CRadioRemConTargetImp::MrccatoSelectDiskFunction ( currently unsupported in Visual Radio )" );
       
   294     }
       
   295 
       
   296 // ---------------------------------------------------------------------------
       
   297 //
       
   298 // ---------------------------------------------------------------------------
       
   299 //
       
   300 void CRadioRemConTargetImp::MrccatoSelectAvInputFunction( TUint8 /*aAvInputSignalNumber*/,
       
   301                                                        TRemConCoreApiButtonAction /*aButtonAct*/)
       
   302     {
       
   303     LOG( "CRadioRemConTargetImp::MrccatoSelectAvInputFunction ( currently unsupported in Visual Radio )" );
       
   304     }
       
   305 
       
   306 // ---------------------------------------------------------------------------
       
   307 //
       
   308 // ---------------------------------------------------------------------------
       
   309 //
       
   310 void CRadioRemConTargetImp::MrccatoSelectAudioInputFunction( TUint8 /*aAudioInputSignalNumber*/,
       
   311                                                           TRemConCoreApiButtonAction /*aButtonAct*/)
       
   312     {
       
   313     LOG( "CRadioRemConTargetImp::MrccatoSelectAudioInputFunction ( currently unsupported in Visual Radio )" );
       
   314     }
       
   315 
       
   316 // ---------------------------------------------------------------------------
       
   317 //
       
   318 // ---------------------------------------------------------------------------
       
   319 //
       
   320 TInt CRadioRemConTargetImp::RepeatTimerCallback( TAny* aPtr )
       
   321     {
       
   322     LOG( "CRadioRemConTargetImp::RepeatTimerCallback" );
       
   323 
       
   324     CRadioRemConTargetImp* self = reinterpret_cast<CRadioRemConTargetImp*>( aPtr );
       
   325 
       
   326     if ( self )
       
   327         {
       
   328         if ( self->iObserver )
       
   329             {
       
   330             switch ( self->iRepeatId )
       
   331                 {
       
   332                 case ERemConCoreApiVolumeUp:
       
   333                     {
       
   334                     TRAP_IGNORE( self->iObserver->VolumeUpL( ETrue ); self->iObserver->VolumeUpL( EFalse ))
       
   335                     break;
       
   336                     }
       
   337                 case ERemConCoreApiVolumeDown:
       
   338                     {
       
   339                     TRAP_IGNORE( self->iObserver->VolumeDownL( ETrue ); self->iObserver->VolumeDownL( EFalse ))
       
   340                     break;
       
   341                     }
       
   342                 default:
       
   343                     {
       
   344                     break;
       
   345                     }
       
   346                 }
       
   347             }
       
   348         }
       
   349 
       
   350     return KErrNone;
       
   351     }
       
   352 
       
   353 // ---------------------------------------------------------------------------
       
   354 //
       
   355 // ---------------------------------------------------------------------------
       
   356 //
       
   357 void CRadioRemConTargetImp::AnswerCall()
       
   358     {
       
   359     LOG( "CRadioRemConTargetImp::AnswerCall() ( currently unsupported in Visual Radio )" );
       
   360     }
       
   361 
       
   362 // ---------------------------------------------------------------------------
       
   363 //
       
   364 // ---------------------------------------------------------------------------
       
   365 //
       
   366 void CRadioRemConTargetImp::AnswerEndCall()
       
   367     {
       
   368     LOG( "CRadioRemConTargetImp::AnswerEndCall() " );
       
   369     if ( iObserver )
       
   370         {
       
   371         TRAP_IGNORE( iObserver->AnswerEndCallL())
       
   372         }
       
   373     }
       
   374 
       
   375 // ---------------------------------------------------------------------------
       
   376 //
       
   377 // ---------------------------------------------------------------------------
       
   378 //
       
   379 void CRadioRemConTargetImp::DialCall( const TDesC8& /*aTelNumber*/ )
       
   380     {
       
   381     LOG( "CRadioRemConTargetImp::DialCall ( currently unsupported in Visual Radio )" );
       
   382     }
       
   383 
       
   384 // ---------------------------------------------------------------------------
       
   385 //
       
   386 // ---------------------------------------------------------------------------
       
   387 //
       
   388 void CRadioRemConTargetImp::EndCall()
       
   389     {
       
   390     LOG( "CRadioRemConTargetImp::EndCall() ( currently unsupported in Visual Radio )" );
       
   391     }
       
   392 
       
   393 // ---------------------------------------------------------------------------
       
   394 //
       
   395 // ---------------------------------------------------------------------------
       
   396 //
       
   397 void CRadioRemConTargetImp::GenerateDTMF( const TChar /*aChar*/ )
       
   398     {
       
   399     LOG( "CRadioRemConTargetImp::GenerateDTMF ( currently unsupported in Visual Radio )" );
       
   400     }
       
   401 
       
   402 // ---------------------------------------------------------------------------
       
   403 //
       
   404 // ---------------------------------------------------------------------------
       
   405 //
       
   406 void CRadioRemConTargetImp::LastNumberRedial()
       
   407     {
       
   408     LOG( "CRadioRemConTargetImp::LastNumberRedial ( currently unsupported in Visual Radio )" );
       
   409     }
       
   410 
       
   411 // ---------------------------------------------------------------------------
       
   412 //
       
   413 // ---------------------------------------------------------------------------
       
   414 //
       
   415 void CRadioRemConTargetImp::MultipartyCalling( const TDesC8& /*aData*/ )
       
   416     {
       
   417     LOG( "CRadioRemConTargetImp::MultipartyCalling ( currently unsupported in Visual Radio )" );
       
   418     }
       
   419 
       
   420 // ---------------------------------------------------------------------------
       
   421 //
       
   422 // ---------------------------------------------------------------------------
       
   423 //
       
   424 void CRadioRemConTargetImp::SpeedDial( const TInt /*aIndex*/ )
       
   425     {
       
   426     LOG( "CRadioRemConTargetImp::SpeedDial ( currently unsupported in Visual Radio )" );
       
   427     }
       
   428 
       
   429 // ---------------------------------------------------------------------------
       
   430 //
       
   431 // ---------------------------------------------------------------------------
       
   432 //
       
   433 void CRadioRemConTargetImp::VoiceDial( const TBool /*aActivate*/ )
       
   434     {
       
   435     LOG( "CRadioRemConTargetImp::VoiceDial ( currently unsupported in Visual Radio )" );
       
   436     }