Revision: 201025 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 15 Jul 2010 18:50:18 +0300
branchRCL_3
changeset 20 eede1356aa52
parent 18 5a89845f78e2
child 21 0ba996a9b75d
Revision: 201025 Kit: 2010127
bluetoothengine/bthid/keyboard/group/keyboard.mmp
bluetoothengine/bthid/keyboard/inc/keyboard.h
bluetoothengine/bthid/keyboard/src/keyboard.cpp
bluetoothengine/btnotif/inc/BTNGenericQueryNotifier.h
bluetoothengine/btnotif/inc/btnotifier.h
bluetoothengine/btnotif/src/BTNGenericQueryNotifier.cpp
cbsatplugin/atmisccmdplugin/src/cfuncommandhandler.cpp
--- a/bluetoothengine/bthid/keyboard/group/keyboard.mmp	Mon Jun 21 15:51:46 2010 +0300
+++ b/bluetoothengine/bthid/keyboard/group/keyboard.mmp	Thu Jul 15 18:50:18 2010 +0300
@@ -60,5 +60,5 @@
 LIBRARY       apgrfx.lib
 LIBRARY       apparc.lib 
 LIBRARY       bthidsettings.lib
-//LIBRARY       avkon.lib
+LIBRARY       avkon.lib
 DEBUGLIBRARY       flogger.lib
--- a/bluetoothengine/bthid/keyboard/inc/keyboard.h	Mon Jun 21 15:51:46 2010 +0300
+++ b/bluetoothengine/bthid/keyboard/inc/keyboard.h	Thu Jul 15 18:50:18 2010 +0300
@@ -22,7 +22,7 @@
 #include <e32std.h>
 #include <w32std.h>
 #include <e32event.h>
-//#include <aknkeylock.h>
+#include <aknkeylock.h>
 
 #include "hidinterfaces.h"
 #include "hidkeys.h"
@@ -360,7 +360,7 @@
     CTimeOutTimer* iRepeatEndTimer;
     
     TUint8 iNavKeyDown;
-//    RAknKeyLock iKeyLock;
+    RAknKeyLock iKeyLock;
     };
 
 // ----------------------------------------------------------------------
--- a/bluetoothengine/bthid/keyboard/src/keyboard.cpp	Mon Jun 21 15:51:46 2010 +0300
+++ b/bluetoothengine/bthid/keyboard/src/keyboard.cpp	Thu Jul 15 18:50:18 2010 +0300
@@ -136,9 +136,9 @@
     iSettings = CBtHidSettings::NewL();
     
     // create a keylock session
-/*    TInt err = iKeyLock.Connect();
+    TInt err = iKeyLock.Connect();
     TRACE_INFO( (_L("[HID]\tCHidKeyboardDriver::ConstructL: key lock err = %d"), err));
-    User::LeaveIfError(err);    */
+    User::LeaveIfError(err);    
     }
 
 //----------------------------------------------------------------------------
@@ -163,7 +163,7 @@
     if (iSettings)
         delete iSettings;
 
-//    iKeyLock.Close();
+    iKeyLock.Close();
     }
 
 //----------------------------------------------------------------------------
@@ -1913,7 +1913,7 @@
                 }
             
             // ESC when keylock enabled >>> Disabled key lock
-/*            else if (aIsKeyDown &&
+            else if (aIsKeyDown &&
                 iKeyLock.IsKeyLockEnabled())
                 {
                 TRACE_INFO((_L("[HID]\tESC >>> DISBALE KEY LOCK DOWN")));
@@ -1923,7 +1923,7 @@
                 ret = ETrue;
                 iNavKeyDown = (iNavKeyDown | EEsc);
                 }
-*/
+
             break;
             }
         case EStdKeyF8:
--- a/bluetoothengine/btnotif/inc/BTNGenericQueryNotifier.h	Mon Jun 21 15:51:46 2010 +0300
+++ b/bluetoothengine/btnotif/inc/BTNGenericQueryNotifier.h	Thu Jul 15 18:50:18 2010 +0300
@@ -1,20 +1,19 @@
 /*
-* Copyright (c) 2002 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"
-* which accompanies this distribution, and is available
-* at the URL "http://www.eclipse.org/legal/epl-v10.html".
-*
-* Initial Contributors:
-* Nokia Corporation - initial contribution.
-*
-* Contributors:
-*
-* Description:  Declares Generic Query Notifier Class.
-*
-*/
-
+ * Copyright (c) 2002, 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"
+ * which accompanies this distribution, and is available
+ * at the URL "http://www.eclipse.org/legal/epl-v10.html".
+ *
+ * Initial Contributors:
+ * Nokia Corporation - initial contribution.
+ *
+ * Contributors:
+ *
+ * Description:  Declares Generic Query Notifier Class.
+ *
+ */
 
 #ifndef BTNGENERICQUERYNOTIFIER_H
 #define BTNGENERICQUERYNOTIFIER_H
