bluetoothengine/bteng/src/btengsrvkeywatcher.cpp
changeset 19 43824b19ee35
parent 17 f05641c183ff
child 56 9386f31cc85b
child 65 001a94c71129
--- a/bluetoothengine/bteng/src/btengsrvkeywatcher.cpp	Mon May 03 12:40:50 2010 +0300
+++ b/bluetoothengine/bteng/src/btengsrvkeywatcher.cpp	Fri May 14 16:01:46 2010 +0300
@@ -27,7 +27,6 @@
 #include "btengserver.h"
 #include "btengsrvpluginmgr.h"
 #include "btengsrvsettingsmgr.h"
-#include "btengpairman.h"
 #include "btengprivatepskeys.h"
 #include "btengprivatecrkeys.h"
 #include "debug.h"
@@ -48,8 +47,7 @@
 const TInt KBTEngSapWatcher = 22;
 /**  Identification for active object */
 const TInt KBTEngAddrWatcher = 23;
-/**  Identification for active object */
-const TInt KBTEngRegistryWatcher = 24;
+
 /**  Identification for active object */
 const TInt KBTEngSspDebugWatcher = 25;
 /**  Buffer size for BT device address as stored in CenRep */
@@ -129,16 +127,6 @@
         iEmergencyCallKey.Subscribe( iEmergencyCallWatcher->RequestStatus() );
         iEmergencyCallWatcher->GoActive();
         }
