bluetoothengine/bteng/src/btengincpair.cpp
changeset 25 9c3798b88e30
parent 1 6a1fe72036e3
--- a/bluetoothengine/bteng/src/btengincpair.cpp	Fri Apr 23 23:54:40 2010 +0300
+++ b/bluetoothengine/bteng/src/btengincpair.cpp	Sat Apr 24 00:12:05 2010 +0300
@@ -99,6 +99,8 @@
     if ( iAddr == aAddr )
         {
         err = KErrNone;
+        iUserAwarePairing = ETrue; // This function is called by a notifier, which means the UI has been involved
+        // Therefore we can display it in the paired devices list
         if ( !iActive->IsActive() && !OpenPhysicalLinkAdaptor() )
             {
             // If we are observing physical link, or showing user a note,
@@ -171,46 +173,46 @@
         iActivePairingOk->CancelRequest();
         UnSetPairResult();  // we might have set it before (if the link went down) so we want to reset it.   
         }
-    switch ( aDev.LinkKeyType() )
-        {
-        case ELinkKeyUnauthenticatedNonUpgradable:
-            {
-            // If an application uses btengconnman API to connect a service of 
-            // this device and JW pairing occurred as part of security enforcement,
-            // it shall be a user aware pairing, and we shall add this device in paired
-            // view. In this way, user is able to disconnect the device from our UI.
-            // Otherwise the link key has been created by a device without IO requesting 
-            // a service connection with phone. We won't take any action (e.g. remove 
-            // link key) in this case. As the result, this device can't be seen in our UI, 
-            // however other applications are still freely to use its services.
-            TRACE_INFO(_L("[BTEng]: CBTEngIncPair: JW pairing with no IO device" ) )
-            TBTEngConnectionStatus status = iParent.IsDeviceConnected( aDev.Address() );
-            if ( status == EBTEngConnecting || status == EBTEngConnected )
-                {
-                // the return error is ingore as we can not have other proper 
-                // exception handling option:
-                (void) iParent.AddUiCookieJustWorksPaired( aDev );
-                }
-            iParent.RenewPairer( NULL );
-            break;
-            }
-        case ELinkKeyUnauthenticatedUpgradable:
-            {
-            // The linkkey has been created  by an incoming OBEX service request
-            // which resulted a pairing event received from pair server.
-            TRACE_INFO(_L("[BTEng]: CBTEngIncPair: JW pairing with IO device" ) )
-            iParent.RenewPairer( NULL );
-            break;
-            }
-        default:
-            {
-            // Other pairing model than Just Works:
-            CancelPlaNotification();
-            SetPairResult( KErrNone );
-            ShowPairingNoteAndAuthorizeQuery();
-            break;
-            }
-        }
+    if (aDev.LinkKeyType() == ELinkKeyUnauthenticatedNonUpgradable && !iUserAwarePairing)
+		{
+		// If an application uses btengconnman API to connect a service of 
+		// this device and JW pairing occurred as part of security enforcement,
+		// it shall be a user aware pairing, and we shall add this device in paired
+		// view. In this way, user is able to disconnect the device from our UI.
+		// Otherwise the link key has been created by a device without IO requesting 
+		// a service connection with phone. We won't take any action (e.g. remove 
+		// link key) in this case. As the result, this device can't be seen in our UI, 
+		// however other applications are still freely to use its services.
+		TRACE_INFO(_L("[BTEng]: CBTEngIncPair: JW pairing with no IO device" ) )
+		TBTEngConnectionStatus status = iParent.IsDeviceConnected( aDev.Address() );
+		if ( status == EBTEngConnecting || status == EBTEngConnected )
+			{
+			// the return error is ingore as we can not have other proper 
+			// exception handling option:
+			(void) iParent.AddUiCookieJustWorksPaired( aDev );
+			}
+		iParent.RenewPairer( NULL );
+		}
+    else if (aDev.LinkKeyType() == ELinkKeyUnauthenticatedUpgradable && !iUserAwarePairing)
+		{
+		// The linkkey has been created  by an incoming OBEX service request
+		// which resulted a pairing event received from pair server.
+		TRACE_INFO(_L("[BTEng]: CBTEngIncPair: JW pairing with IO device" ) )
+		iParent.RenewPairer( NULL );
+		}
+    else
+		{
+		if (aDev.LinkKeyType() == ELinkKeyUnauthenticatedNonUpgradable || aDev.LinkKeyType() == ELinkKeyUnauthenticatedUpgradable)
+			{
+			// The user was involved in the pairing, so display in the paired devices list
+			(void) iParent.AddUiCookieJustWorksPaired(aDev);
+			}
+		TRACE_INFO(_L("[BTEng]: CBTEngIncPair: Non-JW pairing"))
+		// Other pairing model than Just Works:
+		CancelPlaNotification();
+		SetPairResult( KErrNone );
+		ShowPairingNoteAndAuthorizeQuery();
+		}
     TRACE_FUNC_EXIT
     }