@@ -22,88 +21,116 @@
 // INCLUDES
 
 #include "btnotifier.h" // Base class
+#include "btnotifactive.h"
 
 // FORWARD DECLARATIONS
 
 // CLASS DECLARATION
-NONSHARABLE_CLASS(CBTGenericQueryNotifier) : public CBTNotifierBase
-    {
-    public: // Constructors and destructor
+NONSHARABLE_CLASS(CBTGenericQueryNotifier): public CBTNotifierBase,
+		public MBTNotifActiveObserver
+	{
+public:
+	// Constructors and destructor
+
+	/**
+	 * Two-phased constructor.
+	 */
+	static CBTGenericQueryNotifier* NewL();
+
+	/**
+	 * Destructor.
+	 */
+	virtual ~CBTGenericQueryNotifier();
+
+private:
+	// Functions from base classes
 
-        /**
-        * Two-phased constructor.
-        */
-        static CBTGenericQueryNotifier* NewL();
+	/**
+	 * From CBTNotifierBase Called when a notifier is first loaded
+	 * to allow any initial construction that is required.
+	 * @param None.
+	 * @return A structure containing priority and channel info.
+	 */
+	TNotifierInfo RegisterL();
+
+	/** From CBTNotifierBase Synchronic notifier launch.
+	 * @param aBuffer Received parameter data.
+	 * @return A pointer to return value.
+	 */
+	TPtrC8 StartL(const TDesC8& aBuffer);
 
-        /**
-        * Destructor.
-        */
-        virtual ~CBTGenericQueryNotifier();
+	/**
+	 * From CBTNotifierBase Used in asynchronous notifier launch to
+	 * store received parameters into members variables and
+	 * make needed initializations.
+	 * @param aBuffer A buffer containing received parameters
+	 * @param aReturnVal The return value to be passed back.
+	 * @param aMessage Should be completed when the notifier is deactivated.
+	 * @return None.
+	 */
+	void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot,
+			const RMessagePtr2& aMessage);
 
-    private: // Functions from base classes
+	/**
+	 * From CBTNotifierBase Updates a currently active notifier.
+	 * @param aBuffer The updated data.
+	 * @return A pointer to return value.
+	 */
+	TPtrC8 UpdateL(const TDesC8& aBuffer);
 
-        /**
-        * From CBTNotifierBase Called when a notifier is first loaded 
-        * to allow any initial construction that is required.
-        * @param None.
-        * @return A structure containing priority and channel info.
-        */
-        TNotifierInfo RegisterL();
-       
-        /** From CBTNotifierBase Synchronic notifier launch.        
-        * @param aBuffer Received parameter data.
-        * @return A pointer to return value.
-        */
-        TPtrC8 StartL(const TDesC8& aBuffer );
-                
-        /**
-        * From CBTNotifierBase Used in asynchronous notifier launch to 
-        * store received parameters into members variables and 
-        * make needed initializations.
-        * @param aBuffer A buffer containing received parameters
-        * @param aReturnVal The return value to be passed back.
-        * @param aMessage Should be completed when the notifier is deactivated.
-        * @return None.
-        */
-        void GetParamsL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage);
+	/**
+	 * From MBTNotifActiveObserver
+	 * Gets called when P&S key notifies change.
+	 */
+	void RequestCompletedL(CBTNotifActive* aActive, TInt aId, TInt aStatus);
+
+	/**
+	 * From MBTNotifActiveObserver
+	 */
+	void HandleError(CBTNotifActive* aActive, TInt aId, TInt aError);
+
+	/**
+	 * From MBTNotifActiveObserver
+	 */
+	void DoCancelRequest(CBTNotifActive* aActive, TInt aId);
+
+private:
+
+	/**
+	 * Parse the data out of the message that is sent by the client of the notifier.
+	 * @param aBuffer A package buffer containing received parameters.
+	 * @return None.
+	 */
+	void ProcessParamBufferL(const TDesC8& aBuffer);
 
-		/**
-        * From CBTNotifierBase Updates a currently active notifier.
-        * @param aBuffer The updated data.
-        * @return A pointer to return value.
-        */
-        TPtrC8 UpdateL(const TDesC8& aBuffer);
-        
-    private:
+	/**
+	 * C++ default constructor.
+	 */
+	CBTGenericQueryNotifier();
+
+	/**
+	 * Symbian 2nd phase constructor.
+	 */
+	void ConstructL();
 