-
-    err = iBtRegistryKey.Attach( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothGetRegistryTableChange );
-    if( !err )
-        {
-        iBtRegistryWatcher = CBTEngActive::NewL( *this, KBTEngRegistryWatcher, 
-                                                 CActive::EPriorityStandard );
-        iBtRegistryKey.Subscribe( iBtRegistryWatcher->RequestStatus() );
-        iBtRegistryWatcher->GoActive();
-        }
-
     err = iSspDebugModeKey.Attach( KPSUidBluetoothTestingMode, KBTSspDebugmode );
     if( !err )
         {
@@ -192,75 +180,32 @@
 //
 CBTEngSrvKeyWatcher::~CBTEngSrvKeyWatcher()
     {
-    if( iDutModeKey.Handle() )
-        {
-        iDutModeKey.Cancel();
-        }
     delete iDutModeWatcher;
     iDutModeKey.Close();
 
 #ifdef RD_REMOTELOCK
-    if( iPhoneLockKey.Handle() )
-        {
-        iPhoneLockKey.Cancel();
-        }
     delete iPhoneLockWatcher;
     iPhoneLockKey.Close();
 #endif  //RD_REMOTELOCK
 
-    if( iSystemStateKey.Handle() )
-        {
-        iSystemStateKey.Cancel();
-        }
     delete iSystemStateWatcher;
-    iSystemStateKey.Close();    
-     
-    if( iBtConnectionKey.Handle() )
-        {
-        iBtConnectionKey.Cancel();
-        }
+    iSystemStateKey.Close();
+
     delete iBtConnectionWatcher;
     iBtConnectionKey.Close();
-    
-    if( iBtScanningKey.Handle() )
-        {
-        iBtScanningKey.Cancel();
-        }
+
     delete iBtScanningWatcher;
     iBtScanningKey.Close();
 
-    if( iEmergencyCallKey.Handle() )
-        {
-        iEmergencyCallKey.Cancel();
-        }
     delete iEmergencyCallWatcher;
     iEmergencyCallKey.Close();
-    
-    if( iSspDebugModeKey.Handle() )
-        {
-        iSspDebugModeKey.Cancel();
-        }
+
     delete iSspDebugModeWatcher;
     iSspDebugModeKey.Close();
 
-    if( iBtRegistryKey.Handle() )
-    	{
-    	iBtRegistryKey.Cancel();
-    	}
-    delete iBtRegistryWatcher;
-    iBtRegistryKey.Close();
-
-    if( iSapKeyCenRep )
-        {
-        iSapKeyCenRep->NotifyCancel( KBTSapEnabled );
-        }
     delete iSapModeWatcher;
     delete iSapKeyCenRep;
 
-    if( iBdaddrKey.Handle() )
-        {
-        iBdaddrKey.Cancel();
-        }
     delete iBdaddrWatcher;
     iBdaddrKey.Close();
     }
@@ -271,13 +216,13 @@
 // Processes a changed key value.
 // ---------------------------------------------------------------------------
 //
-void CBTEngSrvKeyWatcher::RequestCompletedL( CBTEngActive* aActive, TInt aId, 
+void CBTEngSrvKeyWatcher::RequestCompletedL( CBTEngActive* aActive, 
     TInt aStatus )
     {
     TRACE_FUNC_ARG( ( _L( "status %d" ), aStatus ) )
     ASSERT( aStatus != KErrPermissionDenied );
     TInt val = 0;
-    switch( aId )
+    switch( aActive->RequestId() )
         {
         case KBTEngDutWatcher:
             {
@@ -360,22 +305,6 @@
                 }
             break;
             }
-        case KBTEngRegistryWatcher:
-        	{
-            TRACE_INFO( ( _L( "BT Registry key changed" ) ) )
-            TInt myChangedTable;
-
-			iBtRegistryKey.Subscribe( aActive->RequestStatus() );
-			aActive->GoActive();
-
-            TInt err = iBtRegistryKey.Get( myChangedTable );
-            if( !err && myChangedTable == KRegistryChangeRemoteTable )
-            	{
-            	TRACE_INFO( ( _L("BT Remote registry key changed") ) )
-            	iServer->PairManager()->RemoteRegistryChangeDetected();
-            	}
-        	break;
-        	}    
         case KBTEngSapWatcher:
             {
             TRACE_INFO( ( _L( "SAP mode key changed" ) ) )
@@ -428,7 +357,7 @@
             break;
         default:
             {
-            TRACE_INFO( ( _L( "[BTENG]\t wrong key notification! id=%d" ), aId ) )
+            TRACE_INFO( ( _L( "[BTENG]\t wrong key notification! id=%d" ), aActive->RequestId() ) )
             }
             break;
 
@@ -436,6 +365,73 @@
     TRACE_FUNC_EXIT
     }
 
+// ---------------------------------------------------------------------------
+// From class MBTEngActiveObserver.
+// Handles cancelation of an outstanding request
+// ---------------------------------------------------------------------------
+//
+void CBTEngSrvKeyWatcher::CancelRequest( TInt aRequestId )
+    {
+    TRACE_FUNC_ARG( ( _L( "reqID %d" ), aRequestId ) )
+    switch( aRequestId )
+        {
+        case KBTEngDutWatcher:
+            {
+            iDutModeKey.Cancel();
+            break;
+            }
+        case KBTEngLockWatcher:
+            {
+            iPhoneLockKey.Cancel();
+            break;
+            }
+        case KBTEngSysWatcher:
+            {
+            iSystemStateKey.Cancel();
+            break;
+            }
+        case KBTEngBtConnectionWatcher:
+            {
+            iBtConnectionKey.Cancel();
+            break;
+            }
+                    
+        case KBTEngScanningWatcher:
+            {
+            iBtScanningKey.Cancel();
+            break;
+            }
+            
+        case KBTEngEmergencyWatcher:
+            {
+            iEmergencyCallKey.Cancel();
+            break;
+            }
+            
+        case KBTEngSspDebugWatcher:
+            {
+            iSspDebugModeKey.Cancel();
+            break;
+            }   
+        case KBTEngSapWatcher:
+            {
+            iSapKeyCenRep->NotifyCancel( KBTSapEnabled );
+            break;
+            }
+            
+        case KBTEngAddrWatcher:
+            {
+            iBdaddrKey.Cancel();
+            break;
+            }
+        default:
+            {
+            TRACE_INFO( ( _L( "[BTENG]\t wrong key notification! id=%d" ), aRequestId ) )
+            break;
+            }
+        }
+    TRACE_FUNC_EXIT 
+    }
 
 // ---------------------------------------------------------------------------
 // From class MBTEngActiveObserver.
@@ -443,14 +439,14 @@
 // the subscriptions are active.
 // ---------------------------------------------------------------------------
 //
-void CBTEngSrvKeyWatcher::HandleError( CBTEngActive* aActive, TInt aId, 
+void CBTEngSrvKeyWatcher::HandleError( CBTEngActive* aActive, 
     TInt aError )
     {
     TRACE_FUNC_ARG( ( _L( "status %d" ), aError ) )
     (void) aError;
     if( !aActive->IsActive() )
         {
-        switch( aId )
+        switch( aActive->RequestId() )
             {
             case KBTEngDutWatcher:
                 {
@@ -483,7 +479,7 @@
                 break;
             default:
                 {
-                TRACE_INFO( ( _L( "[BTENG]\t wrong key notification! id=%d" ), aId ) )
+                TRACE_INFO( ( _L( "[BTENG]\t wrong key notification! id=%d" ), aActive->RequestId() ) )
                 }
                 return; // we don't want to go active without subscribing
             }