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