-		/**
-        * Parse the data out of the message that is sent by the client of the notifier. 
-		* @param aBuffer A package buffer containing received parameters.
-        * @return None.
-        */
-		void ProcessParamBufferL(const TDesC8& aBuffer);
-		
-        /**
-        * C++ default constructor.
-        */
-        CBTGenericQueryNotifier();   
-        
-        /**
-         * Show query and complete message.
-         */
-        void ShowQueryAndCompleteL();
-                
-    private:
-    	
-        RBuf				iQueryMessage;
-		HBufC*				iQueryHeader;
-        HBufC*				iName;
+	/**
+	 * Show query and complete message.
+	 */
+	void ShowQueryAndCompleteL();
+
+private:
 
-	    TInt 		iMessageResourceId;
-	    TSecondaryDisplayBTnotifDialogs	iSecondaryDisplayCommand;
-		TBool 		iIsMessageQuery;
-		TBool 		iIsNameQuery;
-    };
+	RBuf iQueryMessage;
+	HBufC* iQueryHeader;
+	HBufC* iName;
+
+	TInt iMessageResourceId;
+	TSecondaryDisplayBTnotifDialogs iSecondaryDisplayCommand;
+	TBool iIsMessageQuery;
+	TBool iIsNameQuery;
+	RProperty iPhonePowerKey;
+	CBTNotifActive* iPhonePowerKeyWatcher;
+	};
 
 #endif
 
--- a/bluetoothengine/btnotif/inc/btnotifier.h	Mon Jun 21 15:51:46 2010 +0300
+++ b/bluetoothengine/btnotif/inc/btnotifier.h	Thu Jul 15 18:50:18 2010 +0300
@@ -39,7 +39,7 @@
 const TUid KBTPowerModeChannel          = {0x00000606}; // Channel for power mode notifier
 const TUid KBTAudioAccessoryChannel     = {0x00000607}; // Channel for audio accessory notifier
 const TUid KBTLowMemoryChannel          = {0x00000608}; // Channel for low memory notifier
-const TUid KBTPairedDeviceSettingChannel  = {0x00000610}; 
+const TUid KBTPairedDeviceSettingChannel  = {0x00000610};
 
 // FORWARD DECLARATIONS
 class CBTEngSettings;
@@ -73,7 +73,7 @@
         * @return A boolean according to autolock state.
         */
         TBool AutoLockOnL();
-        
+
     protected: // Constructors and destructor
 
         /**
@@ -81,25 +81,23 @@
         */
         CBTNotifierBase();
 
+    protected: // New functions
+
         /**
         * Symbian 2nd phase constructor.
         */
         virtual void ConstructL();
-        
-
-
-    protected: // New functions
 
         /**
-        * Used in asynchronous notifier launch to store received parameters 
-        * into members variables and make needed initializations.        
+        * Used in asynchronous notifier launch to store received parameters
+        * into members variables and make needed initializations.
         * @param aBuffer A buffer containing received parameters
         * @param aReturnVal The return value to be passed back.
         * @param aMessage Should be completed when the notifier is deactivated.
         * @return None.
         */
