localconnectivityservice/headset/src/headset.cpp
changeset 13 0feebc799606
parent 0 c3e98f10fcf4
equal deleted inserted replaced
1:388a17646e40 13:0feebc799606
     1 /*
     1 /*
     2 * Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
     2 * Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
     3 * All rights reserved.
     3 * All rights reserved.
     4 * This component and the accompanying materials are made available
     4 * This component and the accompanying materials are made available
     5 * under the terms of "Eclipse Public License v1.0"
     5 * under the terms of "Eclipse Public License v1.0"
     6 * which accompanies this distribution, and is available
     6 * which accompanies this distribution, and is available
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
    22 #include <coedef.h>
    22 #include <coedef.h>
    23 #include <eiksvdef.h>
    23 #include <eiksvdef.h>
    24 #include <apgcli.h>
    24 #include <apgcli.h>
    25 #include <apgtask.h>
    25 #include <apgtask.h>
    26 #include <e32property.h>
    26 #include <e32property.h>
       
    27 #ifdef NO101APPDEPFIXES
    27 #include <alarmuidomainpskeys.h>
    28 #include <alarmuidomainpskeys.h>
       
    29 #else   //NO101APPDEPFIXES
       
    30 const TUid KPSUidAlarmExtCntl = { 0x102072D4 }; // reusing an AlarmUI dll UID
       
    31 const TUint32 KAlarmStopKey = 0x00000001;
       
    32 enum TAlarmUIStopAlarm
       
    33     {
       
    34     EAlarmUIStopAlarmUninitialized = 0,
       
    35     EAlarmUIStopAlarm
       
    36     };
       
    37 const TUint32 KAlarmSnoozeKey = 0x00000002;
       
    38 enum TAlarmUISnoozeAlarm
       
    39     {
       
    40     EAlarmUISnoozeAlarmUninitialized = 0,
       
    41     EAlarmUISnoozeAlarm
       
    42     };
       
    43 #endif  //NO101APPDEPFIXES
    28 
    44 
    29 #include <mpxplaybackmessage.h>
    45 #include <mpxplaybackmessage.h>
    30 #include <mpxmessagegeneraldefs.h>
    46 #include <mpxmessagegeneraldefs.h>
    31 #include <mpxplaybackmessagedefs.h>
    47 #include <mpxplaybackmessagedefs.h>
    32 
    48 
    38 #include "debug.h"
    54 #include "debug.h"
    39 
    55 
    40 const TInt KHidUndefinedKeyCode = 0;
    56 const TInt KHidUndefinedKeyCode = 0;
    41 const TInt KHidNotSetKeyValue = 0;
    57 const TInt KHidNotSetKeyValue = 0;
    42 const TInt KDoubleClickTimeout = 900000; // 0,9 seconds
    58 const TInt KDoubleClickTimeout = 900000; // 0,9 seconds
       
    59 const TInt KDoubleClickTimeoutRing = 500000; // 0,5 seconds
    43 const TInt KScanClickTimeout = 500000; // 0,5 seconds
    60 const TInt KScanClickTimeout = 500000; // 0,5 seconds
    44 const TInt KLongClickTimeout = 3000000; // 3 seconds
    61 const TInt KLongClickTimeout = 3000000; // 3 seconds
    45 
    62 
    46 // ======== MEMBER FUNCTIONS ========
    63 // ======== MEMBER FUNCTIONS ========
    47 
    64 
   732     if ( aStatus )
   749     if ( aStatus )
   733         {
   750         {
   734         switch ( hookStatus )
   751         switch ( hookStatus )
   735             {
   752             {
   736             case EOnHook:
   753             case EOnHook:
   737                 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook On Pressed"));
   754                 if ( !iIncomingCallStatus )
   738                 iOnHookPressed = ETrue;
   755                     {
   739                 break;
   756                     // For the first click, trigger the timer 
       
   757                     // single click is handled in ExpiredDoubleClickTimer
       
   758                     if ( iDoubleClicktimer )
       
   759                         {
       
   760                         delete iDoubleClicktimer;
       
   761                         iDoubleClicktimer = NULL;
       
   762                         }
       
   763                     TRAP_IGNORE( iDoubleClicktimer = CKeyPressTimer::NewL( this,
       
   764                         TTimeIntervalMicroSeconds32( KDoubleClickTimeoutRing ),
       
   765                         EDoubleClickTimer ) );
       
   766                     if ( iDoubleClicktimer )
       
   767                         {
       
   768                         iIncomingCallStatus = ETrue;
       
   769                         }
       
   770                     else // If fail to create timer, handle as single click, 
       
   771                     // for double click case, the next click will hang off
       
   772                         {
       
   773                         iIncomingCallStatus = EFalse;
       
   774                         iOnHookPressed = ETrue;
       
   775                         }
       
   776                     break; // switch
       
   777                     }
       
   778                 else
       
   779                     {
       
   780                     iIncomingCallStatus = EFalse;
       
   781                     if ( iDoubleClicktimer )
       
   782                         {
       
   783                         delete iDoubleClicktimer;
       
   784                         iDoubleClicktimer = NULL;
       
   785                         }
       
   786                     // This is the double click case, handle as EOffHook
       
   787                     }
       
   788                 // No break here
   740             case EOffHook:
   789             case EOffHook:
   741                 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook Off Pressed"));
   790                 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook Off Pressed"));
   742                 iOffHookPressed = ETrue;
   791                 iOffHookPressed = ETrue;
   743                 break;
   792                 break;
   744             case ENoHook:
   793             case ENoHook:
   745                 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook None Pressed"));                
   794                 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook None Pressed")); 
   746                 TRAP_IGNORE( HandleNoneHookPressL() );                
   795                 TRAP_IGNORE( HandleNoneHookPressL() );                
   747                 break;
   796                 break;
   748             default:
   797             default:
   749                 TRACE_INFO(_L("CHidHeadsetDriver::HookKeyPres : Not \
   798                 TRACE_INFO(_L("CHidHeadsetDriver::HookKeyPres : Not \
   750                         supported"));                
   799                         supported"));                
  1028     {
  1077     {
  1029     TRACE_FUNC_ENTRY
  1078     TRACE_FUNC_ENTRY
  1030     switch ( aTimerType )
  1079     switch ( aTimerType )
  1031         {
  1080         {
  1032         case EDoubleClickTimer:
  1081         case EDoubleClickTimer:
  1033             ExpiredDubleClickTimer();
  1082             ExpiredDoubleClickTimer();
  1034             break;
  1083             break;
  1035         case ELongPressTimer:
  1084         case ELongPressTimer:
  1036             ExpiredLongClickTimer();
  1085             ExpiredLongClickTimer();
  1037             break;
  1086             break;
  1038         case EScanNextPressTimer:
  1087         case EScanNextPressTimer:
  1051         }
  1100         }
  1052     TRACE_FUNC_EXIT
  1101     TRACE_FUNC_EXIT
  1053     }
  1102     }
  1054 
  1103 
  1055 // ---------------------------------------------------------------------------
  1104 // ---------------------------------------------------------------------------
  1056 // ExpiredDubleClickTimer()
  1105 // ExpiredDoubleClickTimer()
  1057 // ---------------------------------------------------------------------------
  1106 // ---------------------------------------------------------------------------
  1058 //
  1107 //
  1059 void CHidHeadsetDriver::ExpiredDubleClickTimer()
  1108 void CHidHeadsetDriver::ExpiredDoubleClickTimer()
  1060     {
  1109     {
  1061     TRACE_FUNC_ENTRY
  1110     TRACE_FUNC_ENTRY
  1062     if ( iDoubleClicktimer )
  1111     if ( iDoubleClicktimer )
  1063         {
  1112         {
  1064         delete iDoubleClicktimer;
  1113         delete iDoubleClicktimer;
  1065         iDoubleClicktimer = NULL;
  1114         iDoubleClicktimer = NULL;
       
  1115         
       
  1116         if ( iIncomingCallStatus )
       
  1117             {
       
  1118             iIncomingCallStatus = EFalse;
       
  1119             iOnHookPressed = ETrue;
       
  1120             ReleaseHookKey();
       
  1121             }
  1066         if ( iAlarmStatus )
  1122         if ( iAlarmStatus )
  1067             {
  1123             {
  1068             RProperty::Set( KPSUidAlarmExtCntl, KAlarmStopKey,
  1124             RProperty::Set( KPSUidAlarmExtCntl, KAlarmStopKey,
  1069                     EAlarmUIStopAlarm );
  1125                     EAlarmUIStopAlarm );
  1070             iAlarmStatus = EFalse;
  1126             iAlarmStatus = EFalse;