localconnectivityservice/headset/src/headset.cpp
branchRCL_3
changeset 9 a2f12998bb04
parent 0 c3e98f10fcf4
--- a/localconnectivityservice/headset/src/headset.cpp	Fri Feb 19 23:43:38 2010 +0200
+++ b/localconnectivityservice/headset/src/headset.cpp	Fri Mar 12 15:46:58 2010 +0200
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2004-2010 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
@@ -40,6 +40,7 @@
 const TInt KHidUndefinedKeyCode = 0;
 const TInt KHidNotSetKeyValue = 0;
 const TInt KDoubleClickTimeout = 900000; // 0,9 seconds
+const TInt KDoubleClickTimeoutRing = 500000; // 0,5 seconds
 const TInt KScanClickTimeout = 500000; // 0,5 seconds
 const TInt KLongClickTimeout = 3000000; // 3 seconds
 
@@ -734,15 +735,47 @@
         switch ( hookStatus )
             {
             case EOnHook:
-                TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook On Pressed"));
-                iOnHookPressed = ETrue;
-                break;
+                if ( !iIncomingCallStatus )
+                    {
+                    // For the first click, trigger the timer 
+                    // single click is handled in ExpiredDoubleClickTimer
+                    if ( iDoubleClicktimer )
+                        {
+                        delete iDoubleClicktimer;
+                        iDoubleClicktimer = NULL;
+                        }
+                    TRAP_IGNORE( iDoubleClicktimer = CKeyPressTimer::NewL( this,
+                        TTimeIntervalMicroSeconds32( KDoubleClickTimeoutRing ),
+                        EDoubleClickTimer ) );
+                    if ( iDoubleClicktimer )
+                        {
+                        iIncomingCallStatus = ETrue;
+                        }
+                    else // If fail to create timer, handle as single click, 
+                    // for double click case, the next click will hang off
+                        {
+                        iIncomingCallStatus = EFalse;
+                        iOnHookPressed = ETrue;
+                        }
+                    break; // switch
+                    }
+                else
+                    {
+                    iIncomingCallStatus = EFalse;
+                    if ( iDoubleClicktimer )
+                        {
+                        delete iDoubleClicktimer;
+                        iDoubleClicktimer = NULL;
+                        }
+                    // This is the double click case, handle as EOffHook
+                    }
+                // No break here
             case EOffHook:
                 TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook Off Pressed"));
                 iOffHookPressed = ETrue;
                 break;
             case ENoHook:
-                TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook None Pressed"));                
+                TRACE_INFO(_L("[HID]\tCHidHeadsetDriver Hook None Pressed")); 
                 TRAP_IGNORE( HandleNoneHookPressL() );                
                 break;
             default:
@@ -1030,7 +1063,7 @@
     switch ( aTimerType )
         {
         case EDoubleClickTimer:
-            ExpiredDubleClickTimer();
+            ExpiredDoubleClickTimer();
             break;
         case ELongPressTimer:
             ExpiredLongClickTimer();
@@ -1053,16 +1086,23 @@
     }
 
 // ---------------------------------------------------------------------------
-// ExpiredDubleClickTimer()
+// ExpiredDoubleClickTimer()
 // ---------------------------------------------------------------------------
 //
-void CHidHeadsetDriver::ExpiredDubleClickTimer()
+void CHidHeadsetDriver::ExpiredDoubleClickTimer()
     {
     TRACE_FUNC_ENTRY
     if ( iDoubleClicktimer )
         {
         delete iDoubleClicktimer;
         iDoubleClicktimer = NULL;
+        
+        if ( iIncomingCallStatus )
+            {
+            iIncomingCallStatus = EFalse;
+            iOnHookPressed = ETrue;
+            ReleaseHookKey();
+            }
         if ( iAlarmStatus )
             {
             RProperty::Set( KPSUidAlarmExtCntl, KAlarmStopKey,