-        virtual void GetParamsL(const TDesC8& aBuffer, 
-                                TInt aReplySlot, 
+        virtual void GetParamsL(const TDesC8& aBuffer,
+                                TInt aReplySlot,
                                 const RMessagePtr2& aMessage)=0;
 
         /**
@@ -108,15 +106,15 @@
         * @return ETrue if BT is turned on successfully; EFalse otherwise
         */
         TBool CheckAndSetPowerOnL();
-		
+
 		/**
-		* A function for setting BT name 
+		* A function for setting BT name
 		* @return ETrue if BT name is set successfully; EFalse otherwise
 		*/
 		TBool AskLocalBTNameQueryL();
 
         /**
-		* Check if there is any existing connection to audio profiles from 
+		* Check if there is any existing connection to audio profiles from
 		* the same device
 		* @return ETrue if the device is connected.
 		*/
@@ -135,16 +133,16 @@
         * @return None
         */
         void CompleteMessage(TInt aValueToReplySlot, TInt aErr);
-        
+
        /**
         * Complete Client/Server message and Nulled the reply slot.
         * @param aErr  Error code for client notification.
         * @return None
         */
         void CompleteMessage(const TDesC8& aDesToReplySlot, TInt aErr);
-        
+
 		/**
-		* Checks from central repository whether the Bluetooth friendly name 
+		* Checks from central repository whether the Bluetooth friendly name
         * has been modified .
 		* @return ETure if the name has been modified.
 		*/
@@ -154,12 +152,12 @@
 		 * Get the device information from BT Registry by the given address.
 		 */
 		void GetDeviceFromRegL(const TBTDevAddr& aAddr);
-		
+
 		/**
 		 * virtual function to be ovewritten by sub-classes.
 		 * Will be called when Getting Device by BTEng DevMan is completed.
 		 * @param aDev the device from registry if it is not null. indicates either a failure
-		 *             or the device is not available in registry. 
+		 *             or the device is not available in registry.
 		 */
 		virtual void HandleGetDeviceCompletedL(const CBTDevice* aDev);
 
@@ -191,21 +189,21 @@
         void CheckAndHandleQueryIntervalL();
 
     private:
-        
+
         void DoHandleGetDevicesCompleteL(TInt aErr, CBTDeviceArray* aDeviceArray );
-		
+
     protected: // Functions from base classes
 
         /**
-        * From MEikSrvNotifierBase2 Called when a notifier is first loaded 
+        * From MEikSrvNotifierBase2 Called when a notifier is first loaded
         * to allow any initial construction that is required.
         * @param None.
         * @return A structure containing priority and channel info.
         */
         virtual TNotifierInfo RegisterL()=0;
-        
+
         /**
-        * From MEikSrvNotifierBase2 The notifier has been deactivated 
+        * From MEikSrvNotifierBase2 The notifier has been deactivated
         * so resources can be freed and outstanding messages completed.
         * @param None.
         * @return None.
@@ -219,12 +217,12 @@
 		 * @return KErrNone
 		 */
 		static TInt LaunchHelp(TAny *TCoeHelpContext=NULL);
-#endif        
+#endif
 
-    private: // Functions from base classes        
-        
+    private: // Functions from base classes
+
         /**
-        * From MEikSrvNotifierBase2 Called when all resources allocated 
+        * From MEikSrvNotifierBase2 Called when all resources allocated
         * by notifiers should be freed.
         * @param None.
         * @return None.
@@ -232,7 +230,7 @@
         virtual void Release();
 
         /**
-        * From MEikSrvNotifierBase2 Return the priority a notifier takes 
+        * From MEikSrvNotifierBase2 Return the priority a notifier takes
         * and the channels it acts on.
         * @param None.
         * @return A structure containing priority and channel info.
@@ -240,12 +238,12 @@
         virtual TNotifierInfo Info() const;
 
         /**
-        * From MEikSrvNotifierBase2 Synchronic notifier launch.        
+        * From MEikSrvNotifierBase2 Synchronic notifier launch.
         * @param aBuffer Received parameter data.
         * @return A pointer to return value.
         */
         virtual TPtrC8 StartL(const TDesC8& aBuffer);
-        
+
         /**
         * From MEikSrvNotifierBase2 Asynchronic notifier launch.
         * @param aBuffer A buffer containing received parameters
@@ -254,26 +252,26 @@
         * @return A pointer to return value.
         */
         virtual void StartL(const TDesC8& aBuffer, TInt aReplySlot, const RMessagePtr2& aMessage);
-        
+
         /**
         * From MEikSrvNotifierBase2 Updates a currently active notifier.
         * @param aBuffer The updated data.
         * @return A pointer to return value.
         */
-        virtual TPtrC8 UpdateL(const TDesC8& aBuffer);        
-		
+        virtual TPtrC8 UpdateL(const TDesC8& aBuffer);
+
         /**
          * From MBTEngDevManObserver
-         * Indicates to the caller that adding, deleting or modifying a device 
+         * Indicates to the caller that adding, deleting or modifying a device
          * has completed.
          */
         virtual void HandleDevManComplete(TInt aErr);
-        
+
         /**
          * From MBTEngDevManObserver
          * Call back function when GetDevices() request is completed.
          * @param aErr Status information, if there is an error.
-         * @param aDeviceArray Array of devices that match the given criteria 
+         * @param aDeviceArray Array of devices that match the given criteria
          *                     (the array provided by the calller).
          */
         void HandleGetDevicesComplete( TInt aErr, CBTDeviceArray* aDeviceArray );
@@ -301,7 +299,7 @@
         CBTEngDevMan*               iDevMan;  // for BT registry manipulation
 
 
-        
+
     };
 
 #endif
--- a/bluetoothengine/btnotif/src/BTNGenericQueryNotifier.cpp	Mon Jun 21 15:51:46 2010 +0300
+++ b/bluetoothengine/btnotif/src/BTNGenericQueryNotifier.cpp	Thu Jul 15 18:50:18 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2002, 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"
@@ -26,12 +26,15 @@
 #include <bluetoothuiutil.h>
 #include "BTNGenericQueryNotifier.h"      // Own class definition
 #include "btNotifDebug.h"       // Debugging macros
+#include <coreapplicationuisdomainpskeys.h>
 
 #ifdef __SERIES60_HELP
 #include <hlplch.h>
 #include <csxhelp/bt.hlp.hrh> // The bt hrh info is needed, for help launching
 #endif
 
+const TInt KBTNotifPhonePowerKeyWatcher = 30;
+
 // ================= MEMBER FUNCTIONS =======================
 
 // ----------------------------------------------------------
@@ -55,7 +58,7 @@
 // ----------------------------------------------------------
 //
 CBTGenericQueryNotifier::CBTGenericQueryNotifier()
-    {	
+    {
     }
 
 // ----------------------------------------------------------
@@ -65,10 +68,42 @@
 CBTGenericQueryNotifier::~CBTGenericQueryNotifier()
     {
     Cancel();   // Free own resources
-    delete iName; 
-    iQueryMessage.Close(); 
+    delete iName;
+    iQueryMessage.Close();
 	delete iQueryHeader;
-    }
+	if (iPhonePowerKey.Handle())
+		{
+		iPhonePowerKey.Cancel();
+		}
+	delete iPhonePowerKeyWatcher;
+	iPhonePowerKey.Close();
+	}
+
+// ----------------------------------------------------------
+// CBTGenericQueryNotifier::ConstructL
+// Symbian 2nd phase constructor can leave.
+// Attach to the P&S property and create
+// ----------------------------------------------------------
+//
+void CBTGenericQueryNotifier::ConstructL()
+	{
+	CBTNotifierBase::ConstructL();
+
+	/**
+	 * SysAp notifies Alarm UI to hide alarm when powerkey is pressed.
+	 * This is called from CSysApAppUi::HandleShortPowerKeyPressedL(),
+	 * so it seems to be a better choice than the following keys:
+	 * 	KPSUidAvkonDomain/KAknPowerMenuStatus
+	 * 	KPSUidCoreApplicationUIs/KCoreAppUIsAutolockStatus
+	 * KCoreAppUIsAutolockStatus  would be ideal, but it comes too late.
+	 */
+	User::LeaveIfError(iPhonePowerKey.Attach(KPSUidCoreApplicationUIs,
+			KCoreAppUIsHideAlarm));
+	iPhonePowerKeyWatcher = CBTNotifActive::NewL(this,
+			KBTNotifPhonePowerKeyWatcher, CActive::EPriorityStandard);
+	iPhonePowerKey.Subscribe(iPhonePowerKeyWatcher->RequestStatus());
+	iPhonePowerKeyWatcher->GoActive();
+	}
 
 // ----------------------------------------------------------
 // CBTGenericQueryNotifier::RegisterL
@@ -95,36 +130,36 @@
     FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::StartL()"));
 
     TPtrC8 ret(KNullDesC8);
-    return (ret);    
-    
+    return (ret);
+
     }
 
 // ----------------------------------------------------------
 // CBTGenericQueryNotifier::GetParamsL
-// Mandatory for BT Notifiers when using asynchronous launch. 
+// Mandatory for BT Notifiers when using asynchronous launch.
 // This notifier is synchronous so no implementation is needed.
 // ----------------------------------------------------------
 //
-void CBTGenericQueryNotifier::GetParamsL(const TDesC8& aBuffer, 
-                                     TInt aReplySlot, 
+void CBTGenericQueryNotifier::GetParamsL(const TDesC8& aBuffer,
+                                     TInt aReplySlot,
                                      const RMessagePtr2& aMessage)
     {
-   	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::GetParamsL"));    
+   	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::GetParamsL"));
 
    	if (iMessage.Handle())
    	    {
    	    aMessage.Complete(KErrInUse);
    	    return;
    	    }
-   	
+
 	ProcessParamBufferL(aBuffer);
-	
+
     iMessage = aMessage;
     iReplySlot = aReplySlot;
-    
+
     ShowQueryAndCompleteL();
-    
-   	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::GetParamsL Complete"));    
+
+   	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::GetParamsL Complete"));
     }
 
 // ----------------------------------------------------------
@@ -134,7 +169,7 @@
 // ----------------------------------------------------------
 void CBTGenericQueryNotifier::ProcessParamBufferL(const TDesC8& aBuffer)
 	{
-	
+
 	TBTGenericQueryNotifierParams bParams;
 	TPckgC<TBTGenericQueryNotifierParams> bPckg(bParams);
 	bPckg.Set( aBuffer );
@@ -149,118 +184,118 @@
 		{
 		case EBTReceiveMessageQuery:
 			iIsMessageQuery=EFalse;
-			iMessageResourceId=R_BT_RECEIVE_MESSAGE	;	
-			iSecondaryDisplayCommand=ECmdShowReceiveMessageFromDeviceDlg; 
+			iMessageResourceId=R_BT_RECEIVE_MESSAGE	;
+			iSecondaryDisplayCommand=ECmdShowReceiveMessageFromDeviceDlg;
 			break;
 		case EBTReceiveMessagePairedQuery:
-			iIsMessageQuery=EFalse;		
+			iIsMessageQuery=EFalse;
 			iMessageResourceId=R_BT_RECEIVE_MESSAGE_PAIRED;
-			iSecondaryDisplayCommand= ECmdShowReceiveMessageFromPairedDeviceDlg; 
-			break;			
+			iSecondaryDisplayCommand= ECmdShowReceiveMessageFromPairedDeviceDlg;
+			break;
 		case EBTIsOffQuery:
-			iIsMessageQuery=EFalse;		
+			iIsMessageQuery=EFalse;
     		iMessageResourceId=R_BT_POWER_IS_OFF ;
-			iSecondaryDisplayCommand=ECmdShowBtIsOffDlg;		
-			break;			
+			iSecondaryDisplayCommand=ECmdShowBtIsOffDlg;
+			break;
 		case EBTActivateOffLineQuery:
-			iIsMessageQuery=EFalse;		
+			iIsMessageQuery=EFalse;
     		iMessageResourceId=R_BT_ACTIVATE_IN_OFFLINE;
-			iSecondaryDisplayCommand=ECmdShowBtActivateInOfflineDlg;		
-			break;			
+			iSecondaryDisplayCommand=ECmdShowBtActivateInOfflineDlg;
+			break;
 		case EBTNoDevicesFoundQuery:
-			iIsMessageQuery=EFalse;		
+			iIsMessageQuery=EFalse;
 			iMessageResourceId=R_BT_NO_DEVICES_FOUND;
-			break;	
+			break;
 		case EBTAcceptRequestQuery:
-			iIsMessageQuery=EFalse;		
+			iIsMessageQuery=EFalse;
 			iMessageResourceId=R_BT_AUTHORISATION_NAME ;
 			iSecondaryDisplayCommand=ECmdShowAcceptConnRequestDlg;
-			break;		
-			
-		case EBTIsOffJavaQuery:	
-			iIsMessageQuery=ETrue; 	
-			if( bPckg().iNameExists )			
+			break;
+
+		case EBTIsOffJavaQuery:
+			iIsMessageQuery=ETrue;
+			if( bPckg().iNameExists )
 				{
-				iMessageResourceId=R_BT_IS_OFF_JAVA_APPNAME; // when caller provide Java application name.	
+				iMessageResourceId=R_BT_IS_OFF_JAVA_APPNAME; // when caller provide Java application name.
 				}
 			else
 				{
-				iMessageResourceId=R_BT_IS_OFF_JAVA; //r_bt_is_hidden_java	
-				}		
+				iMessageResourceId=R_BT_IS_OFF_JAVA; //r_bt_is_hidden_java
+				}
 			iSecondaryDisplayCommand=ECmdShowBtBtIsOffJavaDlg;
-			iQueryHeader=StringLoader::LoadL( R_BT_IS_OFF_JAVA_HEADER);		
+			iQueryHeader=StringLoader::LoadL( R_BT_IS_OFF_JAVA_HEADER);
 			break;
 
 		case EBTIsNotShownQuery:
-			iIsMessageQuery=ETrue;			
+			iIsMessageQuery=ETrue;
 			if( bPckg().iNameExists )
 				{
-				iMessageResourceId=R_BT_IS_HIDDEN_JAVA_APPNAME; // when caller provide Java application name.	
+				iMessageResourceId=R_BT_IS_HIDDEN_JAVA_APPNAME; // when caller provide Java application name.
 				}
 			else
 				{
-				iMessageResourceId=R_BT_IS_HIDDEN_JAVA; //r_bt_is_hidden_java	
-				}									
+				iMessageResourceId=R_BT_IS_HIDDEN_JAVA; //r_bt_is_hidden_java
+				}
 			iSecondaryDisplayCommand=ECmdShowBtIsNotVisibleDlg;
 			iQueryHeader=StringLoader::LoadL( R_BT_IS_HIDDEN_JAVA_HEADER);
 			break;
-			
+
 		case EBTBlockConnectionQuery:
-		case EBTBlockPairedConnectionQuery:		
-			iIsMessageQuery=ETrue;		
+		case EBTBlockPairedConnectionQuery:
+			iIsMessageQuery=ETrue;
 			if( bPckg().iMessageType == EBTBlockConnectionQuery )
-				iMessageResourceId = R_BT_BLOCK_DEVICE_NOHELP; 
+				iMessageResourceId = R_BT_BLOCK_DEVICE_NOHELP;
 			else
-				iMessageResourceId = R_BT_BLOCK_PAIRED_DEVICE_NOHELP ; 
-				
+				iMessageResourceId = R_BT_BLOCK_PAIRED_DEVICE_NOHELP ;
+
 			iQueryHeader= StringLoader::LoadL( R_BT_BLOCK_DEVICE_HEADER );
 			break;
-			
+
 		case EBTSwitchOffAnyway:
-			iIsMessageQuery=EFalse;		
+			iIsMessageQuery=EFalse;
 			iMessageResourceId=R_BT_SWITCH_OFF_ANYWAY;
-			break;		
-					
+			break;
+
 		default:
-			FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier:: Unkown messageType! ")); 
- 			User::Leave(KErrNotFound);		
+			FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier:: Unkown messageType! "));
+ 			User::Leave(KErrNotFound);
 		}
-	
+
 	// if the logic string contains substitute indicator "%U", replace it with device name:
 	//
 	HBufC* buf = StringLoader::LoadL( iMessageResourceId);
 	iQueryMessage.Assign( buf );
 
 	TInt keyLen;
-	TInt pos = BluetoothUiUtil::GetStringSubstringKeyPos( 
+	TInt pos = BluetoothUiUtil::GetStringSubstringKeyPos(
 	        iQueryMessage, 0, keyLen );
 	if( pos > KErrNotFound)
-		{		
+		{
 		//if no device name provided, default name will be used:
-		if( !bPckg().iNameExists )			
+		if( !bPckg().iNameExists )
 			iName=StringLoader::LoadL(R_BT_DIALOG_DEF_NAME);
 		else
 			{
 			iName=HBufC::NewL(bPckg().iName.Length() );
 			iName->Des().Copy(bPckg().iName);
 			}
-		BluetoothUiUtil::LoadResourceAndSubstringL( 
+		BluetoothUiUtil::LoadResourceAndSubstringL(
 		        iQueryMessage, iMessageResourceId, *iName, 0);
 		}
 	else
 		{
-		iName=NULL;		
-		}		
+		iName=NULL;
+		}
 	}
 
 // ----------------------------------------------------------
 // CBTGenericQueryNotifier::UpdateL
 // Update notifier according to new data
 // ----------------------------------------------------------
-//	
+//
 TPtrC8 CBTGenericQueryNotifier::UpdateL(const TDesC8& aBuffer)
 	{
-   	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::UpdateL")); 
+   	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::UpdateL"));
 	ProcessParamBufferL(aBuffer);
 	if( !iNotifUiUtil->IsQueryReleased() )
 		{
@@ -273,10 +308,10 @@
 		    iNotifUiUtil->UpdateQueryDlgL(iQueryMessage);
 		    }
 		}
-   	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::UpdateL complete")); 	
+   	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::UpdateL complete"));
 
     TPtrC8 ret(KNullDesC8);
-    return (ret);   	
+    return (ret);
 	}
 
 // ----------------------------------------------------------
@@ -285,12 +320,12 @@
 // ----------------------------------------------------------
 //
 void CBTGenericQueryNotifier::ShowQueryAndCompleteL()
-	{ 
-   	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::ShowQueryAndCompleteL")); 	
-	
+	{
+   	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::ShowQueryAndCompleteL"));
+
 	// Turn lights on and deactivate apps -key
 	//
-   	iNotifUiUtil->TurnLightsOn();  	
+   	iNotifUiUtil->TurnLightsOn();
 	if( iIsNameQuery )
 	    {
 	    TBool nameStatus = IsLocalNameModifiedL();
@@ -298,25 +333,25 @@
 	        {
 	        (void) AskLocalBTNameQueryL();
 	        }
-        // Check if Local name is set again before turn BT on. 
+        // Check if Local name is set again before turn BT on.
         // Turn BT on only when there is local name, since user still has chance
-        // to ignore the asking name query - like pressing End-key     
-        //             
-        TBTDeviceName localName;           
+        // to ignore the asking name query - like pressing End-key
+        //
+        TBTDeviceName localName;
         localName.Zero();
         TInt err = iBTEngSettings->GetLocalName(localName);
-              
+
         if (localName.Length() <= 0)
-            {   
+            {
             err = KErrCancel;
             }
-	    	    
+
 	    CompleteMessage( (!err) ? ETrue : EFalse, KErrNone );
 
-	    FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::ShowQueryAndCompleteL iIsNameQuery complete")); 
+	    FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::ShowQueryAndCompleteL iIsNameQuery complete"));
 	    return;
 	    }
-	
+
 	TInt keypress;
     TBTDeviceName name(KNullDesC);
     if( iName )
@@ -325,19 +360,80 @@
 	    }
     if( iIsMessageQuery	)
 		{
-		
-        keypress = iNotifUiUtil->ShowMessageQueryL(iQueryMessage, *iQueryHeader, 
-                        R_BT_GENERIC_MESSAGE_QUERY, CAknQueryDialog::EConfirmationTone );        
+
+        keypress = iNotifUiUtil->ShowMessageQueryL(iQueryMessage, *iQueryHeader,
+                        R_BT_GENERIC_MESSAGE_QUERY, CAknQueryDialog::EConfirmationTone );
 		}
 	else
     	{
-    	keypress = iNotifUiUtil->ShowQueryL( iQueryMessage, R_BT_GENERIC_QUERY, 
+    	keypress = iNotifUiUtil->ShowQueryL( iQueryMessage, R_BT_GENERIC_QUERY,
     	        iSecondaryDisplayCommand, name, CAknQueryDialog::EConfirmationTone );
     	}
-	
+
    	CompleteMessage( (keypress) ? ETrue: EFalse, KErrNone );
 
-   	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::ShowQueryAndCompleteL complete")); 			
+   	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::ShowQueryAndCompleteL complete"));
+	}
+
+// ----------------------------------------------------------
+// CBTAuthNotifier::RequestCompletedL
+// Gets called when P&S key notifies the change
+// ----------------------------------------------------------
+void CBTGenericQueryNotifier::RequestCompletedL(CBTNotifActive* aActive,
+		TInt aId, TInt aStatus)
+	{
+	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::RequestCompletedL()"));
+	switch (aId)
+		{
+	case KBTNotifPhonePowerKeyWatcher:
+		{
+		iPhonePowerKey.Subscribe(aActive->RequestStatus());
+		aActive->GoActive();
+		TInt val = 0;
+		// If the Power key is pressed it is likely that he user does not
+		// want to continue with existing query, so we dismiss it to avoid
+		// any clashes with subsequent popups (ie for setting Lock code).
+		// This is probably just a temporary solution to resolve immediate problem,
+		// and the issue is raised with UI Framework team.
+		if (!aStatus && !iPhonePowerKey.Get(val) && val == ECoreAppUIsHideAlarm)
+			{
+			// DismissDialog() internally checks that actual query dialog is NOT NULL,
+			// so it is safe to call it here.
+			iNotifUiUtil->DismissDialog();
+			}
+		}
+		break;
+		}
+
+	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::RequestCompletedL() completed"));
+	}
+
+// ----------------------------------------------------------
+// CBTAuthNotifier::HandleError
+// ----------------------------------------------------------
+void CBTGenericQueryNotifier::HandleError(CBTNotifActive* aActive, TInt aId,
+		TInt aError)
+	{
+	FTRACE(FPrint(_L("[BTNOTIF]\t CBTGenericQueryNotifier::HandleError() error = %d"), aError ));
+	(void) aActive;
+	(void) aId;
+	(void) aError;
+	}
+
+// ----------------------------------------------------------
+// CBTAuthNotifier::DoCancelRequest
+// Root caller is CBTNotifActive::CancelRequest(), which calls
+// CActive::Cancel that calls DoCancel() if request is active.
+// ----------------------------------------------------------
+void CBTGenericQueryNotifier::DoCancelRequest(CBTNotifActive* aActive, TInt aId)
+	{
+	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::DoCancel() >>"));
+	(void) aActive;
+	(void) aId;
+
+	iPhonePowerKey.Cancel();
+
+	FLOG(_L("[BTNOTIF]\t CBTGenericQueryNotifier::DoCancel() <<"));
 	}
 
 // End of File
--- a/cbsatplugin/atmisccmdplugin/src/cfuncommandhandler.cpp	Mon Jun 21 15:51:46 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/src/cfuncommandhandler.cpp	Thu Jul 15 18:50:18 2010 +0300
@@ -154,7 +154,7 @@
     TInt systemState;
     
     TInt ret = iProperty.Get(systemState);
-    if (ret != KErrNone)
+    if (ret == KErrNone)
         {
         if (systemState != iExpectedState)
             {
@@ -166,6 +166,7 @@
             ret = RestartDevice();
             }
         }
+    
     if (!IsActive())
         {
         if (ret != KErrNone)
@@ -206,7 +207,7 @@
         TRACE_FUNC_EXIT
         return err;
         }
-    
+   
     switch (aFunc)
         {
         case (0):
@@ -216,15 +217,17 @@
             // issue the profile change request and start monitoring the property
             if (systemState != ESwStateNormalRfOff)
                 {
-                err = SetActiveProfile(KOfflineProfileId);
-                
-                
+                err = SetActiveProfile(KOfflineProfileId);                
                 if (err == KErrNone)
                     {
                     iExpectedState = ESwStateNormalRfOff;
                     iProperty.Subscribe(iStatus);
                     SetActive();
-                    }           
+                    }       
+                }
+            else if (iReset)
+                {
+                err = RestartDevice();
                 }
             break;
             }
@@ -243,6 +246,10 @@
                     SetActive();
                     }
                 }
+            else if (iReset)
+                {
+                err = RestartDevice();
+                }
             break;
             }
         default: