201035_7
authorhgs
Fri, 03 Sep 2010 16:17:59 +0300
changeset 57 5ebadcda06cb
parent 51 625f43ae9362
child 65 001a94c71129
201035_7
atcommands/lccustomplugin/inc/lccustomplugin.h
atcommands/lccustomplugin/src/lccustomplugin.cpp
atcommands/modematplugin/group/modematplugin.mmp
atcommands/modematplugin/inc/cmdpluginobserver.h
atcommands/modematplugin/inc/modematplugin.h
atcommands/modematplugin/src/modematplugin.cpp
bluetoothengine/btaudioman/group/btaudioman.mmp
bluetoothengine/btaudioman/group/btaudiomanclient.mmp
bluetoothengine/btaudioman/src/basrvaccstateattach.cpp
bluetoothengine/btaudiostreamer/group/btaudiostreamer.mmp
bluetoothengine/btctrldcmoadapter/group/btctrldcmoadapter.mmp
bluetoothengine/btctrldcmoadapter/src/btctrldcmoadapter.cpp
bluetoothengine/bteng/data/backup_registration.xml
bluetoothengine/bteng/group/bld.inf
bluetoothengine/bteng/group/btbearer.mmp
bluetoothengine/bteng/group/btpsmplugin.mmp
bluetoothengine/bteng/rom/bteng.iby
bluetoothengine/bthid/bthidengplugin/group/bthidengplugin.mmp
bluetoothengine/bthid/bthidkbdsettings/group/bthidkbdsettings.mmp
bluetoothengine/bthid/bthidkbdsettings/group/bthidsettings.mmp
bluetoothengine/bthid/bthidserver/group/bthidserver.mmp
bluetoothengine/bthid/keyboard/group/keyboard.mmp
bluetoothengine/bthid/layouts/group/kbdlayout.mmp
bluetoothengine/bthid/manager/group/layoutmgr.mmp
bluetoothengine/bthid/mouse/hidmousedriver/group/mouse.mmp
bluetoothengine/btmac/group/ATCodec.mmp
bluetoothengine/btmac/group/BTMAC.mmp
bluetoothengine/btmac/group/BTMonoCmdHandler.mmp
bluetoothengine/btmac/group/btmonobearer.mmp
bluetoothengine/btmac/inc/btmac/btmrfcommsock.h
bluetoothengine/btmac/src/btmac/btmrfcommsock.cpp
bluetoothengine/btmac/src/btmac/btmsaudio.cpp
bluetoothengine/btmac/src/btmac/btmsyncsock.cpp
bluetoothengine/btnotif/btdevicedialogplugin/btdevicedialogplugin.pro
bluetoothengine/btnotif/btdevicedialogplugin/docml/bt-device-search-dialog.docml
bluetoothengine/btnotif/btdevicedialogplugin/docml/bt-more-devices-dialog.docml
bluetoothengine/btnotif/btdevicedialogplugin/docml/bt-receive-auth-dialog.docml
bluetoothengine/btnotif/btdevicedialogplugin/docml/bt-receive-done-dialog.docml
bluetoothengine/btnotif/btdevicedialogplugin/docml/bt-recv-progress-dialog.docml
bluetoothengine/btnotif/btdevicedialogplugin/docml/bt-send-dialog.docml
bluetoothengine/btnotif/btdevicedialogplugin/inc/btdevicedialoginputwidget.h
bluetoothengine/btnotif/btdevicedialogplugin/inc/btdevicedialognotifwidget.h
bluetoothengine/btnotif/btdevicedialogplugin/inc/btdevicedialogplugin.h
bluetoothengine/btnotif/btdevicedialogplugin/inc/btdevicedialogquerywidget.h
bluetoothengine/btnotif/btdevicedialogplugin/inc/btdevicedialogrecvquerywidget.h
bluetoothengine/btnotif/btdevicedialogplugin/inc/btdevicedialogutils.h
bluetoothengine/btnotif/btdevicedialogplugin/inc/btdeviceinfowidget.h
bluetoothengine/btnotif/btdevicedialogplugin/inc/btdevicesearchdialogwidget.h
bluetoothengine/btnotif/btdevicedialogplugin/inc/btmoredevicesdialogwidget.h
bluetoothengine/btnotif/btdevicedialogplugin/inc/btrecvcompleteddialogwidget.h
bluetoothengine/btnotif/btdevicedialogplugin/src/btdevicedialoginputwidget.cpp
bluetoothengine/btnotif/btdevicedialogplugin/src/btdevicedialognotifwidget.cpp
bluetoothengine/btnotif/btdevicedialogplugin/src/btdevicedialogplugin.cpp
bluetoothengine/btnotif/btdevicedialogplugin/src/btdevicedialogquerywidget.cpp
bluetoothengine/btnotif/btdevicedialogplugin/src/btdevicedialogrecvquerywidget.cpp
bluetoothengine/btnotif/btdevicedialogplugin/src/btdeviceinfowidget.cpp
bluetoothengine/btnotif/btdevicedialogplugin/src/btdevicesearchdialogwidget.cpp
bluetoothengine/btnotif/btdevicedialogplugin/src/btmoredevicesdialogwidget.cpp
bluetoothengine/btnotif/btdevicedialogplugin/src/btrecvcompleteddialogwidget.cpp
bluetoothengine/btnotif/btdevicedialogplugin/src/btrecvprgrsdialogwidget.cpp
bluetoothengine/btnotif/btdevicedialogplugin/src/btsenddialogwidget.cpp
bluetoothengine/btnotif/btnotifsrv/inc/bluetoothnotification.h
bluetoothengine/btnotif/btnotifsrv/inc/btnotifbasepairinghandler.h
bluetoothengine/btnotif/btnotifsrv/inc/btnotifdeviceselector.h
bluetoothengine/btnotif/btnotifsrv/inc/btnotifgeninfonotifier.h
bluetoothengine/btnotif/btnotifsrv/inc/btnotifincomingpairinghandler.h
bluetoothengine/btnotif/btnotifsrv/inc/btnotifoutgoingpairinghandler.h
bluetoothengine/btnotif/btnotifsrv/inc/btnotifpairnotifier.h
bluetoothengine/btnotif/btnotifsrv/inc/btnotifpowernotifier.h
bluetoothengine/btnotif/btnotifsrv/inc/btnotifsecuritymanager.h
bluetoothengine/btnotif/btnotifsrv/inc/btnotifserver.h
bluetoothengine/btnotif/btnotifsrv/src/bluetoothnotification.cpp
bluetoothengine/btnotif/btnotifsrv/src/btnotifbasepairinghandler.cpp
bluetoothengine/btnotif/btnotifsrv/src/btnotifdeviceselector.cpp
bluetoothengine/btnotif/btnotifsrv/src/btnotifgeninfonotifier.cpp
bluetoothengine/btnotif/btnotifsrv/src/btnotifincomingpairinghandler.cpp
bluetoothengine/btnotif/btnotifsrv/src/btnotifoutgoingpairinghandler.cpp
bluetoothengine/btnotif/btnotifsrv/src/btnotifpairnotifier.cpp
bluetoothengine/btnotif/btnotifsrv/src/btnotifpowernotifier.cpp
bluetoothengine/btnotif/btnotifsrv/src/btnotifsecuritymanager.cpp
bluetoothengine/btnotif/btnotifsrv/src/btnotifserver.cpp
bluetoothengine/btnotif/btnotifsrv/src/btnotifserviceauthorizer.cpp
bluetoothengine/btnotif/btnotifsrv/src/btnotifsession.cpp
bluetoothengine/btnotif/btnotifwrapper/src/btnotifwrapperproxy.cpp
bluetoothengine/btnotif/group/btnotifsrv.mmp
bluetoothengine/btnotif/inc/bluetoothdevicedialogs.h
bluetoothengine/btpbap/group/btpbap.mmp
bluetoothengine/btsac/btrcc/group/btrcc.mmp
bluetoothengine/btsac/btrcc/inc/btrccLinker.h
bluetoothengine/btsac/btrcc/inc/btrccplayerstarter.h
bluetoothengine/btsac/btrcc/src/btrccLinker.cpp
bluetoothengine/btsac/btrcc/src/btrccplayerstarter.cpp
bluetoothengine/btsac/group/btsac.mmp
bluetoothengine/btsap/group/BTSap.mmp
bluetoothengine/btui/btcpplugin/btcpplugin.cpp
bluetoothengine/btui/btcpplugin/btcpplugin.pro
bluetoothengine/btui/btcpplugin/btcpplugin.qrc
bluetoothengine/btui/btcpplugin/btcpuibaseview.cpp
bluetoothengine/btui/btcpplugin/btcpuibaseview.h
bluetoothengine/btui/btcpplugin/btcpuidevicedetail.cpp
bluetoothengine/btui/btcpplugin/btcpuidevicedetail.h
bluetoothengine/btui/btcpplugin/btcpuidevicedetailsview.cpp
bluetoothengine/btui/btcpplugin/btcpuidevicedetailsview.h
bluetoothengine/btui/btcpplugin/btcpuideviceview.cpp
bluetoothengine/btui/btcpplugin/btcpuideviceview.h
bluetoothengine/btui/btcpplugin/btcpuimaingridviewitem.cpp
bluetoothengine/btui/btcpplugin/btcpuimaingridviewitem.h
bluetoothengine/btui/btcpplugin/btcpuimainlistviewitem.cpp
bluetoothengine/btui/btcpplugin/btcpuimainlistviewitem.h
bluetoothengine/btui/btcpplugin/btcpuimainview.cpp
bluetoothengine/btui/btcpplugin/btcpuimainview.h
bluetoothengine/btui/btcpplugin/btcpuisearchlistviewitem.cpp
bluetoothengine/btui/btcpplugin/btcpuisearchlistviewitem.h
bluetoothengine/btui/btcpplugin/btcpuisearchview.cpp
bluetoothengine/btui/btcpplugin/btcpuisearchview.h
bluetoothengine/btui/btcpplugin/btcpuisettingitem.cpp
bluetoothengine/btui/btcpplugin/btcpuisettingitem.h
bluetoothengine/btui/btcpplugin/btcpuiviewmgr.h
bluetoothengine/btui/btcpplugin/docml/bt-device-details-view.docml
bluetoothengine/btui/btcpplugin/docml/bt-device-view.docml
bluetoothengine/btui/btcpplugin/docml/bt-main-view.docml
bluetoothengine/btui/btcpplugin/docml/bt-search-view.docml
bluetoothengine/btui/btcpplugin/docml/btcpuimaingridviewitem.css
bluetoothengine/btui/btcpplugin/docml/btcpuimaingridviewitem.widgetml
bluetoothengine/btui/btcpplugin/docml/btcpuisearchlistviewitem.css
bluetoothengine/btui/btcpplugin/docml/btcpuisearchlistviewitem.widgetml
bluetoothengine/btui/btuidelegate/btabstractdelegate.cpp
bluetoothengine/btui/btuidelegate/btabstractdelegate.h
bluetoothengine/btui/btuidelegate/btdelegateconnect.cpp
bluetoothengine/btui/btuidelegate/btdelegateconnect.h
bluetoothengine/btui/btuidelegate/btdelegateconsts.h
bluetoothengine/btui/btuidelegate/btdelegatedevname.cpp
bluetoothengine/btui/btuidelegate/btdelegatedevname.h
bluetoothengine/btui/btuidelegate/btdelegatedevremove.cpp
bluetoothengine/btui/btuidelegate/btdelegatedevremove.h
bluetoothengine/btui/btuidelegate/btdelegatedevsecurity.cpp
bluetoothengine/btui/btuidelegate/btdelegatedevsecurity.h
bluetoothengine/btui/btuidelegate/btdelegatedisconnect.cpp
bluetoothengine/btui/btuidelegate/btdelegatedisconnect.h
bluetoothengine/btui/btuidelegate/btdelegatefactory.cpp
bluetoothengine/btui/btuidelegate/btdelegatefactory.h
bluetoothengine/btui/btuidelegate/btdelegateinquiry.cpp
bluetoothengine/btui/btuidelegate/btdelegateinquiry.h
bluetoothengine/btui/btuidelegate/btdelegatepair.cpp
bluetoothengine/btui/btuidelegate/btdelegatepair.h
bluetoothengine/btui/btuidelegate/btdelegatepower.cpp
bluetoothengine/btui/btuidelegate/btdelegatepower.h
bluetoothengine/btui/btuidelegate/btdelegateremotedevname.cpp
bluetoothengine/btui/btuidelegate/btdelegateremotedevname.h
bluetoothengine/btui/btuidelegate/btdelegatevisibility.cpp
bluetoothengine/btui/btuidelegate/btdelegatevisibility.h
bluetoothengine/btui/btuidelegate/btuidelegate.pro
bluetoothengine/btui/btuidelegate/bwins/btuidelegateu.def
bluetoothengine/btui/btuidelegate/eabi/btuidelegateu.def
bluetoothengine/btui/btuimodel/btdevicemodel.cpp
bluetoothengine/btui/btuimodel/btdevicemodel_p.cpp
bluetoothengine/btui/btuimodel/btsettingmodel_p.cpp
bluetoothengine/btui/btuimodel/btsettingmodel_p.h
bluetoothengine/btui/btuimodel/bwins/btuimodelu.def
bluetoothengine/btui/btuimodel/eabi/btuimodelu.def
bluetoothengine/btui/inc/btabstractdelegate.h
bluetoothengine/btui/inc/btdelegateconsts.h
bluetoothengine/btui/inc/btdelegatefactory.h
bluetoothengine/btui/inc/btdevicemodel.h
bluetoothengine/btui/inc/btqtconstants.h
bluetoothengine/btui/inc/traceconfig.h
bluetoothengine/btxqservice/btxqservice.pro
bluetoothengine/btxqservice/inc/btxqaddrservice.h
bluetoothengine/btxqservice/inc/btxqdutservice.h
bluetoothengine/btxqservice/inc/btxqpowerservice.h
bluetoothengine/btxqservice/inc/btxqserviceapi.h
bluetoothengine/btxqservice/inc/btxqsspdebugservice.h
bluetoothengine/btxqservice/rom/btxqservice.iby
bluetoothengine/btxqservice/rom/btxqservice.pkg
bluetoothengine/btxqservice/src/btxqaddrservice.cpp
bluetoothengine/btxqservice/src/btxqdutservice.cpp
bluetoothengine/btxqservice/src/btxqpowerservice.cpp
bluetoothengine/btxqservice/src/btxqsspdebugservice.cpp
bluetoothengine/btxqservice/src/main.cpp
bluetoothengine/btxqservice/xml/btxqservice_conf.xml
btobexprofiles/inc/BTServiceParameterList.h
btobexprofiles/inc/btserviceapi.h
btobexprofiles/inc/obexutilsdialog.h
btobexprofiles/inc/obexutilspropertynotifier.h
btobexprofiles/obexreceiveservices/bip/group/obexservicebip.mmp
btobexprofiles/obexreceiveservices/bip/inc/BIPController.h
btobexprofiles/obexreceiveservices/bip/src/BIPController.cpp
btobexprofiles/obexreceiveservices/btmsgviewer/btmsgviewer.pro
btobexprofiles/obexreceiveservices/btmsgviewer/inc/btmsgviewer.h
btobexprofiles/obexreceiveservices/btmsgviewer/inc/btmsgviewerutils.h
btobexprofiles/obexreceiveservices/btmsgviewer/src/btmsgviewer.cpp
btobexprofiles/obexreceiveservices/btmsgviewer/src/btmsgviewerutils.cpp
btobexprofiles/obexreceiveservices/btmsgviewer/src/main.cpp
btobexprofiles/obexreceiveservices/mtmuibluetooth/group/btmtmui.mmp
btobexprofiles/obexreceiveservices/mtmuiinfrared/group/irmtmui.mmp
btobexprofiles/obexreceiveservices/opp/group/obexserviceopp.mmp
btobexprofiles/obexreceiveservices/opp/inc/oppcontroller.h
btobexprofiles/obexreceiveservices/opp/src/oppcontroller.cpp
btobexprofiles/obexsendservices/group/bld.inf
btobexprofiles/obexsendservices/group/sendutils.mmp
btobexprofiles/obexsendservices/obexhighway/obexhighway.pro
btobexprofiles/obexsendservices/obexhighway/src/btsendserviceprovider.cpp
btobexprofiles/obexsendservices/obexhighway/src/btsssendlisthandler.cpp
btobexprofiles/obexsendservices/obexhighway/xml/obexhighway_conf.xml
btobexprofiles/obexsendservices/obexservicesendutils/inc/BTServiceStarter.h
btobexprofiles/obexsendservices/obexservicesendutils/src/BTSBIPController.cpp
btobexprofiles/obexsendservices/obexservicesendutils/src/BTServiceClient.cpp
btobexprofiles/obexsendservices/obexservicesendutils/src/BTServiceStarter.cpp
btobexprofiles/obexserviceman/group/obexserviceman.mmp
btobexprofiles/obexserviceman/group/obexservicemanclient.mmp
btobexprofiles/obexserviceman/group/obexusbapi.mmp
btobexprofiles/obexserviceman/obexservicemanclient/inc/obexsmclient.h
btobexprofiles/obexserviceman/obexservicemanclient/inc/usbobex.h
btobexprofiles/obexserviceman/obexservicemanclient/src/usbobex.cpp
btobexprofiles/obexserviceman/plugins/group/obexservicemanbt.mmp
btobexprofiles/obexserviceman/plugins/group/obexservicemanir.mmp
btobexprofiles/obexserviceman/plugins/group/obexservicemanusb.mmp
btobexprofiles/obexserviceman/rom/obex.iby
btobexprofiles/obexserviceman/utils/group/bld.inf
btobexprofiles/obexserviceman/utils/group/obexutils.mmp
btobexprofiles/obexserviceman/utils/src/obexutilsdialog.cpp
btobexprofiles/obexserviceman/utils/src/obexutilsentryhandler.cpp
btobexprofiles/obexserviceman/utils/src/updatemusiccollection.cpp
btservices.pro
cbsatplugin/atmisccmdplugin/group/atmisccmdplugin.mmp
cbsatplugin/atmisccmdplugin/src/atcommandparser.cpp
package_definition.xml
--- a/atcommands/lccustomplugin/inc/lccustomplugin.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/atcommands/lccustomplugin/inc/lccustomplugin.h	Fri Sep 03 16:17:59 2010 +0300
@@ -140,7 +140,7 @@
      *               EReplyTypeUndefined.
      * @return None
      */
-    virtual TInt CreateReplyAndComplete( TATExtensionReplyType aReplyType,
+    virtual void CreateReplyAndComplete( TATExtensionReplyType aReplyType,
                                          const TDesC8& aSrcBuffer=KNullDesC8,
                                          TInt aError=KErrNone ) = 0;
 
@@ -379,7 +379,7 @@
      *               EReplyTypeUndefined.
      * @return None
      */
-    TInt CreateReplyAndComplete( TATExtensionReplyType aReplyType,
+    void CreateReplyAndComplete( TATExtensionReplyType aReplyType,
                                  const TDesC8& aSrcBuffer=KNullDesC8,
                                  TInt aError=KErrNone );
 
--- a/atcommands/lccustomplugin/src/lccustomplugin.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/atcommands/lccustomplugin/src/lccustomplugin.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -241,14 +241,18 @@
         TRACE_FUNC_EXIT
         return KErrNotFound;
         }
-    aDstBuffer.Create( iReplyBuffer, partLength );
-    iReplyBuffer.Delete( 0, partLength );
+    aDstBuffer.Close();
+    TInt err = aDstBuffer.Create( iReplyBuffer, partLength );
+    if (!err)
+    	{
+    	iReplyBuffer.Delete( 0, partLength );
+    	}
     if ( iReplyBuffer.Length() == 0 )
         {
         iReplyBuffer.Close();
         }
     TRACE_FUNC_EXIT
-    return KErrNone;
+    return err;
     }
 
 // ---------------------------------------------------------------------------
@@ -256,46 +260,40 @@
 // request to ATEXT. Uses iReplyBuffer for reply storage.
 // ---------------------------------------------------------------------------
 //
-TInt CLcCustomPlugin::CreateReplyAndComplete( TATExtensionReplyType aReplyType,
+void CLcCustomPlugin::CreateReplyAndComplete( TATExtensionReplyType aReplyType,
                                               const TDesC8& aSrcBuffer,
 											  TInt aError )
     {
     TRACE_FUNC_ENTRY
     iReplyBuffer.Close();
-    if ( aError != KErrNone )
-        {
-        HandleCommandCompleted( aError, EReplyTypeUndefined );
-        iHcCmd = NULL;
-        iHcReply = NULL;
-        TRACE_FUNC_EXIT
-        return KErrNone;
-        }
-    if ( !iHcReply )
-        {
-        TRACE_FUNC_EXIT
-        return KErrGeneral;
-        }
-    switch ( aReplyType )
-        {
-        case EReplyTypeOther:
-            iReplyBuffer.Create( aSrcBuffer );
-            break;
-        case EReplyTypeOk:
-            CreateOkOrErrorReply( iReplyBuffer, ETrue );
-            break;
-        case EReplyTypeError:
-            CreateOkOrErrorReply( iReplyBuffer, EFalse );
-            break;
-        default:
-            TRACE_FUNC_EXIT
-            return KErrGeneral;
-        }
-    CreatePartOfReply( *iHcReply );
-    HandleCommandCompleted( KErrNone, aReplyType );
+    ASSERT(iHcReply);
+    if ( !aError )
+    	{
+		switch ( aReplyType )
+			{
+			case EReplyTypeOther:
+				aError = iReplyBuffer.Create( aSrcBuffer );
+				break;
+			case EReplyTypeOk:
+				aError = CreateOkOrErrorReply( iReplyBuffer, ETrue );
+				break;
+			case EReplyTypeError:
+				aError = CreateOkOrErrorReply( iReplyBuffer, EFalse );
+				break;
+			default:
+				aError = KErrGeneral;
+			}
+    	}
+	if ( !aError )
+		{
+		aError = CreatePartOfReply( *iHcReply );
+		}
+
     iHcCmd = NULL;
     iHcReply = NULL;
+
+    HandleCommandCompleted( aError, aError ? EReplyTypeUndefined : aReplyType );
     TRACE_FUNC_EXIT
-    return KErrNone;
     }
 
 // ---------------------------------------------------------------------------
--- a/atcommands/modematplugin/group/modematplugin.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/atcommands/modematplugin/group/modematplugin.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -40,7 +40,7 @@
 
 SYSTEMINCLUDE           /epoc32/include/ecom
 
-LIBRARY	ECom.lib
+LIBRARY	ecom.lib
 LIBRARY euser.lib
 LIBRARY atextpluginbase.lib
 LIBRARY etelmm.lib 
--- a/atcommands/modematplugin/inc/cmdpluginobserver.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/atcommands/modematplugin/inc/cmdpluginobserver.h	Fri Sep 03 16:17:59 2010 +0300
@@ -58,7 +58,7 @@
      *               EReplyTypeUndefined.
      * @return None
      */
-    virtual TInt CreateReplyAndComplete( TATExtensionReplyType aReplyType,
+    virtual void CreateReplyAndComplete( TATExtensionReplyType aReplyType,
                                          const TDesC8& aSrcBuffer=KNullDesC8,
                                          TInt aError=KErrNone ) = 0;
 
--- a/atcommands/modematplugin/inc/modematplugin.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/atcommands/modematplugin/inc/modematplugin.h	Fri Sep 03 16:17:59 2010 +0300
@@ -270,7 +270,7 @@
      *               EReplyTypeUndefined.
      * @return None
      */
-    TInt CreateReplyAndComplete( TATExtensionReplyType aReplyType,
+    void CreateReplyAndComplete( TATExtensionReplyType aReplyType,
                                  const TDesC8& aSrcBuffer=KNullDesC8,
                                  TInt aError=KErrNone );
 
--- a/atcommands/modematplugin/src/modematplugin.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/atcommands/modematplugin/src/modematplugin.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -246,14 +246,18 @@
         TRACE_FUNC_EXIT
         return KErrNotFound;
         }
-    aDstBuffer.Create( iReplyBuffer, partLength );
-    iReplyBuffer.Delete( 0, partLength );
+    aDstBuffer.Close();
+    TInt err = aDstBuffer.Create( iReplyBuffer, partLength );
+    if ( !err )
+    	{
+    	iReplyBuffer.Delete( 0, partLength );
+    	}
     if ( iReplyBuffer.Length() == 0 )
         {
         iReplyBuffer.Close();
         }
     TRACE_FUNC_EXIT
-    return KErrNone;
+    return err;
     }
 
 // ---------------------------------------------------------------------------
@@ -261,46 +265,40 @@
 // request to ATEXT. Uses iReplyBuffer for reply storage.
 // ---------------------------------------------------------------------------
 //
-TInt CModemAtPlugin::CreateReplyAndComplete( TATExtensionReplyType aReplyType,
+void CModemAtPlugin::CreateReplyAndComplete( TATExtensionReplyType aReplyType,
                                               const TDesC8& aSrcBuffer,
                                               TInt aError )
     {
     TRACE_FUNC_ENTRY
     iReplyBuffer.Close();
-    if ( aError != KErrNone )
-        {
-        HandleCommandCompleted( aError, EReplyTypeUndefined );
-        iHcCmd = NULL;
-        iHcReply = NULL;
-        TRACE_FUNC_EXIT
-        return KErrNone;
-        }
-    if ( !iHcReply )
-        {
-        TRACE_FUNC_EXIT
-        return KErrGeneral;
-        }
-    switch ( aReplyType )
+    ASSERT(iHcReply); 
+    if ( !aError )
         {
-        case EReplyTypeOther:
-            iReplyBuffer.Create( aSrcBuffer );
-            break;
-        case EReplyTypeOk:
-            CreateOkOrErrorReply( iReplyBuffer, ETrue );
-            break;
-        case EReplyTypeError:
-            CreateOkOrErrorReply( iReplyBuffer, EFalse );
-            break;
-        default:
-            TRACE_FUNC_EXIT
-            return KErrGeneral;
+		switch ( aReplyType )
+			{
+			case EReplyTypeOther:
+				aError = iReplyBuffer.Create( aSrcBuffer );
+				break;
+			case EReplyTypeOk:
+				aError = CreateOkOrErrorReply( iReplyBuffer, ETrue );
+				break;
+			case EReplyTypeError:
+				aError = CreateOkOrErrorReply( iReplyBuffer, EFalse );
+				break;
+			default:
+				TRACE_FUNC_EXIT
+				aError = KErrGeneral;
+			}
         }
-    CreatePartOfReply( *iHcReply );
-    HandleCommandCompleted( KErrNone, aReplyType );
+    
+    if ( !aError )
+    	{
+    	aError = CreatePartOfReply( *iHcReply );
+    	}
     iHcCmd = NULL;
     iHcReply = NULL;
+    HandleCommandCompleted( aError, aError ? EReplyTypeUndefined : aReplyType );
     TRACE_FUNC_EXIT
-    return KErrNone;
     }
 
 // ---------------------------------------------------------------------------
--- a/bluetoothengine/btaudioman/group/btaudioman.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btaudioman/group/btaudioman.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -52,7 +52,7 @@
 SOURCE        basrvaccfwconn.cpp
 
 USERINCLUDE     ../inc
-SYSTEMINCLUDE   ../../inc ../../../inc
+SYSTEMINCLUDE   ../../inc
 MW_LAYER_SYSTEMINCLUDE
 
 LIBRARY			euser.lib
@@ -64,7 +64,7 @@
 LIBRARY 		btmanclient.lib
 LIBRARY 		btengdevman.lib
 LIBRARY         centralrepository.lib
-LIBRARY 		AccPolicy.lib
+LIBRARY 		accpolicy.lib
 
 #ifdef PRJ_USE_STUB
 LIBRARY         sdpagent_stub.lib
--- a/bluetoothengine/btaudioman/group/btaudiomanclient.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btaudioman/group/btaudiomanclient.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -41,7 +41,7 @@
 SOURCE      BTAccInfoRequester.cpp
 
 USERINCLUDE    ../inc
-SYSTEMINCLUDE  ../../inc ../../../inc /epoc32/include/ecom
+SYSTEMINCLUDE  ../../inc /epoc32/include/ecom
 MW_LAYER_SYSTEMINCLUDE
 
 LIBRARY     euser.lib
--- a/bluetoothengine/btaudioman/src/basrvaccstateattach.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btaudioman/src/basrvaccstateattach.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -108,7 +108,8 @@
         {
         Parent().AccMan().ListenAudioRequestL();        	
         Parent().AccMan().PluginMan().AccInUse();
-        Parent().ChangeStateL(CBasrvAccStateAttached::NewL(Parent(), !iConnecting));
+        // we always show connect/disconnect notes regardless of the initiator
+        Parent().ChangeStateL(CBasrvAccStateAttached::NewL(Parent(), ETrue));
         }
     else
         {
--- a/bluetoothengine/btaudiostreamer/group/btaudiostreamer.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btaudiostreamer/group/btaudiostreamer.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -30,11 +30,11 @@
 SOURCE		btaudiostreamsendersbc.cpp
 
 USERINCLUDE     ../inc
-SYSTEMINCLUDE   ../../inc ../../../inc
+SYSTEMINCLUDE   ../../inc
 MW_LAYER_SYSTEMINCLUDE
 
-LIBRARY		EUSER.LIB		// user library 
-LIBRARY		ESOCK.LIB		// socket services 
+LIBRARY		euser.lib		// user library 
+LIBRARY		esock.lib		// socket services 
 LIBRARY		rtp.lib			// RTP implementation 
 LIBRARY		efsrv.lib		// file server 
 LIBRARY		bluetooth.lib   // TBTSockAddr 
--- a/bluetoothengine/btctrldcmoadapter/group/btctrldcmoadapter.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btctrldcmoadapter/group/btctrldcmoadapter.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -27,6 +27,8 @@
 
 MW_LAYER_SYSTEMINCLUDE
 SYSTEMINCLUDE /epoc32/include/ecom
+SYSTEMINCLUDE /epoc32/include/mw/hb/hbwidgets
+SYSTEMINCLUDE /epoc32/include/mw/hb/hbcore
 
 USERINCLUDE 	../inc 
 
@@ -42,5 +44,7 @@
 LIBRARY euser.lib 
 LIBRARY	ecom.lib 
 LIBRARY	efsrv.lib
-LIBRARY commonengine.lib
+LIBRARY CommonEngine.lib
 LIBRARY btfeatures.lib
+LIBRARY HbCore.lib 
+LIBRARY HbWidgets.lib
--- a/bluetoothengine/btctrldcmoadapter/src/btctrldcmoadapter.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btctrldcmoadapter/src/btctrldcmoadapter.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -17,20 +17,32 @@
  * ==============================================================================
  */
 
-#include <stringresourcereader.h>
-#include <data_caging_path_literals.hrh> 
 #include <bautils.h>
 
-#include <dcmo.rsg>
+#include <hbtextresolversymbian.h>
 #include <btfeaturescfg.h>
 
 #include "btctrldcmoadapter.h"
 
+
+// ----------------------------------------------------------------------
+
+#ifndef DBG
+#ifdef _DEBUG
+#define DBG(a) a
+#else
+#define DBG(a)
+#endif
+#endif
+
+// ----------------------------------------------------------------------
+
 _LIT(KBluetoothDcmoPanicName, "BT DCMO Adapter");
 
 _LIT( KBluetoothControlProperty, "Bluetooth" );
 _LIT( KDisableBluetoothDescription, "Used to enable/disable the Bluetooth connectivity." ); // Description
-_LIT( KRuntimeResourceFileName, "z:dcmo.rsc" );
+_LIT( KdcmoResourceFileName, "deviceupdates_" );    
+_LIT( KdcmoResourceFilePath, "z:/resource/qt/translations/" );  
 
 TDCMOStatus CBluetoothCtrlDcmoAdapter::MapFeatureControlError(TInt aErrorCode)
     {
@@ -234,22 +246,10 @@
 
 void CBluetoothCtrlDcmoAdapter::GetLocalizedNameL(HBufC*& aLocName)
     {
-    TFileName* fileName = new(ELeave) TFileName;
-    CleanupStack::PushL(fileName);
-    TParse* parseObj = new(ELeave) TParse();
-    CleanupStack::PushL(parseObj);
-    User::LeaveIfError(parseObj->Set(KRuntimeResourceFileName(), &KDC_RESOURCE_FILES_DIR, NULL));
-    *fileName = parseObj->FullName();
-    CleanupStack::PopAndDestroy(parseObj);
-    
-    CStringResourceReader* resReader = CStringResourceReader::NewL(*fileName);
-    CleanupStack::PushL(resReader);
-    
-    TPtrC buf;
-    buf.Set(resReader->ReadResourceString(R_DM_RUN_TIME_VAR_BLUETOOTH)); 
-    aLocName = buf.AllocL() ; 
-    
-    CleanupStack::PopAndDestroy(2,fileName); //resReader,fileName
+    TBool result = HbTextResolverSymbian::Init(KdcmoResourceFileName, KdcmoResourceFilePath );              
+    _LIT(KTextBluetooth, "txt_device_update_info_bluetooth");
+    aLocName = HbTextResolverSymbian::LoadL(KTextBluetooth);
+    DBG(RDebug::Print(aLocName->Des()));
     }
 
 void CBluetoothCtrlDcmoAdapter::Panic(TBluetoothDcmoPanic aPanic)
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/bteng/data/backup_registration.xml	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,5 @@
+<?xml version="1.0" standalone="yes"?>
+<backup_registration>
+	<proxy_data_manager sid = "0x10202BE9" />
+	<restore requires_reboot = "yes"/>
+</backup_registration>
--- a/bluetoothengine/bteng/group/bld.inf	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/bteng/group/bld.inf	Fri Sep 03 16:17:59 2010 +0300
@@ -40,6 +40,8 @@
 
 ../data/btrfs.txt                           z:/resource/btrfs.txt
 
+../data/backup_registration.xml             z:/private/10005950/backup_registration.xml
+
 
 PRJ_MMPFILES
 bteng.mmp
--- a/bluetoothengine/bteng/group/btbearer.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/bteng/group/btbearer.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -42,7 +42,6 @@
 
 MW_LAYER_SYSTEMINCLUDE
 SYSTEMINCLUDE           /epoc32/include/ecom
-SYSTEMINCLUDE           ../../../inc
 SYSTEMINCLUDE  /epoc32/include/mw/hb/hbcore
 
 LIBRARY                 euser.lib
--- a/bluetoothengine/bteng/group/btpsmplugin.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/bteng/group/btpsmplugin.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -41,7 +41,6 @@
 
 
 SYSTEMINCLUDE   ../../inc   	//for private API headers (BluetoothEngine subsystem)
-SYSTEMINCLUDE   ../../../inc    //for internal API headers (localconnectivity)
 SYSTEMINCLUDE   /epoc32/include/ecom
 MW_LAYER_SYSTEMINCLUDE
 
--- a/bluetoothengine/bteng/rom/bteng.iby	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/bteng/rom/bteng.iby	Fri Sep 03 16:17:59 2010 +0300
@@ -32,6 +32,7 @@
 data=ZPRIVATE\10003A3F\APPS\bttoggle_reg.rsc 			Private\10003a3f\apps\bttoggle_reg.rsc
 data=DATAZ_\RESOURCE_FILES_DIR\btengsdp.rsc       RESOURCE_FILES_DIR\btengsdp.rsc
 data=DATAZ_\RESOURCE_FILES_DIR\btrfs.txt       RESOURCE_FILES_DIR\btrfs.txt
+data=ZPRIVATE\10005950\backup_registration.xml			private\10005950\backup_registration.xml
 
 ECOM_PLUGIN( btbearer.dll, btbearer.rsc )
 ECOM_PLUGIN( btrfsplugin.dll, btrfsplugin.rsc )
--- a/bluetoothengine/bthid/bthidengplugin/group/bthidengplugin.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/bthid/bthidengplugin/group/bthidengplugin.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -34,7 +34,6 @@
 USERINCLUDE     ../../bthidserver/inc
 
 MW_LAYER_SYSTEMINCLUDE
-SYSTEMINCLUDE   ../../../../inc 
 
 START RESOURCE ../data/2001E308.rss
 	TARGET bthidengplugin.rsc
--- a/bluetoothengine/bthid/bthidkbdsettings/group/bthidkbdsettings.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/bthid/bthidkbdsettings/group/bthidkbdsettings.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -53,7 +53,7 @@
 #ifdef __SERIES60_HELP
 SYSTEMINCLUDE   /epoc32/include/cshelp
 #endif
-SYSTEMINCLUDE ../../../../inc ../../../inc
+SYSTEMINCLUDE ../../../inc
 
 //***********ECOM resource definition******************
 //--Ecom resource TARGET name must be same as DLL name,
--- a/bluetoothengine/bthid/bthidkbdsettings/group/bthidsettings.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/bthid/bthidkbdsettings/group/bthidsettings.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -34,7 +34,7 @@
 
 
 MW_LAYER_SYSTEMINCLUDE
-SYSTEMINCLUDE ../../../../inc ../../../inc
+SYSTEMINCLUDE ../../../inc
 
 LIBRARY       euser.lib 
 LIBRARY       ecom.lib
--- a/bluetoothengine/bthid/bthidserver/group/bthidserver.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/bthid/bthidserver/group/bthidserver.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -34,7 +34,6 @@
 USERINCLUDE   ../../bthidkbdsettings/inc
 
 MW_LAYER_SYSTEMINCLUDE
-SYSTEMINCLUDE ../../../../inc 
 
 SOURCEPATH    ../../common/src
 SOURCE        genericserver.cpp
--- a/bluetoothengine/bthid/keyboard/group/keyboard.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/bthid/keyboard/group/keyboard.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -43,7 +43,6 @@
 
 
 MW_LAYER_SYSTEMINCLUDE
-SYSTEMINCLUDE ../../../../inc
 
 SOURCEPATH		../data 
 START RESOURCE          hidkeyboard.rss 
--- a/bluetoothengine/bthid/layouts/group/kbdlayout.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/bthid/layouts/group/kbdlayout.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -48,7 +48,6 @@
 USERINCLUDE   ../../common/inc
 
 MW_LAYER_SYSTEMINCLUDE
-SYSTEMINCLUDE ../../../../inc
 
 SOURCEPATH		../data 
 START RESOURCE          kbdlayout.rss 
--- a/bluetoothengine/bthid/manager/group/layoutmgr.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/bthid/manager/group/layoutmgr.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -46,7 +46,6 @@
 
 
 MW_LAYER_SYSTEMINCLUDE
-SYSTEMINCLUDE ../../../../inc
 
 LIBRARY       euser.lib
 LIBRARY       ecom.lib
--- a/bluetoothengine/bthid/mouse/hidmousedriver/group/mouse.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/bthid/mouse/hidmousedriver/group/mouse.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -39,7 +39,6 @@
 
 
 MW_LAYER_SYSTEMINCLUDE
-SYSTEMINCLUDE  ../../../../../inc
 
 SOURCEPATH		../data 
 START RESOURCE          hidmouse.rss 
--- a/bluetoothengine/btmac/group/ATCodec.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btmac/group/ATCodec.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -33,7 +33,7 @@
 SOURCE  atcparam.cpp
 
 USERINCLUDE    ../inc/atcodec ../common
-SYSTEMINCLUDE         ../../inc ../../../inc 
+SYSTEMINCLUDE         ../../inc 
 MW_LAYER_SYSTEMINCLUDE
 
 LIBRARY euser.lib
--- a/bluetoothengine/btmac/group/BTMAC.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btmac/group/BTMAC.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -54,7 +54,7 @@
 SOURCE      btmpagescanparametersmanager.cpp
 
 USERINCLUDE ../inc/btmac ../common
-SYSTEMINCLUDE ../../inc ../../../inc /epoc32/include/ecom
+SYSTEMINCLUDE ../../inc /epoc32/include/ecom
 MW_LAYER_SYSTEMINCLUDE
 LIBRARY	ecom.lib
 LIBRARY euser.lib
@@ -69,10 +69,10 @@
 LIBRARY bluetooth.lib
 LIBRARY BTMonoCmdHandler.lib
 #endif
-LIBRARY atcodec.lib
+LIBRARY ATCodec.lib
 
 LIBRARY btdevice.lib    // BT Device
-LIBRARY BAFL.lib        // Des array
+LIBRARY bafl.lib        // Des array
 LIBRARY btengdiscovery.lib
 
 #ifdef PRJ_FILE_TRACE
--- a/bluetoothengine/btmac/group/BTMonoCmdHandler.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btmac/group/BTMonoCmdHandler.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -54,8 +54,7 @@
 
 USERINCLUDE   ../inc/btmonocmdhandler 
 USERINCLUDE   ../common
-USERINCLUDE   ../../inc 
-USERINCLUDE   ../../../inc
+USERINCLUDE   ../../inc
 
 #ifdef NO101APPDEPFIXES
 APP_LAYER_SYSTEMINCLUDE
@@ -76,7 +75,7 @@
 #ifdef __PROTOCOL_CDMA
 LIBRARY etelcdma.lib
 #endif
-LIBRARY BAFL.lib
+LIBRARY bafl.lib
 LIBRARY btengdiscovery.lib
 #ifdef PRJ_FILE_TRACE
 LIBRARY flogger.lib
--- a/bluetoothengine/btmac/group/btmonobearer.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btmac/group/btmonobearer.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -38,7 +38,7 @@
 SOURCE		playercontrolistener.cpp
 
 USERINCLUDE ../inc/btmonobearer ../common
-SYSTEMINCLUDE ../../inc ../../../inc  /epoc32/include/ecom
+SYSTEMINCLUDE ../../inc /epoc32/include/ecom
 MW_LAYER_SYSTEMINCLUDE
 
 LIBRARY         euser.lib 
--- a/bluetoothengine/btmac/inc/btmac/btmrfcommsock.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btmac/inc/btmac/btmrfcommsock.h	Fri Sep 03 16:17:59 2010 +0300
@@ -106,14 +106,6 @@
      * @return the BD address
      */
     const TBTDevAddr& Remote() const; 
-
-    /**
-     * Requests for master role
-     *
-     * @since S60 v3.1
-     * @return the completion error code
-     */
-    TInt RequestMasterRole();
     
     /**
      * Activates the notification of baseband events
--- a/bluetoothengine/btmac/src/btmac/btmrfcommsock.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btmac/src/btmac/btmrfcommsock.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -170,19 +170,6 @@
     return iRemote;
     }
 
-TInt CBtmRfcommSock::RequestMasterRole()
-    {
-    TRACE_FUNC
-    TRACE_ASSERT(iDataSocket, EBTPanicNullPointer)
-    TUint32 basebandState = 0;
-    TInt err = iDataSocket->PhysicalLinkState( basebandState );
-    if (!err && (basebandState & ENotifySlave))
-        {
-        err = iDataSocket->RequestMasterRole();
-        }
-    return err;
-    }
-
 TBool CBtmRfcommSock::IsInSniff() const
     {
     return iInSniff;
@@ -244,7 +231,8 @@
     if (aErr == KErrNone)
         {
         iInData.ReAllocL(256);
-        RequestMasterRole();
+        // Previously a request to become piconet master was made here, for IOP reasons this
+        // was removed (as theoretically being a piconet master is not required for HFP/HSP AG).
         TInt err = iAda.Open(iServer, iRemote);
         TRACE_INFO((_L("ada.Open err %d"), err))
         iDataSocket->ActivateBasebandEventNotifier(ENotifyAnyPowerMode | ENotifyAnyRole | 
@@ -275,7 +263,8 @@
    if (aErr == KErrNone)
         {
         iInData.ReAllocL(256);
-        RequestMasterRole();
+        // Previously a request to become piconet master was made here, for IOP reasons this
+        // was removed (as theoretically being a piconet master is not required for HFP/HSP AG).
         TInt err = iAda.Open(iServer, iRemote);
         TRACE_INFO((_L("ada.Open err %d"), err))
         iDataSocket->ActivateBasebandEventNotifier(ENotifyAnyPowerMode | ENotifyAnyRole |
--- a/bluetoothengine/btmac/src/btmac/btmsaudio.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btmac/src/btmac/btmsaudio.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-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"
@@ -110,6 +110,13 @@
 
 void CBtmsAudio::SyncLinkDisconnectCompleteL(TInt /*aErr*/)
     {
+    // Need to delete the socket _now_ as the destructor is called from an async
+    // callback and that is too late - the listener RSocket owned by iSco needs
+    // to be shut down before the ChangeStateL() call below because Entry actions
+    // in Ctrl/Sniffm open a new one.
+    delete iSco;
+    iSco = NULL;
+
     CBtmsInuse* next;
     if (iRfcomm->IsInSniff())
         next = CBtmsSniffm::NewL(Parent(), SwapStateRfcommSock(), NULL); 
--- a/bluetoothengine/btmac/src/btmac/btmsyncsock.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btmac/src/btmac/btmsyncsock.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -1,5 +1,5 @@
 /*
-* Copyright (c) 2005-2006 Nokia Corporation and/or its subsidiary(-ies).
+* Copyright (c) 2005-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"
@@ -70,7 +70,7 @@
     TRACE_FUNC_ENTRY
     iScoAcceptor = TScoAcceptor(this);
     iSco->SetNotifier(iScoAcceptor);
-    iSco->AcceptConnection(TBTSyncPackets(KScoPacketTypeSpec));
+    User::LeaveIfError(iSco->AcceptConnection(TBTSyncPackets(KScoPacketTypeSpec)));
     if (aAllowEsco)
         {
         iESco_Acceptor = TScoAcceptor(this);
--- a/bluetoothengine/btnotif/btdevicedialogplugin/btdevicedialogplugin.pro	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/btdevicedialogplugin.pro	Fri Sep 03 16:17:59 2010 +0300
@@ -36,7 +36,8 @@
     inc/btdevicedialogplugintrace.h \
     inc/btdevicedialogrecvquerywidget.h \
     inc/btrecvprgrsdialogwidget.h \
-    inc/btrecvcompleteddialogwidget.h
+    inc/btrecvcompleteddialogwidget.h \
+    inc/btdeviceinfowidget.h
 
     
 SOURCES += src/btdevicedialogplugin.cpp \
@@ -48,7 +49,8 @@
     src/btsenddialogwidget.cpp \
     src/btdevicedialogrecvquerywidget.cpp \
     src/btrecvprgrsdialogwidget.cpp \
-    src/btrecvcompleteddialogwidget.cpp
+    src/btrecvcompleteddialogwidget.cpp \
+    src/btdeviceinfowidget.cpp
 
 RESOURCES += btdevicedialogplugin.qrc
     
@@ -64,7 +66,7 @@
     		-lxqserviceutil \
     
     hblib.sources = Hb.dll
-    hblib.path = \sys\bin
+    hblib.path = /sys/bin
     hblib.depends = "(0xEEF9EA38), 1, 0, 0, {\"Hb\"}"
     pluginstub.sources = $${TARGET}.dll
     pluginstub.path = /resource/plugins/devicedialogs
--- a/bluetoothengine/btnotif/btdevicedialogplugin/docml/bt-device-search-dialog.docml	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/docml/bt-device-search-dialog.docml	Fri Sep 03 16:17:59 2010 +0300
@@ -1,25 +1,25 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <hbdocument version="1.1">
-    <object name="viewaction" type="HbAction">
+    <object name="viewByAction" type="HbAction">
         <string locid="txt_common_button_show" name="text" value="Show"/>
     </object>
-    <object name="stopretryaction" type="HbAction">
+    <object name="stopRetryAction" type="HbAction">
         <string locid="txt_common_button_stop" name="text" value="Retry"/>
     </object>
-    <object name="cancelaction" type="HbAction">
+    <object name="cancelAction" type="HbAction">
         <string locid="txt_common_button_cancel" name="text" value="Cancel"/>
     </object>
-    <widget name="searchdialog" type="HbDialog">
+    <widget name="searchDialog" type="HbDialog">
         <rect height="96un" name="geometry" width="60.73134un" x="1.2un" y="4.1791un"/>
         <sizehint type="PREFERRED" width="49.73134un"/>
         <sizehint type="MAXIMUM" width="50.73134un"/>
         <size height="91.52239un" name="size" width="50.73134un"/>
-        <widget name="heading" role="HbDialog:headingWidget" type="HbLabel">
+        <widget name="bluetoothSearchHeading" role="HbDialog:headingWidget" type="HbLabel">
             <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
             <string locid="txt_bt_subhead_bluetooth_found_devices" name="plainText"/>
         </widget>
-        <widget name="container" role="HbDialog:contentWidget" type="HbWidget">
-            <widget name="container_1" type="HbWidget">
+        <widget name="itemContainer" role="HbDialog:contentWidget" type="HbWidget">
+            <widget name="labelContainer" type="HbWidget">
                 <widget name="searchDoneLabel" type="HbLabel">
                     <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
                     <sizehint height="3.8806un" type="PREFERRED" width="26.86567un"/>
@@ -29,36 +29,36 @@
                     <sizehint height="3.8806un" type="PREFERRED" width="18.95522un"/>
                     <string locid="txt_bt_subhead_searching" name="plainText"/>
                 </widget>
-                <widget name="iconLabel" type="HbLabel">
+                <widget name="searchIconLabel" type="HbLabel">
                     <sizehint height="3.8806un" type="PREFERRED" width="3.43284un"/>
                 </widget>
                 <real name="z" value="0"/>
                 <sizehint height="25" type="PREFERRED" width="23.8806un"/>
                 <layout type="anchor">
-                    <anchoritem dst="iconLabel" dstEdge="LEFT" spacing="0.14925un" src="" srcEdge="LEFT"/>
-                    <anchoritem dst="iconLabel" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
+                    <anchoritem dst="searchIconLabel" dstEdge="LEFT" spacing="0.14925un" src="" srcEdge="LEFT"/>
+                    <anchoritem dst="searchIconLabel" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
                     <anchoritem dst="searchDoneLabel" dstEdge="LEFT" spacing="0.14925un" src="" srcEdge="LEFT"/>
                     <anchoritem dst="searchDoneLabel" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
                     <anchoritem dst="searchLabel" dstEdge="LEFT" spacing="4.47761un" src="" srcEdge="LEFT"/>
                     <anchoritem dst="searchLabel" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
                 </layout>
             </widget>
-            <widget name="listView" type="HbListView">
+            <widget name="deviceList" type="HbListView">
                 <widget name="listItemPrototype" role="HbAbstractView:prototype" type="HbListViewItem"/>
                 <enums name="verticalScrollBarPolicy" value="ScrollBarAsNeeded"/>
                 <sizehint height="65.7612un" type="PREFERRED" width="35.8209un"/>
             </widget>
             <layout type="grid">
-                <griditem column="0" itemname="container_1" row="0"/>
-                <griditem column="0" itemname="listView" row="1"/>
+                <griditem column="0" itemname="labelContainer" row="0"/>
+                <griditem column="0" itemname="deviceList" row="1"/>
             </layout>
         </widget>
-        <ref object="viewaction" role="HbWidget:addAction"/>
-        <ref object="stopretryaction" role="HbWidget:addAction"/>
-        <ref object="cancelaction" role="HbWidget:addAction"/>
+        <ref object="viewByAction" role="HbWidget:addAction"/>
+        <ref object="stopRetryAction" role="HbWidget:addAction"/>
+        <ref object="cancelAction" role="HbWidget:addAction"/>
     </widget>
     <metadata activeUIState="Common ui state" display="NHD-3.2-inch_portrait" unit="un">
         <uistate name="Common ui state" sections="#common"/>
-        <dummydata objectName="listView" section="#common" value="empty_dummydata_template"/>
+        <dummydata objectName="deviceList" section="#common" value="empty_dummydata_template"/>
     </metadata>
 </hbdocument>
--- a/bluetoothengine/btnotif/btdevicedialogplugin/docml/bt-more-devices-dialog.docml	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/docml/bt-more-devices-dialog.docml	Fri Sep 03 16:17:59 2010 +0300
@@ -1,36 +1,36 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <hbdocument version="1.1">
-    <object name="moreaction" type="HbAction">
+    <object name="moreAction" type="HbAction">
         <enums name="softKeyRole" value="NoSoftKey"/>
         <string locid="txt_bt_button_more_devices" name="text"/>
         <string locid="txt_bt_button_more_devices" name="toolTip"/>
     </object>
-    <object name="cancelaction" type="HbAction">
+    <object name="cancelAction" type="HbAction">
         <string locid="txt_common_button_cancel" name="text"/>
         <string locid="txt_common_button_cancel" name="toolTip"/>
     </object>
-    <widget name="lastuseddialog" type="HbDialog">
+    <widget name="lastUsedDevicesDialog" type="HbDialog">
         <rect height="68.20896un" name="geometry" width="49.73134un" x="1.73134un" y="11.64179un"/>
-        <widget name="useddeviceslabel" role="HbDialog:headingWidget" type="HbLabel">
+        <widget name="sendToHeading" role="HbDialog:headingWidget" type="HbLabel">
             <real name="z" value="1"/>
             <string locid="txt_bt_title_send_to" name="plainText"/>
         </widget>
-        <widget name="container_2" role="HbDialog:contentWidget" type="HbWidget">
-            <widget name="listView" type="HbListView">
-                <widget name="listItemPrototype_1" role="HbAbstractView:prototype" type="HbListViewItem"/>
+        <widget name="listContainer" role="HbDialog:contentWidget" type="HbWidget">
+            <widget name="deviceList" type="HbListView">
+                <widget name="listItemPrototype" role="HbAbstractView:prototype" type="HbListViewItem"/>
                 <enums name="verticalScrollBarPolicy" value="ScrollBarAsNeeded"/>
                 <sizehint height="47.7612un" type="PREFERRED" width="35.8209un"/>
             </widget>
             <real name="z" value="2"/>
             <layout type="grid">
-                <griditem column="0" itemname="listView" row="0"/>
+                <griditem column="0" itemname="deviceList" row="0"/>
             </layout>
         </widget>
-        <ref object="moreaction" role="HbWidget:addAction"/>
-        <ref object="cancelaction" role="HbWidget:addAction"/>
+        <ref object="moreAction" role="HbWidget:addAction"/>
+        <ref object="cancelAction" role="HbWidget:addAction"/>
     </widget>
     <metadata activeUIState="Common ui state" display="NHD-3.2-inch_portrait" unit="un">
         <uistate name="Common ui state" sections="#common"/>
-        <dummydata objectName="listView" section="#common" value="empty_dummydata_template"/>
+        <dummydata objectName="deviceList" section="#common" value="empty_dummydata_template"/>
     </metadata>
 </hbdocument>
--- a/bluetoothengine/btnotif/btdevicedialogplugin/docml/bt-receive-auth-dialog.docml	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/docml/bt-receive-auth-dialog.docml	Fri Sep 03 16:17:59 2010 +0300
@@ -1,25 +1,25 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <hbdocument version="1.1">
-    <object name="noaction" type="HbAction">
+    <object name="noAction" type="HbAction">
         <string locid="txt_common_button_no" name="iconText"/>
         <string locid="txt_common_button_no" name="text"/>
         <string locid="txt_common_button_no" name="toolTip"/>
     </object>
-    <object name="yesaction" type="HbAction">
+    <object name="yesAction" type="HbAction">
         <string locid="txt_common_button_yes" name="iconText"/>
         <string locid="txt_common_button_yes" name="text"/>
         <string locid="txt_common_button_yes" name="toolTip"/>
     </object>
-    <widget name="senddialog" type="HbDialog">
-        <rect height="40.59702un" name="geometry" width="49.73134un" x="1.49254un" y="36.26866un"/>
-        <widget name="heading" role="HbDialog:headingWidget" type="HbLabel">
+    <widget name="receiveAuthorizationDialog" type="HbDialog">
+        <sizehint height="40un" type="MAXIMUM" width="60un"/>
+        <widget name="receiveAuthorizationHeading" role="HbDialog:headingWidget" type="HbLabel">
             <real name="z" value="1"/>
             <string name="plainText"/>
         </widget>
-        <ref object="yesaction" role="HbWidget:addAction"/>
-        <ref object="noaction" role="HbWidget:addAction"/>
-        <widget name="container" role="HbDialog:contentWidget" type="HbWidget">
-            <widget name="filecontainer" type="HbWidget">
+        <ref object="yesAction" role="HbWidget:addAction"/>
+        <ref object="noAction" role="HbWidget:addAction"/>
+        <widget name="itemContainer" role="HbDialog:contentWidget" type="HbWidget">
+            <widget name="deviceDetailsContainer" type="HbWidget">
                 <widget name="deviceIcon" type="HbLabel">
                     <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
                     <real name="z" value="1"/>
@@ -45,13 +45,13 @@
                     <anchoritem dst="deviceName" dstEdge="TOP" spacing="0.44776un" src="" srcEdge="TOP"/>
                 </layout>
             </widget>
-            <widget name="checkbox" type="HbCheckBox">
+            <widget name="authorizeUser" type="HbCheckBox">
                 <string locid="txt_bt_list_dont_ask_again_with_this_device" name="text"/>
             </widget>
             <real name="z" value="2"/>
             <layout orientation="Vertical" type="linear">
-                <linearitem itemname="filecontainer"/>
-                <linearitem itemname="checkbox"/>
+                <linearitem itemname="deviceDetailsContainer"/>
+                <linearitem itemname="authorizeUser"/>
             </layout>
         </widget>
     </widget>
--- a/bluetoothengine/btnotif/btdevicedialogplugin/docml/bt-receive-done-dialog.docml	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/docml/bt-receive-done-dialog.docml	Fri Sep 03 16:17:59 2010 +0300
@@ -1,24 +1,24 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <hbdocument version="1.1">
-    <object name="showaction" type="HbAction">
+    <object name="showAction" type="HbAction">
         <string locid="txt_common_button_show" name="iconText"/>
         <string locid="txt_common_button_show" name="text"/>
         <string locid="txt_common_button_show" name="toolTip"/>
     </object>
-    <object name="cancelaction" type="HbAction">
+    <object name="cancelAction" type="HbAction">
         <string locid="txt_common_button_cancel" name="iconText"/>
         <string locid="txt_common_button_cancel" name="text"/>
         <string locid="txt_common_button_cancel" name="toolTip"/>
     </object>
-    <widget name="recvCompleteddialog" type="HbDialog">
-        <rect height="37.46269un" name="geometry" width="49.73134un" x="1.49254un" y="36.26866un"/>
-        <widget name="heading" role="HbDialog:headingWidget" type="HbLabel">
+    <widget name="receiveCompleteDialog" type="HbDialog">
+        <sizehint height="40un" type="MAXIMUM" width="60un"/>
+        <widget name="receiveCompleteHeading" role="HbDialog:headingWidget" type="HbLabel">
             <real name="z" value="1"/>
             <string name="plainText"/>
         </widget>
-        <widget name="container" role="HbDialog:contentWidget" type="HbWidget">
-            <widget name="filecontainer" type="HbWidget">
-                <widget name="fileiconlabel" type="HbLabel">
+        <widget name="itemContainer" role="HbDialog:contentWidget" type="HbWidget">
+            <widget name="fileDetailsContainer" type="HbWidget">
+                <widget name="fileIcon" type="HbLabel">
                     <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
                     <icon iconName="qtg_small_smiley_very_cool" name="icon"/>
                     <real name="z" value="1"/>
@@ -36,26 +36,26 @@
                 <real name="z" value="0"/>
                 <sizehint height="9.8806un" type="PREFERRED" width="23.8806un"/>
                 <layout type="anchor">
-                    <anchoritem dst="fileiconlabel" dstEdge="LEFT" spacing="1.04478un" src="" srcEdge="LEFT"/>
-                    <anchoritem dst="fileiconlabel" dstEdge="BOTTOM" spacing="-0.71767un" src="" srcEdge="BOTTOM"/>
+                    <anchoritem dst="fileIcon" dstEdge="LEFT" spacing="1.04478un" src="" srcEdge="LEFT"/>
+                    <anchoritem dst="fileIcon" dstEdge="BOTTOM" spacing="-0.71767un" src="" srcEdge="BOTTOM"/>
                     <anchoritem dst="fileSize" dstEdge="LEFT" spacing="9.30448un" src="" srcEdge="LEFT"/>
                     <anchoritem dst="fileSize" dstEdge="BOTTOM" spacing="-0.26991un" src="" srcEdge="BOTTOM"/>
                     <anchoritem dst="fileName" dstEdge="LEFT" spacing="9.30448un" src="" srcEdge="LEFT"/>
                     <anchoritem dst="fileName" dstEdge="TOP" spacing="0.44776un" src="" srcEdge="TOP"/>
                 </layout>
             </widget>
-            <widget name="fileCount_label" type="HbLabel">
+            <widget name="fileCount" type="HbLabel">
                 <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
                 <string name="plainText"/>
             </widget>
             <real name="z" value="2"/>
             <layout orientation="Vertical" type="linear">
-                <linearitem itemname="filecontainer"/>
-                <linearitem itemname="fileCount_label"/>
+                <linearitem itemname="fileDetailsContainer"/>
+                <linearitem itemname="fileCount"/>
             </layout>
         </widget>
-        <ref object="showaction" role="HbWidget:addAction"/>
-        <ref object="cancelaction" role="HbWidget:addAction"/>
+        <ref object="showAction" role="HbWidget:addAction"/>
+        <ref object="cancelAction" role="HbWidget:addAction"/>
     </widget>
     <metadata activeUIState="Common ui state" display="NHD-3.2-inch_portrait" unit="un">
         <uistate name="Common ui state" sections="#common"/>
--- a/bluetoothengine/btnotif/btdevicedialogplugin/docml/bt-recv-progress-dialog.docml	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/docml/bt-recv-progress-dialog.docml	Fri Sep 03 16:17:59 2010 +0300
@@ -1,24 +1,24 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <hbdocument version="1.1">
-    <object name="hideaction" type="HbAction">
+    <object name="hideAction" type="HbAction">
         <string locid="txt_common_button_hide" name="iconText"/>
         <string locid="txt_common_button_hide" name="text"/>
         <string locid="txt_common_button_hide" name="toolTip"/>
     </object>
-    <object name="cancelaction" type="HbAction">
+    <object name="cancelAction" type="HbAction">
         <string locid="txt_common_button_cancel" name="iconText"/>
         <string locid="txt_common_button_cancel" name="text"/>
         <string locid="txt_common_button_cancel" name="toolTip"/>
     </object>
-    <widget name="senddialog" type="HbDialog">
-        <rect height="37.46269un" name="geometry" width="49.73134un" x="1.49254un" y="36.26866un"/>
-        <widget name="heading" role="HbDialog:headingWidget" type="HbLabel">
+    <widget name="receiveProgressDialog" type="HbDialog">
+        <sizehint height="40un" type="MAXIMUM" width="60un"/>
+        <widget name="receiveProgressHeading" role="HbDialog:headingWidget" type="HbLabel">
             <real name="z" value="1"/>
             <string name="plainText"/>
         </widget>
-        <widget name="container" role="HbDialog:contentWidget" type="HbWidget">
-            <widget name="filecontainer" type="HbWidget">
-                <widget name="fileiconlabel" type="HbLabel">
+        <widget name="itemContainer" role="HbDialog:contentWidget" type="HbWidget">
+            <widget name="fileDetailsContainer" type="HbWidget">
+                <widget name="fileIcon" type="HbLabel">
                     <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
                     <icon iconName="qtg_small_smiley_very_cool" name="icon"/>
                     <real name="z" value="1"/>
@@ -36,16 +36,16 @@
                 <real name="z" value="0"/>
                 <sizehint height="9.8806un" type="PREFERRED" width="23.8806un"/>
                 <layout type="anchor">
-                    <anchoritem dst="fileiconlabel" dstEdge="LEFT" spacing="1.04478un" src="" srcEdge="LEFT"/>
-                    <anchoritem dst="fileiconlabel" dstEdge="BOTTOM" spacing="-0.71767un" src="" srcEdge="BOTTOM"/>
+                    <anchoritem dst="fileIcon" dstEdge="LEFT" spacing="1.04478un" src="" srcEdge="LEFT"/>
+                    <anchoritem dst="fileIcon" dstEdge="BOTTOM" spacing="-0.71767un" src="" srcEdge="BOTTOM"/>
                     <anchoritem dst="fileSize" dstEdge="LEFT" spacing="9.30448un" src="" srcEdge="LEFT"/>
                     <anchoritem dst="fileSize" dstEdge="BOTTOM" spacing="-0.26991un" src="" srcEdge="BOTTOM"/>
                     <anchoritem dst="fileName" dstEdge="LEFT" spacing="9.30448un" src="" srcEdge="LEFT"/>
                     <anchoritem dst="fileName" dstEdge="TOP" spacing="0.44776un" src="" srcEdge="TOP"/>
                 </layout>
             </widget>
-            <widget name="progresscontainer" type="HbWidget">
-                <widget name="horizontalProgressBar" type="HbProgressBar">
+            <widget name="progressContainer" type="HbWidget">
+                <widget name="receiveProgressBar" type="HbProgressBar">
                     <integer name="progressValue" value="30"/>
                     <integer name="minimum" value="0"/>
                     <sizehint height="3un" type="PREFERRED" width="7.46un"/>
@@ -57,22 +57,22 @@
                 <sizehint height="1un" type="MINIMUM"/>
                 <layout orientation="Vertical" spacing="0un" type="linear">
                     <contentsmargins bottom="0un" left="0un" right="0un" top="0un"/>
-                    <linearitem itemname="horizontalProgressBar"/>
+                    <linearitem itemname="receiveProgressBar"/>
                 </layout>
             </widget>
-            <widget name="fileCount_label" type="HbLabel">
+            <widget name="fileCount" type="HbLabel">
                 <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
                 <string name="plainText"/>
             </widget>
             <real name="z" value="2"/>
             <layout orientation="Vertical" type="linear">
-                <linearitem itemname="filecontainer"/>
-                <linearitem itemname="fileCount_label"/>
-                <linearitem itemname="progresscontainer"/>
+                <linearitem itemname="fileDetailsContainer"/>
+                <linearitem itemname="fileCount"/>
+                <linearitem itemname="progressContainer"/>
             </layout>
         </widget>
-        <ref object="hideaction" role="HbWidget:addAction"/>
-        <ref object="cancelaction" role="HbWidget:addAction"/>
+        <ref object="hideAction" role="HbWidget:addAction"/>
+        <ref object="cancelAction" role="HbWidget:addAction"/>
     </widget>
     <metadata activeUIState="Common ui state" display="NHD-3.2-inch_portrait" unit="un">
         <uistate name="Common ui state" sections="#common"/>
--- a/bluetoothengine/btnotif/btdevicedialogplugin/docml/bt-send-dialog.docml	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/docml/bt-send-dialog.docml	Fri Sep 03 16:17:59 2010 +0300
@@ -1,33 +1,33 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <hbdocument version="1.1">
-    <object name="hideaction" type="HbAction">
+    <object name="hideAction" type="HbAction">
         <bool name="enabled" value="FALSE"/>
         <string locid="txt_common_button_hide" name="text"/>
     </object>
-    <object name="cancelaction" type="HbAction">
+    <object name="cancelAction" type="HbAction">
         <string locid="txt_common_button_cancel" name="text"/>
     </object>
-    <widget name="senddialog" type="HbDialog">
-        <rect height="32.68657un" name="geometry" width="49.73134un" x="1.49254un" y="36.26866un"/>
-        <widget name="heading" role="HbDialog:headingWidget" type="HbLabel">
+    <widget name="sendProgressDialog" type="HbDialog">
+        <sizehint height="40un" type="MAXIMUM" width="60un"/>
+        <widget name="sendDialogHeading" role="HbDialog:headingWidget" type="HbLabel">
             <real name="z" value="1"/>
             <string name="plainText" value="Sending File x/y to Device"/>
         </widget>
-        <ref object="hideaction" role="HbWidget:addAction"/>
-        <ref object="cancelaction" role="HbWidget:addAction"/>
-        <widget name="container" role="HbDialog:contentWidget" type="HbWidget">
-            <widget name="filecontainer" type="HbWidget">
-                <widget name="fileiconlabel" type="HbLabel">
+        <ref object="hideAction" role="HbWidget:addAction"/>
+        <ref object="cancelAction" role="HbWidget:addAction"/>
+        <widget name="itemContainer" role="HbDialog:contentWidget" type="HbWidget">
+            <widget name="fileDetailsContainer" type="HbWidget">
+                <widget name="fileIcon" type="HbLabel">
                     <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
                     <icon iconName="qtg_small_smiley_very_cool" name="icon"/>
                     <real name="z" value="1"/>
                 </widget>
-                <widget name="filesizelabel" type="HbLabel">
+                <widget name="fileSize" type="HbLabel">
                     <real name="z" value="3"/>
                     <sizehint height="4.02985un" type="PREFERRED" width="24.32836un"/>
                     <string name="plainText" value="Label"/>
                 </widget>
-                <widget name="filenamelabel" type="HbLabel">
+                <widget name="fileName" type="HbLabel">
                     <real name="z" value="4"/>
                     <sizehint height="4.1791un" type="PREFERRED" width="35.07463un"/>
                     <string name="plainText" value="Label"/>
@@ -35,16 +35,16 @@
                 <real name="z" value="0"/>
                 <sizehint height="9.8806un" type="PREFERRED" width="23.8806un"/>
                 <layout type="anchor">
-                    <anchoritem dst="fileiconlabel" dstEdge="LEFT" spacing="1.04478un" src="" srcEdge="LEFT"/>
-                    <anchoritem dst="fileiconlabel" dstEdge="BOTTOM" spacing="-0.71767un" src="" srcEdge="BOTTOM"/>
-                    <anchoritem dst="filesizelabel" dstEdge="LEFT" spacing="9.30448un" src="" srcEdge="LEFT"/>
-                    <anchoritem dst="filesizelabel" dstEdge="BOTTOM" spacing="-0.26991un" src="" srcEdge="BOTTOM"/>
-                    <anchoritem dst="filenamelabel" dstEdge="LEFT" spacing="9.30448un" src="" srcEdge="LEFT"/>
-                    <anchoritem dst="filenamelabel" dstEdge="TOP" spacing="0.44776un" src="" srcEdge="TOP"/>
+                    <anchoritem dst="fileIcon" dstEdge="LEFT" spacing="1.04478un" src="" srcEdge="LEFT"/>
+                    <anchoritem dst="fileIcon" dstEdge="BOTTOM" spacing="-0.71767un" src="" srcEdge="BOTTOM"/>
+                    <anchoritem dst="fileSize" dstEdge="LEFT" spacing="9.30448un" src="" srcEdge="LEFT"/>
+                    <anchoritem dst="fileSize" dstEdge="BOTTOM" spacing="-0.26991un" src="" srcEdge="BOTTOM"/>
+                    <anchoritem dst="fileName" dstEdge="LEFT" spacing="9.30448un" src="" srcEdge="LEFT"/>
+                    <anchoritem dst="fileName" dstEdge="TOP" spacing="0.44776un" src="" srcEdge="TOP"/>
                 </layout>
             </widget>
-            <widget name="progresscontainer" type="HbWidget">
-                <widget name="horizontalProgressBar" type="HbProgressBar">
+            <widget name="progressContainer" type="HbWidget">
+                <widget name="sendProgressBar" type="HbProgressBar">
                     <integer name="progressValue" value="30"/>
                     <integer name="minimum" value="0"/>
                     <sizehint height="3un" type="PREFERRED" width="7.46un"/>
@@ -56,13 +56,13 @@
                 <sizehint height="1un" type="MINIMUM"/>
                 <layout orientation="Vertical" spacing="0un" type="linear">
                     <contentsmargins bottom="0un" left="0un" right="0un" top="0un"/>
-                    <linearitem itemname="horizontalProgressBar"/>
+                    <linearitem itemname="sendProgressBar"/>
                 </layout>
             </widget>
             <real name="z" value="2"/>
             <layout orientation="Vertical" type="linear">
-                <linearitem itemname="filecontainer"/>
-                <linearitem itemname="progresscontainer"/>
+                <linearitem itemname="fileDetailsContainer"/>
+                <linearitem itemname="progressContainer"/>
             </layout>
         </widget>
     </widget>
--- a/bluetoothengine/btnotif/btdevicedialogplugin/inc/btdevicedialoginputwidget.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/inc/btdevicedialoginputwidget.h	Fri Sep 03 16:17:59 2010 +0300
@@ -29,10 +29,8 @@
     \class BtDeviceDialogInputWidget
     \brief Widget class with properties setting. 
 
-    BtDeviceDialogInputWidget, inherited from HbInputDialog, 
-    implements interface HbDeviceDialogInterface. The Q_Properties
-    here are interfaces for caller of HbDeviceDialog to configue
-    what to be shown in the widget. 
+    BtDeviceDialogInputWidget, inherited from HbDeviceDialogInterface , 
+    uses HbInputDialog. 
     
  */
 class BtDeviceDialogInputWidget :
--- a/bluetoothengine/btnotif/btdevicedialogplugin/inc/btdevicedialognotifwidget.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/inc/btdevicedialognotifwidget.h	Fri Sep 03 16:17:59 2010 +0300
@@ -30,10 +30,8 @@
     \class BtDeviceDialogNotifWidget
     \brief Widget class with properties setting. 
 
-    BtDeviceDialogQueryWidget, inherited from HbNotificationDialog, 
-    implements interface HbDeviceDialogInterface. The Q_Properties
-    here are interfaces for caller of HbDeviceDialog to configue
-    what to be shown in the widget. 
+    BtDeviceDialogNotifWidget, inherited from HbDeviceDialogInterface, 
+    uses HbNotificationDialog. 
     
  */
 class BtDeviceDialogNotifWidget :
--- a/bluetoothengine/btnotif/btdevicedialogplugin/inc/btdevicedialogplugin.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/inc/btdevicedialogplugin.h	Fri Sep 03 16:17:59 2010 +0300
@@ -70,6 +70,7 @@
     BtDeviceDialogPluginPrivate *d;
     HbTranslator* mDialogTranslator;
     HbTranslator* mViewTranslator;
+    HbTranslator* mCommonErrorsTranslator;
 };
 
 #endif // BTDEVICEDIALOGPLUGIN_P_H
--- a/bluetoothengine/btnotif/btdevicedialogplugin/inc/btdevicedialogquerywidget.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/inc/btdevicedialogquerywidget.h	Fri Sep 03 16:17:59 2010 +0300
@@ -29,10 +29,8 @@
     \class BtDeviceDialogQueryWidget
     \brief Widget class with properties setting. 
 
-    BtDeviceDialogQueryWidget, inherited from HbMessageBox, 
-    implements interface HbDeviceDialogInterface. The Q_Properties
-    here are interfaces for caller of HbDeviceDialog to configue
-    what to be shown in the widget. 
+    BtDeviceDialogQueryWidget, inherited from HbDeviceDialogInterface, 
+    implemented using HbMessageBox. 
     
  */
 class BtDeviceDialogQueryWidget :
@@ -62,6 +60,7 @@
     void processParam(const QVariantMap &parameters);
     bool constructQueryDialog(const QVariantMap &parameters);
     void resetProperties();
+    QString& GetPasskeyEntryStatusString(int aStatus);
         
 private:
     Q_DISABLE_COPY(BtDeviceDialogQueryWidget)
@@ -69,6 +68,9 @@
     int mLastError;
     int mSendAction;
     bool mShowEventReceived;
+    QString mDisplayPasskeyStatus;
+    bool mSendPasskeyEntryCompletedAction;
+    int mDispPassKeyNumDigit;
     
     HbMessageBox *mMessageBox;
 };
--- a/bluetoothengine/btnotif/btdevicedialogplugin/inc/btdevicedialogrecvquerywidget.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/inc/btdevicedialogrecvquerywidget.h	Fri Sep 03 16:17:59 2010 +0300
@@ -66,9 +66,9 @@
     HbLabel             *mDeviceName;
     HbLabel             *mDeviceType;
     HbLabel             *mDeviceIcon;
-    HbAction            *mYes;
-    HbAction            *mNo;
-    HbCheckBox          *mCheckBox;
+    HbAction            *mYesAction;
+    HbAction            *mNoAction;
+    HbCheckBox          *mAuthorizeUser;
     HbDialog            *mDialog;
     
     Q_DISABLE_COPY(BTRecvQueryDialogWidget)
--- a/bluetoothengine/btnotif/btdevicedialogplugin/inc/btdevicedialogutils.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/inc/btdevicedialogutils.h	Fri Sep 03 16:17:59 2010 +0300
@@ -15,8 +15,8 @@
  *
  */
 
-#ifndef BTDEVICESDIALOGUTILS_H
-#define BTDEVICESDIALOGUTILS_H
+#ifndef BTDEVICEDIALOGUTILS_H
+#define BTDEVICEDIALOGUTILS_H
 
 #include <QMap>
 #include <QList>
@@ -57,4 +57,4 @@
 }
 
 
-#endif /*BTDEVICESDIALOGUTILS_H*/
+#endif /* BTDEVICEDIALOGUTILS_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/inc/btdeviceinfowidget.h	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2009 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:  
+ *
+ */
+
+
+#ifndef BTDEVICEINFOWIDGET_H
+#define BTDEVICEINFOWIDGET_H
+
+#include <QObject>
+#include <QVariantMap>
+#include <hbdevicedialoginterface.h>
+#include <hbmessagebox.h>
+
+
+class BtDeviceInfoWidget : public QObject, public HbDeviceDialogInterface
+    {
+    Q_OBJECT
+    
+public:
+    BtDeviceInfoWidget(const QVariantMap &parameters);
+    ~BtDeviceInfoWidget();
+    
+public: // from HbDeviceDialogInterface
+    bool setDeviceDialogParameters(const QVariantMap &parameters);
+    int deviceDialogError() const;
+    void closeDeviceDialog(bool byClient);
+    HbPopup *deviceDialogWidget() const;
+    QObject* signalSender() const;
+            
+signals:
+    void deviceDialogClosed();
+    void deviceDialogData(QVariantMap data);
+
+private:
+    bool constructDialog(const QVariantMap &parameters);
+    
+public slots:
+    void messageBoxClosed(HbAction *action);
+    void messageBoxClosed(int action);
+    
+private:
+    HbMessageBox* mMessageBox;
+    int mLastError;
+    
+    Q_DISABLE_COPY(BtDeviceInfoWidget)
+    };
+
+#endif /* BTDEVICEINFOWIDGET_H */
--- a/bluetoothengine/btnotif/btdevicedialogplugin/inc/btdevicesearchdialogwidget.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/inc/btdevicesearchdialogwidget.h	Fri Sep 03 16:17:59 2010 +0300
@@ -33,16 +33,6 @@
 #include <hbselectiondialog.h>
 #include "btdevicedialogutils.h"
 
-
-
-/*struct device
-    {
-    QString mDeviceName;
-    QString mDeviceType;
-    int     mDeviceIdx;
-    };*/
-
-
 class BTDeviceSearchDialogWidget : public QObject,
                                 public HbDeviceDialogInterface
     {
@@ -61,10 +51,8 @@
     
 public slots:
     void stopRetryClicked();
-    void retryClicked();
     void viewByClicked();
     void deviceSelected(const QModelIndex& modelIndex);
-//    void viewByItemSelected(int index);
     void selectionDialogClosed(HbAction *action);
     void searchDialogClosed(); 
     
@@ -87,26 +75,15 @@
 private:
     HbDocumentLoader *mLoader;
     
-    /**
-     * 
-     * item model for content list view.
-     */
-    
     QStandardItemModel* mContentItemModel;
     
     HbSelectionDialog *mQuery;
-//    QList<QString>      mDeviceTypeList;
     QStringList mDevTypeList;
-//    QList<device>       mDeviceList;
-    HbListView*         mListView;
+    HbListView*         mDeviceList;
     HbLabel*            mSearchLabel; 
     HbLabel*            mSearchIconLabel;
     HbLabel*            mSearchDoneLabel;
-//    bool                mViewByChosen;
-//    QList<device>       mDeviceLstOfType;
-//    int                 mDeviceLstIdx;
     int                 mSelectedDeviceType;
-//    int                 mDeviceDialogData;
     HbDialog *mSearchDevicesDialog;
     HbAction *mStopRetryAction;
     HbAction *mShowAction;
--- a/bluetoothengine/btnotif/btdevicedialogplugin/inc/btmoredevicesdialogwidget.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/inc/btmoredevicesdialogwidget.h	Fri Sep 03 16:17:59 2010 +0300
@@ -52,11 +52,6 @@
     
 private:
     bool constructDialog(const QVariantMap &parameters);
- //   void hideEvent(QHideEvent *event);
- //   void showEvent(QShowEvent *event);
-    QIcon icon(/*QString deviceType*/);
- //   void setMajorProperty(
-//           BtSendDataItem& qtdev, int prop, bool addto);
     
 signals:
     void deviceDialogClosed();
@@ -64,18 +59,10 @@
     
 private:
     HbDocumentLoader *mLoader;
-    int              mDeviceDialogData;
-    HbDialog *mMoreDeviceDialog;
+    HbDialog *mLastUsedDeviceDialog;
     HbAction *mMoreAction;
     HbAction *mCancelAction;
-    
-    /**
-     * 
-     * item model for content list view.
-     */
-    
     QStandardItemModel* mContentItemModel;
-    
     BtSendDataSource mData;
     
     Q_DISABLE_COPY(BTMoreDevicesDialogWidget)
--- a/bluetoothengine/btnotif/btdevicedialogplugin/inc/btrecvcompleteddialogwidget.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/inc/btrecvcompleteddialogwidget.h	Fri Sep 03 16:17:59 2010 +0300
@@ -16,8 +16,8 @@
 */
 
 
-#ifndef BTRECVCOMPLETEDDIALOGWIDGET_H_
-#define BTRECVCOMPLETEDDIALOGWIDGET_H_
+#ifndef BTRECVCOMPLETEDDIALOGWIDGET_H
+#define BTRECVCOMPLETEDDIALOGWIDGET_H
 
 #include <QObject>
 #include <QVariantMap>
@@ -76,14 +76,15 @@
     HbLabel             *mFileName;
     HbLabel             *mFileSize;
     HbLabel             *mFileCount;
-    HbAction            *mShow;
-    HbAction            *mCancel;
-    HbDialog            *mDialog;
+    HbAction            *mShowAction;
+    HbAction            *mCancelAction;
+    HbDialog            *mReceiveCompleteDialog;
     int                 mFileSz;
+    bool                mOpenConversationView;
     
     Q_DISABLE_COPY(BTRecvcompletedDialogWidget)
     };
 
 
 
-#endif /* BTRECVCOMPLETEDDIALOGWIDGET_H_ */
+#endif /* BTRECVCOMPLETEDDIALOGWIDGET_H */
--- a/bluetoothengine/btnotif/btdevicedialogplugin/src/btdevicedialoginputwidget.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/src/btdevicedialoginputwidget.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -138,7 +138,7 @@
         // Numeric value only
         mInputDialog->setInputMode(HbInputDialog::RealInput);
         title = QString(hbTrId("txt_bt_title_pairing_with_1"));
-        // todo: Fixe the multiline problem
+        // todo: Fix the multiline problem
         prompt = QString( hbTrId( "txt_bt_dialog_please_enter_the_passcode_for_1" ) );
     }
     else {
@@ -165,7 +165,7 @@
                         QRegExp(regExp, Qt::CaseInsensitive), validator ),"");
         mInputDialog->setValidator(validator);
     }else{
-    // Minimum requirement is to have at least 1 digit
+        // Minimum requirement is to have at least 1 digit
         regExp = tr("^\\d{1,}$");
         HbValidator* validator = new HbValidator(mInputDialog->lineEdit());
         validator->addField(
@@ -173,7 +173,7 @@
                         QRegExp(regExp, Qt::CaseInsensitive), validator ),"");
         mInputDialog->setValidator(validator);    
     }
-    // replace % with the miniLength and device name
+    // replace % with the minimum length and device name
     int repls = prompt.count( QString( "%" ) );
     if ( repls > 1 ) {
         prompt = prompt.arg( param.toString() );
--- a/bluetoothengine/btnotif/btdevicedialogplugin/src/btdevicedialognotifwidget.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/src/btdevicedialognotifwidget.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -23,6 +23,8 @@
 #include <hbdialog.h>
 #include "btdevicedialogpluginerrors.h"
 #include <btuiiconutil.h>
+#include <btnotif.h>
+
 /*!
     class Constructor
  */
@@ -125,7 +127,7 @@
 {
     TRACE_ENTRY
     QString keyStr, prompt,title;
-    QVariant classOfDevice;
+    QVariant classOfDevice, notifType;
     keyStr.setNum( TBluetoothDialogParams::EResource );
     // Validate if the resource item exists.
     QVariantMap::const_iterator i = parameters.constFind( keyStr );
@@ -135,6 +137,8 @@
         return;
     }
     HbIcon icon;
+    QString textStr;
+    QString devName;
     QVariant param = parameters.value( keyStr );
     int key = param.toInt();
     switch ( key ) {
@@ -158,6 +162,87 @@
             prompt = QString( hbTrId( "txt_bt_dpopinfo_is_now_hidden" ) );
             mNotificationDialog->setIcon(HbIcon("qtg_large_bluetooth"));
             break;
+        case EGenericInfo:
+            {
+            notifType = parameters.value(QString::number( TBluetoothDeviceDialog::EAdditionalInt ));
+            int type = notifType.toInt();
+            switch (notifType.toInt())
+                {
+                case EBTConnected:
+                    title = QString(hbTrId( "txt_bt_dpophead_connected" ));
+                    prompt = QString( hbTrId( "txt_bt_dpopinfo_connected_to_1" ) );
+                    classOfDevice = parameters.value(QString::number( TBluetoothDeviceDialog::EDeviceClass ));
+                    icon = getBadgedDeviceTypeIcon(classOfDevice.toInt());
+                    mNotificationDialog->setIcon(icon);
+                    break;
+                case EBTClosed:
+                    title = QString(hbTrId( "txt_bt_dpophead_disconnected" ));
+                    prompt = QString( hbTrId( "txt_bt_dpopinfo_disconnected_from_1" ) );
+                    classOfDevice = parameters.value(QString::number( TBluetoothDeviceDialog::EDeviceClass ));
+                    icon = getBadgedDeviceTypeIcon(classOfDevice.toInt());
+                    mNotificationDialog->setIcon(icon);
+                    break;
+                case EBTDisconnected:
+                case EBTDeviceNotAvailable:
+                case EBTOfflineDisabled:
+                case EBTEnterSap:
+                case EBTSapOk:
+                case EBTSapFailed:
+                case EBTSapNoSim:
+                case EBTDeviceBusy:
+                case ECmdShowBtBatteryLow:
+                case ECmdShowBtBatteryCritical:
+                case EBTStayPowerOn:
+                    break;
+                case EBTSwitchedOn:
+                    title = QString(hbTrId("txt_bt_dpophead_bluetooth"));
+                    prompt = QString(hbTrId("txt_bt_dpopinfo_is_now_on"));
+                    icon = QString("qtg_large_bluetooth");
+                    mNotificationDialog->setIcon(icon);
+                    break;
+                case EBTSwitchedOff:
+                    title = QString(hbTrId("txt_bt_dpophead_bluetooth"));
+                    prompt = QString(hbTrId("txt_bt_dpopinfo_is_now_off"));
+                    icon = QString("qtg_large_bluetooth");
+                    mNotificationDialog->setIcon(icon);
+                    break;
+                // not used anymore?
+                case EIRNotSupported:
+                case EBTVisibilityTimeout:                    
+                case EBTAudioAccessory:
+                case EBTAudioHandset:
+                default:
+                    break;
+                }
+            break;
+            }
+        case EBluetoothTestMode:
+            title = QString(hbTrId("txt_bt_dpophead_bluetooth_test_mode"));
+            prompt = QString(hbTrId("txt_bt_dpopinfo_restart_to_exit"));
+            icon = QString("qtg_large_bluetooth");
+            mNotificationDialog->setIcon(icon);
+            break;
+            
+        case ESendCompleted:
+            title = QString(hbTrId("txt_bt_dpophead_all_files_sent"));
+            textStr = QString(hbTrId("txt_bt_dpopinfo_sent_to_1"));
+            devName = QString(parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceName)).toString());
+            prompt = QString(textStr.arg(devName));
+            icon = getBadgedDeviceTypeIcon(parameters.value(
+                    QString::number(TBluetoothDeviceDialog::EDeviceClass)).toDouble());
+            mNotificationDialog->setIcon(icon);
+            break;
+        
+        /*case ESendCancelled:
+            title = QString(hbTrId("txt_bt_dpophead_sending_cancelled"));
+            textStr = QString(hbTrId("txt_bt_dpopinfo_sent_to_1"));
+            devName = QString(parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceName)).toString());
+            prompt = QString(textStr.arg(devName));
+            icon = getBadgedDeviceTypeIcon(parameters.value(QString::number(
+                    TBluetoothDeviceDialog::EDeviceClass)).toDouble());
+            mNotificationDialog->setIcon(icon);
+            break;*/
+
         default:
             mLastError = ParameterError;
             break;
--- a/bluetoothengine/btnotif/btdevicedialogplugin/src/btdevicedialogplugin.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/src/btdevicedialogplugin.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -32,12 +32,14 @@
 #include "btsenddialogwidget.h"
 #include "btdevicedialogrecvquerywidget.h"
 #include "btrecvcompleteddialogwidget.h"
+#include "btdeviceinfowidget.h"
 #include <hbtranslator.h>
 
 Q_EXPORT_PLUGIN2(btdevicedialogplugin, BtDeviceDialogPlugin)
 
 const char* BTDIALOG_TRANSLATION = "btdialogs";
-const char* BTVIEW_TRANSLATION = "btviews";        
+const char* BTVIEW_TRANSLATION = "btviews";
+const char* COMMON_ERRORS_TRANSLATION = "common_errors";
 
 // This plugin implements one device dialog type
 static const struct {
@@ -65,7 +67,7 @@
     BtDeviceDialogPlugin Constructor
  */
 BtDeviceDialogPlugin::BtDeviceDialogPlugin():
- mDialogTranslator(0),mViewTranslator(0)
+ mDialogTranslator(0),mViewTranslator(0),mCommonErrorsTranslator(0)
 {
     d = new BtDeviceDialogPluginPrivate;
 }
@@ -78,6 +80,7 @@
     delete d;
     delete mDialogTranslator;
     delete mViewTranslator;
+    delete mCommonErrorsTranslator;
 }
 
 /*! 
@@ -114,6 +117,11 @@
         {
         mViewTranslator = new HbTranslator(BTVIEW_TRANSLATION);
         }
+    if(!mCommonErrorsTranslator)
+        {
+        mCommonErrorsTranslator = new HbTranslator(COMMON_ERRORS_TRANSLATION);
+        }
+    
     // verify that requested dialog type is supported
     const int numTypes = sizeof(noteInfos) / sizeof(noteInfos[0]);
     for(i = 0; i < numTypes; i++) {
@@ -233,6 +241,9 @@
         case TBluetoothDialogParams::EReceiveDone:
             deviceDialog = new BTRecvcompletedDialogWidget(parameters);
             break;
+        case TBluetoothDialogParams::EInformationDialog:
+            deviceDialog = new BtDeviceInfoWidget(parameters);
+            break;
         default:
             d->mError = UnknownDeviceDialogError;
             break;
--- a/bluetoothengine/btnotif/btdevicedialogplugin/src/btdevicedialogquerywidget.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/src/btdevicedialogquerywidget.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -23,6 +23,9 @@
 #include <hbdialog.h>
 #include <hblabel.h>
 #include "btdevicedialogpluginerrors.h"
+#include <Bluetooth\hci\hcitypes.h>
+
+const int MaxPasskeyLength = 6;
 
 /*!
     class Constructor
@@ -111,6 +114,48 @@
     TRACE_EXIT
     return true;
 }
+/*!
+    Take parameter values and generate the input status string
+ */
+QString& BtDeviceDialogQueryWidget::GetPasskeyEntryStatusString(int aStatus)
+    {
+        switch(aStatus)
+            {
+            case EPasskeyDigitEntered :
+                mDispPassKeyNumDigit ++; // keep count of remote entry
+                if(mDisplayPasskeyStatus.length()< MaxPasskeyLength + 1) // + 1 space
+                    {
+                    if(mDisplayPasskeyStatus.length()== 3)
+                        {
+                        mDisplayPasskeyStatus.append(tr(" ")); // cosmetic
+                        }
+                    mDisplayPasskeyStatus.append(tr("*"));
+                    }
+                break;
+            case EPasskeyDigitDeleted :
+                // passkey entry is limited to 6 digits
+                if((mDisplayPasskeyStatus.length()> 0 )&& (mDispPassKeyNumDigit < MaxPasskeyLength + 1))
+                    {
+                    if(mDisplayPasskeyStatus.length() == 5) // cosmetic
+                        {
+                        mDisplayPasskeyStatus = mDisplayPasskeyStatus.left(mDisplayPasskeyStatus.length()-1);
+                        }
+                    mDisplayPasskeyStatus = mDisplayPasskeyStatus.left(mDisplayPasskeyStatus.length()-1);
+                    // we only decrement if the string is not zero
+                    mDispPassKeyNumDigit --;
+                    }
+                break;
+            case EPasskeyCleared :
+            case EPasskeyEntryStarted :
+            case EPasskeyEntryCompleted :
+            default:
+                mDispPassKeyNumDigit = 0;
+                mDisplayPasskeyStatus.clear();
+                mDisplayPasskeyStatus.append(tr(""));
+                break;
+            }
+        return mDisplayPasskeyStatus;
+    }
 
 /*!
     Take parameter values and generate relevant property of this widget
@@ -119,7 +164,8 @@
 {
     TRACE_ENTRY
     QString keyStr, prompt,title;
-    QVariant name,param,addval;
+    int status = -1;
+    QVariant name,param,addval,passkeyinputstatus;
     keyStr.setNum( TBluetoothDialogParams::EResource );
     // Validate if the resource item exists.
     QVariantMap::const_iterator i = parameters.constFind( keyStr );
@@ -128,7 +174,10 @@
         mLastError = UnknownDeviceDialogError;
         return;
     }
-
+    // For passkey display the dialog may be terminated by
+    // a passkey entry completed event from the remote side
+    mSendPasskeyEntryCompletedAction = false;
+    
     param = parameters.value( keyStr );
     int key = param.toInt();
     switch ( key ) {
@@ -164,11 +213,18 @@
             // todo: Formating the prompt need to be discussed with UI designer
             // The passcode could be displayed on a separate row if it the label did support
             // the use of newline escape character.
-            prompt.append(tr("\n\n")); // insert 2 newlines for clarity
+            prompt.append(tr("\n")); // insert 1 newlines for clarity
             prompt.append(addval.toString());
             if(key == EPasskeyDisplay)
                 {
-                prompt.append("\n");   
+                prompt.append("\n");
+                bool ret = false;
+                passkeyinputstatus = parameters.value( QString::number( TBluetoothDeviceDialog::EAdditionalInt ));
+                status = passkeyinputstatus.toInt(&ret);
+                if(ret)
+                    {
+                        prompt.append(GetPasskeyEntryStatusString(status));
+                    }
                 }
             }
     }
@@ -179,7 +235,14 @@
         title = title.arg(name.toString());
         mMessageBox->setHeadingWidget(new HbLabel(title));
         mMessageBox->setIconVisible(false);
-        mMessageBox->setStandardButtons( HbMessageBox::Yes | HbMessageBox::No);
+        if(key == EPasskeyDisplay)
+            {
+            mMessageBox->setStandardButtons(HbMessageBox::Cancel);
+            }
+        else
+            {
+            mMessageBox->setStandardButtons( HbMessageBox::Yes | HbMessageBox::No);
+            }
         }
     else
         {
@@ -193,6 +256,11 @@
             }
         }
     mMessageBox->setText( prompt );
+    if(status == EPasskeyEntryCompleted && key == EPasskeyDisplay)
+        {
+        mSendPasskeyEntryCompletedAction = true;
+        mMessageBox->close();
+        }
     TRACE_EXIT
 }
 
@@ -207,6 +275,7 @@
     mMessageBox->setTimeout(HbDialog::NoTimeout);
     mMessageBox->setDismissPolicy(HbDialog::NoDismiss);
     mSendAction = true;
+    mDispPassKeyNumDigit = 0;
     TRACE_EXIT
     return;
 }
@@ -214,19 +283,38 @@
 
 void BtDeviceDialogQueryWidget::messageBoxClosed(HbAction* action)
 {
+    TRACE_ENTRY
     QVariantMap data;
     
     HbMessageBox *dlg=static_cast<HbMessageBox*>(sender());
-    if(dlg->actions().first() == action) {
-        //Yes
-        data.insert( QString( "result" ), QVariant(true));
-    } 
-    else if(dlg->actions().at(1) == action) {
+    if(dlg->actions().first() == action) 
+        {
+        if(dlg->actions().count() > 1)
+            {
+            data.insert( QString( "result" ), QVariant(true));
+            }
+        else
+            {
+            // this is a passkey display dialog with a cancel button
+            data.insert( QString( "result" ), QVariant(false));
+            }
+        } 
+    else if(dlg->actions().count() > 1)
+        {
+        if(dlg->actions().at(1) == action) {
         //No
         data.insert( QString( "result" ), QVariant(false));
+        }
     }
-    
+    if(mSendPasskeyEntryCompletedAction)
+        {
+        // complete successfully the dialog
+        // The BT stack will determine if pairing was ok 
+        data.insert( QString( "result" ), QVariant(true));
+        mSendPasskeyEntryCompletedAction = false;
+        }
     emit deviceDialogData(data);
     emit deviceDialogClosed();
     mSendAction = false;
+    TRACE_EXIT
 }
--- a/bluetoothengine/btnotif/btdevicedialogplugin/src/btdevicedialogrecvquerywidget.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/src/btdevicedialogrecvquerywidget.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -53,6 +53,7 @@
 {
     Q_UNUSED(byClient);
     mDialog->close();
+    emit deviceDialogClosed();
 }
 
 HbPopup* BTRecvQueryDialogWidget::deviceDialogWidget() const
@@ -73,8 +74,8 @@
     mLoader->load(DOCML_BT_RECV_QUERY_DIALOG, &ok);
     if(ok)
     {
-        mDialog = qobject_cast<HbDialog*>(mLoader->findWidget("senddialog"));
-        mHeading = qobject_cast<HbLabel*>(mLoader->findWidget("heading"));
+        mDialog = qobject_cast<HbDialog*>(mLoader->findWidget("receiveAuthorizationDialog"));
+        mHeading = qobject_cast<HbLabel*>(mLoader->findWidget("receiveAuthorizationHeading"));
         
         mDeviceName = qobject_cast<HbLabel*>(mLoader->findWidget("deviceName"));
         mDeviceType = qobject_cast<HbLabel*>(mLoader->findWidget("deviceType"));
@@ -87,10 +88,10 @@
         mDeviceName->setPlainText(parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceName)).toString());
         mDeviceType->setPlainText(getDeviceTypeString(classOfDevice));
         
-        mYes = qobject_cast<HbAction*>(mLoader->findObject("yesaction"));
-        mNo = qobject_cast<HbAction*>(mLoader->findObject("noaction"));
+        mYesAction = qobject_cast<HbAction*>(mLoader->findObject("yesAction"));
+        mNoAction = qobject_cast<HbAction*>(mLoader->findObject("noAction"));
         
-        mCheckBox = qobject_cast<HbCheckBox*>(mLoader->findWidget("checkbox"));
+        mAuthorizeUser = qobject_cast<HbCheckBox*>(mLoader->findWidget("authorizeUser"));
 
         int dialogType = parameters.value(QString::number(TBluetoothDialogParams::EDialogTitle)).toInt();
         switch(dialogType)
@@ -103,17 +104,17 @@
             case TBluetoothDialogParams::EReceiveFromPairedDevice:
             {
                 mHeading->setPlainText(hbTrId("txt_bt_title_receive_messages_from_paired_device"));
-                mCheckBox->setCheckState(Qt::Checked);
+                mAuthorizeUser->setCheckState(Qt::Checked);
             }break;
             
             case TBluetoothDialogParams::EConnect:
             {
                 mHeading->setPlainText(hbTrId("txt_bt_title_connect_to"));
-                mCheckBox->setCheckState(Qt::Checked);
+                mAuthorizeUser->setCheckState(Qt::Checked);
             }break;
             case TBluetoothDialogParams::EPairingRequest:
                 mHeading->setPlainText(hbTrId("txt_bt_title_pair_with"));
-                mCheckBox->setCheckState(Qt::Checked);                
+                mAuthorizeUser->setCheckState(Qt::Checked);                
                 break;
             default:
                 break;
@@ -126,9 +127,9 @@
     mDialog->setDismissPolicy(HbPopup::NoDismiss);
     mDialog->setTimeout(HbPopup::NoTimeout);
      
-    connect(mYes, SIGNAL(triggered()), this, SLOT(yesClicked()));
-    connect(mNo, SIGNAL(triggered()), this, SLOT(noClicked()));
-    connect(mCheckBox, SIGNAL(clicked(bool)), this, SLOT(checkBoxStateChanged(bool)));
+    connect(mYesAction, SIGNAL(triggered()), this, SLOT(yesClicked()));
+    connect(mNoAction, SIGNAL(triggered()), this, SLOT(noClicked()));
+    connect(mAuthorizeUser, SIGNAL(clicked(bool)), this, SLOT(checkBoxStateChanged(bool)));
     
     return true;
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/src/btdeviceinfowidget.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,233 @@
+/*
+ * Copyright (c) 2009 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:  
+ *
+ */
+
+
+#include "btdeviceinfowidget.h"
+#include "bluetoothdevicedialogs.h"
+#include "btdevicedialogpluginerrors.h"
+#include <btuiiconutil.h>
+
+const int timeOut = 30000;
+
+BtDeviceInfoWidget::BtDeviceInfoWidget(const QVariantMap &parameters)
+:mLastError(NoError)
+{
+    constructDialog(parameters);
+}
+
+BtDeviceInfoWidget::~BtDeviceInfoWidget()
+{
+    
+}
+
+bool BtDeviceInfoWidget::setDeviceDialogParameters(const QVariantMap &parameters)
+{
+    Q_UNUSED(parameters);
+    return true;
+}
+
+int BtDeviceInfoWidget::deviceDialogError() const
+{
+    return mLastError;
+}
+
+void BtDeviceInfoWidget::closeDeviceDialog(bool byClient)
+{
+    Q_UNUSED(byClient);
+    mMessageBox->close();
+    emit deviceDialogClosed();
+}
+
+HbPopup* BtDeviceInfoWidget::deviceDialogWidget() const
+{
+    return mMessageBox;
+}
+
+QObject* BtDeviceInfoWidget::signalSender() const
+    {
+    return const_cast<BtDeviceInfoWidget*>(this);
+    }
+
+bool BtDeviceInfoWidget::constructDialog(const QVariantMap &parameters)
+{
+    QString keyStrDialogTitle, keyStrResource;
+    keyStrDialogTitle.setNum(TBluetoothDialogParams::EDialogTitle);
+    QVariantMap::const_iterator i = parameters.constFind(keyStrDialogTitle);
+    
+    keyStrResource.setNum(TBluetoothDialogParams::EResource);
+    QVariantMap::const_iterator j = parameters.constFind(keyStrResource);
+    
+    if(i != parameters.end())
+        {
+        int dialogTitle = parameters.value(QString::number(TBluetoothDialogParams::EDialogTitle)).toInt();
+        
+        switch(dialogTitle)
+            {
+                case TBluetoothDialogParams::EBTAddress:
+                {
+                    mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation);
+                    QString textStr(hbTrId("txt_bt_info_bluetooth_device_address_1"));
+                    QString deviceAddr(parameters.value(QString::number(TBluetoothDeviceDialog::ELocalAddress)).toString());
+                    mMessageBox->setText(textStr.arg(deviceAddr));
+                    HbIcon icon(QString("qtg_large_bluetooth"));
+                    mMessageBox->setIcon(icon);
+                    mMessageBox->setTimeout(timeOut);
+                    connect(mMessageBox, SIGNAL(finished(HbAction*)), this, SLOT(messageBoxClosed(HbAction*)));
+                }break;
+                //TODO: Remove this piece of code if notifier is used in toggle
+                case TBluetoothDialogParams::EOfflineQuery:
+                {
+                    mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
+                    mMessageBox->setText(hbTrId("txt_bt_info_trun_bluetooth_on_ini_offline_mode"));
+                    mMessageBox->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
+                    HbIcon icon(QString("qtg_large_bluetooth"));
+                    mMessageBox->setIcon(icon);
+                    mMessageBox->setTimeout(timeOut);
+                    connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
+                    connect(mMessageBox, SIGNAL(finished(HbAction*)), this, SLOT(messageBoxClosed(HbAction*)));
+                }break;
+                
+                case TBluetoothDialogParams::ERecvFailed:
+                {
+                    mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation);
+                    QString textStr(hbTrId("txt_bt_dpophead_receiving_failed"));
+                    QString devName(parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceName)).toString());
+                    mMessageBox->setText(textStr.arg(devName));
+                    int classOfDevice = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass)).toDouble();
+                    HbIcon icon = getBadgedDeviceTypeIcon(classOfDevice);
+                    mMessageBox->setIcon(icon);
+                    mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
+                    connect(mMessageBox, SIGNAL(finished(HbAction*)), this, SLOT(messageBoxClosed(HbAction*)));
+                }break;
+        
+                case TBluetoothDialogParams::ESendFailed:
+                {
+                    mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeInformation);
+                    QString textStr(hbTrId("txt_bt_dpophead_sending_failed"));
+                    QString devName(parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceName)).toString());
+                    mMessageBox->setText(textStr.arg(devName));
+                    int classOfDevice = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass)).toDouble();
+                    HbIcon icon = getBadgedDeviceTypeIcon(classOfDevice);
+                    mMessageBox->setIcon(icon);
+                    mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
+                    connect(mMessageBox, SIGNAL(finished(HbAction*)), this, SLOT(messageBoxClosed(HbAction*)));
+                }break;
+                
+                case TBluetoothDialogParams::EMemoryFull:
+                {
+                    mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeWarning);
+                    QString textStr(hbTrId("txt_error_info_memory_full_delete_data"));
+                    QString driveLetter(parameters.value(QString::number(TBluetoothDeviceDialog::EDriveLetter)).toChar());
+                    QString driveName(parameters.value(QString::number(TBluetoothDeviceDialog::EDriveName)).toString());
+                    mMessageBox->setText(textStr.arg(driveLetter).arg(driveName));
+                    mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
+                    connect(mMessageBox, SIGNAL(finished(HbAction*)), this, SLOT(messageBoxClosed(HbAction*)));
+                }break;
+                
+                case TBluetoothDialogParams::EDriveNotFound:
+                {
+                    mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeWarning);
+                    mMessageBox->setText(hbTrId("txt_bt_info_file_not_fould_memory_card_has_been_r"));
+                    mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
+                    connect(mMessageBox, SIGNAL(finished(HbAction*)), this, SLOT(messageBoxClosed(HbAction*)));
+                }break;
+                
+                case TBluetoothDialogParams::EFileMoved:
+                {
+                    mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeWarning);
+                    mMessageBox->setText(hbTrId("txt_bt_info_file_not_fould_it_may_be_removed_or_d"));
+                    mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
+                    connect(mMessageBox, SIGNAL(finished(HbAction*)), this, SLOT(messageBoxClosed(HbAction*)));
+                }break;
+                
+                case TBluetoothDialogParams::EUnsupportedImages:
+                {
+                    mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
+                    QString textStr(parameters.value(QString::number(TBluetoothDeviceDialog::EAdditionalDesc)).toString());
+                    mMessageBox->setText(textStr);
+                    mMessageBox->setStandardButtons(HbMessageBox::Continue| HbMessageBox::Cancel);
+                    int classOfDevice = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass)).toDouble();
+                    HbIcon icon = getBadgedDeviceTypeIcon(classOfDevice);
+                    mMessageBox->setIcon(icon);
+                    mMessageBox->setDismissPolicy(HbPopup::NoDismiss);
+                    connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
+                }break;
+                    
+                default:
+                    mLastError = UnknownDeviceDialogError;
+                    break;
+            }
+        }
+    
+    else if(j != parameters.end())
+        {
+        int resourceType = parameters.value(QString::number(TBluetoothDialogParams::EResource)).toInt();
+        
+        switch(resourceType)
+            {
+            case EIssueOfflineQuery:
+                {
+                mMessageBox = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
+                mMessageBox->setText(hbTrId("txt_bt_info_trun_bluetooth_on_ini_offline_mode"));
+                mMessageBox->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
+                HbIcon icon(QString("qtg_large_bluetooth"));
+                mMessageBox->setIcon(icon);
+                mMessageBox->setTimeout(timeOut);
+                connect(mMessageBox, SIGNAL(finished(int)), this, SLOT(messageBoxClosed(int)));
+                connect(mMessageBox, SIGNAL(finished(HbAction*)), this, SLOT(messageBoxClosed(HbAction*)));
+                }break;
+                
+            default:
+                mLastError = UnknownDeviceDialogError;
+                break; 
+            }
+        }
+    
+    else
+        {
+        mLastError = UnknownDeviceDialogError;
+        }
+    
+    if(!mLastError)
+        {
+        mMessageBox->setAttribute(Qt::WA_DeleteOnClose);
+        return true;
+        }
+    
+    return false;
+}
+
+void BtDeviceInfoWidget::messageBoxClosed(HbAction *action)
+{
+    Q_UNUSED(action);
+    emit deviceDialogClosed();
+}
+
+void BtDeviceInfoWidget::messageBoxClosed(int action)
+    {
+    QVariantMap data;
+    if((action == HbMessageBox::Yes) || (action == HbMessageBox::Continue))
+        {
+        data.insert(QString("actionResult"), QVariant(true));
+        }
+    else if((action == HbMessageBox::No) || (action == HbMessageBox::Cancel))
+        {
+        data.insert(QString("actionResult"), QVariant(false));
+        }
+    emit deviceDialogData(data);
+    emit deviceDialogClosed();
+    }
--- a/bluetoothengine/btnotif/btdevicedialogplugin/src/btdevicesearchdialogwidget.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/src/btdevicesearchdialogwidget.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -38,14 +38,12 @@
 #define LOC_SEARCH_DONE hbTrId("txt_bt_subhead_search_done")
 #define LOC_SEARCH_STOP hbTrId("txt_common_button_stop")
 #define LOC_SEARCH_RETRY hbTrId("txt_common_button_retry")
+#define LOC_SHOW_DIALOG_TITLE hbTrId("txt_bt_title_show")
 
 
 BTDeviceSearchDialogWidget::BTDeviceSearchDialogWidget(const QVariantMap &parameters)
-    {
-//    mDeviceLstIdx = 0;
-//    mViewByChosen = false;
+{
     mSelectedDeviceType = 0;
- //   mDeviceDialogData = 0;
     mLoader = 0;
     mContentItemModel = 0;
     mStopRetryFlag = 0; // Stop 
@@ -56,24 +54,22 @@
             BtuiDevProperty::WearableDev | BtuiDevProperty::ImagingDev |
             BtuiDevProperty::HealthDev | BtuiDevProperty::UncategorizedDev);       
     constructDialog(parameters);
-    }
+}
 
 BTDeviceSearchDialogWidget::~BTDeviceSearchDialogWidget()
-    {
+{
     delete mLoader;
     delete mContentItemModel;
-    if ( mQuery ) {
+    if ( mQuery )
+    {
         delete mQuery;
     }
-    
- //   delete mRbl;
- //   delete mViewByDialog;
-    }
+}
 
 bool BTDeviceSearchDialogWidget::setDeviceDialogParameters(const QVariantMap &parameters)
+{
+    if(parameters.keys().contains("Search Completed"))
     {
-    if(parameters.keys().at(0).compare("Search Completed")==0)
-        {
         mStopRetryFlag = 1; // Retry 
         mSearchLabel->hide();
         
@@ -85,19 +81,20 @@
         mSearchDoneLabel->setPlainText(LOC_SEARCH_DONE);
         
         mStopRetryAction->setText(LOC_SEARCH_RETRY);
-        }
+    }
     else
-        {
-        double cod  = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass)).toDouble();
+    {
+        int cod  = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass)).toInt();
         int uiMajorDevice;
         int uiMinorDevice;
     
         BtuiDevProperty::mapDeiveType(uiMajorDevice, uiMinorDevice, cod);
 
         BtSendDataItem devData;
-        devData[NameAliasRole] = QVariant(parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceName)).toString());
-        devData[ReadableBdaddrRole] = QVariant(parameters.value(QString::number(TBluetoothDialogParams::EAddress)).toString());
-        devData[CoDRole] = QVariant(cod);
+        //TODO Need to create string constant for Name as enum EDeviceName is not working for this
+        devData[NameAliasRole] =parameters.value("Name").toString();
+        devData[ReadableBdaddrRole] = parameters.value(QString::number(TBluetoothDeviceDialog::EAddress));
+        devData[CoDRole] = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass));
         devData[DeviceTypeRole] = QVariant(uiMajorDevice);
         setMajorProperty(devData,BtuiDevProperty::Bonded,
                 parameters.value("Bonded").toBool());
@@ -110,113 +107,96 @@
         mData.append(devData);
         
         if(mSelectedDeviceType & devData[DeviceTypeRole].toInt())
-            {
+        {
             QStandardItem* listitem = new QStandardItem();
             QStringList info;
             info.append(devData[NameAliasRole].toString());
             listitem->setData(info, Qt::DisplayRole);
-            HbIcon icon =  getBadgedDeviceTypeIcon(devData[CoDRole].toDouble(),
+            HbIcon icon =  getBadgedDeviceTypeIcon(devData[CoDRole].toInt(),
                     devData[MajorPropertyRole].toInt(),
                     BtuiBottomLeft | BtuiBottomRight | BtuiTopLeft | BtuiTopRight);
             listitem->setIcon(icon.qicon());
             mContentItemModel->appendRow(listitem);    
             mSelectedData.append(devData);
-            }
         }
+    }
                 
     return true;
-    }
+}
 
 int BTDeviceSearchDialogWidget::deviceDialogError() const
-    {
+{
     return 0;
-    }
+}
 
 void BTDeviceSearchDialogWidget::closeDeviceDialog(bool byClient)
-    {
+{
     Q_UNUSED(byClient);
     mSearchDevicesDialog->close();
-    //@ TODO to check below code is required which is written based on the documentation of closeDeviceDialog API
-    
- /*   QVariantMap val;
-    QVariant index(-1);
-    val.insert("selectedindex",index);
-    emit deviceDialogData(val);    
-    emit deviceDialogClosed();*/
-    }
+    if(!byClient)
+        {
+        QVariantMap val;
+        QVariant index(-1);
+        val.insert("selectedindex",index);
+        emit deviceDialogData(val);    
+        }
+    emit deviceDialogClosed();
+}
 
 HbPopup* BTDeviceSearchDialogWidget::deviceDialogWidget() const
-    {
+{
     return mSearchDevicesDialog;
-    }
+}
 
 QObject* BTDeviceSearchDialogWidget::signalSender() const
-    {
+{
     return const_cast<BTDeviceSearchDialogWidget*>(this);
-    }
+}
 
 bool BTDeviceSearchDialogWidget::constructDialog(const QVariantMap &parameters)
-    {
+{
     (void) parameters;
     bool ok = false;
     
     mLoader = new HbDocumentLoader();
     mLoader->load(DOCML_BTDEV_SEARCH_DIALOG, &ok);
     if(ok)
-        {
-        mSearchDevicesDialog = qobject_cast<HbDialog*>(mLoader->findWidget("searchdialog"));
-
- /*       HbLabel* heading = qobject_cast<HbLabel*>(mLoader->findWidget("heading"));
-        heading->setTextWrapping(Hb::TextWordWrap);
-        heading->setAlignment(Qt::AlignHCenter);
-        heading->setPlainText("Bluetooth - Found devices");
-        setHeadingWidget(heading);*/
+    {
+        mSearchDevicesDialog = qobject_cast<HbDialog*>(mLoader->findWidget("searchDialog"));
         
         mSearchLabel = qobject_cast<HbLabel*>(mLoader->findWidget("searchLabel"));
         mSearchLabel->setTextWrapping(Hb::TextWordWrap);
         mSearchLabel->setAlignment(Qt::AlignHCenter);
         mSearchLabel->setPlainText(LOC_SEARCHING_DEVICE);
  
-        mSearchIconLabel = qobject_cast<HbLabel*>(mLoader->findWidget("iconLabel"));
-        mSearchIconLabel->setIcon(QIcon(QString(":/icons/qtg_large_bluetooth.svg")));
+        mSearchIconLabel = qobject_cast<HbLabel*>(mLoader->findWidget("searchIconLabel"));
+        mSearchIconLabel->setIcon(HbIcon("qtg_large_bluetooth"));
 
         mSearchDoneLabel = qobject_cast<HbLabel*>(mLoader->findWidget("searchDoneLabel"));
         mSearchDoneLabel->hide();
         
-        
-        mSearchDevicesDialog->setFrameType(HbDialog::Strong);
-        mSearchDevicesDialog->setBackgroundFaded(false);
-
- //       mViewByBtn = qobject_cast<HbPushButton*>(mLoader->findWidget("viewby"));
-  //      mStopRetryBtn = qobject_cast<HbPushButton*>(mLoader->findWidget("stop"));
-        
-        mListView = qobject_cast<HbListView*>(mLoader->findWidget("listView"));
-        mListView->setSelectionMode(HbAbstractItemView::SingleSelection);
+        mDeviceList = qobject_cast<HbListView*>(mLoader->findWidget("deviceList"));
+        mDeviceList->setSelectionMode(HbAbstractItemView::SingleSelection);
 
         mContentItemModel = new QStandardItemModel(this);
-        mListView->setModel(mContentItemModel);//, prototype);
+        mDeviceList->setModel(mContentItemModel);//, prototype);
 
-        connect(mListView, SIGNAL(activated(QModelIndex)), this, SLOT(deviceSelected(QModelIndex)));
- //       connect(mStopRetryBtn, SIGNAL(clicked()), this, SLOT(stopRetryClicked()));
- //       connect(mViewByBtn, SIGNAL(clicked()), this, SLOT(viewByClicked()));
+        connect(mDeviceList, SIGNAL(activated(QModelIndex)), this, SLOT(deviceSelected(QModelIndex)));
         
-        mShowAction = static_cast<HbAction*>( mLoader->findObject( "viewaction" ) );
-        mShowAction->disconnect(mSearchDevicesDialog);
+        mShowAction = static_cast<HbAction*>( mLoader->findObject( "viewByAction" ) );
+        //if action is not disconnected the dialog will be closed when action is clicked 
+        mShowAction->disconnect(mSearchDevicesDialog); 
         
-        mStopRetryAction = static_cast<HbAction*>( mLoader->findObject( "stopretryaction" ) );
-        mStopRetryAction->disconnect(mSearchDevicesDialog);
         
-//        mCancelAction = static_cast<HbAction*>( mLoader->findObject( "cancelaction" ) );
-//        mCancelAction->disconnect(mSearchDevicesDialog);
+        mStopRetryAction = static_cast<HbAction*>( mLoader->findObject( "stopRetryAction" ) );
+        //if action is not disconnected the dialog will be closed when action is clicked         
+        mStopRetryAction->disconnect(mSearchDevicesDialog); 
         
         connect(mShowAction, SIGNAL(triggered()), this, SLOT(viewByClicked()));
         connect(mStopRetryAction, SIGNAL(triggered()), this, SLOT(stopRetryClicked()));
 
         connect(mSearchDevicesDialog, SIGNAL(aboutToClose()), this, SLOT(searchDialogClosed()));
-        
-//        QGraphicsWidget *widget = mLoader->findWidget(QString("container"));
-        //setContentWidget(widget);
-        }
+    }
     mSearchDevicesDialog->setBackgroundFaded(false);
     mSearchDevicesDialog->setDismissPolicy(HbPopup::NoDismiss);
     mSearchDevicesDialog->setTimeout(HbPopup::NoTimeout);
@@ -228,26 +208,22 @@
             << hbTrId("txt_bt_list_phones") 
             << hbTrId("txt_bt_list_other_devices");
     
- /*   mViewByDialog = new HbDialog();
-    mRbl = new HbRadioButtonList(mViewByDialog);
-    connect(mRbl, SIGNAL(itemSelected(int)), this, SLOT(viewByItemSelected(int)));*/
-    
     return true;
-    }
+}
 
 
 void BTDeviceSearchDialogWidget::stopRetryClicked()
-    {
+{
     QVariantMap val;
-    if(mStopRetryFlag == 1)//mStopRetryAction->text().compare(LOC_SEARCH_RETRY)==0
-        {
+    if(mStopRetryFlag == 1)
+    {
         mStopRetryFlag = 0; // Stop 
         QVariant index("Retry");
         val.insert("Retry",index); 
         emit deviceDialogData(val);
         delete mContentItemModel;
         mContentItemModel = new QStandardItemModel(this);
-        mListView->setModel(mContentItemModel);
+        mDeviceList->setModel(mContentItemModel);
         mStopRetryAction->setText(LOC_SEARCH_STOP);
         
         mSearchLabel->setTextWrapping(Hb::TextWordWrap);
@@ -260,9 +236,9 @@
         mSearchIconLabel->show();
         
         mSearchDoneLabel->hide();
-        }
+    }
     else
-        {
+    {
         mStopRetryFlag = 1; //Retry 
         mStopRetryAction->setText(LOC_SEARCH_RETRY);
         
@@ -279,26 +255,13 @@
         QVariant index("Stop");
         val.insert("Stop",index); 
         emit deviceDialogData(val);    
-        }
     }
-
-void BTDeviceSearchDialogWidget::retryClicked()
-    {
-    QVariantMap val;
-    QVariant index("Retry");
-    val.insert("Retry",index); 
-    emit deviceDialogData(val);
-    delete mContentItemModel;
-    mContentItemModel = new QStandardItemModel(this);
-    mListView->setModel(mContentItemModel);
-    
-
-    }
+}
 
 void BTDeviceSearchDialogWidget::viewByClicked()
+{
+    if ( !mQuery )
     {
-    
-    if ( !mQuery ) {
         mQuery = new HbSelectionDialog;
         mQuery->setStringItems(mDevTypeList, 0);
         mQuery->setSelectionMode(HbAbstractItemView::MultiSelection);
@@ -312,90 +275,79 @@
         
 //        mQuery->setAttribute(Qt::WA_DeleteOnClose);
         // Set the heading for the dialog.
-        HbLabel *headingLabel = new HbLabel(hbTrId("txt_bt_title_show"), mQuery);
+        HbLabel *headingLabel = new HbLabel(LOC_SHOW_DIALOG_TITLE, mQuery);
         mQuery->setHeadingWidget(headingLabel);
     }
     mQuery->open(this,SLOT(selectionDialogClosed(HbAction*)));
-
-     
-    }
+}
 
 void BTDeviceSearchDialogWidget::searchDialogClosed() 
-    {
+{
     QVariantMap val;
     QVariant index(-1);
     val.insert("selectedindex",index);
     emit deviceDialogData(val);    
     emit deviceDialogClosed();
-    }
+}
 
 void BTDeviceSearchDialogWidget::selectionDialogClosed(HbAction* action)
-    {
-    Q_UNUSED(action);
-    
-    disconnect( mQuery ); 
+{
+    disconnect( mQuery, 0, this, 0 ); 
     int devTypesWanted = 0;
 
-    if (action == mQuery->actions().first()) {  // user pressed "Ok"
+    if (action == mQuery->actions().first())
+    {  // user pressed "Ok"
         // Get selected items.
         QList<QVariant> selections;
         selections = mQuery->selectedItems();
         
-        for (int i=0; i < selections.count(); i++) {
-            switch (selections.at(i).toInt()) {
-            case BtUiDevAudioDevice:
-                devTypesWanted |= BtuiDevProperty::AVDev;
-                break;
-            case BtUiDevComputer:
-                devTypesWanted |= BtuiDevProperty::Computer;
-                break;
-            case BtUiDevInputDevice:
-                devTypesWanted |= BtuiDevProperty::Peripheral;
-                break;
-            case BtUiDevPhone:
-                devTypesWanted |= BtuiDevProperty::Phone;
-                break;
-            case BtUiDevOtherDevice:
-                devTypesWanted |= (BtuiDevProperty::LANAccessDev |
-                        BtuiDevProperty::Toy |
-                        BtuiDevProperty::WearableDev |
-                        BtuiDevProperty::ImagingDev |
-                        BtuiDevProperty::HealthDev |
-                        BtuiDevProperty::UncategorizedDev);
-                break;
-            default:
-                // should never get here
-                break;
+        for (int i=0; i < selections.count(); i++) 
+        {
+            switch (selections.at(i).toInt()) 
+            {
+                case BtUiDevAudioDevice:
+                    devTypesWanted |= BtuiDevProperty::AVDev;
+                    break;
+                case BtUiDevComputer:
+                    devTypesWanted |= BtuiDevProperty::Computer;
+                    break;
+                case BtUiDevInputDevice:
+                    devTypesWanted |= BtuiDevProperty::Peripheral;
+                    break;
+                case BtUiDevPhone:
+                    devTypesWanted |= BtuiDevProperty::Phone;
+                    break;
+                case BtUiDevOtherDevice:
+                    devTypesWanted |= (BtuiDevProperty::LANAccessDev |
+                            BtuiDevProperty::Toy |
+                            BtuiDevProperty::WearableDev |
+                            BtuiDevProperty::ImagingDev |
+                            BtuiDevProperty::HealthDev |
+                            BtuiDevProperty::UncategorizedDev);
+                    break;
+                default:
+                    // should never get here
+                    break;
             }
         }
     }
     else
-        {
+    {
         devTypesWanted = mSelectedDeviceType;
-        }
-        
-    
-
- /*   HbSelectionDialog *dlg = (HbSelectionDialog*)(sender());
-    if(dlg->actions().first() == action) {
+    }
 
-     } 
-    else if(dlg->actions().at(1) == action) {
-     }*/
-    
     if((devTypesWanted != mSelectedDeviceType) &&(devTypesWanted !=0))
-        {
+    {
         mSelectedDeviceType = devTypesWanted;
-//        mViewByChosen = true;
         delete mContentItemModel;
         mContentItemModel = new QStandardItemModel(this);
-        mListView->setModel(mContentItemModel);
+        mDeviceList->setModel(mContentItemModel);
         mSelectedData.clear();
         for(int i=0;i<mData.count();i++)
-            {
+        {
             const BtSendDataItem& qtdev = mData[i];
             if(devTypesWanted & qtdev[DeviceTypeRole].toInt() )
-                {
+            {
                 QStandardItem* listitem = new QStandardItem();
                 QStringList info;
                 info.append(qtdev[NameAliasRole].toString());
@@ -407,39 +359,24 @@
                 listitem->setIcon(icon.qicon());
                 mContentItemModel->appendRow(listitem);        
                 mSelectedData.append(qtdev);
-                }
             }
         }
     }
+}
 
 void BTDeviceSearchDialogWidget::deviceSelected(const QModelIndex& modelIndex)
-    {
+{
     int row = 0;
-    
- /*   if(mViewByChosen)
-        {
-        row = mDeviceLstOfType[modelIndex.row()].mDeviceIdx;
-        }
+    QVariantMap val;
     
-    else*/
-        {
-        row = modelIndex.row();
-        }
-    
-    QVariantMap val;
-//    QVariant index(row);
-//    val.insert("selectedindex",index);
-    
+    row = modelIndex.row();
     const BtSendDataItem& qtdev = mSelectedData.at(row);
     val.insert("selectedindex",QVariant(row));
-    val.insert("devicename",QVariant(qtdev[NameAliasRole]));
-    val.insert("deviceaddress",QVariant(qtdev[ReadableBdaddrRole]));
-    val.insert("deviceclass",QVariant(qtdev[CoDRole]));
+    val.insert("devicename",qtdev[NameAliasRole]);
+    val.insert("deviceaddress",qtdev[ReadableBdaddrRole]);
+    val.insert("deviceclass",qtdev[CoDRole]);
 
     emit deviceDialogData(val);
-//    mDeviceDialogData = 1;//flag is to say that device dialog data is emitted required when we cancel the dialog
-    //emit deviceDialogClosed();
-  //  this->close();
-    }
+}
 
 
--- a/bluetoothengine/btnotif/btdevicedialogplugin/src/btmoredevicesdialogwidget.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/src/btmoredevicesdialogwidget.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -32,8 +32,7 @@
 
 
 BTMoreDevicesDialogWidget::BTMoreDevicesDialogWidget(const QVariantMap &parameters)
-    {
-    mDeviceDialogData = 0;
+{
     mLoader = 0;
     mContentItemModel = 0;
     constructDialog(parameters);
@@ -48,27 +47,28 @@
             Q_UNUSED(badAlloc);
           //   = UnknownDeviceDialogError;
             }*/
-    }
+}
 
 BTMoreDevicesDialogWidget::~BTMoreDevicesDialogWidget()
-    {
+{
     delete mLoader;
     delete mContentItemModel;
-    }
+}
 
 bool BTMoreDevicesDialogWidget::setDeviceDialogParameters(const QVariantMap &parameters)
-    {
-    double cod  = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass)).toDouble();
+{
+    int cod  = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass)).toInt();
     int uiMajorDevice;
     int uiMinorDevice;
 
     BtuiDevProperty::mapDeiveType(uiMajorDevice, uiMinorDevice, cod);
     if ((uiMajorDevice & BtuiDevProperty::Phone)||(uiMajorDevice & BtuiDevProperty::Computer) )
-        {
+    {
         BtSendDataItem devData;
-        devData[NameAliasRole] = QVariant(parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceName)).toString());
-        devData[ReadableBdaddrRole] = QVariant(parameters.value(QString::number(TBluetoothDialogParams::EAddress)).toString());
-        devData[CoDRole] = QVariant(cod);
+        //todo Need to create string constant for name as enum EDeviceName has an issue
+        devData[NameAliasRole] = parameters.value("Name");
+        devData[ReadableBdaddrRole] = parameters.value(QString::number(TBluetoothDeviceDialog::EAddress));
+        devData[CoDRole] = parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceClass));
         
         setMajorProperty(devData,BtuiDevProperty::Bonded,
                 parameters.value("Bonded").toBool());
@@ -85,212 +85,111 @@
         info.append(devData[NameAliasRole].toString());
 
         listitem->setData(info, Qt::DisplayRole);
-        HbIcon icon =  getBadgedDeviceTypeIcon(devData[CoDRole].toDouble(),
+        HbIcon icon =  getBadgedDeviceTypeIcon(devData[CoDRole].toInt(),
                 devData[MajorPropertyRole].toInt(),
-                BtuiBottomLeft | BtuiBottomRight | BtuiTopLeft | BtuiTopRight);        
+                BtuiBottomLeft | BtuiBottomRight | BtuiTopLeft | BtuiTopRight);
         listitem->setIcon(icon.qicon());
-     //   listitem->setIcon(icon(parameters.value("deviceType").toString()));
         
         mContentItemModel->appendRow(listitem);        
-        }
+    }
     return true;
-    }
+}
 
 
 
 
 int BTMoreDevicesDialogWidget::deviceDialogError() const
-    {
+{
     return 0;
-    }
+}
 
 void BTMoreDevicesDialogWidget::closeDeviceDialog(bool byClient)
-    {
-    Q_UNUSED(byClient);
-    // below code is required and written based on the documentation of closeDeviceDialog API
-    mMoreDeviceDialog->close();
-    QVariantMap val;
-    QVariant index(-1);
-    val.insert("selectedindex",index);
-    emit deviceDialogData(val);    
-    //below signal is emitted to make dialog server aware that our dialog is closed
+{
+    mLastUsedDeviceDialog->close();
+    if(!byClient)
+        {
+        QVariantMap val;
+        QVariant index(-1);
+        val.insert("selectedindex",index);
+        emit deviceDialogData(val);
+        }
     emit deviceDialogClosed();
-    }
+}
 
 HbPopup* BTMoreDevicesDialogWidget::deviceDialogWidget() const
-    {
-    return mMoreDeviceDialog;
-    }
+{
+    return mLastUsedDeviceDialog;
+}
 
 QObject* BTMoreDevicesDialogWidget::signalSender() const
-    {
+{
     return const_cast<BTMoreDevicesDialogWidget*>(this);
-    }
+}
 
-bool BTMoreDevicesDialogWidget::constructDialog(const QVariantMap &/*parameters*/)
-    {
+bool BTMoreDevicesDialogWidget::constructDialog(const QVariantMap &parameters)
+{
+    Q_UNUSED(parameters);
     mLoader = new HbDocumentLoader();
     bool ok = false;
     
     mLoader->load(DOCML_BT_MORE_DEV_DIALOG, &ok);
     if(ok)
-        {
-        mMoreDeviceDialog = qobject_cast<HbDialog*>(mLoader->findWidget("lastuseddialog"));
-        mMoreDeviceDialog->setFrameType(HbDialog::Strong);
-        mMoreDeviceDialog->setBackgroundFaded(false);
-/*        HbLabel* label = qobject_cast<HbLabel*>(mLoader->findWidget("label"));
-        if(label)
-            {
-            label->setTextWrapping(Hb::TextWordWrap);
-            label->setPlainText("Send to:");
-            }
-        this->setHeadingWidget(label);*/
-   //     HbPushButton* moreDevices = qobject_cast<HbPushButton*>(mLoader->findWidget("moreDevices"));
-    //    HbPushButton* cancel = qobject_cast<HbPushButton*>(mLoader->findWidget("cancel"));
+    {
+        mLastUsedDeviceDialog = qobject_cast<HbDialog*>(mLoader->findWidget("lastUsedDevicesDialog"));
+  
         
-        HbListView* listView = qobject_cast<HbListView*>(mLoader->findWidget("listView"));
-        listView->setSelectionMode(HbAbstractItemView::SingleSelection);
+        HbListView* deviceList = qobject_cast<HbListView*>(mLoader->findWidget("deviceList"));
+        deviceList->setSelectionMode(HbAbstractItemView::SingleSelection);
 
         mContentItemModel = new QStandardItemModel(this);
-        listView->setModel(mContentItemModel);//, prototype);
+        deviceList->setModel(mContentItemModel);
         
- //       QList<QVariant> values = parameters.values();
+        connect(deviceList, SIGNAL(activated(QModelIndex)), this, SLOT(deviceSelected(QModelIndex)));
         
- /*       for(int i=0;i < values.count();i++)
-            {
-            QStandardItem* listitem = new QStandardItem();
-            // parameters.
-      //      QString string = values.at(i).toString();
-                        
-            listitem->setData(values.at(i).toString(), Qt::DisplayRole);
-   //         listitem->setData(QString("search"), Qt::DisplayRole);
-            //Todo - Insert icons based on the device class        
-            QIcon icon(QString(":/qgn_prop_sml_bt.svg"));
-            listitem->setIcon(icon);
+        mMoreAction = static_cast<HbAction*>( mLoader->findObject( "moreAction" ) );
+        
+        mCancelAction = static_cast<HbAction*>( mLoader->findObject( "cancelAction" ) );
         
-            mContentItemModel->appendRow(listitem);
-            }*/
-        
-        connect(listView, SIGNAL(activated(QModelIndex)), this, SLOT(deviceSelected(QModelIndex)));
-  //      connect(moreDevices, SIGNAL(clicked()), this, SLOT(moreDevicesClicked()));
-   //     connect(cancel, SIGNAL(clicked()), this, SLOT(cancelClicked()));
-        mMoreAction = static_cast<HbAction*>( mLoader->findObject( "moreaction" ) );
-        mMoreAction->disconnect(mMoreDeviceDialog);
-        
-        mCancelAction = static_cast<HbAction*>( mLoader->findObject( "cancelaction" ) );
-        mCancelAction->disconnect(mMoreDeviceDialog);
-//        QGraphicsWidget *widget = mLoader->findWidget(QString("container"));
-  //      mMoreDeviceDialog->setContentWidget(widget);
-        
-         connect(mMoreAction, SIGNAL(triggered()), this, SLOT(moreDevicesClicked()));
-         connect(mCancelAction, SIGNAL(triggered()), this, SLOT(cancelClicked()));
+        connect(mMoreAction, SIGNAL(triggered()), this, SLOT(moreDevicesClicked()));
+        connect(mCancelAction, SIGNAL(triggered()), this, SLOT(cancelClicked()));
                
-        }
+    }
+    mLastUsedDeviceDialog->setBackgroundFaded(false);
+    mLastUsedDeviceDialog->setDismissPolicy(HbPopup::NoDismiss);
+    mLastUsedDeviceDialog->setTimeout(HbPopup::NoTimeout);
+    mLastUsedDeviceDialog->setAttribute(Qt::WA_DeleteOnClose);
+    return true;
+}
 
 
-    mMoreDeviceDialog->setBackgroundFaded(false);
-    mMoreDeviceDialog->setDismissPolicy(HbPopup::NoDismiss);
-    mMoreDeviceDialog->setTimeout(HbPopup::NoTimeout);
-    mMoreDeviceDialog->setAttribute(Qt::WA_DeleteOnClose);
-    return true;
-    }
-
-/*void BTMoreDevicesDialogWidget::hideEvent(QHideEvent *event)
-    {
-    //HbDialog::hideEvent(event);
-    mMoreDeviceDialog->hideEvent(event);
-//    if(mDeviceDialogData == 0)
-        {
-        QVariantMap val;
-        QVariant index(-1);
-        val.insert("selectedindex",index);
-        emit deviceDialogData(val);    
-        emit deviceDialogClosed();
-        }*/    
- //   
-   // }
-
-/*void BTMoreDevicesDialogWidget::showEvent(QShowEvent *event)
-    {
-    //HbDialog::showEvent(event);
-    }*/
-
 void BTMoreDevicesDialogWidget::moreDevicesClicked()
-    {
+{
     QVariantMap val;
     QVariant index("MoreDevices");
     val.insert("MoreDevices",index);    
     emit deviceDialogData(val);
- //   mDeviceDialogData = 1;//flag is to say that device dialog data is emitted required when we cancel the dialog
-   // this->close();
-    // TODO
-    }
+    emit deviceDialogClosed();
+}
 
 void BTMoreDevicesDialogWidget::cancelClicked()
-    {
-    // TODO
-    mMoreDeviceDialog->close();
+{
+    mLastUsedDeviceDialog->close();
     QVariantMap val;
     QVariant index(-1);
     val.insert("selectedindex",index);
     emit deviceDialogData(val);    
     emit deviceDialogClosed();
-    }
+}
 
 void BTMoreDevicesDialogWidget::deviceSelected(const QModelIndex& modelIndex)
-    {
+{
     int row = modelIndex.row();
     QVariantMap val;
-//    QVariant index(row);
     const BtSendDataItem& qtdev = mData.at(row);
     val.insert("selectedindex",QVariant(row));
     val.insert("devicename",QVariant(qtdev[NameAliasRole]));
     val.insert("deviceaddress",QVariant(qtdev[ReadableBdaddrRole]));
     val.insert("deviceclass",QVariant(qtdev[CoDRole]));
     emit deviceDialogData(val);
-  //  mDeviceDialogData = 1;//flag is to say that device dialog data is emitted required when we cancel the dialog    
-   // this->close();
-
-    }
-  
-QIcon BTMoreDevicesDialogWidget::icon(/*QString deviceType*/)
-    {
- /*   if(deviceType == "Audio")
-        {
-        return (QIcon(QString(":/qgn_prop_bt_audio.svg")));
-        }
-    else if(deviceType == "Car-kit")
-        {
-        return (QIcon(QString(":/qgn_prop_bt_car_kit.svg")));
-        }
-    else if(deviceType == "Computer")
-        {
-        return (QIcon(QString(":/qgn_prop_bt_computer.svg")));
-        }
-    else if(deviceType == "Headset")
-        {
-        return (QIcon(QString(":/qgn_prop_bt_headset.svg")));
-        }
-    else if(deviceType == "Keyboard")
-        {
-        return (QIcon(QString(":/qgn_prop_bt_keyboard.svg")));
-        }
-    else if(deviceType == "Mouse")
-        {
-        return (QIcon(QString(":/qgn_prop_bt_mouse.svg")));
-        }
-    else if(deviceType == "Phone")
-        {
-        return (QIcon(QString(":/qgn_prop_bt_phone.svg")));
-        }
-    else if(deviceType == "Printer")
-        {
-        return (QIcon(QString(":/qgn_prop_bt_printer.svg")));
-        }
-    else
-        {
-        return (QIcon(QString(":/qgn_prop_bt_unknown.svg")));
-        }*/
-    return QIcon(QString(":/icons/qtg_large_bluetooth.svg"));
-    }
-
+}
+ 
--- a/bluetoothengine/btnotif/btdevicedialogplugin/src/btrecvcompleteddialogwidget.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/src/btrecvcompleteddialogwidget.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -15,10 +15,10 @@
 *
 */
 
+#include "btrecvcompleteddialogwidget.h"
 #include <xqaiwrequest.h>
 #include <xqappmgr.h>
 #include <QThreadPool>
-#include "btrecvcompleteddialogwidget.h"
 #include "bluetoothdevicedialogs.h"
 
 const char* DOCML_BT_RECV_CMPLTD_DIALOG = ":/docml/bt-receive-done-dialog.docml";
@@ -56,8 +56,9 @@
 
 
 BTRecvcompletedDialogWidget::BTRecvcompletedDialogWidget(const QVariantMap &parameters)
+:mLoader(0),
+ mOpenConversationView(false)
 {
-    mLoader = 0;
     constructDialog(parameters);
 }
 
@@ -72,6 +73,7 @@
 
 bool BTRecvcompletedDialogWidget::setDeviceDialogParameters(const QVariantMap &parameters)
 {
+    Q_UNUSED(parameters);
     return true;
 }
 
@@ -83,12 +85,13 @@
 void BTRecvcompletedDialogWidget::closeDeviceDialog(bool byClient)
 {
     Q_UNUSED(byClient);
-    mDialog->close();
+    mReceiveCompleteDialog->close();
+    emit deviceDialogClosed();
 }
 
 HbPopup* BTRecvcompletedDialogWidget::deviceDialogWidget() const
 {
-    return mDialog;
+    return mReceiveCompleteDialog;
 }
 
 QObject* BTRecvcompletedDialogWidget::signalSender() const
@@ -104,23 +107,23 @@
     mLoader->load(DOCML_BT_RECV_CMPLTD_DIALOG, &ok);
     if(ok)
     {
-        mDialog = qobject_cast<HbDialog*>(mLoader->findWidget("recvCompleteddialog"));
-        mHeading = qobject_cast<HbLabel*>(mLoader->findWidget("heading"));
+    	mReceiveCompleteDialog = qobject_cast<HbDialog*>(mLoader->findWidget("receiveCompleteDialog"));
+        mHeading = qobject_cast<HbLabel*>(mLoader->findWidget("receiveCompleteHeading"));
         
         mFileName = qobject_cast<HbLabel*>(mLoader->findWidget("fileName"));
         mFileSize = qobject_cast<HbLabel*>(mLoader->findWidget("fileSize"));
-        mFileCount = qobject_cast<HbLabel*>(mLoader->findWidget("fileCount_label"));
+        mFileCount = qobject_cast<HbLabel*>(mLoader->findWidget("fileCount"));
         mFileCount->setVisible(false);
         
         //TODO - set icon based on the file icon.
         
-        mShow = qobject_cast<HbAction*>(mLoader->findObject("showaction"));
-        mCancel = qobject_cast<HbAction*>(mLoader->findObject("cancelaction"));
+        mShowAction = qobject_cast<HbAction*>(mLoader->findObject("showAction"));
+        mCancelAction = qobject_cast<HbAction*>(mLoader->findObject("cancelAction"));
         
         QString headingStr(hbTrId("txt_bt_title_received_from_1"));
         QString senderName(parameters.value(QString::number(TBluetoothDeviceDialog::EDeviceName)).toString());
         mHeading->setPlainText(headingStr.arg(senderName));
-        mDialog->setHeadingWidget(mHeading);
+        mReceiveCompleteDialog->setHeadingWidget(mHeading);
         
         mFileName->setPlainText(parameters.value(QString::number(TBluetoothDeviceDialog::EReceivingFileName)).toString());
         
@@ -169,22 +172,31 @@
             }
     }
 
-    mDialog->setBackgroundFaded(false);
-    mDialog->setDismissPolicy(HbPopup::NoDismiss);
-    mDialog->setTimeout(HbPopup::NoTimeout);
+    mReceiveCompleteDialog->setBackgroundFaded(false);
+    mReceiveCompleteDialog->setDismissPolicy(HbPopup::NoDismiss);
+    mReceiveCompleteDialog->setTimeout(HbPopup::NoTimeout);
      
-    connect(mShow, SIGNAL(triggered()), this, SLOT(showClicked()));
-    connect(mCancel, SIGNAL(triggered()), this, SLOT(cancelClicked()));
+    connect(mShowAction, SIGNAL(triggered()), this, SLOT(showClicked()));
+    connect(mCancelAction, SIGNAL(triggered()), this, SLOT(cancelClicked()));
+    
+    QVariantMap::const_iterator i = parameters.find("OpenCnvView");
+    if(i != parameters.end())
+        {
+        mOpenConversationView = (i.value().toBool() == true) ? true : false; 
+        }
     
     return true;
 }
 
 void BTRecvcompletedDialogWidget::showClicked()
 {   
-    CoversationViewServiceStarter* service = new CoversationViewServiceStarter(KBluetoothMsgsConversationId);
-    service->setAutoDelete(true);
-    
-    QThreadPool::globalInstance()->start(service);
+    if(mOpenConversationView)
+        {
+        CoversationViewServiceStarter* service = new CoversationViewServiceStarter(KBluetoothMsgsConversationId);
+        service->setAutoDelete(true);
+        
+        QThreadPool::globalInstance()->start(service);
+        }
           
     QVariantMap data;
     data.insert(QString("actionResult"), QVariant(TBluetoothDialogParams::EShow));
--- a/bluetoothengine/btnotif/btdevicedialogplugin/src/btrecvprgrsdialogwidget.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/src/btrecvprgrsdialogwidget.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -54,6 +54,7 @@
 {
     Q_UNUSED(byClient);
     mDialog->close();
+    emit deviceDialogClosed();
 }
 
 HbPopup* BTRecvPrgrsDialogWidget::deviceDialogWidget() const
@@ -74,20 +75,20 @@
     mLoader->load(DOCML_BT_RECV_PRGRS_DIALOG, &ok);
     if(ok)
     {
-        mDialog = qobject_cast<HbDialog*>(mLoader->findWidget("senddialog"));
-        mHeading = qobject_cast<HbLabel*>(mLoader->findWidget("heading"));
+        mDialog = qobject_cast<HbDialog*>(mLoader->findWidget("receiveProgressDialog"));
+        mHeading = qobject_cast<HbLabel*>(mLoader->findWidget("receiveProgressHeading"));
         
         mFileName = qobject_cast<HbLabel*>(mLoader->findWidget("fileName"));
         mFileSize = qobject_cast<HbLabel*>(mLoader->findWidget("fileSize"));
-        mFileCount = qobject_cast<HbLabel*>(mLoader->findWidget("fileCount_label"));
+        mFileCount = qobject_cast<HbLabel*>(mLoader->findWidget("fileCount"));
         mFileCount->setVisible(false);
         
         //TODO - set icon based on the file icon.
         
-        mHide = qobject_cast<HbAction*>(mLoader->findObject("hideaction"));
-        mCancel = qobject_cast<HbAction*>(mLoader->findObject("cancelaction"));
+        mHide = qobject_cast<HbAction*>(mLoader->findObject("hideAction"));
+        mCancel = qobject_cast<HbAction*>(mLoader->findObject("cancelAction"));
         
-        mProgressBar = qobject_cast<HbProgressBar*>(mLoader->findWidget("horizontalProgressBar"));
+        mProgressBar = qobject_cast<HbProgressBar*>(mLoader->findWidget("receiveProgressBar"));
         
         int dialogType = parameters.value(QString::number(TBluetoothDialogParams::EDialogTitle)).toInt();
         switch(dialogType)
--- a/bluetoothengine/btnotif/btdevicedialogplugin/src/btsenddialogwidget.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btdevicedialogplugin/src/btsenddialogwidget.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -29,25 +29,25 @@
 const char* DOCML_BT_SEND_DIALOG = ":/docml/bt-send-dialog.docml";
 
 BTSendDialogWidget::BTSendDialogWidget(const QVariantMap &parameters)
-    {
+{
     mLoader = 0;
     constructDialog(parameters);
-    }
+}
 
 BTSendDialogWidget::~BTSendDialogWidget()
-    {
+{
     delete mLoader;
  /*   if(mContentItemModel)
         {
         delete mContentItemModel;
         mContentItemModel = NULL;
         }*/
-    }
+}
 
 bool BTSendDialogWidget::setDeviceDialogParameters(const QVariantMap &parameters)
-    {
+{
     if(mFileIndex != parameters.value("currentFileIdx").toString().toInt() )
-        {
+    {
         mDialogHeading->setTextWrapping(Hb::TextWordWrap);
         mDialogHeading->setAlignment(Qt::AlignHCenter);
         //Todo - replace this with the actual text from parameters
@@ -89,31 +89,31 @@
         mProgressBar->setProgressValue(0);
         mProgressBar->setMaximum(parameters.value("fileSz").toInt());
         mFileIndex = parameters.value("currentFileIdx").toString().toInt();
-        }
+    }
     else
-        {
+    {
         mProgressBar->setProgressValue(parameters.value("progressValue").toInt());
-        }
+    }
     return true;
-    }
+}
 
 int BTSendDialogWidget::deviceDialogError() const
-    {
+{
     return 0;
-    }
+}
 
 void BTSendDialogWidget::closeDeviceDialog(bool byClient)
-    {
+{
     Q_UNUSED(byClient);
     mSendDialog->close();
 // below redundant call is required because of the api documentation. 
     emit deviceDialogClosed();
-    }
+}
 
 HbPopup* BTSendDialogWidget::deviceDialogWidget() const
-    {
+{
     return mSendDialog;
-    }
+}
 
 QObject *BTSendDialogWidget::signalSender() const
 {
@@ -121,18 +121,18 @@
 }  
 
 bool BTSendDialogWidget::constructDialog(const QVariantMap&/*parameters*/)
-    {
+{
     mLoader = new HbDocumentLoader();
     bool ok = false;
     
     mLoader->load(DOCML_BT_SEND_DIALOG, &ok);
     if(ok)
-        {
-        mSendDialog = qobject_cast<HbDialog*>(mLoader->findWidget("senddialog"));
-        mDialogHeading = qobject_cast<HbLabel*>(mLoader->findWidget("heading"));
-        mFileIconLabel = qobject_cast<HbLabel*>(mLoader->findWidget("fileiconlabel"));
-        mFileNameLabel = qobject_cast<HbLabel*>(mLoader->findWidget("filenamelabel"));
-        mFileSizeLabel = qobject_cast<HbLabel*>(mLoader->findWidget("filesizelabel"));
+    {
+        mSendDialog = qobject_cast<HbDialog*>(mLoader->findWidget("sendProgressDialog"));
+        mDialogHeading = qobject_cast<HbLabel*>(mLoader->findWidget("sendDialogHeading"));
+        mFileIconLabel = qobject_cast<HbLabel*>(mLoader->findWidget("fileIcon"));
+        mFileNameLabel = qobject_cast<HbLabel*>(mLoader->findWidget("fileName"));
+        mFileSizeLabel = qobject_cast<HbLabel*>(mLoader->findWidget("fileSize"));
  //       mSendDialog->setHeadingWidget(mLabel);
    /*     mListView = qobject_cast<HbListView*>(mLoader->findWidget("listView"));
         if(mListView)
@@ -141,7 +141,7 @@
             mListView->setModel(mContentItemModel);//, prototype);
             }*/
          
-        mProgressBar = qobject_cast<HbProgressBar*>(mLoader->findWidget("horizontalProgressBar"));
+        mProgressBar = qobject_cast<HbProgressBar*>(mLoader->findWidget("sendProgressBar"));
                 
    //     HbAction* hide = new HbAction("Hide");
      //   HbAction* cancel = new HbAction("Cancel");
@@ -151,23 +151,23 @@
         
   //      QGraphicsWidget *widget = mLoader->findWidget(QString("container"));
    //     this->setContentWidget(widget);
-        }
+    }
 
     mSendDialog->setBackgroundFaded(false);
     mSendDialog->setDismissPolicy(HbPopup::NoDismiss);
     mSendDialog->setTimeout(HbPopup::NoTimeout);
     mSendDialog->setAttribute(Qt::WA_DeleteOnClose);
     
-    mHideAction = static_cast<HbAction*>( mLoader->findObject( "hideaction" ) );
-    mHideAction->disconnect(mSendDialog);
+    mHideAction = static_cast<HbAction*>( mLoader->findObject( "hideAction" ) );
+    mHideAction->disconnect(mSendDialog);  // Todo:  needed?
     
-    mCancelAction = static_cast<HbAction*>( mLoader->findObject( "cancelaction" ) );
-    mCancelAction->disconnect(mSendDialog);
+    mCancelAction = static_cast<HbAction*>( mLoader->findObject( "cancelAction" ) );
+    mCancelAction->disconnect(mSendDialog); // Todo:  needed?
     
     connect(mCancelAction, SIGNAL(triggered()), this, SLOT(cancelClicked()));
 
     return true;
-    }
+}
 
 /*void BTSendDialogWidget::hideEvent(QHideEvent *event)
     {
@@ -188,10 +188,10 @@
     }*/
 
 void BTSendDialogWidget::cancelClicked()
-    {
+{
     mSendDialog->close();
     emit deviceDialogClosed();
-    }
+}
 
 /*void BTSendDialogWidget::inputClosed(HbAction* action)
     {
--- a/bluetoothengine/btnotif/btnotifsrv/inc/bluetoothnotification.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btnotifsrv/inc/bluetoothnotification.h	Fri Sep 03 16:17:59 2010 +0300
@@ -21,6 +21,7 @@
 
 #include <e32base.h>
 #include <hb/hbcore/hbdevicedialogsymbian.h>
+#include <btservices/btsimpleactive.h>
 #include "bluetoothdevicedialogs.h"
 #include "btnotificationresult.h"
 #include "bluetoothtrace.h"
@@ -34,7 +35,8 @@
  *  @since Symbian^4
  */
 NONSHARABLE_CLASS( CBluetoothNotification ) : public CBase,
-                                              public MHbDeviceDialogObserver
+                                              public MHbDeviceDialogObserver,
+                                              public MBtSimpleActiveObserver
     {
 
 
@@ -101,6 +103,15 @@
     inline void SetNotificationType( TBluetoothDialogParams::TBTDialogType aType,
                 TBTDialogResourceId aResourceId )
             { iType = aType; iResourceId = aResourceId; }
+    
+    /**
+     * Creates New Notification Data to be shown to the user
+     *
+     * @since Symbian^4
+     * @return CHbSymbianVariantMap newly created notification data for the device dialog
+     */
+    CHbSymbianVariantMap* CreateNotificationDataL();
+    
 
     /**
      * Sets the data to be shown to the user.
@@ -132,6 +143,15 @@
     TInt Update( const TDesC& aData =KNullDesC );
 
     /**
+     * Updates the data to be shown to the user.
+     *
+     * @since Symbian^4
+     * @param ?arg1 ?description
+     * @return Error code
+     */
+    TInt Update( TInt aData);
+
+    /**
      * Show the notification, which means that it 
      * is added to the queue.
      *
@@ -150,6 +170,31 @@
      */
     TInt Close();
 
+    /**
+     * Set a dialog shutdown timer.
+     * This is used by passkey input entry when incoming
+     * pairing failed since the phone is the only
+     * display.
+     *
+     * @since Symbian^4
+     * @param a time after which the dialog is automatically closed.
+     */
+    void SetCloseTimer(TInt aAfter);
+    
+    /**
+     * From MBtSimpleActiveObserver
+     */
+    void RequestCompletedL( CBtSimpleActive* aActive, TInt aStatus );
+    
+    /**
+     * From MBtSimpleActiveObserver
+     */   
+    void CancelRequest( TInt aRequestId );
+    
+    /**
+     * From MBtSimpleActiveObserver
+     */    
+    void HandleError( CBtSimpleActive* aActive, TInt aError );
 
 private:
 
@@ -174,6 +219,24 @@
      * @param aData Additional integer data to be shown in the dialog.
      */
     void SetDataL( TInt aType, TInt aData );
+
+    /**
+     * Update the data to be shown to the user, leaves on error.
+     *
+     * @since Symbian^4
+     * @param aType Identifies the type of data parameter to be set.
+     * @param aData Additional descriptor data to be shown in the dialog.
+     */
+    void UpdateDataL( TInt aType, const TDesC& aData );
+
+    /**
+     * Update the data to be shown to the user, leaves on error.
+     *
+     * @since Symbian^4
+     * @param aType Identifies the type of data parameter to be set.
+     * @param aData Additional integer data to be shown in the dialog.
+     */
+    void UpdateDataL( TInt aType, TInt aData );
     
     /**
      * From MHbDeviceDialogObserver.
@@ -243,6 +306,15 @@
      */
     CHbDeviceDialogSymbian *iDialog;
     
+    /**
+     * Active object helper for asynchronous operations.
+     * Own.
+     * Used by the closing dialog timer
+     */
+    CBtSimpleActive* iActive;
+    
+    RTimer iClosingTimer;
+    
     BTUNITTESTHOOK
 
     };
--- a/bluetoothengine/btnotif/btnotifsrv/inc/btnotifbasepairinghandler.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btnotifsrv/inc/btnotifbasepairinghandler.h	Fri Sep 03 16:17:59 2010 +0300
@@ -23,6 +23,7 @@
 #include <btnotif.h>
 #include <btengconstants.h>
 #include <btservices/btsimpleactive.h>
+#include "bluetoothnotification.h"
 
 class CBTNotifSecurityManager;
 
@@ -100,6 +101,16 @@
      * @param aResult The result of the pairing
      */
     void ShowPairingResultNoteL(TInt aResult);
+
+    /**
+     * Set pairing cancelled by the user
+     */
+    void PairingCancelledByUser();
+
+    /**
+     * Set device as trusted
+     */
+    void SetTrusted();
     
 protected:
     
@@ -174,6 +185,22 @@
      * Own.
      */
     CBtSimpleActive* iActive;
+
+    /**
+     * Pairing cancelled by user.
+     */
+    TBool iPairingCancelledByUser;
+
+    /**
+     * Did the user checks the trusted checkbox?
+     */    
+    TBool iTrustDevice;
+
+    /**
+     * Pointer to a notification
+     */ 
+    CBluetoothNotification* iNotification;
+    
     };
 
 #endif /*BTNOTIFBASEPAIRINGHANDLER_H*/
--- a/bluetoothengine/btnotif/btnotifsrv/inc/btnotifdeviceselector.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btnotifsrv/inc/btnotifdeviceselector.h	Fri Sep 03 16:17:59 2010 +0300
@@ -5,7 +5,7 @@
 *  Description : Class for tracking Bluetooth settings, and also for 
 *                handling notes unrelated to specific connection.
 *
-*  Copyright © 2009 Nokia Corporation and/or its subsidiary(-ies).
+*  Copyright © 2009-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"
@@ -89,7 +89,7 @@
     /**
      * From MBTNotificationResult.
      * Handle an intermediate result from a user query.
-     * This ffunction is called if the user query passes information
+     * This function is called if the user query passes information
      * back before it has finished i.e. is dismissed. The final acceptance/
      * denial of a query is passed back in MBRNotificationClosed.
      *
@@ -162,11 +162,21 @@
 	
 	void setMajorProperty(TInt aMajorProperty, TInt prop, TBool addto);
 	
-	TBool isBonded( const CBTDevice &dev );
+	TBool isBonded( const CBTDevice &dev ) const;
 	
 	CBtDevExtension* GetDeviceFromRepositoryL( const TBTDevAddr& addr );
 	
 	void SendSelectedDeviceL( CHbSymbianVariantMap& aData );
+	
+	void SortUsedDevicesL();
+	
+	void RemoveUnWantedDevices();
+	
+	void SendLastUsedDevicesL();
+	
+	void SendPairedDevicesL();
+	
+	void LoadDeviceDetailsL(const CBtDevExtension& aDevice);
     
 private: // data    
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btnotif/btnotifsrv/inc/btnotifgeninfonotifier.h	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,117 @@
+/*
+* ============================================================================
+*  Name        : btnotifgeninfonotifier.h
+*  Part of     : BTProximity / BTProximity
+*  Description : Class for the generic info notifier.
+*
+*  Copyright © 2009-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:
+*  Nokia Corporation
+* ============================================================================
+* Template version: 4.2
+*/
+
+#ifndef BTNOTIFGENINFONOTIFIER_H
+#define BTNOTIFGENINFONOTIFIER_H
+
+
+#include "bluetoothnotification.h"
+#include "btnotifserver.h"
+#include <btservices/btdevextension.h>
+#include <hb/hbcore/hbsymbianvariant.h>
+
+/**
+ *  CBTNotifGenInfoNotifier for generic info notifier
+ *  
+ *  @since Symbian^4
+ */
+NONSHARABLE_CLASS( CBTNotifGenInfoNotifier ) : 
+        public CBase,
+        public MBTNotificationResult
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aServer Pointer to our parent
+     */
+    static CBTNotifGenInfoNotifier* NewL( CBTNotifServer* aServer );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CBTNotifGenInfoNotifier();
+
+    /**
+     * Processes a message from a notifier client related to settings.
+     *
+     * @since Symbian^4
+     * @param aMessage The message containing the details of the client request.
+     */
+    void HandleNotifierRequestL( const RMessage2& aMessage );
+
+private:
+// from base class MBTNotificationResult
+
+    /**
+     * From MBTNotificationResult.
+     * Handle an intermediate result from a user query.
+     * This function is called if the user query passes information
+     * back before it has finished i.e. is dismissed. The final acceptance/
+     * denial of a query is passed back in MBRNotificationClosed.
+     *
+     * @since Symbian^4
+     * @param aData the returned data. The actual format 
+     *              is dependent on the actual notifier.
+     */
+    virtual void MBRDataReceived( CHbSymbianVariantMap& aData );
+
+    /**
+     * From MBTNotificationResult.
+     * The notification is finished. The resulting data (e.g. user input or
+     * acceptance/denial of the query) is passed back here.
+     *
+     * @since Symbian^4
+     * @param aErr KErrNone or one of the system-wide error codes.
+     * @param aData the returned data. The actual format 
+     *              is dependent on the actual notifier.
+     */
+    virtual void MBRNotificationClosed( TInt aError, const TDesC8& aData );
+    
+    // From MDevDiscoveryObserver
+    
+private:
+
+    CBTNotifGenInfoNotifier( CBTNotifServer* aServer );
+
+    void ConstructL();
+    
+    void ShowNotificationL(const RMessage2& aMessage);
+			
+private: // data    
+
+    /**
+     * Reference to our parent the server class.
+     * Not own.
+     */
+    CBTNotifServer* iServer;
+    
+    /**
+     * Pointer to an outstanding user interaction.
+     * Not own.
+     */
+    CBluetoothNotification* iNotification;
+    
+    };
+
+#endif // BTNOTIFDEVICESELECTOR_H
--- a/bluetoothengine/btnotif/btnotifsrv/inc/btnotifincomingpairinghandler.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btnotifsrv/inc/btnotifincomingpairinghandler.h	Fri Sep 03 16:17:59 2010 +0300
@@ -20,7 +20,7 @@
 #define BTNOTIFINCOMINGPAIRINGHANDLER_H
 
 #include <bt_sock.h>
-#include "btnotifBasePairingHandler.h"
+#include "btnotifbasepairinghandler.h"
 
 /**
  *  Class CBTNotifIncomingPairingHandler
--- a/bluetoothengine/btnotif/btnotifsrv/inc/btnotifoutgoingpairinghandler.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btnotifsrv/inc/btnotifoutgoingpairinghandler.h	Fri Sep 03 16:17:59 2010 +0300
@@ -275,6 +275,11 @@
      * Number of pairing attempt
      */
     TInt iPairingAttempt;
+
+    /**
+     * Pairing failure dialog is not deleted when the handler is deleted
+     */
+    TBool iDialogIsOrphan;
     
     };
 
--- a/bluetoothengine/btnotif/btnotifsrv/inc/btnotifpairnotifier.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btnotifsrv/inc/btnotifpairnotifier.h	Fri Sep 03 16:17:59 2010 +0300
@@ -72,10 +72,9 @@
      * Update an outstanding request for this connection.
      *  
      * @since Symbian^4
-     * @param aUid The UID of the notifier for this update.
-     * @param aParams The updated parameters for this request from the client.
+     * @param aMessage.
      */
-    void UpdatePairingNotifierL( TInt aUid, const TDesC8& aParams );
+    void CBTNotifPairNotifier::UpdatePairingNotifierL( const RMessage2& aMessage);
 
     /**
      * Cancel an outstanding request for this connection.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btnotif/btnotifsrv/inc/btnotifpowernotifier.h	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,137 @@
+/*
+* Copyright (c) 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: Server class for handling commands from clients, and the 
+*                central class in btnotif thread.
+*
+*/
+
+#ifndef BTNOTIFPOWERNOTIFIER_H_
+#define BTNOTIFPOWERNOTIFIER_H_
+
+#include "bluetoothnotification.h"
+#include "btnotifserver.h"
+#include <hb/hbcore/hbsymbianvariant.h>
+#include <btengsettings.h>
+
+
+/**
+ *  CBTNotifPowerNotifier for BT power related notifications
+ *  
+ *  @since Symbian^4
+ */
+NONSHARABLE_CLASS( CBTNotifPowerNotifier ) : 
+        public CBase,
+        public MBTNotificationResult,
+        public MBTEngSettingsObserver
+    {
+
+public:
+
+    /**
+     * Two-phased constructor.
+     * @param aServer Pointer to our parent
+     */
+    static CBTNotifPowerNotifier* NewL( CBTNotifServer* aServer );
+
+    /**
+    * Destructor.
+    */
+    virtual ~CBTNotifPowerNotifier();
+
+    /**
+     * Processes a message from a notifier client related to settings.
+     *
+     * @since Symbian^4
+     * @param aMessage The message containing the details of the client request.
+     */
+    void HandleNotifierRequestL( const RMessage2& aMessage );
+
+private:
+// from base class MBTNotificationResult
+
+    /**
+     * From MBTNotificationResult.
+     * Handle an intermediate result from a user query.
+     * This function is called if the user query passes information
+     * back before it has finished i.e. is dismissed. The final acceptance/
+     * denial of a query is passed back in MBRNotificationClosed.
+     *
+     * @since Symbian^4
+     * @param aData the returned data. The actual format 
+     *              is dependent on the actual notifier.
+     */
+    virtual void MBRDataReceived( CHbSymbianVariantMap& aData );
+
+    /**
+     * From MBTNotificationResult.
+     * The notification is finished. The resulting data (e.g. user input or
+     * acceptance/denial of the query) is passed back here.
+     *
+     * @since Symbian^4
+     * @param aErr KErrNone or one of the system-wide error codes.
+     * @param aData the returned data. The actual format 
+     *              is dependent on the actual notifier.
+     */
+    virtual void MBRNotificationClosed( TInt aError, const TDesC8& aData );
+    
+    // From MDevDiscoveryObserver
+    
+private:
+
+    CBTNotifPowerNotifier( CBTNotifServer* aServer );
+
+    void ConstructL();
+    
+    void ShowNotificationL(const RMessage2& aMessage);
+    
+private: // From 
+    void PowerStateChanged( TBTPowerStateValue aState );
+    void VisibilityModeChanged( TBTVisibilityMode aState );
+        
+private: // data    
+
+    /**
+     * Reference to our parent the server class.
+     * Not own.
+     */
+    CBTNotifServer* iServer;
+    
+    /**
+     * Pointer to an outstanding user interaction.
+     * Not own.
+     */
+    CBluetoothNotification* iNotification;
+    
+    /**
+     * The client request.
+     */
+    RMessage2 iNotifierMessage;
+    
+    /**
+     * Represents the choice made by the client, Yes/No
+     */
+    TBool iTurnBTOn;
+
+    /**
+     * Represents the response to the client of the power notifier.
+     */
+    TPckgBuf<TBool> iClientResponse;
+    
+    /**
+     * Owned object of CBTEngSettings to turn BT power on.
+     */
+    CBTEngSettings* iBTEngSettings;
+    };
+
+#endif /* BTNOTIFPOWERNOTIFIER_H_ */
--- a/bluetoothengine/btnotif/btnotifsrv/inc/btnotifsecuritymanager.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btnotifsrv/inc/btnotifsecuritymanager.h	Fri Sep 03 16:17:59 2010 +0300
@@ -162,6 +162,16 @@
      */
     void TrustDevice( const TBTDevAddr& aAddr );
     
+    /**
+     * Trust a device via the registry
+     */
+    void UnTrustDevice( const TBTDevAddr& aAddr );
+
+    /**
+     * Return the pairing handler
+     */
+    CBTNotifBasePairingHandler* PairingHandler();
+    
 private: 
     
     // from base class MBtSimpleActiveObserver
@@ -379,7 +389,7 @@
     CBtSimpleActive* iAuthenResultActive;
 
     /**
-     * pairing hanlder at the time.
+     * pairing handler at the time.
      * Own.
      */
     CBTNotifBasePairingHandler* iPairingHandler;
--- a/bluetoothengine/btnotif/btnotifsrv/inc/btnotifserver.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btnotifsrv/inc/btnotifserver.h	Fri Sep 03 16:17:59 2010 +0300
@@ -29,6 +29,8 @@
 class CBTNotifSettingsTracker;
 class CBTNotificationManager;
 class CBTNotifDeviceSelector;
+class CBTNotifGenInfoNotifier;
+class CBTNotifPowerNotifier;
 class CBtDevRepository;
 
 class CbtnotifServerTest; // ToDo: shall be refactored under compile flag?
@@ -145,6 +147,15 @@
     CBtDevRepository& DevRepository();
     
     CBTNotifDeviceSelector& DeviceSelectorL();
+
+    /**
+     * Returns a handle to the Generic info notifier.
+     *
+     * @since Symbian^4
+     * @param Pointer to the Generic info notifier.
+     */
+    inline CBTNotifGenInfoNotifier* GenericInfoNotifier() const
+        { return iGenInfoNotifier; }
     
 // from base class CPolicyServer
 
@@ -159,7 +170,15 @@
      * @return A pointer to the newly created server-side session object.
      */
     virtual CSession2* NewSessionL( const TVersion& aVersion, const RMessage2& aMessage ) const;
-
+    
+    /**
+     * Returns a handle to the BT poser notifier.
+     * @since Symbian^4
+     * @return A pointer to the newly created server-side session object.
+     */
+    inline CBTNotifPowerNotifier* BTPowerNotifier() const
+            { return iBTPowerNotifier; }
+    
 private:
 
     CBTNotifServer();
@@ -228,6 +247,11 @@
      * Own.
      */
     CBTNotifDeviceSelector* iDevSelector;
+
+    /**
+     * Generic info notifier.
+     */    
+    CBTNotifGenInfoNotifier* iGenInfoNotifier;
     
     /**
      * Callback for asynchronous processing.
@@ -246,6 +270,11 @@
      */
     TDeltaTimerEntry iShutdownTimerEntry;
     
+    /**
+     * BT power notifier
+     */
+    CBTNotifPowerNotifier* iBTPowerNotifier;
+    
     BTUNITTESTHOOK
 
     };
--- a/bluetoothengine/btnotif/btnotifsrv/src/bluetoothnotification.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btnotifsrv/src/bluetoothnotification.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -29,6 +29,11 @@
 _LIT( KBTDevDialogResult, "result" );
 _LIT( KBTDevDialogInput, "input" );
 
+enum TDialogState
+    {
+    EWaitingForClosing,
+    };
+
 // ======== MEMBER FUNCTIONS ========
 
 // ---------------------------------------------------------------------------
@@ -38,6 +43,7 @@
 CBluetoothNotification::CBluetoothNotification( CBTNotificationManager* aManager )
 :   iManager( aManager )
     {
+    iActive = NULL;
     }
 
 
@@ -76,12 +82,38 @@
 CBluetoothNotification::~CBluetoothNotification()
 {
     BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    if(iActive)
+        {
+        if(iActive->IsActive())
+            {
+            iActive->Cancel();
+            }
+        delete iActive;
+        }
+    iClosingTimer.Close();
     delete iDialog;
     delete iNotificationData;
     delete iReturnData;
 	BOstraceFunctionExit1( DUMMY_DEVLIST, this )
 }
 
+
+// ---------------------------------------------------------------------------
+// Creates new notification data.
+// ---------------------------------------------------------------------------
+//
+CHbSymbianVariantMap* CBluetoothNotification::CreateNotificationDataL()
+    {
+    if(iNotificationData!=NULL)
+        {
+        delete iNotificationData;
+        iNotificationData = NULL;
+        }
+    iNotificationData = CHbSymbianVariantMap::NewL();
+    return iNotificationData;
+    }
+
+
 // ---------------------------------------------------------------------------
 // Sets the data to be shown to the user.
 // ---------------------------------------------------------------------------
@@ -110,15 +142,30 @@
 TInt CBluetoothNotification::Update( const TDesC& aData )
     {
     BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
-    (void) aData;
-    int ret = iDialog->Update( *iNotificationData );
-    delete iNotificationData;
-    iNotificationData = NULL;
-    TRAP( ret, iNotificationData = CHbSymbianVariantMap::NewL() );
+    TRAPD(ret,UpdateDataL( TBluetoothDeviceDialog::EDeviceName, aData ));
+    if(!ret)
+        {
+            int ret = iDialog->Update( *iNotificationData );
+        }
     BOstraceFunctionExit1( DUMMY_DEVLIST, this );
     return ret;
     }
 
+// ---------------------------------------------------------------------------
+// Updates the data to be shown to the user.
+// ---------------------------------------------------------------------------
+//
+TInt CBluetoothNotification::Update( TInt aData )
+    {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    TRAPD(ret,UpdateDataL( TBluetoothDeviceDialog::EAdditionalInt, aData ));
+    if(!ret)
+        {
+            ret = iDialog->Update( *iNotificationData );
+        }
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
+    return ret;
+    }
 
 // ---------------------------------------------------------------------------
 // Show the notification, which means that it is added to the queue.
@@ -133,9 +180,6 @@
     iReturnData = NULL;
     iReturnData = CHbSymbianVariantMap::NewL();
     iDialog->Show( KBTDevDialogId(), *iNotificationData, this );
-    delete iNotificationData;
-    iNotificationData = NULL;
-    iNotificationData = CHbSymbianVariantMap::NewL();
     BOstraceFunctionExit1( DUMMY_DEVLIST, this );
     }
 
@@ -205,12 +249,116 @@
 		BOstraceFunctionExit1( DUMMY_DEVLIST, this );
     }
 
+// ---------------------------------------------------------------------------
+// Sets the data to be shown to the user.
+// ---------------------------------------------------------------------------
+//
+void CBluetoothNotification::SetDataL( TInt aType, TInt aData )
+    {
+    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aType );
+    TBuf<6> key;
+    CHbSymbianVariant* value = NULL;
+    switch( aType )
+        {
+        case TBluetoothDialogParams::EDialogType:
+        case TBluetoothDialogParams::EResource:
+        case TBluetoothDialogParams::EDialogTitle:
+        case TBluetoothDeviceDialog::EDeviceClass:
+        case TBluetoothDeviceDialog::EAdditionalInt:
+            key.Num(aType);
+            value = CHbSymbianVariant::NewL( (TAny*) &aData, CHbSymbianVariant::EInt );
+            BtTraceBlock( 
+                    TBuf<32> buf;
+                    switch (aType) {
+                        case TBluetoothDialogParams::EDialogType:
+                            buf = _L("EDialogType"); 
+                            break;
+                        case TBluetoothDialogParams::EResource:
+                            buf = _L("EResource");
+                            break;
+                        case TBluetoothDeviceDialog::EDeviceClass:
+                            buf = _L("EDeviceClass");
+                            break;
+                        case TBluetoothDeviceDialog::EAdditionalInt:
+                            buf = _L("EAdditionalInt");
+                            break;
+                    }
+                    TPtrC p(buf);
+                    TInt *intPtr = (TInt *)value->Data();
+                    BOstraceExt2( TRACE_DEBUG, DUMMY_DEVLIST, "SetData [%S] = [%d]", &p, *intPtr);
+                    );
+            User::LeaveIfError(iNotificationData->Add( key, value ));   // Takes ownership of value
+            break;
+        case TBluetoothDialogParams::EAddress:
+        case TBluetoothDeviceDialog::EDeviceName:
+            PanicServer( EBTNotifPanicBadArgument );
+            break;
+        case TBluetoothDialogParams::ENoParams:
+        case TBluetoothDeviceDialog::ENoParams:
+        default:
+            break;
+        }
+        BOstraceFunctionExit1( DUMMY_DEVLIST, this );
+    }
 
 // ---------------------------------------------------------------------------
 // Sets the data to be shown to the user.
 // ---------------------------------------------------------------------------
 //
-void CBluetoothNotification::SetDataL( TInt aType, TInt aData )
+void CBluetoothNotification::UpdateDataL( TInt aType, const TDesC& aData )
+    {
+    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aType );
+    TBuf16<6> key;
+    CHbSymbianVariant* value = NULL;
+    switch( aType )
+        {
+        case TBluetoothDialogParams::EAddress:
+        case TBluetoothDeviceDialog::EDeviceName:
+        case TBluetoothDeviceDialog::EAdditionalDesc:
+        case TBluetoothDialogParams::EDialogTitle:
+            key.Num(aType);
+            value = CHbSymbianVariant::NewL( (TAny*) &aData, CHbSymbianVariant::EDes );
+            BtTraceBlock( 
+                    TBuf<32> buf;
+                    switch (aType) {
+                        case TBluetoothDialogParams::EAddress:
+                            _LIT(KAddress,"EAddress");
+                            buf.Append(KAddress); 
+                            break;
+                        case TBluetoothDeviceDialog::EDeviceName:
+                            _LIT(KDeviceName,"EDeviceName");
+                            buf.Append(KDeviceName); 
+                            break;
+                        case TBluetoothDeviceDialog::EAdditionalDesc:
+                            _LIT(KAdditionalDesc,"EAdditionalDesc");
+                            buf.Append(KAdditionalDesc); 
+                            break;
+                    }
+                    TPtrC p(buf);
+                    TPtrC16 *ptr = (TPtrC16 *)value->Data();
+                    BOstraceExt2( TRACE_DEBUG, DUMMY_DEVLIST, "SetData [%S] = [%S]", &p, ptr);
+                    );
+            User::LeaveIfError(iNotificationData->Delete( key));
+            User::LeaveIfError(iNotificationData->Add( key, value ));   // Takes ownership of value
+            break;
+        case TBluetoothDialogParams::EResource:
+        case TBluetoothDeviceDialog::EDeviceClass:
+        case TBluetoothDeviceDialog::EAdditionalInt:
+            PanicServer( EBTNotifPanicBadArgument );
+            break;
+        case TBluetoothDialogParams::ENoParams:
+        case TBluetoothDeviceDialog::ENoParams:
+        default:
+            break;
+        }
+        BOstraceFunctionExit1( DUMMY_DEVLIST, this );
+    }
+
+// ---------------------------------------------------------------------------
+// Sets the data to be shown to the user.
+// ---------------------------------------------------------------------------
+//
+void CBluetoothNotification::UpdateDataL( TInt aType, TInt aData )
     {
     BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aType );
     TBuf<6> key;
@@ -244,6 +392,7 @@
                     TInt *intPtr = (TInt *)value->Data();
                     BOstraceExt2( TRACE_DEBUG, DUMMY_DEVLIST, "SetData [%S] = [%d]", &p, *intPtr);
                     );
+			User::LeaveIfError(iNotificationData->Delete(key));
 			User::LeaveIfError(iNotificationData->Add( key, value ));   // Takes ownership of value
             break;
         case TBluetoothDialogParams::EAddress:
@@ -258,6 +407,7 @@
 		BOstraceFunctionExit1( DUMMY_DEVLIST, this );
     }
 
+
 // ---------------------------------------------------------------------------
 // From class MHbDeviceDialogObserver.
 // Callback called when data is received from a device dialog.
@@ -393,3 +543,47 @@
     BOstraceFunctionExit0( DUMMY_DEVLIST );
     }
 
+// ---------------------------------------------------------------------------
+// Activate a timer which will automatically close the dialog when expired.
+// ---------------------------------------------------------------------------
+//
+void CBluetoothNotification::SetCloseTimer(TInt aAfter)
+    {
+    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aAfter );
+    TRAP_IGNORE(iActive = CBtSimpleActive::NewL(*this, EWaitingForClosing ));
+    User::LeaveIfError( iClosingTimer.CreateLocal() );
+    iClosingTimer.After(iActive->iStatus, aAfter);
+    iActive->GoActive();
+    }
+
+// ---------------------------------------------------------------------------
+// From MBtSimpleActiveObserver
+// ---------------------------------------------------------------------------
+//
+void CBluetoothNotification::RequestCompletedL( CBtSimpleActive* aActive, TInt aStatus )
+    {
+    (void)aActive;
+    (void)aStatus;
+    Close();
+    }
+
+// ---------------------------------------------------------------------------
+// From MBtSimpleActiveObserver
+// ---------------------------------------------------------------------------
+//
+void CBluetoothNotification::CancelRequest( TInt aRequestId )
+    {
+    (void)aRequestId;
+    // ignore    
+    }
+
+// ---------------------------------------------------------------------------
+// From MBtSimpleActiveObserver
+// ---------------------------------------------------------------------------
+//
+void CBluetoothNotification::HandleError( CBtSimpleActive* aActive, TInt aError )
+    {
+    (void)aActive;
+    (void)aError;
+    // ignore
+    }
--- a/bluetoothengine/btnotif/btnotifsrv/src/btnotifbasepairinghandler.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btnotifsrv/src/btnotifbasepairinghandler.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -39,7 +39,9 @@
 //
 void CBTNotifBasePairingHandler::BaseConstructL( )
     {
-    iActive = CBtSimpleActive::NewL( *this, 0 );  
+    iActive = CBtSimpleActive::NewL( *this, 0 );
+    iPairingCancelledByUser = EFalse;
+    iTrustDevice = EFalse;
     }
 
 // ---------------------------------------------------------------------------
@@ -132,31 +134,59 @@
 void CBTNotifBasePairingHandler::ShowPairingResultNoteL(TInt aResult)
     {
     BOstraceFunctionEntry0( DUMMY_DEVLIST );
-    CBluetoothNotification* notification = 
+    iNotification = 
             iParent.ConnectionTracker().NotificationManager()->GetNotification();
-    User::LeaveIfNull( notification ); // For OOM exception, leaves with KErrNoMemory
+    User::LeaveIfNull( iNotification ); // For OOM exception, leaves with KErrNoMemory
     TBTDialogResourceId resourceId = EPairingSuccess;
     if(KErrNone != aResult)
         {
         resourceId = EPairingFailureOk;
+        iNotification->SetNotificationType( TBluetoothDialogParams::EQuery, resourceId );
         }
-    notification->SetNotificationType( TBluetoothDialogParams::ENote, resourceId );
+    else
+        {
+        iNotification->SetNotificationType( TBluetoothDialogParams::ENote, resourceId );
+        }
+    
     const CBtDevExtension* dev = iParent.BTDevRepository().Device(iAddr);
     if(dev)
         {
-        User::LeaveIfError(notification->SetData( TBluetoothDeviceDialog::EDeviceName, dev->Alias()));
-        User::LeaveIfError(notification->SetData( TBluetoothDeviceDialog::EDeviceClass, dev->Device().DeviceClass().DeviceClass()));
+        User::LeaveIfError(iNotification->SetData( TBluetoothDeviceDialog::EDeviceName, dev->Alias()));
+        User::LeaveIfError(iNotification->SetData( TBluetoothDeviceDialog::EDeviceClass, dev->Device().DeviceClass().DeviceClass()));
         }
     else
         {
         TBTDeviceName name;
         iAddr.GetReadable(name);
-        User::LeaveIfError(notification->SetData( TBluetoothDialogParams::EAddress, name ));
-        User::LeaveIfError(notification->SetData( TBluetoothDeviceDialog::EDeviceClass, 0)); // No device class
+        User::LeaveIfError(iNotification->SetData( TBluetoothDialogParams::EAddress, name ));
+        User::LeaveIfError(iNotification->SetData( TBluetoothDeviceDialog::EDeviceClass, 0)); // No device class
         }
-    iParent.ConnectionTracker().NotificationManager()->QueueNotificationL( notification);
+    iParent.ConnectionTracker().NotificationManager()->QueueNotificationL( iNotification);
     BOstraceFunctionExit0( DUMMY_DEVLIST );
     }
 
+// ---------------------------------------------------------------------------
+// The notifier can call this function to inform the handler
+// when the pairing is cancelled by the user. This is used
+// to decide if a pairing fails dialog must be displayed or not
+// ---------------------------------------------------------------------------
+//
+void CBTNotifBasePairingHandler::PairingCancelledByUser()
+    {
+    iPairingCancelledByUser = ETrue;
+    }
+
+// ---------------------------------------------------------------------------
+// The notifier call this function whenever the trust checkbox is checked
+// in the accept pairing dialog.
+// This is needed because we want to trust the device only when pairing
+// is successfull.
+// ---------------------------------------------------------------------------
+//
+void CBTNotifBasePairingHandler::SetTrusted()
+    {
+    iTrustDevice = ETrue;
+    }
+
 
 
--- a/bluetoothengine/btnotif/btnotifsrv/src/btnotifdeviceselector.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btnotifsrv/src/btnotifdeviceselector.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -25,8 +25,10 @@
 #include "btnotifserver.h"
 #include "btnotificationmanager.h"
 #include "btnotifclientserver.h"
+
 // Key description length
 const TInt KMaxKeyDesCLength  = 20;
+const TInt KLastUsedDevices = 5;
 
 // ======== MEMBER FUNCTIONS ========
 
@@ -80,7 +82,6 @@
     iDevices.ResetAndDestroy();
     iDevices.Close();
     delete iDiscoverer;
-    
     }
 
 // ---------------------------------------------------------------------------
@@ -131,15 +132,14 @@
             if(iServer.DevRepository().IsInitialized())
                 {
                 iLoadDevices = ETrue;
+                iDevices.ResetAndDestroy();
                 if(iServer.DevRepository().AllDevices().Count()==0)
                      {
                      PrepareNotificationL(TBluetoothDialogParams::EDeviceSearch, ENoResource);
-                     iDevices.ResetAndDestroy();
                      iDiscoverer->DiscoverDeviceL();
                      }
                 else
                      {
-                     iDevices.ResetAndDestroy();
                      PrepareNotificationL(TBluetoothDialogParams::EMoreDevice, ENoResource);
                      LoadUsedDevicesL();
                      }
@@ -180,15 +180,10 @@
 
         if ( !iMessage.IsNull() )
             {
-           // TInt sel = val;// - TBluetoothDialogParams::EDialogExt;
             TBTDeviceResponseParamsPckg devParams;    
             if (  val > -1 && val < iDevices.Count() )
                 {
                 TRAP(err,SendSelectedDeviceL(aData));
-             /*   devParams().SetDeviceAddress( iDevices[val]->Addr() );
-                devParams().SetDeviceClass(iDevices[val]->Device().DeviceClass());
-                devParams().SetDeviceName(iDevices[val]->Alias());
-                err = iMessage.Write( EBTNotifSrvReplySlot, devParams );*/
                 iNotification->RemoveObserver();
                 iNotification->Close(); // Also dequeues the notification from the queue.
                 iNotification = NULL;                
@@ -241,11 +236,6 @@
 void CBTNotifDeviceSelector::HandleNextDiscoveryResultL( 
         const TInquirySockAddr& aAddr, const TDesC& aName )
     {
-    // Todo: look for this device in repository before creating it.
-    TBuf<KBTDevAddrSize * 2> addr; 
-    
-    
-    
     CBtDevExtension* devext = GetDeviceFromRepositoryL(aAddr.BTAddr());
     
     if(!devext)
@@ -263,41 +253,7 @@
         {// conditional check required as CAdvanceDevDiscoverer sends discovered devices at times
          // even after canceldiscovery is issued and notification is set to NULL
          // this causes EExcDataAbort
-    CHbSymbianVariantMap* map = iNotification->Data();
-/*    TBuf<KMaxKeyDesCLength> keyStr;
-    CHbSymbianVariant* devEntry;
-
-    keyStr.Num( TBluetoothDialogParams::EDialogExt + iDevices.Count() - 1 );
-    devEntry = CHbSymbianVariant::NewL( (TAny*) &(devext->Alias()), 
-            CHbSymbianVariant::EDes );
-    map->Add( keyStr, devEntry );*/
-    
-    User::LeaveIfError(iNotification->SetData(TBluetoothDeviceDialog::EDeviceName,
-            devext->Alias()));
-    
-    devext->Addr().GetReadable(addr);
-    User::LeaveIfError(iNotification->SetData(TBluetoothDialogParams::EAddress,addr));
-    
-    TInt classOfDevice;
-    classOfDevice =  devext->Device().DeviceClass().DeviceClass();
-    User::LeaveIfError(iNotification->SetData(TBluetoothDeviceDialog::EDeviceClass,classOfDevice));
-
-    TBool status;
-    status = isBonded( devext->Device());
-    
- //   setMajorProperty(majorProperty, _L("Bonded"), isBonded( devArray[i]->Device() ));
-    AddDataL(map,_L("Bonded"),&status,CHbSymbianVariant::EBool);
-    status = devext->Device().GlobalSecurity().Banned();
-    AddDataL(map,_L("Blocked"),&status,
-            CHbSymbianVariant::EBool);
-    status = devext->Device().GlobalSecurity().NoAuthorise();
-    AddDataL(map,_L("Trusted"),&status,
-            CHbSymbianVariant::EBool);
-    status = devext->ServiceConnectionStatus() == EBTEngConnected;
-    AddDataL(map,_L("Connected"),&status,
-            CHbSymbianVariant::EBool);
- 
-    iNotification->Update();
+        LoadDeviceDetailsL(*devext);
         }
     }
 
@@ -338,16 +294,15 @@
     if(!iLoadDevices)
         {
         iLoadDevices = ETrue;
+        iDevices.ResetAndDestroy();
         if(iServer.DevRepository().AllDevices().Count()==0)
              {
-             iDevices.ResetAndDestroy();
              TRAP(err, {
              PrepareNotificationL(TBluetoothDialogParams::EDeviceSearch, ENoResource);
              iDiscoverer->DiscoverDeviceL(); } );
              }
         else
              {
-             iDevices.ResetAndDestroy();
              TRAP( err, 
                      {PrepareNotificationL(
                              TBluetoothDialogParams::EMoreDevice, ENoResource);
@@ -410,73 +365,120 @@
 void CBTNotifDeviceSelector::LoadUsedDevicesL()
     {
     const RDevExtensionArray& devArray= iServer.DevRepository().AllDevices();
-    TBuf<KBTDevAddrSize * 2> addr; 
     for(TInt i=0; i< devArray.Count(); i++ )
         {
-      const TTime& usedTime = devArray[i]->Device().Used();
-        TTime monthBack;
-        monthBack.HomeTime();
-        monthBack -= TTimeIntervalDays(30);
-        if(usedTime >= monthBack)
-            {
-            iDevices.AppendL( devArray[i]->CopyL() );
-            CHbSymbianVariantMap* map = iNotification->Data();
- //           TBuf<KMaxKeyDesCLength> keyStr;
- //           CHbSymbianVariant* devEntry;
+        iDevices.AppendL( devArray[i]->CopyL() );
+        }
+        SortUsedDevicesL();
+        RemoveUnWantedDevices();
+        SendLastUsedDevicesL();
+        SendPairedDevicesL();
+        
+    }
+
 
-  //          keyStr.Num( TBluetoothDialogParams::EDialogExt + iDevices.Count() - 1 );
-//            devEntry = CHbSymbianVariant::NewL( (TAny*) &(devArray[i]->Alias()), 
-  //                  CHbSymbianVariant::EDes );
-  //          map->Add( keyStr, devEntry, );
-            User::LeaveIfError(iNotification->SetData(TBluetoothDeviceDialog::EDeviceName,
-                    devArray[i]->Alias()));
-//            AddDataL(map,keyStr,&(devArray[i]->Alias()),CHbSymbianVariant::EDes);
-            devArray[i]->Addr().GetReadable(addr);
-            User::LeaveIfError(iNotification->SetData(TBluetoothDialogParams::EAddress,addr));
-            addr.Zero();
-            TInt classOfDevice;
-            classOfDevice =  devArray[i]->Device().DeviceClass().DeviceClass();
-            User::LeaveIfError(iNotification->SetData(TBluetoothDeviceDialog::EDeviceClass,classOfDevice));
-            
-            TBool status;
-            status = isBonded( devArray[i]->Device());
-            
-         //   setMajorProperty(majorProperty, _L("Bonded"), isBonded( devArray[i]->Device() ));
-            AddDataL(map,_L("Bonded"),&status,CHbSymbianVariant::EBool);
-            status = devArray[i]->Device().GlobalSecurity().Banned();
-            AddDataL(map,_L("Blocked"),&status,
-                    CHbSymbianVariant::EBool);
-            status = devArray[i]->Device().GlobalSecurity().NoAuthorise();
-            AddDataL(map,_L("Trusted"),&status,
-                    CHbSymbianVariant::EBool);
-            status = devArray[i]->ServiceConnectionStatus() == EBTEngConnected;
-            AddDataL(map,_L("Connected"),&status,
-                    CHbSymbianVariant::EBool);
-             // set blocked status:
-/*             setMajorProperty(majorProperty, BtuiDevProperty::Blocked, 
-                     devArray[i]->Device().GlobalSecurity().Banned() );
-             // set trusted status:
-             setMajorProperty(majorProperty, BtuiDevProperty::Trusted, 
-                     devArray[i]->Device().GlobalSecurity().NoAuthorise() );
-             // set connected status:
-             // EBTEngConnecting is an intermediate state between connected and not-connected, 
-             // we do not treat it as connected:         
-             setMajorProperty(majorProperty, BtuiDevProperty::Connected, devArray[i]->ServiceConnectionStatus() == EBTEngConnected);
+void CBTNotifDeviceSelector::SortUsedDevicesL() 
+    { 
+    TInt count  = iDevices.Count();
+    for(TInt i=0;i<(count-1);i++) 
+        {
+        for(TInt j=0;j<(count-(i+1));j++)
+            {
+            if(iDevices[j]->Device().Used().Int64() < iDevices[j+1]->Device().Used().Int64())
+                {
+                CBtDevExtension* devextension = iDevices[j+1];
+                iDevices.Remove(j+1);
+                iDevices.InsertL(devextension,j);
+                }
+            }
+        }
+    } 
+
 
-  */          
-
- //           AddDataL(map,keyStr,&(devArray[i]->Alias()),CHbSymbianVariant::EDes);
-            iNotification->Update();
+void CBTNotifDeviceSelector::RemoveUnWantedDevices()
+    {
+    for(TInt i=(iDevices.Count()-1);i>-1;i--)
+        {
+        TInt classOfDevice = iDevices[i]->Device().DeviceClass().DeviceClass();
+        TBTDeviceClass codClass = TBTDeviceClass( classOfDevice );
+        TUint8 majorDevCls = codClass.MajorDeviceClass();
+        if((majorDevCls ==EMajorDeviceComputer)|| (majorDevCls ==EMajorDevicePhone))
+            {
+            }
+        else
+            {
+            CBtDevExtension* devextension = iDevices[i];
+            iDevices.Remove(i);
+            delete devextension;
+            devextension = NULL;
+            iDevices.Compress();
             }
         }
     }
 
+void CBTNotifDeviceSelector::SendLastUsedDevicesL()
+    {
+    TInt Count = iDevices.Count();
+    if(Count > KLastUsedDevices)
+        Count = KLastUsedDevices;
+    for(TInt i=0;i < Count;i++)
+        {
+        LoadDeviceDetailsL(*(iDevices[i]));
+        }
+    }
 
 
+void CBTNotifDeviceSelector::SendPairedDevicesL()
+    {
+    TInt count = iDevices.Count();
+    if(count > KLastUsedDevices)
+        {
+        for(TInt i = KLastUsedDevices; i< count; i++)
+            {
+            if(isBonded( iDevices[i]->Device()))
+                {
+                LoadDeviceDetailsL(*(iDevices[i]));
+                }
+            }
+        }
+        
+    }
+
+void CBTNotifDeviceSelector::LoadDeviceDetailsL(const CBtDevExtension& aDevice)
+    {
+    TBuf<KBTDevAddrSize * 2> addr;
+    TUint32 classOfDevice;
+    TBool status;
+
+    //TODO Need to create string constants Also try Enum value for device name rather 
+    //than hadrdcoded string for key. It was not working previously
+    CHbSymbianVariantMap* map = iNotification->CreateNotificationDataL();
+    AddDataL(map,_L("Name"),(TAny*) &(aDevice.Alias()),CHbSymbianVariant::EDes);
+    
+    aDevice.Addr().GetReadable(addr);
+    User::LeaveIfError(iNotification->SetData(TBluetoothDeviceDialog::EAddress,addr));
+    
+    classOfDevice =  aDevice.Device().DeviceClass().DeviceClass();
+    User::LeaveIfError(iNotification->SetData(TBluetoothDeviceDialog::EDeviceClass,classOfDevice));
+    
+    status = isBonded( aDevice.Device());
+    AddDataL(map,_L("Bonded"),&status,CHbSymbianVariant::EBool);
+    
+    status = aDevice.Device().GlobalSecurity().Banned();
+    AddDataL(map,_L("Blocked"),&status,CHbSymbianVariant::EBool);
+    
+    status = aDevice.Device().GlobalSecurity().NoAuthorise();
+    AddDataL(map,_L("Trusted"),&status,CHbSymbianVariant::EBool);
+    
+    status = aDevice.ServiceConnectionStatus() == EBTEngConnected;
+    AddDataL(map,_L("Connected"),&status,CHbSymbianVariant::EBool);
+    iNotification->Update();
+    }
+
 /*!
   Tells if the given device is bonded.
 */
-TBool CBTNotifDeviceSelector::isBonded( const CBTDevice &dev )
+TBool CBTNotifDeviceSelector::isBonded( const CBTDevice &dev ) const
 {
     // todo: this has not addresses Just Works pairing mode yet.
     return dev.IsValidPaired() && dev.IsPaired() &&
@@ -512,20 +514,11 @@
         return devArray[pos]->CopyL();
         }
     return NULL;
-/*    addrSymbianToReadbleString( addrStr, addr );
-    for (int i = 0; i < mData.count(); ++i ) {
-        if ( mData.at( i ).value( BtDeviceModel::ReadableBdaddrRole ) 
-                == addrStr ) {
-            return i;
-        }
-    }
-    return -1;*/
 }
 
 
 void CBTNotifDeviceSelector::SendSelectedDeviceL( CHbSymbianVariantMap& aData )
     {
-    TInt err; 
     TBTDeviceResponseParamsPckg devParams;
     TBTDevAddr address; 
     User::LeaveIfError(address.SetReadable(
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btnotif/btnotifsrv/src/btnotifgeninfonotifier.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,220 @@
+/*
+* Copyright (c) 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: 
+*
+*/
+
+#include <e32base.h>
+#include <hb/hbcore/hbdevicedialogsymbian.h>
+#include <btnotif.h>
+#include <btservices/btdevextension.h>
+#include <btservices/btdevrepository.h>
+#include "btnotifgeninfonotifier.h"
+
+#include "btnotifserver.h"
+#include "btnotifclientserver.h"
+#include "bluetoothnotification.h"
+#include "btnotificationmanager.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// C++ default constructor
+// ---------------------------------------------------------------------------
+//
+CBTNotifGenInfoNotifier::CBTNotifGenInfoNotifier( CBTNotifServer* aServer )
+:   iServer( aServer )
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// Symbian 2nd-phase constructor
+// ---------------------------------------------------------------------------
+//
+void CBTNotifGenInfoNotifier::ConstructL()
+    {
+    }
+
+// ---------------------------------------------------------------------------
+// NewL.
+// ---------------------------------------------------------------------------
+//
+CBTNotifGenInfoNotifier* CBTNotifGenInfoNotifier::NewL( CBTNotifServer* aServer )
+    {
+    CBTNotifGenInfoNotifier* self = new( ELeave ) CBTNotifGenInfoNotifier( aServer );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CBTNotifGenInfoNotifier::~CBTNotifGenInfoNotifier()
+    {
+    if( iNotification )
+        {
+        // Clear the notification callback, we cannot receive them anymore.
+        iNotification->RemoveObserver();
+        iNotification->Close(); // Also dequeues the notification from the queue.
+        iNotification = NULL;
+        }
+    }
+
+// ---------------------------------------------------------------------------
+// Process a client message related to notifiers.
+// ---------------------------------------------------------------------------
+//
+void CBTNotifGenInfoNotifier::HandleNotifierRequestL( const RMessage2& aMessage )
+    {
+    BOstraceFunctionEntryExt ( DUMMY_LIST, this, aMessage.Function() );
+    TInt opcode = aMessage.Function();
+    TInt uid = aMessage.Int0();
+    TInt err = KErrNone;
+    switch ( opcode ) 
+        {
+        case EBTNotifCancelNotifier:
+            {
+            aMessage.Complete( err );
+            break;
+            }
+        case EBTNotifUpdateNotifier:
+            {
+            aMessage.Complete( err );
+            break;
+            }
+        case EBTNotifStartSyncNotifier:
+            {
+            TRAP(err,ShowNotificationL(aMessage));
+            aMessage.Complete( err );
+            break;
+            }
+        case EBTNotifStartAsyncNotifier:
+            {
+            TRAP(err,ShowNotificationL(aMessage));
+            aMessage.Complete( err );
+            break;
+            }
+        default:
+            {
+            aMessage.Complete( KErrNotSupported );
+            }
+        }
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
+    }
+
+// ---------------------------------------------------------------------------
+// From class MBTNotificationResult.
+// Handle a result from a user query.
+// ---------------------------------------------------------------------------
+//
+void CBTNotifGenInfoNotifier::MBRDataReceived( CHbSymbianVariantMap& aData )
+    {
+    (void) aData;
+    }
+
+
+// ---------------------------------------------------------------------------
+// From class MBTNotificationResult.
+// The notification is finished.
+// ---------------------------------------------------------------------------
+//
+void CBTNotifGenInfoNotifier::MBRNotificationClosed( TInt aError, const TDesC8& aData  )
+    {
+    (void) aError;
+    (void) aData;
+    iNotification->RemoveObserver();
+    iNotification = NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// Get and configure a notification.
+// ---------------------------------------------------------------------------
+//
+void CBTNotifGenInfoNotifier::ShowNotificationL(const RMessage2& aMessage )
+    {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
+    if(iNotification)
+        {
+        iNotification->RemoveObserver();
+        iNotification = NULL;
+        }
+    iNotification = iServer->NotificationManager()->GetNotification();
+    User::LeaveIfNull( iNotification ); // For OOM exception, leaves with KErrNoMemory
+    iNotification->SetObserver( this );
+    iNotification->SetNotificationType( TBluetoothDialogParams::ENote, EGenericInfo );
+    
+    // read the message parameters
+    RBuf8 params;
+    params.CreateL( aMessage.GetDesLengthL( EBTNotifSrvParamSlot ) );
+    aMessage.ReadL( EBTNotifSrvParamSlot, params );
+    TBTGenericInfoNotifierParams notifparams;
+    TPckgC<TBTGenericInfoNotifierParams> paramsPckg( notifparams );
+    paramsPckg.Set( params );
+    TInt notifType = paramsPckg().iMessageType;
+    
+    switch(notifType)
+        {
+        case EBTSwitchedOn:
+        case EBTSwitchedOff:
+            {
+            User::LeaveIfError(iNotification->SetData( TBluetoothDeviceDialog::EAdditionalInt, notifType));
+            }break;
+            
+        default:
+            {
+            TBTDevAddr addr(paramsPckg().iRemoteAddr);
+
+            // Get the device name
+            TInt err = KErrNone;
+
+            const CBtDevExtension* dev = iServer->DevRepository().Device(addr);
+            if(dev)
+                {
+                if(0 != dev->Device().FriendlyName().Length()&& dev->Device().IsValidFriendlyName())
+                    {
+                    // If we have a friendly name use it for the UI
+                    err = iNotification->SetData( TBluetoothDeviceDialog::EDeviceName, dev->Device().FriendlyName() );
+                    }
+                else
+                    {
+                    err = iNotification->SetData( TBluetoothDeviceDialog::EDeviceName, dev->Alias() );
+                    }
+                if(!err)
+                    {
+                    err = iNotification->SetData( TBluetoothDeviceDialog::EDeviceClass, dev->Device().DeviceClass().DeviceClass());
+                    }
+                }
+            else
+                {
+                TBTDeviceName name;
+                addr.GetReadable(name);
+                err = iNotification->SetData( TBluetoothDeviceDialog::EDeviceName, name);
+                }
+            if(!err)
+                {
+                err = iNotification->SetData( TBluetoothDeviceDialog::EAdditionalInt, notifType);
+                }
+            }break;
+        }
+    
+    iServer->NotificationManager()->QueueNotificationL( iNotification,CBTNotificationManager::EPriorityHigh );
+    params.Close();
+    BOstraceFunctionExit0( DUMMY_DEVLIST );
+    }
+
+
--- a/bluetoothengine/btnotif/btnotifsrv/src/btnotifincomingpairinghandler.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btnotifsrv/src/btnotifincomingpairinghandler.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -22,6 +22,7 @@
 #include "bluetoothtrace.h"
 
 const TInt KBTNotifWaitingForPairingOkDelay = 500000; // 0.5s
+const TInt KBTNotif10SecondTimer = 10000000;
 
 enum TPairingStageId
     {
@@ -156,6 +157,11 @@
         {
         // Pair failure situation.
         SetPairResult( aResult );
+        TRAPD(err , ShowPairingResultNoteL(KErrGeneral));
+        if(!err && iNotification)
+            {
+            iNotification->SetCloseTimer(KBTNotif10SecondTimer);
+            }
         }
     BOstraceFunctionExit0( DUMMY_DEVLIST );
     }
@@ -175,6 +181,11 @@
         iActivePairingOk->Cancel();
         UnSetPairResult();  // we might have set it before (if the link went down) so we want to reset it.   
         }
+    // If the user checked the trusted checkbox then we trust the device
+    if(iTrustDevice)
+        {
+        iParent.TrustDevice(iAddr);
+        }
     if (aDev.LinkKeyType() == ELinkKeyUnauthenticatedNonUpgradable && !iUserAwarePairing)
 		{
 		// If an application uses btengconnman API to connect a service of 
@@ -245,6 +256,11 @@
                 // it has been reset. But we need to have it set to an error as we are notifying 
                 // the "unable to pair" message.
                 SetPairResult(KErrGeneral);
+                TRAPD(err , ShowPairingResultNoteL(KErrGeneral));
+                if(!err && iNotification)
+                    {
+                    iNotification->SetCloseTimer(KBTNotif10SecondTimer);
+                    }
                 }
             iParent.RenewPairingHandler( NULL );
             break;
--- a/bluetoothengine/btnotif/btnotifsrv/src/btnotifoutgoingpairinghandler.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btnotifsrv/src/btnotifoutgoingpairinghandler.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -85,6 +85,7 @@
 CBTNotifOutgoingPairingHandler::CBTNotifOutgoingPairingHandler( CBTNotifSecurityManager& aParent, const TBTDevAddr& aAddr)
     :  CBTNotifBasePairingHandler( aParent, aAddr )
     {
+    iDialogIsOrphan = EFalse;
     }
 
 // ---------------------------------------------------------------------------
@@ -125,13 +126,18 @@
     iBondingSession.Close();
     iSocket.Close();
     iTimer.Close();
-    if( iNotification )
+    if( iNotification && !iDialogIsOrphan)
         {
         // Clear the notification callback, we cannot receive them anymore.
         iNotification->RemoveObserver();
         iNotification->Close(); // Also dequeues the notification from the queue.
         iNotification = NULL;
         }
+    if( iNotification && iDialogIsOrphan)
+        {
+        // Clear the notification callback, we cannot receive them anymore.
+        iNotification->RemoveObserver();
+        }
     }
 
 // ---------------------------------------------------------------------------
@@ -179,15 +185,8 @@
 void CBTNotifOutgoingPairingHandler::CancelOutgoingPair()
     {
     BOstraceFunctionEntry0( DUMMY_DEVLIST );
+    ShowPairingFailureDialog();
     iParent.RenewPairingHandler( NULL );
-    if( iNotification )
-        {
-        // Cancel the user query
-        // This will also unregister us from the notification.
-        TInt err = iNotification->Close();
-        NOTIF_NOTHANDLED( !err )
-        iNotification = NULL;
-        }
     }
 
 
@@ -207,7 +206,7 @@
         {
         // if the pairing requires a stronger security level (indicated
         // by aMinPinLength), 
-        // 0000 will not be supplied as it does not mmet the security
+        // 0000 will not be supplied as it does not meet the security
         // requirements
         const TUint8 KZeroPinValue = '0';
         for (TInt i = 0; i < KDefaultHeadsetPinLength; ++i)
@@ -229,14 +228,6 @@
         {
         iParent.OutgoingPairCompleted( KErrCancel );
         iParent.RenewPairingHandler( NULL );
-        if( iNotification )
-            {
-            // Cancel the user query
-            // This will also unregister us from the notification.
-            TInt err = iNotification->Close();
-            NOTIF_NOTHANDLED( !err )
-            iNotification = NULL;
-            }
         }
     }
 
@@ -252,6 +243,9 @@
 		// if EPairingNotAllowed is recieved then any further pairing attempts will fail
 		// so don't attampt to pair
         iPairMode = EBTOutgoingPairNone;
+        ShowPairingFailureDialog();
+        iParent.OutgoingPairCompleted( aResult );
+        iParent.RenewPairingHandler( NULL );
 		}
     }
 
@@ -275,9 +269,15 @@
         }
     iActive->Cancel();
     SetPairResult( err ? err : KErrNone );
-    if(err == KErrNone){
-    TRAP_IGNORE(ShowPairingResultNoteL(err));
-    }
+    if(err == KErrNone)
+	    {
+        // Trust the device
+        if(iTrustDevice)
+		    {
+            iParent.TrustDevice(iAddr);
+            }
+        TRAP_IGNORE(ShowPairingResultNoteL(err));
+        }
     iParent.OutgoingPairCompleted( err );
     iParent.RenewPairingHandler( NULL );
     }
@@ -292,7 +292,8 @@
         CBtSimpleActive* aActive, TInt aStatus )
     {
     BOstraceFunctionEntry0( DUMMY_DEVLIST );
-    BOstraceExt3(TRACE_DEBUG,DUMMY_DEVLIST,"reqid %d, status: %d, pair mode %d ", aActive->RequestId(), aStatus, iPairMode);
+    BOstraceExt3(TRACE_DEBUG,DUMMY_DEVLIST,"reqid %d, status: %d, pair mode %d ", aActive->RequestId(), 
+            aStatus, iPairMode);
     if( aActive->RequestId() == EDedicatedBonding && 
 				( aStatus == KErrRemoteDeviceIndicatedNoBonding || 
 					( aStatus && iPairMode != EBTOutgoingNoneHeadsetPairing && iPairMode != EBTOutgoingPairNone ) )   )
@@ -329,10 +330,10 @@
             {
             SetPairResult( aStatus );
             }
-        if ( aStatus )
+        if ( aStatus <= KHCIErrorBase - EUnknownOpcode)
             {
             // retry pairing
-            if(aStatus && iPairingAttempt > 0)
+            if(iPairingAttempt > 0)
                 {
                 if(aActive->RequestId() == EGeneralBondingRetry && iPairMode == EBTOutgoingHeadsetManualPairing)
                     {
@@ -345,9 +346,17 @@
             else
                 {
                 iPairingAttempt --;
+                iParent.OutgoingPairCompleted( aStatus );
                 ShowPairingFailureDialog();
+                iParent.RenewPairingHandler( NULL );
                 }
              }
+        else
+            {
+            iParent.OutgoingPairCompleted( aStatus );
+            ShowPairingFailureDialog();
+            iParent.RenewPairingHandler( NULL );
+            }
         }
     }
 
@@ -394,14 +403,6 @@
     (void) aActive;
     iParent.OutgoingPairCompleted( aError );
     iParent.RenewPairingHandler( NULL );
-    if( iNotification )
-        {
-        // Cancel the user query
-        // This will also unregister us from the notification.
-        TInt err = iNotification->Close();
-        NOTIF_NOTHANDLED( !err )
-        iNotification = NULL;
-        }
     }
 
 // ---------------------------------------------------------------------------
@@ -546,7 +547,11 @@
 //
 void CBTNotifOutgoingPairingHandler::ShowPairingFailureDialog()
     {
-    PrepareNotificationL( TBluetoothDialogParams::EQuery, EPairingFailureOk );
+    if(!iPairingCancelledByUser)
+        {
+        iDialogIsOrphan = ETrue;
+        PrepareNotificationL( TBluetoothDialogParams::EQuery, EPairingFailureOk );
+        }
     }
 
 
--- a/bluetoothengine/btnotif/btnotifsrv/src/btnotifpairnotifier.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btnotifsrv/src/btnotifpairnotifier.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -26,6 +26,7 @@
 #include "btnotificationmanager.h"
 #include "bluetoothnotification.h"
 #include "btnotifserver.h"
+#include "btnotifbasepairinghandler.h"
 #include "bluetoothtrace.h"
 
 
@@ -114,26 +115,30 @@
         User::Leave(KErrServerBusy );
         }
     
-    if(opCode == EBTNotifCancelNotifier){
+    if(opCode == EBTNotifCancelNotifier)
+        {
         CancelPairingNotifierL(uid);
         aMessage.Complete(KErrNone);
         return;
-    }
+        }
     
-    // Store the parameters locally, we need them later again.
-    iParams.CreateL( aMessage.GetDesLengthL( EBTNotifSrvParamSlot ) );
-    aMessage.ReadL( EBTNotifSrvParamSlot, iParams );
-    iNotifierMessage = aMessage;
-    
-    // Read the notifier parameters
-    ParseNotifierReqParamsL();
+    if(opCode != EBTNotifUpdateNotifier)
+        {
+        // Store the parameters locally, we need them later again.
+        iParams.CreateL( aMessage.GetDesLengthL( EBTNotifSrvParamSlot ) );
+        aMessage.ReadL( EBTNotifSrvParamSlot, iParams );
+        iNotifierMessage = aMessage;
+        // Read the notifier parameters
+        ParseNotifierReqParamsL();
+        }
 
-    if(opCode ==EBTNotifUpdateNotifier ){
-        UpdatePairingNotifierL(uid,iParams);
+    if(opCode ==EBTNotifUpdateNotifier )
+        {
+        UpdatePairingNotifierL(aMessage);
         aMessage.Complete(KErrNone);
         return;
-    }
-    
+        }
+ 
     const CBtDevExtension* dev = iParent.BTDevRepository().Device(iRemote);
     if(dev)
         {
@@ -182,8 +187,7 @@
         }
     else
         {
-        TInt uid = iNotifierMessage.Int0();
-        if(uid == KBTNumericComparisonNotifierUid.iUid)
+        if(uid == KBTNumericComparisonNotifierUid.iUid || uid == KBTPasskeyDisplayNotifierUid.iUid)
             {
             StartPairingUserInputL();
             }
@@ -220,23 +224,34 @@
 // is currently being served.
 // ---------------------------------------------------------------------------
 //
-void CBTNotifPairNotifier::UpdatePairingNotifierL( TInt aUid, const TDesC8& aParams )
+void CBTNotifPairNotifier::UpdatePairingNotifierL( const RMessage2& aMessage )
     {
     BOstraceFunctionEntry0( DUMMY_DEVLIST );
-    (void) aUid;
+    RBuf8 msgParams;
+    msgParams.CreateL( aMessage.GetDesLengthL( EBTNotifSrvParamSlot ) );
+    aMessage.ReadL( EBTNotifSrvParamSlot, msgParams );
     TBTNotifierUpdateParams2 params;    // Enough for reading the base class type parameter
     TPckgC<TBTNotifierUpdateParams2> paramsPckg( params );
-    paramsPckg.Set( aParams );
+    paramsPckg.Set( msgParams );
     if( paramsPckg().Type() == TBTNotifierUpdateParams2::EPasskeyDisplay )
         {
         // Paskey display update - keypress on remote device.
+        TBTPasskeyDisplayUpdateParams keyUpdate;
+        TPckgC<TBTPasskeyDisplayUpdateParams> keyUpdatePckg( keyUpdate );
+        keyUpdatePckg.Set(msgParams);
+        THCIPasskeyEntryNotificationType keyType = keyUpdatePckg().KeypressNotification();
+        if( iNotification )
+            {
+            // Update the dialog
+            iNotification->Update(keyType);
+            }        
         }
     else
         {
         // name update
         TBTDeviceNameUpdateParams nameUpdate;
         TPckgC<TBTDeviceNameUpdateParams> nameUpdatePckg( nameUpdate );
-        nameUpdatePckg.Set( aParams );
+        nameUpdatePckg.Set( msgParams );
         // The result means result of conversion to unicode
         if( !nameUpdatePckg().Result() )
             {
@@ -246,14 +261,17 @@
                 {
                 if(0 != dev->Device().FriendlyName().Length()&& dev->Device().IsValidFriendlyName())
                     {
-                    return;
+                    iCurrentDeviceName = dev->Device().FriendlyName();
                     }
-                // We don't have a friendly name then use this name
-                iCurrentDeviceName = nameUpdatePckg().DeviceName();
-                if(0 == iCurrentDeviceName.Length())
+                else
                     {
-                    // The new name is empty then use the Alias
-                    iCurrentDeviceName = dev->Alias();
+                    // We don't have a friendly name then use this name
+                    iCurrentDeviceName = nameUpdatePckg().DeviceName();
+                    if(0 == iCurrentDeviceName.Length())
+                        {
+                        // The new name is empty then use the Alias
+                        iCurrentDeviceName = dev->Alias();
+                        }
                     }
                 }
             else
@@ -274,6 +292,7 @@
                 }
             }
         }
+    msgParams.Close();
     BOstraceFunctionExit0( DUMMY_DEVLIST );
     }
 
@@ -383,6 +402,7 @@
         {
         // The returned data is the entered passkey.
         const CBtDevExtension* dev = iParent.BTDevRepository().Device(iRemote);
+
         if(dev)
             {
             iParent.ConnectionTracker().UpdateBlockingHistoryL(&dev->Device(),aResult);
@@ -393,7 +413,7 @@
             userAcceptance() = aResult;
             resultData.Set( userAcceptance );
             }
-        if( aResult )
+         if( aResult )
             {
             if( uid == KBTManPinNotifierUid.iUid 
                 || uid == KBTPinCodeEntryNotifierUid.iUid )
@@ -479,11 +499,10 @@
             }
         if( iAcceptPairingResult )
             {
-            // User accepted, continue to show pairing query.
-            // Trust the device
-            if(iCheckBoxState){
-            iParent.TrustDevice(iRemote);
-            }
+            if(iCheckBoxState)
+                {
+                (iParent.PairingHandler())->SetTrusted();
+                }
             StartPairingUserInputL();
             }
         else
@@ -621,6 +640,7 @@
     paramsPckg.Set( iParams );
     aLocallyInitiated = paramsPckg().LocallyInitiated();
     aNumVal.Format( KPassKeyFormat, paramsPckg().NumericalValue() );
+    aNumVal.Insert(3,_L(" "));
     aAddr = paramsPckg().DeviceAddress();
     iCurrentDeviceName = paramsPckg().DeviceName();
     BOstraceFunctionExit0( DUMMY_DEVLIST );
@@ -681,6 +701,11 @@
     result.Set( aData.Ptr(), result.Length() ); // Read the part containing the result
     // Set a pointer descriptor to capture the remaining data, if any.
     TPtrC8 dataPtr( aData.Mid( result.Length() ) );
+    
+    if(!result())
+        {
+        (iParent.PairingHandler())->PairingCancelledByUser();
+        }
 
     if ( iState == EIncomingPairingAcceptconfirm )
         {
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btnotif/btnotifsrv/src/btnotifpowernotifier.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,257 @@
+/*
+* Copyright (c) 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: Server class for handling commands from clients, and the 
+*                central class in btnotif thread.
+*
+*/
+
+#include <e32base.h>
+#include <hb/hbcore/hbdevicedialogsymbian.h>
+#include <btnotif.h>
+#include "btnotifpowernotifier.h"
+
+#include "btnotifserver.h"
+#include "btnotifclientserver.h"
+#include "bluetoothnotification.h"
+#include "btnotificationmanager.h"
+
+// ======== MEMBER FUNCTIONS ========
+
+// ---------------------------------------------------------------------------
+// C++ default constructor
+// ---------------------------------------------------------------------------
+//
+CBTNotifPowerNotifier::CBTNotifPowerNotifier( CBTNotifServer* aServer )
+:   iServer( aServer ), iTurnBTOn(ETrue)
+    {
+    }
+
+
+// ---------------------------------------------------------------------------
+// Symbian 2nd-phase constructor
+// ---------------------------------------------------------------------------
+//
+void CBTNotifPowerNotifier::ConstructL()
+    {
+    iBTEngSettings = CBTEngSettings::NewL(this);
+    }
+
+// ---------------------------------------------------------------------------
+// NewL.
+// ---------------------------------------------------------------------------
+//
+CBTNotifPowerNotifier* CBTNotifPowerNotifier::NewL( CBTNotifServer* aServer )
+    {
+    CBTNotifPowerNotifier* self = new( ELeave ) CBTNotifPowerNotifier( aServer );
+    CleanupStack::PushL( self );
+    self->ConstructL();
+    CleanupStack::Pop( self );
+    return self;
+    }
+
+// ---------------------------------------------------------------------------
+// Destructor
+// ---------------------------------------------------------------------------
+//
+CBTNotifPowerNotifier::~CBTNotifPowerNotifier()
+    {
+    if( iNotification )
+        {
+        // Clear the notification callback, we cannot receive them anymore.
+        iNotification->RemoveObserver();
+        iNotification->Close(); // Also dequeues the notification from the queue.
+        iNotification = NULL;
+        }
+    delete iBTEngSettings;
+    }
+
+// ---------------------------------------------------------------------------
+// Process a client message related to notifiers.
+// ---------------------------------------------------------------------------
+//
+void CBTNotifPowerNotifier::HandleNotifierRequestL( const RMessage2& aMessage )
+    {
+    BOstraceFunctionEntryExt ( DUMMY_LIST, this, aMessage.Function() );
+    TInt opcode = aMessage.Function();
+    TInt uid = aMessage.Int0();
+    TInt err = KErrNone;
+    switch ( opcode ) 
+        {
+        case EBTNotifCancelNotifier:
+            {
+            aMessage.Complete( err );
+            break;
+            }
+        case EBTNotifUpdateNotifier:
+            {
+            aMessage.Complete( err );
+            break;
+            }
+        case EBTNotifStartSyncNotifier:
+            {
+            TRAP(err,ShowNotificationL(aMessage));
+            if(err)
+                {
+                aMessage.Complete(err);
+                }
+            break;
+            }
+        case EBTNotifStartAsyncNotifier:
+            {
+            TRAP(err,ShowNotificationL(aMessage));
+            if(err)
+                {
+                aMessage.Complete(err);
+                }
+            break;
+            }
+        default:
+            {
+            aMessage.Complete( KErrNotSupported );
+            }
+        }
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
+    }
+
+// ---------------------------------------------------------------------------
+// From class MBTNotificationResult.
+// Handle a result from a user query.
+// ---------------------------------------------------------------------------
+//
+void CBTNotifPowerNotifier::MBRDataReceived( CHbSymbianVariantMap& aData )
+    {
+    if(aData.Keys().MdcaPoint(0).Compare(_L("actionResult")) == 0)
+        {
+        iTurnBTOn = *(static_cast<TInt*>(aData.Get(_L("actionResult"))->Data()));
+        }
+    }
+
+
+// ---------------------------------------------------------------------------
+// From class MBTNotificationResult.
+// The notification is finished.
+// ---------------------------------------------------------------------------
+//
+void CBTNotifPowerNotifier::MBRNotificationClosed( TInt aError, const TDesC8& aData  )
+    {
+    (void) aError;
+    (void) aData;
+
+    if(iTurnBTOn)
+        {
+        //Turn BT on.
+        iBTEngSettings->SetPowerState(EBTPowerOn);
+        }
+    
+    else if ( !iNotifierMessage.IsNull() )
+        {
+        //User choose No. So, complete the request with out turning BT on.
+        iClientResponse() = EFalse;
+        iNotifierMessage.Write(EBTNotifSrvReplySlot, iClientResponse);
+        iNotifierMessage.Complete(KErrNone);
+        }
+    iNotification->RemoveObserver();
+    iNotification = NULL;
+    }
+
+// ---------------------------------------------------------------------------
+// Get and configure a notification.
+// ---------------------------------------------------------------------------
+//
+void CBTNotifPowerNotifier::ShowNotificationL(const RMessage2& aMessage )
+    {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
+    
+    iNotifierMessage = aMessage;
+    
+    if(iNotification)
+        {
+        iNotification->RemoveObserver();
+        iNotification = NULL;
+        }
+    iNotification = iServer->NotificationManager()->GetNotification();
+    User::LeaveIfNull( iNotification ); // For OOM exception, leaves with KErrNoMemory
+    iNotification->SetObserver( this );
+    //iNotification->SetNotificationType( TBluetoothDialogParams::ENote, EGenericInfo );
+    
+    // read the message parameters
+    RBuf8 params;
+    params.CreateL( aMessage.GetDesLengthL( EBTNotifSrvParamSlot ) );
+    aMessage.ReadL( EBTNotifSrvParamSlot, params );
+    TBTGenericInfoNotifierParams notifparams;
+    TPckgC<TBTGenericInfoNotifierParams> paramsPckg( notifparams );
+    paramsPckg.Set( params );
+    TInt notifType = paramsPckg().iMessageType;
+    
+    TCoreAppUIsNetworkConnectionAllowed offLineMode; 
+    TBTEnabledInOfflineMode btEnabled;
+    iBTEngSettings->GetOfflineModeSettings(offLineMode, btEnabled);
+    
+    // Choose user interaction
+    //
+    if ( (btEnabled == EBTEnabledInOfflineMode) && 
+            (offLineMode == ECoreAppUIsNetworkConnectionNotAllowed) )
+        {
+        // Allowed to enable BT in offline mode and device is currently in offline mode.
+        // Launch the offline query notification dialog.
+        iNotification->SetNotificationType( TBluetoothDialogParams::EInformationDialog, EIssueOfflineQuery );
+        iServer->NotificationManager()->QueueNotificationL( iNotification, CBTNotificationManager::EPriorityHigh );
+        }
+    else if(offLineMode == ECoreAppUIsNetworkConnectionAllowed)
+        {
+        //Device not in offline mode, simply turn BT on.
+        iBTEngSettings->SetPowerState(EBTPowerOn);
+        }
+    else
+        {
+        //Return EFalse, indication that BT should not be switched on.
+        if(!iNotifierMessage.IsNull())
+            {
+            iClientResponse() = EFalse;
+            iNotifierMessage.Write(EBTNotifSrvReplySlot, iClientResponse);
+            iNotifierMessage.Complete(KErrNone);
+            }
+        }
+    
+    params.Close();
+    BOstraceFunctionExit0( DUMMY_DEVLIST );
+    }
+
+void CBTNotifPowerNotifier::PowerStateChanged( TBTPowerStateValue aState )
+    {
+    if(!iNotifierMessage.IsNull())
+        {
+        if(aState == EBTPowerOn)
+            {
+            //Request to turn BT on was successful.
+            iClientResponse() = ETrue;
+            iNotifierMessage.Write(EBTNotifSrvReplySlot, iClientResponse);
+            iNotifierMessage.Complete(KErrNone);
+            }
+        else
+            {
+            //Request to turn BT on was not successful.
+            iClientResponse() = EFalse;
+            iNotifierMessage.Write(EBTNotifSrvReplySlot, iClientResponse);
+            iNotifierMessage.Complete(KErrNone);
+            }
+        }
+    }
+
+void CBTNotifPowerNotifier::VisibilityModeChanged( TBTVisibilityMode aState )
+    {
+    (void) aState;    
+    }
+
+
--- a/bluetoothengine/btnotif/btnotifsrv/src/btnotifsecuritymanager.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btnotifsrv/src/btnotifsecuritymanager.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -69,6 +69,7 @@
 //
 void CBTNotifSecurityManager::ConstructL()
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     // Connect to pairing server for authentication & simple pairing 
     // results directly from the BT stack.
     // Pairing server doesn't exist if we run BT 2.0 stack:
@@ -98,6 +99,7 @@
     iPairNotifier = CBTNotifPairNotifier::NewL( *this );
     iDevRepository.AddObserverL( this );
     iServiceAuthorizer = CBTNotifServiceAuthorizer::NewL(*this);
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 // ---------------------------------------------------------------------------
@@ -122,6 +124,7 @@
 //
 CBTNotifSecurityManager::~CBTNotifSecurityManager()
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     delete iSSPResultActive;
     delete iAuthenResultActive;
     delete iPairNotifier;
@@ -142,6 +145,7 @@
         iMessage.Complete( KErrCancel );
         }
     delete iServiceAuthorizer;
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 // ---------------------------------------------------------------------------
@@ -155,6 +159,7 @@
 //
 void CBTNotifSecurityManager::SubscribeLocalAddress()
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     // Check that we have the Bluetooth local address. If we don't then initialise anyway, but subscribe for an update.
     // This allows us to refresh our paired devices list to include updates made to the remote devices table of the 
     // Bluetooth registry from a restore operation. We need to include these devices without mistaking them for new 
@@ -167,6 +172,7 @@
     iPropertyLocalAddr.Subscribe( iLocalAddrActive->iStatus );
     iLocalAddrActive->SetRequestId( ERegistryGetLocalAddress );
     iLocalAddrActive->GoActive();
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 // ---------------------------------------------------------------------------
@@ -202,8 +208,8 @@
 //
 void CBTNotifSecurityManager::HandleBondingRequestL( const RMessage2& aMessage )
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     TInt opcode = aMessage.Function();
-    TBTDevAddrPckgBuf addrPkg;
     switch( opcode )
         {
         case EBTNotifPairDevice:
@@ -236,6 +242,7 @@
             User::Leave( KErrArgument );
             }
         }
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 // ---------------------------------------------------------------------------
@@ -244,6 +251,7 @@
 //
 void CBTNotifSecurityManager::HandleNotifierRequestL( const RMessage2& aMessage )
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     if(aMessage.Int0() == KBTManAuthNotifierUid.iUid)
         {
         iServiceAuthorizer->StartNotifierL( aMessage );
@@ -300,8 +308,10 @@
 void CBTNotifSecurityManager::RenewPairingHandler( 
         CBTNotifBasePairingHandler* aPairingHandler )
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     delete iPairingHandler;
     iPairingHandler = aPairingHandler;
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 // ---------------------------------------------------------------------------
@@ -310,12 +320,14 @@
 //
 void CBTNotifSecurityManager::OutgoingPairCompleted( TInt aErr )
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     // the meaning of KHCIErrorBase equals KErrNone. Hide this specific BT stack
 	// detail from clients:
     if ( !iMessage.IsNull()  )
         {
         iMessage.Complete( (aErr == KHCIErrorBase) ? KErrNone : aErr );
         }
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 // ---------------------------------------------------------------------------
@@ -324,11 +336,13 @@
 //
 void CBTNotifSecurityManager::SessionClosed( CSession2* aSession )
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     BOstrace1(TRACE_DEBUG,DUMMY_DEVLIST," session %x", aSession);
     if ( !iMessage.IsNull() && iMessage.Session() == aSession )
         {
         iMessage.Complete( KErrCancel );
         }
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 // ---------------------------------------------------------------------------
@@ -337,6 +351,7 @@
 //
 void CBTNotifSecurityManager::UnpairDevice( const TBTDevAddr& aAddr )
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     TIdentityRelation<TBTNamelessDevice> addrComp( CompareDeviceByAddress );
     TBTNamelessDevice dev;
     dev.SetAddress( aAddr );
@@ -372,10 +387,12 @@
             (void) UpdateRegDevice( dev );
             }
         }
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 void CBTNotifSecurityManager::BlockDevice( const TBTDevAddr& aAddr , TBool aBanned)
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     TIdentityRelation<TBTNamelessDevice> addrComp( CompareDeviceByAddress );
     TBTNamelessDevice dev;
     dev.SetAddress( aAddr );
@@ -394,10 +411,12 @@
         dev.SetGlobalSecurity(security);
         (void)UpdateRegDevice(dev);
         }
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 TInt CBTNotifSecurityManager::AddUiCookieJustWorksPaired( const TBTNamelessDevice& aDev )
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     TInt err( KErrNone );
     // There might be UI cookies used by other applications,
     // we should not overwrite them. 
@@ -412,6 +431,7 @@
         err = UpdateRegDevice( dev );
         BOstrace1(TRACE_DEBUG,DUMMY_DEVLIST,"Outgoing Pairing write Ui cookie ret %d", err );
         }
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     return err;
     }
 
@@ -421,11 +441,13 @@
 //
 TInt CBTNotifSecurityManager::UpdateRegDevice( const TBTNamelessDevice& aDev )
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     TRequestStatus status( KRequestPending );
     // update the device in registry synchronously
     iRegistry.ModifyDevice( aDev, status );
     User::WaitForRequest( status );
     BOstrace1(TRACE_DEBUG,DUMMY_DEVLIST,"UpdateRegDevice, ret %d", status.Int());
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     return status.Int();
     }
 
@@ -437,6 +459,7 @@
 void CBTNotifSecurityManager::GetPinCode(
         TBTPinCode& aPin, const TBTDevAddr& aAddr, TInt aMinPinLength )
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     if ( iPairingHandler )
         {
         iPairingHandler->GetPinCode( aPin, aAddr, aMinPinLength );
@@ -447,6 +470,7 @@
         aPin.Zero();
         aPin().iLength = 0;
         }
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 // ---------------------------------------------------------------------------
@@ -455,12 +479,14 @@
 //
 TBTEngConnectionStatus CBTNotifSecurityManager::ConnectStatus( const TBTDevAddr& aAddr )
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     const CBtDevExtension* devExt = iDevRepository.Device(aAddr);
     TBTEngConnectionStatus status = EBTEngNotConnected;
     if ( devExt ) 
         {
         status = devExt->ServiceConnectionStatus();
         }
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     return status;
     }
 
@@ -471,6 +497,7 @@
 //
 void CBTNotifSecurityManager::RequestCompletedL( CBtSimpleActive* aActive, TInt aStatus )
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     BOstraceExt2(TRACE_DEBUG,DUMMY_DEVLIST,"aId: %d, aStatus: %d", aActive->RequestId(), aStatus);
     // Check which request is completed.
     switch( aActive->RequestId() )
@@ -510,6 +537,7 @@
             // Should not be possible, but no need for handling.
             break;
         }
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 // ---------------------------------------------------------------------------
@@ -519,6 +547,7 @@
 //
 void CBTNotifSecurityManager::CancelRequest( TInt aRequestId )
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     switch ( aRequestId )
         {
         case ESimplePairingResult:
@@ -540,6 +569,7 @@
             break;
             }
         }
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 // ---------------------------------------------------------------------------
@@ -548,9 +578,11 @@
 //
 void CBTNotifSecurityManager::HandleError( CBtSimpleActive* aActive, TInt aError )
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     BOstraceExt2(TRACE_DEBUG,DUMMY_DEVLIST,"request id: %d, error: %d", aActive->RequestId(), aError);
     (void) aActive;
     (void) aError;
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 // ---------------------------------------------------------------------------
@@ -559,6 +591,7 @@
 //
 void CBTNotifSecurityManager::RepositoryInitialized()
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     TRAPD(err, UpdatePairedDeviceListL() );
     if ( !err && iPairingHandler )
         {
@@ -566,6 +599,7 @@
         // pairing operation already.
         // todo: is some handling for above case needed?
         }
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 // ---------------------------------------------------------------------------
@@ -574,6 +608,7 @@
 //
 void CBTNotifSecurityManager::DeletedFromRegistry( const TBTDevAddr& aAddr )
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     // We are only interested in the removal of a paired device.
     // thus check whether it is in our local paired list:
     TInt i = iPairedDevices.Find( aAddr, MatchDeviceAddress);
@@ -581,6 +616,7 @@
         {
         iPairedDevices.Remove( i );
         }
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 // ---------------------------------------------------------------------------
@@ -589,12 +625,14 @@
 //
 void CBTNotifSecurityManager::AddedToRegistry( const CBtDevExtension& aDevice )
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     // We are only interested in paired device.
     if ( CBtDevExtension::IsBonded( aDevice.Device().AsNamelessDevice() ) )
         {
         TRAP_IGNORE( 
                 HandleRegistryBondingL( aDevice.Device().AsNamelessDevice() ) );
         }
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 
@@ -605,18 +643,22 @@
 void CBTNotifSecurityManager::ChangedInRegistry(
         const CBtDevExtension& aDevice, TUint aSimilarity )
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     // We are only interested in paired device.
     // thus check whether it is in our local paired list:
     TInt i = iPairedDevices.Find( aDevice.Addr(), MatchDeviceAddress);
     TBool bonded = CBtDevExtension::IsBonded( aDevice.Device().AsNamelessDevice() );
     if ( i == KErrNotFound )
         {
+        BOstrace0(TRACE_DEBUG,DUMMY_DEVLIST,"Not found");
         if ( bonded ) 
             {
+            BOstrace0(TRACE_DEBUG,DUMMY_DEVLIST,"Not found but bonded");
             TRAP_IGNORE(
                     HandleRegistryBondingL( 
                             aDevice.Device().AsNamelessDevice() ) );                
             }
+        BOstraceFunctionExit0( DUMMY_DEVLIST);
         return;
         }
     // Device was inregistry before, but we need to evaluate its bonding
@@ -630,13 +672,17 @@
         // no pairing or linkkey change. Nothing to do for pairing handling.
         // but we'd better update local copy just in case other data
         // of this device is needed by someone:
+        BOstrace0(TRACE_DEBUG,DUMMY_DEVLIST,"No pairing or link key change");
         iPairedDevices[i] = aDevice.Device().AsNamelessDevice();
+        BOstraceFunctionExit0( DUMMY_DEVLIST);
         return;
         }
-    if ( !CBtDevExtension::IsBonded( aDevice.Device().AsNamelessDevice() ) )
+    if ( !bonded )
         {
         // device is not user-bonded.
+        UnTrustDevice(iPairedDevices[i].Address());
         iPairedDevices.Remove( i );
+        BOstraceFunctionExit0( DUMMY_DEVLIST);
         return;
         }
     // it is a new paired device if its link-key has been upgraded
@@ -647,6 +693,7 @@
                 HandleRegistryBondingL( 
                         aDevice.Device().AsNamelessDevice() ) );                
         }
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 // ---------------------------------------------------------------------------
@@ -657,8 +704,10 @@
 void CBTNotifSecurityManager::ServiceConnectionChanged(
         const CBtDevExtension& aDevice, TBool aConnected )
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     (void) aDevice;
     (void) aConnected;
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 // ---------------------------------------------------------------------------
@@ -667,6 +716,7 @@
 //
 TInt CBTNotifSecurityManager::SetPairObserver(const TBTDevAddr& aAddr, TBool aActivate)
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     BOstrace1(TRACE_DEBUG,DUMMY_DEVLIST,"%d", aActivate);
     BtTraceBtAddr0(TRACE_DEBUG,DUMMY_DEVLIST, aAddr );
     TInt err( KErrNone );
@@ -676,6 +726,7 @@
             {
             iPairingHandler->StopPairHandling( aAddr );
             }
+        BOstraceFunctionExit0( DUMMY_DEVLIST);
         return err;
         }
     
@@ -691,6 +742,7 @@
         // let the handler decide what to do:
         err = iPairingHandler->ObserveIncomingPair( aAddr );
         }
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     return err;
     }
 
@@ -700,6 +752,7 @@
 //
 void CBTNotifSecurityManager::PairDeviceL( const TBTDevAddr& aAddr, TUint32 aCod )
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     if ( !iPairingHandler)
         {
         // no existing pair handling, create one:
@@ -707,6 +760,7 @@
         }
     // let pair handler decide what to do:
     iPairingHandler->HandleOutgoingPairL( aAddr, aCod );
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 // ---------------------------------------------------------------------------
@@ -716,6 +770,7 @@
 //
 void CBTNotifSecurityManager::CancelSubscribePairingAuthenticate()
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     if( iSSPResultActive )
         {
         // Cancel listening Simple pairing result
@@ -725,6 +780,7 @@
         {
         iAuthenResultActive->Cancel();
         }
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 // ---------------------------------------------------------------------------
@@ -734,11 +790,13 @@
 //
 void CBTNotifSecurityManager::SubscribeSspPairingResult()
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     if ( !iSSPResultActive->IsActive() )
         {
         iPairingResult.SimplePairingResult( iSimplePairingRemote, iSSPResultActive->RequestStatus() );
         iSSPResultActive->GoActive();
         }
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 // ---------------------------------------------------------------------------
@@ -748,12 +806,14 @@
 //
 void CBTNotifSecurityManager::SubscribeAuthenticateResult()
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     if ( !iAuthenResultActive->IsActive() )
         {
         // Subscribe authentication result (which requires pairing for unpaired devices)
         iAuthenResult.AuthenticationResult( iAuthenticateRemote, iAuthenResultActive->RequestStatus() );
         iAuthenResultActive->GoActive();
         }
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 // ---------------------------------------------------------------------------
@@ -762,6 +822,7 @@
 //
 void CBTNotifSecurityManager::HandlePairingResultL( const TBTDevAddr& aAddr, TInt aResult )
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     BOstrace1(TRACE_DEBUG,DUMMY_DEVLIST,"result %d", aResult);
     BtTraceBtAddr0(TRACE_DEBUG,DUMMY_DEVLIST, aAddr );
  
@@ -786,10 +847,12 @@
             iPairingHandler = CBTNotifIncomingPairingHandler::NewL( *this, aAddr );
             }
         }
+
     if ( iPairingHandler )
         {
         iPairingHandler->HandlePairServerResult( aAddr, aResult );
         }
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 // ---------------------------------------------------------------------------
@@ -798,6 +861,7 @@
 //
 void CBTNotifSecurityManager::UpdatePairedDeviceListL()
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     iPairedDevices.Reset();
     const RDevExtensionArray& alldevs = iDevRepository.AllDevices();
     for ( TInt i = 0; i < alldevs.Count(); i++ )
@@ -807,6 +871,7 @@
             iPairedDevices.AppendL( alldevs[i]->Device().AsNamelessDevice() );
             }
         }
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 // ---------------------------------------------------------------------------
@@ -816,6 +881,7 @@
 void CBTNotifSecurityManager::HandleRegistryBondingL(
         const TBTNamelessDevice& aNameless)
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     TInt err = iPairedDevices.Append( aNameless );
     if ( !err && !iPairingHandler)
         {
@@ -837,10 +903,12 @@
         // let us try aborting pairing handling
         iPairingHandler->StopPairHandling( aNameless.Address() );
         }
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
 void CBTNotifSecurityManager::TrustDevice( const TBTDevAddr& aAddr )
     {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
     TIdentityRelation<TBTNamelessDevice> addrComp( CompareDeviceByAddress );
     TBTNamelessDevice dev;
     dev.SetAddress( aAddr );
@@ -856,5 +924,32 @@
         dev.SetGlobalSecurity(security);
         (void)UpdateRegDevice(dev);
         }
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
     }
 
+void CBTNotifSecurityManager::UnTrustDevice( const TBTDevAddr& aAddr )
+    {
+    BOstraceFunctionEntry0( DUMMY_DEVLIST );
+    TIdentityRelation<TBTNamelessDevice> addrComp( CompareDeviceByAddress );
+    TBTNamelessDevice dev;
+    dev.SetAddress( aAddr );
+    TRequestStatus status( KRequestPending );
+    
+    iRegistry.GetDevice(dev,status);
+    User::WaitForRequest( status ); 
+    if(status == KErrNone)
+        {
+        TBTDeviceSecurity security = dev.GlobalSecurity();
+        security.SetNoAuthorise(EFalse);
+        dev.SetGlobalSecurity(security);
+        (void)UpdateRegDevice(dev);
+        }
+    BOstraceFunctionExit0( DUMMY_DEVLIST);
+    }
+
+CBTNotifBasePairingHandler* CBTNotifSecurityManager::PairingHandler()
+    {
+    return iPairingHandler;
+    }
+
+
--- a/bluetoothengine/btnotif/btnotifsrv/src/btnotifserver.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btnotifsrv/src/btnotifserver.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -23,8 +23,10 @@
 #include "btnotifsettingstracker.h"
 #include "btnotificationmanager.h"
 #include "btnotifdeviceselector.h"
+#include "btnotifgeninfonotifier.h"
 #include "btnotifserversecpolicy.h"
 #include "btnotifclientserver.h"
+#include "btnotifpowernotifier.h"
 
 /**  Panic category */
 _LIT( KBTNotifPanic, "BTNotif panic" );
@@ -121,6 +123,8 @@
     iNotificationMgr = CBTNotificationManager::NewL( this );
     iSettingsTracker = CBTNotifSettingsTracker::NewL( this );
     iConnectionTracker = CBTNotifConnectionTracker::NewL( this );
+    iGenInfoNotifier = CBTNotifGenInfoNotifier::NewL( this );
+    iBTPowerNotifier = CBTNotifPowerNotifier::NewL( this );
     iTimer = CDeltaTimer::NewL(CActive::EPriorityLow);
     TCallBack shutdownCb( ShutdownTimeout, this );
     iShutdownTimerEntry.Set( shutdownCb );
@@ -160,6 +164,8 @@
     delete iSettingsTracker;
     delete iConnectionTracker;
     delete iNotificationMgr;
+    delete iGenInfoNotifier;
+    delete iBTPowerNotifier;
     delete iAsyncCb;
     delete iTimer;
     delete iDevRep;
--- a/bluetoothengine/btnotif/btnotifsrv/src/btnotifserviceauthorizer.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btnotifsrv/src/btnotifserviceauthorizer.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -126,7 +126,7 @@
         return;
         }
     
-    // User must namually authorize this request. 
+    // User must manually authorize this request. 
     // Get needed info for the dialog:
     iPairedDevice = (dev == NULL ) ? EFalse : dev->IsUserAwareBonded();
     iDeviceClass = (dev == NULL ) ? 0 : dev->Device().DeviceClass().DeviceClass();
--- a/bluetoothengine/btnotif/btnotifsrv/src/btnotifsession.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btnotifsrv/src/btnotifsession.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -17,6 +17,7 @@
 
 #include "btnotifsession.h"
 #include <btextnotifiers.h>
+#include <btnotif.h>
 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
 #include <btextnotifierspartner.h>
 #endif
@@ -24,6 +25,8 @@
 #include "btnotifsettingstracker.h"
 #include "btnotifconnectiontracker.h"
 #include "btnotifdeviceselector.h"
+#include "btnotifgeninfonotifier.h"
+#include "btnotifpowernotifier.h"
 
 
 // ======== LOCAL FUNCTIONS ========
@@ -92,6 +95,8 @@
 void CBTNotifSession::ServiceL( const RMessage2& aMessage )
     {
     CBTNotifConnectionTracker* connTracker = Server()->ConnectionTracker();
+    CBTNotifGenInfoNotifier* genInfoNotifier = Server()->GenericInfoNotifier();
+    CBTNotifPowerNotifier* bTPowerNotifier = Server()->BTPowerNotifier();
     TInt opCode = aMessage.Function();
     TInt uid = aMessage.Int0();
     TInt err( KErrNotReady );
@@ -136,6 +141,26 @@
                         aMessage.Complete( err );
                         }
                     }
+                else
+                    {
+                    if(uid == KBTGenericInfoNotifierUid.iUid & NULL != genInfoNotifier)
+                        {
+                            TRAP(err,genInfoNotifier->HandleNotifierRequestL(aMessage));
+                            if(err)
+                                {
+                                aMessage.Complete(err);
+                                }
+                        }
+                    
+                    else if(uid == KPowerModeSettingNotifierUid.iUid && NULL != bTPowerNotifier)
+                        {
+                        TRAP(err, bTPowerNotifier->HandleNotifierRequestL(aMessage));
+                        if(err)
+                            {
+                            aMessage.Complete(err);
+                            }
+                        }
+                    }
                 }
             break;
         case EBTNotifPairDevice:
--- a/bluetoothengine/btnotif/btnotifwrapper/src/btnotifwrapperproxy.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/btnotifwrapper/src/btnotifwrapperproxy.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -24,6 +24,7 @@
 #include <ecom/implementationproxy.h>
 #include <btmanclient.h>
 #include <btextnotifiers.h>
+#include <btnotif.h>
 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS
 #include <btextnotifierspartner.h>
 #endif
@@ -41,11 +42,11 @@
 /** Channel for OBEX passkey notifiers */
 //const TUid KBTObexAuthChannel = {0x00000603};
 /** Channel for power mode query */
-//const TUid KBTPowerModeChannel = {0x00000605};
+const TUid KBTPowerModeChannel = {0x00000605};
 /** Channel for query notifiers */
 //const TUid KBTQueryChannel = {0x00000606};
 /** Channel for power mode query */
-//const TUid KBTInfoChannel = {0x00000610};
+const TUid KBTInfoChannel = {0x00000610};
 
 
 // ======== LOCAL FUNCTIONS ========
@@ -84,7 +85,10 @@
     // KBTUserConfirmationNotifierUid for incoming JW dedicated bonding.
     
     CreateAndAppendNotifierLC( *notifiers, KDeviceSelectionNotifierUid, KBTDiscoveryChannel );
+    
+    CreateAndAppendNotifierLC( *notifiers, KBTGenericInfoNotifierUid, KBTInfoChannel );
 
+    CreateAndAppendNotifierLC( *notifiers, KPowerModeSettingNotifierUid, KBTPowerModeChannel );
     /*
      * todo:
      * Other notifiers to be migrated:
@@ -92,12 +96,8 @@
      * existing stack notifiers:
      * CreateAndAppendNotifierL( aArray, KPbapAuthNotifierUid, KBTObexPINChannel );
      * 
-     * S60 SDK API:
-     * CreateAndAppendNotifierL( aArray, KPowerModeSettingNotifierUid, KBTPowerModeChannel );
-     *
      * S60-defined platform:
      * CreateAndAppendNotifierL( aArray, KBTObexPasskeyQueryNotifierUid, KBTObexPINChannel );
-     * CreateAndAppendNotifierL( aArray, KBTGenericInfoNotifierUid, KBTInfoChannel );
      * CreateAndAppendNotifierL( aArray, KBTGenericQueryNotifierUid, KBTQueryChannel );
      * 
      * new (PAN-related):
--- a/bluetoothengine/btnotif/group/btnotifsrv.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/group/btnotifsrv.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -37,7 +37,8 @@
 SOURCE                  btnotifsettingstracker.cpp
 SOURCE                  btnotificationmanager.cpp
 SOURCE                  bluetoothnotification.cpp 
-SOURCE                  btnotifdeviceselector.cpp 
+SOURCE                  btnotifdeviceselector.cpp
+SOURCE			btnotifgeninfonotifier.cpp 
 SOURCE                  btnotifpairnotifier.cpp 
 SOURCE                  btnotifbasepairinghandler.cpp 
 SOURCE                  btnotifincomingpairinghandler.cpp 
@@ -45,13 +46,13 @@
 SOURCE                  btnotifsecuritymanager.cpp
 SOURCE                  btnotifserviceauthorizer.cpp
 SOURCE                  btnotifutil.cpp
+SOURCE                  btnotifpowernotifier.cpp
 
 USERINCLUDE             ../btnotifsrv/inc ../inc
 
 MW_LAYER_SYSTEMINCLUDE
 
 SYSTEMINCLUDE           ../../inc
-SYSTEMINCLUDE           ../../../inc
 
 LIBRARY                 euser.lib
 LIBRARY                 esock.lib
@@ -64,7 +65,7 @@
 LIBRARY                 btengdevman.lib
 LIBRARY                 btserviceutil.lib
 LIBRARY                 HbCore.lib
-LIBRARY                 commonengine.lib
+LIBRARY                 CommonEngine.lib
 LIBRARY					flogger.lib
 LIBRARY					charconv.lib
 
--- a/bluetoothengine/btnotif/inc/bluetoothdevicedialogs.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btnotif/inc/bluetoothdevicedialogs.h	Fri Sep 03 16:17:59 2010 +0300
@@ -43,6 +43,11 @@
     EPairingFailureOk,
     EVisibilityTimeout,
     EUnpairedDevice,
+    EGenericInfo,
+    EBluetoothTestMode,
+    ESendCompleted,
+    ESendCancelled,
+    EIssueOfflineQuery,
     EUnusedResource	// The last ID
     };
 
@@ -70,8 +75,8 @@
         EGlobalNotif,
         EUserAuthorization,
         EReceiveProgress,
-        ETransferFailed, 
-        EReceiveDone
+        EReceiveDone,
+        EInformationDialog
         };
 
     /**  Enumeration for the notification parameters data type to be configured. */
@@ -94,7 +99,13 @@
         EPairingRequest,
         ERecvFailed,
         ESendFailed,
-        EReceiveCompleted
+        EReceiveCompleted,
+        EBTAddress,
+        EOfflineQuery,
+        EMemoryFull,
+        EFileMoved,
+        EDriveNotFound,
+        EUnsupportedImages
         };
     
     enum TDialogActionType
@@ -152,7 +163,10 @@
         EAdditionalDesc,
         EReceivingFileName,
         EReceivingFileSize,
-        EReceivedFileCount
+        EReceivedFileCount,
+        ELocalAddress,
+        EDriveLetter,
+        EDriveName
         };
 
     inline TBluetoothDeviceDialog();
--- a/bluetoothengine/btpbap/group/btpbap.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btpbap/group/btpbap.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -40,12 +40,11 @@
 
 APP_LAYER_SYSTEMINCLUDE
 SYSTEMINCLUDE  	../../inc
-SYSTEMINCLUDE 	../../../inc
 SYSTEMINCLUDE	/epoc32/include/ecom
 
 
 LIBRARY         euser.lib         // Kernel API
-LIBRARY         ECom.lib
+LIBRARY         ecom.lib
 LIBRARY         pbapcli.lib
 LIBRARY         bluetooth.lib
 DEBUGLIBRARY    flogger.lib       // File logging
--- a/bluetoothengine/btsac/btrcc/group/btrcc.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btsac/btrcc/group/btrcc.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -39,14 +39,13 @@
 SOURCE	btrccLinker.cpp
 SOURCE	btrccPlugin.cpp
 SOURCE	btrccAbsoluteVolumeLevelController.cpp 
-SOURCE	btrccplayerstarter.cpp
 SOURCE	btrccBrowsingAdapter.cpp
 SOURCE	btrccLegacyVolumeLevelController.cpp
 SOURCE	btrccVolumeLevelControllerBase.cpp
 SOURCE	btrccActive.cpp
 
 USERINCLUDE     ../inc ../../common
-SYSTEMINCLUDE   ../../../inc ../../../../inc 
+SYSTEMINCLUDE   ../../../inc
 SYSTEMINCLUDE   /epoc32/include/ecom /epoc32/include/mmf/server
 MW_LAYER_SYSTEMINCLUDE
 
@@ -54,7 +53,7 @@
 TARGET btrcc.rsc
 END
 
-LIBRARY	ECom.lib		// Symbian E-Com Plugin definitions and types
+LIBRARY	ecom.lib		// Symbian E-Com Plugin definitions and types
 LIBRARY euser.lib       // User library
 LIBRARY esock.lib       // Socket services
 LIBRARY bluetooth.lib	// Bluetooth type definitions
--- a/bluetoothengine/btsac/btrcc/inc/btrccLinker.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btsac/btrcc/inc/btrccLinker.h	Fri Sep 03 16:17:59 2010 +0300
@@ -45,8 +45,6 @@
 class CRemConInterfaceSelector;
 class CRemConCoreApiController;
 class CBTRCCVolumeLevelController;
-class CRemConCoreApiTarget;
-class CPlayerStarter;
 class CBTRCCBrowsingAdapter;
 
 // CLASS DECLARATION
@@ -293,10 +291,6 @@
 		
 		// For receiving the accessory battery status
         CRemConBatteryApiTarget *iRemConBatteryTgt;
-        
-	    CRemConCoreApiTarget* iCoreTarget; // not own
-	    
-	    CPlayerStarter* iPlayerStarter; // owned
 	    
         // For handling the browsing commands. 
 	    CBTRCCBrowsingAdapter *iBrowsingAdapter;
--- a/bluetoothengine/btsac/btrcc/inc/btrccplayerstarter.h	Fri Aug 06 16:43:21 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,157 +0,0 @@
-/*
-* Copyright (c) 2008 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:   This class implements starting Music play	
-*
-*
-*/
-
-
-#ifndef BTRCCPLAYERSTATER_H
-#define BTRCCPLAYERSTATER_H
-
-//  INCLUDES
-#include <e32base.h>
-#include <remconcoreapitargetobserver.h>
-
-// FORWARD DECLARATIONS
-class CRemConCoreApiTarget;
-
-/**
-*  This class listens to AVRCP PLAY command by headset,if music player is not running 
-*  when such a command is received, it will be launched and requested to start playing.
-* */
-NONSHARABLE_CLASS(CPlayerStarter) : 
-    public CActive, public MRemConCoreApiTargetObserver
-	{
-	
-public:
-
-	/**
-	* Two-phased constructor.
-	*      
-	*/
-	static CPlayerStarter* NewL();
-
-	/**
-	 * Set the reference for AVRCP Core API command receiving and
-	 * responses to those command.
-	 */
-	void SetCoreTarget(CRemConCoreApiTarget& aTarget);
-	
-	/**
-	* Destructor.
-	*/
-	~CPlayerStarter();
-	
-private:  // From CActive
-
-    /**
-    * Informs the observer that an accessory has created a control 
-    * connection to our device.
-    * @param                            None.
-    * @return                           None.
-    */
-    void RunL();
-
-    /**
-    * Handles a possible leave from RunL().
-    * @param aError                     The leave code from RunL().
-    * @return                           KErrNone.
-    */
-    TInt RunError(TInt aError);
-
-    /**
-    * Cancels the volume change operation.
-    * @param                            None.
-    * @return                           None.
-    */
-    void DoCancel();
-    
-    // from base class MRemConCoreApiTargetObserver
-
-    /**
-     * From MRemConCoreApiTargetObserver
-     * A 'play' command has been received.
-     *
-     * @param aSpeed The playback speed.
-     * @param aButtonAct The button action associated with the command.
-     */
-    void MrccatoPlay(
-        TRemConCoreApiPlaybackSpeed aSpeed,
-        TRemConCoreApiButtonAction aButtonAct );
-
-    /**
-     * From MRemConCoreApiTargetObserver
-     * A command has been received.
-     *
-     * @param aOperationId The operation ID of the command.
-     * @param aButtonAct The button action associated with the command.
-     */
-    void MrccatoCommand(
-        TRemConCoreApiOperationId aOperationId,
-        TRemConCoreApiButtonAction aButtonAct );
-
-private:
-
-        /**
-        * C++ default constructor.
-        */
-        CPlayerStarter();
-
-        /**
-        * Symbian 2nd phase constructor.
-        */
-        void ConstructL();
-
-        /**
-         * Start music player if it is not running yet.
-         */
-        void StartPlayIfNeeded();
-        
-        /**
-         * Tells if MPX music player is running or not.
-         */
-        TBool IsMusicPlayerRunning();
-        
-        /**
-         * Tells if Video player is running or not.
-         */
-        TBool IsVideoPlayerRunning();
-
-        /**
-         * Launch MPX player.
-         */
-        void LaunchMusicPlayerL();
-        
-private:
-    enum TOpState
-        {
-        EIdle = 0, 
-        ERespondPlayOk , // responding OK to play command is outstanding
-        ERespondPlayNok,   // responding NOT OK to play command is outstanding
-        EPlayMusicTiming,  // scheduling internal PLAY command to player
-        };
-    
-private:    // Data
-    
-    CRemConCoreApiTarget* iCoreTarget; // not own
-    
-	RTimer iTimer;
-	
-	TOpState iState;
-    };
-
-#endif      // BTRCCACLLINKLISTENER_H
-            
-// End of File
--- a/bluetoothengine/btsac/btrcc/src/btrccLinker.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btsac/btrcc/src/btrccLinker.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -21,14 +21,12 @@
 #include <btaccObserver.h>
 #include <remconinterfaceselector.h>  
 #include <remconaddress.h> 
-#include <remconcoreapitarget.h>
 #include <apacmdln.h>
 #include <apgcli.h>
 #include "btaudioremconpskeys.h"
 #include "btrccLegacyVolumeLevelController.h"
 #include "btrccAbsoluteVolumeLevelController.h"
 #include "btrccLinker.h"
-#include "btrccplayerstarter.h"
 #include "btrccBrowsingAdapter.h"
 #include "debug.h"
 #include <btnotif.h>
@@ -122,10 +120,6 @@
         // If volume control is not supported, we'll need another interface selector session for disconnecting. 
         iInterfaceSelectorForDisconnectingTargetSession = CRemConInterfaceSelector::NewL(); 
     	}
-    
-    iPlayerStarter = CPlayerStarter::NewL();
-    iCoreTarget = CRemConCoreApiTarget::NewL(*iInterfaceSelector, *iPlayerStarter);
-    iPlayerStarter->SetCoreTarget(*iCoreTarget);
 
     iRemConBatteryTgt = CRemConBatteryApiTarget::NewL(*iInterfaceSelector, *this);
 
@@ -156,7 +150,6 @@
 	
     delete iAbsoluteVolController;
     delete iLegacyVolController;
-	delete iPlayerStarter;
 	Cancel();
     iStateArray.ResetAndDestroy();
     iStateArray.Close();
--- a/bluetoothengine/btsac/btrcc/src/btrccplayerstarter.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,303 +0,0 @@
-/*
-* Copyright (c) 2008 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:  This class launchs music player, then send play command
-*                to the player at 2 seconds timeout.
-*
-*/
-
-
-// INCLUDE FILES
-#include <apacmdln.h>
-#include <apgcli.h>
-#include <e32property.h>
-#include <remconcoreapitarget.h>
-#include "btrccplayerstarter.h"
-#include "btaudioremconpskeys.h"
-#include "debug.h"
-
-// MODULE DATA STRUCTURES
-
-// mpx playeris name is mpx.exe in 5.0.
-// it is musicplayer.exe in 3.2.
-_LIT(KMpxPlayerExeName, "mpx.exe");
-
-_LIT(KMpxPlayerSearchPatternBySID, "*102072c3*");
-_LIT(KVideoPlayerSearchPatternBySID, "*200159B2*");
-
-static const TInt KPlayCmdToPlayerDelay = 6000000; // value will be tuned later 
-
-// ================= MEMBER FUNCTIONS =======================
-
-// -----------------------------------------------------------------------------
-// CPlayerStarter::NewL
-// Two-phased constructor.
-// -----------------------------------------------------------------------------
-//
-CPlayerStarter* CPlayerStarter::NewL()
-	{
-	CPlayerStarter* self = new (ELeave) CPlayerStarter();
-	CleanupStack::PushL(self);
-	self->ConstructL();
-	CleanupStack::Pop(self);
-	return self;
-	}
-
-void CPlayerStarter::SetCoreTarget(CRemConCoreApiTarget& aTarget)
-    {
-    iCoreTarget = &aTarget;
-    }
-
-// -----------------------------------------------------------------------------
-// CPlayerStarter::CPlayerStarter
-// C++ constructor.
-// -----------------------------------------------------------------------------
-//
-CPlayerStarter::CPlayerStarter()
-  :CActive(EPriorityNormal)
-    {
-    CActiveScheduler::Add(this);
-    }
-
-// -----------------------------------------------------------------------------
-// CPlayerStarter::ConstructL
-// Symbian 2nd phase constructor.
-// -----------------------------------------------------------------------------
-//
-void CPlayerStarter::ConstructL()
-    {
-    TRACE_FUNC
-    iTimer.CreateLocal();
-    }
-
-// -----------------------------------------------------------------------------
-// Destructor.
-// -----------------------------------------------------------------------------
-//
-CPlayerStarter::~CPlayerStarter()
-	{
-	TRACE_FUNC
-	// Starting player is not finished yet, send play command. Just wish the player 
-	// can receive it.
-	if (IsActive() && iState != ERespondPlayNok)
-	    {
-        RProperty::Set(KBTAudioRemCon, KBTAudioPlayerControl, 
-                EBTAudioResumePlayer);	    
-	    }
-	Cancel();
-	iTimer.Close();
-	}
-
-// -----------------------------------------------------------------------------
-// CPlayerStarter::RunL
-// -----------------------------------------------------------------------------
-//
-void CPlayerStarter::RunL()
-    {
-    TRACE_INFO((_L("CPlayerStarter::RunL() state %d, status %d"), iState, iStatus.Int()));
-    if (iStatus != KErrNone)
-        {
-        iState = EIdle;
-        return;
-        }
-    switch (iState)
-        {
-        case ERespondPlayOk:
-            {
-            // Response OK has been sent to the remote device, start timer waiting
-            // for player's initialization.
-            iTimer.After(iStatus, KPlayCmdToPlayerDelay);
-            SetActive();
-            iState = EPlayMusicTiming;
-            TRACE_INFO(_L("schedule PLAY command ..."));
-            break;
-            }
-        case EPlayMusicTiming:
-            {
-            // Player should have fully up and running. Send PLAY command to it
-            // through our internal Play API.
-            RProperty::Set(KBTAudioRemCon, KBTAudioPlayerControl, 
-                    EBTAudioResumePlayer);
-            TRACE_INFO(_L("PLAY command sent to btmonobearer"));
-            iState = EIdle;
-            break;
-            }
-        default:
-            {
-            iState = EIdle;
-            break;
-            }
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CPlayerStarter::RunError
-// -----------------------------------------------------------------------------
-//
-TInt CPlayerStarter::RunError(TInt aError)
-    {
-    TRACE_FUNC
-    (void) aError;
-    return KErrNone;
-    }
-
-// -----------------------------------------------------------------------------
-// CPlayerStarter::DoCancel
-// -----------------------------------------------------------------------------
-//
-void CPlayerStarter::DoCancel()
-    {
-    TRACE_FUNC
-    switch (iState)
-        {
-        case ERespondPlayOk:
-        case ERespondPlayNok:
-            {
-            // This cancel won't cancel the response sending to the remote 
-            // device. (RemCon FW's cancel mechanism is only completing client's request.
-            // the real operation in its server side won't be stopped.)
-            iCoreTarget->Cancel();
-            break;
-            }
-        case EPlayMusicTiming:
-            {
-            iTimer.Cancel();
-            break;
-            }
-        }
-    }
-// ---------------------------------------------------------------------------
-// A 'play' command has been received.
-// ---------------------------------------------------------------------------
-//
-void CPlayerStarter::MrccatoPlay(
-    TRemConCoreApiPlaybackSpeed /* aSpeed */,
-    TRemConCoreApiButtonAction aButtonAct )
-    {
-    TRACE_FUNC
-    if ( ( aButtonAct == ERemConCoreApiButtonClick ) ||
-        ( aButtonAct == ERemConCoreApiButtonPress ) )
-        {
-        StartPlayIfNeeded();
-        }
-    }
-
-// ---------------------------------------------------------------------------
-// A command has been received.
-// ---------------------------------------------------------------------------
-//
-void CPlayerStarter::MrccatoCommand(
-    TRemConCoreApiOperationId aOperationId,
-    TRemConCoreApiButtonAction aButtonAct )
-    {
-    TRACE_INFO((_L("CPlayerStarter::MrccatoCommand opId %d, button %d"), 
-        aOperationId, aButtonAct));
-    switch (aOperationId)
-        {
-        case ERemConCoreApiPlay:
-            {
-            if ( ( aButtonAct == ERemConCoreApiButtonClick ) ||
-                ( aButtonAct == ERemConCoreApiButtonPress ) )
-                {
-                StartPlayIfNeeded();
-                }
-            break;
-            }
-        case ERemConCoreApiStop:
-        case ERemConCoreApiPause:
-            {
-            if ( ( aButtonAct == ERemConCoreApiButtonClick ) ||
-                ( aButtonAct == ERemConCoreApiButtonPress ) )
-                {
-                // if starting player is ongoing, possibly PLAY command has been scheduled
-                // need to abort it.
-                Cancel();
-                }
-            break;
-            }
-        default:
-            {
-            break;
-            }
-        }
-    }
-
-// -----------------------------------------------------------------------------
-// CPlayerStarter::StartPlayIfNeeded
-// -----------------------------------------------------------------------------
-//
-void CPlayerStarter::StartPlayIfNeeded() 
-    {
-    TRACE_FUNC
-    // unfinished business ongoing, eat the event.
-    if (IsActive())
-        {
-        return;
-        }
-    if (!IsMusicPlayerRunning() && !IsVideoPlayerRunning())
-         {
-         TRAPD(err, LaunchMusicPlayerL());
-         // Send the response of play command to remote device
-         iCoreTarget->PlayResponse(iStatus, err);
-         SetActive();
-         iState = (err) ? ERespondPlayNok : ERespondPlayOk;
-         }
-    }
-
-TBool CPlayerStarter::IsMusicPlayerRunning()
-    {
-    TRACE_FUNC
-    // Music player is running if we can find a thread whose name contains 
-    // S60 Music Player's SID.
-    TFindThread findt(KMpxPlayerSearchPatternBySID);
-    TFullName result;
-    TBool running(EFalse);
-    if (!findt.Next(result))
-        {
-        TRACE_INFO((_L("Thread '%S'is found"), &result));
-        running = ETrue;
-        }
-    return running;
-    }
-
-TBool CPlayerStarter::IsVideoPlayerRunning()
-    {
-    TRACE_FUNC
-    // Video player is running if we can find a thread whose name contains 
-    // Video Player's SID.
-    TFindThread findt(KVideoPlayerSearchPatternBySID);
-    TFullName result;
-    TBool running(EFalse);
-    if (!findt.Next(result))
-        {
-        TRACE_INFO((_L("Thread '%S'is found"), &result));
-        running = ETrue;
-        }
-    return running;
-    }
-
-void CPlayerStarter::LaunchMusicPlayerL()
-    {
-    RApaLsSession ls;
-    User::LeaveIfError(ls.Connect());
-    CleanupClosePushL(ls);
-    CApaCommandLine* cmd = CApaCommandLine::NewL();
-    CleanupStack::PushL(cmd);
-    cmd->SetExecutableNameL( KMpxPlayerExeName );
-    cmd->SetCommandL( EApaCommandOpen );
-    User::LeaveIfError(ls.StartApp( *cmd ));
-    CleanupStack::PopAndDestroy(2); // cmd, ls
-    }
-
-
-//  End of File  
--- a/bluetoothengine/btsac/group/btsac.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btsac/group/btsac.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -60,16 +60,16 @@
 END
 
 USERINCLUDE     ../inc ../common
-SYSTEMINCLUDE   ../../inc ../../../inc /epoc32/include/ecom
+SYSTEMINCLUDE   ../../inc /epoc32/include/ecom
 MW_LAYER_SYSTEMINCLUDE
 
 
 LIBRARY			euser.lib		// Kernel API includes symbian basic class and type definitions and error codes
 LIBRARY			esock.lib		// RSocketServ is used to open Gavdp 
 LIBRARY			bluetooth.lib		// Bluetooth library is used to access bluetooth types and API's
-LIBRARY			bluetoothAV.lib		// A2DP type definitions are needed to use Gavdp
+LIBRARY			bluetoothav.lib		// A2DP type definitions are needed to use Gavdp
 LIBRARY			gavdp.lib		// Bluetooth Generic Audio/Video Distribution Profile (GAVDP) API 
-LIBRARY			ECom.lib		// Symbian E-Com Plugin definitions and types
+LIBRARY			ecom.lib		// Symbian E-Com Plugin definitions and types
 LIBRARY			sdpdatabase.lib		// SDP registeration for Advanced Audio Distribution Profile (A2DP)
 LIBRARY			btaudiostreamer.lib	// Series 60 Bluetooth Audio Streamer component's API 
 LIBRARY			btengdiscovery.lib		// Register A2DP SDP service record
--- a/bluetoothengine/btsap/group/BTSap.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btsap/group/BTSap.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -85,7 +85,7 @@
 #ifdef _DUMMY_CUSTOM_API
 LIBRARY     DummyCustomAPI.lib      // Dummy Custom API
 #else
-LIBRARY     CustomAPI.lib           // Custom API
+LIBRARY     customapi.lib           // Custom API
 #endif
 
 DEBUGLIBRARY     flogger.lib        // File logging
--- a/bluetoothengine/btui/btcpplugin/btcpplugin.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btcpplugin/btcpplugin.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -39,7 +39,7 @@
 QList<CpSettingFormItemData*> BtCpPlugin::createSettingFormItemData(CpItemDataHelper &itemDataHelper) const
 {
     
-    return QList<CpSettingFormItemData*> () << new BtCpUiSettingItem(
+    return QList<CpSettingFormItemData*> () << new BtcpuiSettingItem(
             itemDataHelper);
 
 }
--- a/bluetoothengine/btui/btcpplugin/btcpplugin.pro	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btcpplugin/btcpplugin.pro	Fri Sep 03 16:17:59 2010 +0300
@@ -32,7 +32,7 @@
 
 # Input
 HEADERS += btcpuidevicedetailsview.h\
-	btcpuimainlistviewitem.h \
+	btcpuimaingridviewitem.h \
 	btcpuisearchlistviewitem.h \
     btcpplugin.h \
     btcpuibaseview.h \
@@ -41,9 +41,11 @@
     btcpuideviceview.h \
     btcpuisettingitem.h \
     btuiviewutil.h \
-    btcpuidevicedetail.h
+    btcpuidevicedetail.h \
+    btcpuiviewmgr.h
+    
 SOURCES += btcpuidevicedetailsview.cpp \
-	btcpuimainlistviewitem.cpp \
+	btcpuimaingridviewitem.cpp \
 	btcpuisearchlistviewitem.cpp \
     btcpplugin.cpp \
     btcpuibaseview.cpp \
--- a/bluetoothengine/btui/btcpplugin/btcpplugin.qrc	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btcpplugin/btcpplugin.qrc	Fri Sep 03 16:17:59 2010 +0300
@@ -22,5 +22,9 @@
         <file>docml/bt-search-view.docml</file>
         <file>docml/bt-device-view.docml</file>
         <file>docml/bt-device-details-view.docml</file>
+        <file>docml/btcpuimaingridviewitem.css</file>
+        <file>docml/btcpuimaingridviewitem.widgetml</file>
+        <file>docml/btcpuisearchlistviewitem.css</file>
+        <file>docml/btcpuisearchlistviewitem.widgetml</file>
     </qresource>
 </RCC>
--- a/bluetoothengine/btui/btcpplugin/btcpuibaseview.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btcpplugin/btcpuibaseview.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -17,39 +17,281 @@
 
 #include "btcpuibaseview.h"
 #include <hbaction.h>
+#include <HbInstance>
+#include <bluetoothuitrace.h>
+#include "btcpuiviewmgr.h"
+#include <HbSelectionDialog>
+#include <HbLabel>
+#include "btuidevtypemap.h"
+#include <btabstractdelegate.h>
+#include <btdelegatefactory.h>
 
 /*!
     This constructor constructs new setting and device models.
  */
-BtCpUiBaseView::BtCpUiBaseView(QGraphicsItem *parent )
-    :CpBaseSettingView( 0 , parent )
+BtcpuiBaseView::BtcpuiBaseView(QGraphicsItem *parent) :
+    CpBaseSettingView(0, parent), mViewMgr(0), mDelegate(0), mPreviousView(0),
+            mBack(0), mQuery(0), mContextMenu(0), mBtuiModelSortFilter(0)
 {
     mSettingModel = new BtSettingModel(this);
     mDeviceModel = new BtDeviceModel(this);
+    initialise();
 }
 
 /*!
     This constructor constructs models from the given setting and device models.
-    This implies the model impl and data structure is shared.
+    This implies the model impl and data structure are shared.
  */
-BtCpUiBaseView::BtCpUiBaseView(
-        BtSettingModel &settingModel, 
-        BtDeviceModel &deviceModel, 
-        QGraphicsItem *parent )
-    :CpBaseSettingView( 0 , parent )
+BtcpuiBaseView::BtcpuiBaseView(BtSettingModel &settingModel, 
+        BtDeviceModel &deviceModel,
+        QGraphicsItem *parent) :
+    CpBaseSettingView(0, parent), mViewMgr(0), mDelegate(0), mPreviousView(0),
+            mBack(0), mQuery(0), mContextMenu(0), mBtuiModelSortFilter(0)
 {
     mSettingModel = new BtSettingModel(settingModel, this);
-    mDeviceModel = new BtDeviceModel(deviceModel, this);    
+    mDeviceModel = new BtDeviceModel(deviceModel, this);
+    initialise();
 }
 
 /*!
     Destructor.
  */
-BtCpUiBaseView::~BtCpUiBaseView()
+BtcpuiBaseView::~BtcpuiBaseView()
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    delete mDelegate;
+    delete mQuery;
+    
+    if(mContextMenu) {
+        mContextMenu->clearActions();
+        delete mContextMenu;
+    }
+
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
+}
+
+void BtcpuiBaseView::initialise()
+{
+    bool ret(false); 
+    mMainWindow = hbInstance->allMainWindows().first();
+    mContextMenu = new HbMenu();
+    ret = connect(mContextMenu, SIGNAL(triggered(HbAction *)), this, SLOT(contextMenuTriggered(HbAction *)));
+    BTUI_ASSERT_X( ret, "bt-main-view", "Context Menu can't connect" );
+}
+
+void BtcpuiBaseView::setPreviousView(BtcpuiBaseView *view)
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    mPreviousView = view;
+    // when a non-null previous view is set, it means this view is navigated from an existing
+    // view. And the back-action should navigate to the previous view.
+    if (mPreviousView) {
+        // Back action is created on demand.
+        if (!mBack) {
+            mBack = new HbAction(Hb::BackNaviAction, this);
+            BTUI_ASSERT_X(mBack, "BtcpuiBaseView::setPreviousView", "can't create back action");
+            connect(mBack, SIGNAL(triggered()), this, SLOT(backToPreviousView()));
+        }
+        if (navigationAction() != mBack) {
+            setNavigationAction(mBack);
+        }
+    }
+    else {
+        setNavigationAction(0);
+    }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
+}
+
+void BtcpuiBaseView::setViewMgr(BtcpuiViewMgr *mgr)
 {
+    mViewMgr = mgr;
+}
 
+void BtcpuiBaseView::backToPreviousView()
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    if ( mPreviousView ) {
+        viewMgr()->switchView(this, mPreviousView, QVariant(), true);
+    }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
+}
+
+BtSettingModel *BtcpuiBaseView::settingModel()
+{
+    return mSettingModel;
+}
+
+BtDeviceModel *BtcpuiBaseView::deviceModel()
+{
+    return mDeviceModel;
+}
+
+BtcpuiViewMgr *BtcpuiBaseView::viewMgr()
+{
+    return mViewMgr;
+}
+
+bool BtcpuiBaseView::createDelegate(BtDelegate::EditorType type,
+        QObject *receiver, const char *member)
+{
+    bool ok(false);
+    if(!mDelegate) {
+        mDelegate = BtDelegateFactory::newDelegate(type, mSettingModel, mDeviceModel); 
+        ok = connect(mDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)),
+                receiver, member);
+        BOstraceExt1(TRACE_DEBUG, DUMMY_DEVLIST, "BtcpuiBaseView::createDelegate signal connect %d", ok);
+        if (!ok) {
+            delete mDelegate;
+            mDelegate = 0;
+        }
+    }
+    BOstraceExt2(TRACE_DEBUG, DUMMY_DEVLIST, "BtcpuiBaseView::createDelegate: mDe: 0x%08X, ret %d", mDelegate, ok);
+    return ok;
+}
+
+bool BtcpuiBaseView::createExecuteDelegate(BtDelegate::EditorType type,
+        QObject *receiver, const char *member, const QVariant &param)
+{
+    bool ok = createDelegate(type, receiver, member);
+    if (ok) {
+        mDelegate->exec(param);
+    }
+    return ok;
 }
 
+void BtcpuiBaseView::viewByDeviceTypeDialog()
+{
+    if ( !mQuery ) {
+        mQuery = new HbSelectionDialog();
+        QStringList devTypeList;
+        devTypeList << hbTrId("txt_bt_list_audio_devices")
+                << hbTrId("txt_bt_list_computers") 
+                << hbTrId("txt_bt_list_input_devices") 
+                << hbTrId("txt_bt_list_phones") 
+                << hbTrId("txt_bt_list_other_devices");
 
+        
+        mQuery->setStringItems(devTypeList, 0);
+        mQuery->setSelectionMode(HbAbstractItemView::MultiSelection);
+    
+        QList<QVariant> current;
+        current.append(QVariant(0));
+        mQuery->setSelectedItems(current);
+    
+        // Set the heading for the dialog.
+        HbLabel *headingLabel = new HbLabel(hbTrId("txt_bt_title_show"), mQuery);
+        mQuery->setHeadingWidget(headingLabel);
+    }
+    mQuery->open(this,SLOT(viewByDialogClosed(HbAction*)));
+}
+
+void BtcpuiBaseView::viewByDialogClosed(HbAction* action)
+{
+    Q_UNUSED(action)
+    //ReImpemented in derived classes.
+}
 
+int BtcpuiBaseView::selectedDeviceTypes(HbAction* action)
+{
+    int devTypesWanted = 0;
+    
+    disconnect( mQuery, 0, this, 0);  // remove signal
+    if (action == mQuery->actions().first()) {  // user pressed "Ok"
+        // Get selected items.
+        QList<QVariant> selections;
+        selections = mQuery->selectedItems();
+        
+        for (int i=0; i < selections.count(); i++) {
+            switch (selections.at(i).toInt()) {
+            case BtUiDevAudioDevice:
+                devTypesWanted |= BtuiDevProperty::AVDev;
+                break;
+            case BtUiDevComputer:
+                devTypesWanted |= BtuiDevProperty::Computer;
+                break;
+            case BtUiDevInputDevice:
+                devTypesWanted |= BtuiDevProperty::Peripheral;
+                break;
+            case BtUiDevPhone:
+                devTypesWanted |= BtuiDevProperty::Phone;
+                break;
+            case BtUiDevOtherDevice:
+                devTypesWanted |= (BtuiDevProperty::LANAccessDev |
+                        BtuiDevProperty::Toy |
+                        BtuiDevProperty::WearableDev |
+                        BtuiDevProperty::ImagingDev |
+                        BtuiDevProperty::HealthDev |
+                        BtuiDevProperty::UncategorizedDev);
+                break;
+            default:
+                // should never get here
+                BTUI_ASSERT_X(false, "BtcpuiSearchView::viewByDialogClosed()", 
+                        "wrong device type in viewBy dialog!");
+            }
+        }
+    }
+    
+    return devTypesWanted;
+}
 
+void BtcpuiBaseView::deviceSelected(const QModelIndex& modelIndex)
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    BtcpuiBaseView *devView = viewMgr()->deviceView();
+    // For navigating back to this view:
+    devView->setPreviousView( this );
+    QModelIndex index = mBtuiModelSortFilter->mapToSource(modelIndex);
+    QVariant params;
+    params.setValue(index);
+    viewMgr()->switchView(this, devView, params, false);
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
+}
+
+void BtcpuiBaseView::createContextMenuActions(int majorRole)
+{
+    //Re-Implemented in derived classes.
+    Q_UNUSED(majorRole)
+}
+
+void BtcpuiBaseView::take(BtAbstractDelegate *delegate)
+{
+    mDelegate = delegate;
+    if (mDelegate) {
+        disconnect(mDelegate, 0, 0, 0);
+        connect(mDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)),
+                this, SLOT(handleDelegateCompleted(int)));
+    }
+}
+
+void BtcpuiBaseView::contextMenuTriggered(HbAction *action)
+{
+    if(!(action->text().compare(hbTrId("txt_common_menu_open")))) {
+            deviceSelected(mLongPressedItem->modelIndex());
+        }
+}
+
+void BtcpuiBaseView::showContextMenu(HbAbstractViewItem *item, const QPointF &coords)
+{
+    mLongPressedItem = item;
+    mContextMenu->clearActions();
+    
+    mContextMenu->addAction(hbTrId("txt_common_menu_open"));
+    
+    QModelIndex index = mBtuiModelSortFilter->mapToSource(mLongPressedItem->modelIndex());  
+    
+    int majorPropRole = (mDeviceModel->data(index,BtDeviceModel::MajorPropertyRole)).toInt();
+    if (majorPropRole & BtuiDevProperty::Connectable ) {
+        createContextMenuActions(majorPropRole);
+    }
+    mContextMenu->setPreferredPos(coords);
+    mContextMenu->open();
+}
+
+void BtcpuiBaseView::handleDelegateCompleted(int error, BtAbstractDelegate* delegate)
+{
+    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, error );
+    Q_UNUSED(error);
+    delete mDelegate;
+    mDelegate = 0;
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
+}
--- a/bluetoothengine/btui/btcpplugin/btcpuibaseview.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btcpplugin/btcpuibaseview.h	Fri Sep 03 16:17:59 2010 +0300
@@ -23,39 +23,87 @@
 #include <cpbasesettingview.h>
 #include <btsettingmodel.h>
 #include <btdevicemodel.h>
+#include <btdelegateconsts.h>
+#include <btuimodelsortfilter.h>
+#include <HbAbstractViewItem>
+#include <HbMenu>
+
+class BtcpuiViewMgr;
+class HbSelectionDialog;
+class BtAbstractDelegate;
+class HbMainWindow;
 
 /*!
     \class BtUiBaseView
     \brief the class is the base class for all views in btapplication.
 
  */
-class BtCpUiBaseView : public CpBaseSettingView
+class BtcpuiBaseView : public CpBaseSettingView
 {
     Q_OBJECT
 
 public:
     
-    virtual ~BtCpUiBaseView();
-    virtual void activateView( const QVariant& value, bool fromBackButton ) = 0;
-    virtual void deactivateView() = 0;    
-    virtual void switchToPreviousView() = 0;
+    virtual ~BtcpuiBaseView();
+    
+    virtual void activateView( const QVariant& value, bool backNavi) = 0;
+    virtual void deactivateView() = 0;
+    virtual void setPreviousView(BtcpuiBaseView *view);
+    void setViewMgr(BtcpuiViewMgr *mgr);
+    virtual void take(BtAbstractDelegate *delegate);
+    
+public slots:
+    
+    virtual void backToPreviousView();
+    void viewByDeviceTypeDialog();
+    virtual void viewByDialogClosed(HbAction* action);
+    void contextMenuTriggered(HbAction *action);
+    void deviceSelected(const QModelIndex& modelIndex);
+    void showContextMenu(HbAbstractViewItem *item, const QPointF &coords);
+    void handleDelegateCompleted(int error, BtAbstractDelegate* delegate);
     
 signals:
 
 protected:
-    explicit BtCpUiBaseView(QGraphicsItem *parent = 0);
+    explicit BtcpuiBaseView(QGraphicsItem *parent = 0);
     
-    explicit BtCpUiBaseView( 
-            BtSettingModel &settingModel, 
+    explicit BtcpuiBaseView(BtSettingModel &settingModel, 
             BtDeviceModel &deviceModel, 
             QGraphicsItem *parent = 0);
     
-    virtual void setSoftkeyBack() = 0;
+    void initialise();
+    
+    BtSettingModel *settingModel();
+    
+    BtDeviceModel *deviceModel();
+    
+    BtcpuiViewMgr *viewMgr();
+
+    bool createDelegate(BtDelegate::EditorType type,
+            QObject *receiver, const char *member);
+    
+    bool createExecuteDelegate(BtDelegate::EditorType type,
+            QObject *receiver, const char *member, const QVariant &param);    
 
-    BtSettingModel &getSettingModel();
-    BtDeviceModel &getDeviceModel();
+    int selectedDeviceTypes(HbAction* action);
     
+    virtual void createContextMenuActions(int majorRole);
+
 protected:
+
+    enum devTypeSelectionList {
+        BtUiDevAudioDevice = 0,
+        BtUiDevComputer,
+        BtUiDevInputDevice,
+        BtUiDevPhone,
+        BtUiDevOtherDevice
+    };
+
+    // The view manager from which the device view can be accessed.
+    // not owned.
+    BtcpuiViewMgr *mViewMgr;
+    
+    HbMainWindow *mMainWindow;
     
     // owned
     BtSettingModel *mSettingModel;
@@ -63,10 +111,23 @@
     // owned
     BtDeviceModel *mDeviceModel;
     
-    QGraphicsItem *mParent;
-    int mPreviousViewId;
+    //The run-time singleton delegate in a btui view
+    BtAbstractDelegate* mDelegate;
+    
+    // The view which this view is navigated from.
+    // We will navigate to previous view if the back action is activated.
+    BtcpuiBaseView *mPreviousView;
     
-    Q_DISABLE_COPY(BtCpUiBaseView)
+    // The back action of this view.
+    HbAction *mBack;
+    
+    HbSelectionDialog *mQuery;
+    
+    HbMenu* mContextMenu;
+    HbAbstractViewItem *mLongPressedItem;
+
+    BtuiModelSortFilter*    mBtuiModelSortFilter;
+    Q_DISABLE_COPY(BtcpuiBaseView)
 };
 
 #endif // BTCPUIBASEVIEW_H
--- a/bluetoothengine/btui/btcpplugin/btcpuidevicedetail.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btcpplugin/btcpuidevicedetail.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -32,12 +32,14 @@
 
 BtCpUiDeviceDetail::~BtCpUiDeviceDetail()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     clearDeviceDetailList();
-    delete mDeviceDetailView;
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiDeviceDetail::loadDeviceDetailPlugins(QString deviceAddress, QString deviceName)
+void BtCpUiDeviceDetail::loadDeviceDetailPlugins(QString& deviceAddress, QString& deviceName)
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     QList<BtDevSettingInterface*> interfaces;
     BtAbstractDevSetting *devSetting;
     
@@ -48,7 +50,10 @@
     for (i = interfaces.constBegin(); i != interfaces.constEnd(); ++i) {
         devSetting = 0;
         devSetting = (*i)->createDevSetting( deviceAddress );
+        BtTraceQString1( TRACE_DEBUG, DUMMY_DEVLIST, "device addr=", deviceAddress);
         if(devSetting) {
+            BOstrace0(TRACE_FLOW, DUMMY_DEVLIST, "Plug-in settings appended");
+            //If settings are available add to list and connect to plugin signals.
             appendDeviceToList(devSetting);
         }
     }
@@ -58,32 +63,38 @@
     }
     
     createDeviceDetailsView(deviceName);
+
+    //Notify any changes in settings availability to Device view.
+    //Based on this Device Settings button will be shown.
     notifyDeviceDetailStatus();
-    
+    BOstraceFunctionExit0(DUMMY_DEVLIST);   
 }
 
 void BtCpUiDeviceDetail::appendDeviceToList(BtAbstractDevSetting *devSetting)
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     bool ret = false;
     BtDeviceDetails devicedetails;
-    devicedetails.mSetting = 0;
-    devicedetails.mSettingForm = 0;
-    devicedetails.mSettingAvailable = false;
     
     devicedetails.mSetting = devSetting;
     devicedetails.mSettingAvailable = devSetting->isSettingAvailable();
-    devicedetails.mSettingForm = devSetting->getSettingWidget();
+    devicedetails.mSettingForm = 0;
+    
+    if(devicedetails.mSettingAvailable) {
+        devicedetails.mSettingForm = devSetting->getSettingWidget();
+    }
     
     mDeviceDetailList.append(devicedetails);
     
     ret = connect(devicedetails.mSetting, SIGNAL(settingAvailabilityChanged(BtAbstractDevSetting *, bool)),
             this, SLOT(handleSettingChange(BtAbstractDevSetting *, bool)));
     BTUI_ASSERT_X( ret, "BtCpUiDeviceDetail::appendDeviceToList", "connect settingAvailabilityChanged() failed");
-
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
 void BtCpUiDeviceDetail::handleSettingChange(BtAbstractDevSetting *setting, bool available)
 {
+    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, available );  
     QList<BtDeviceDetails>::iterator i;
        
     for (i = mDeviceDetailList.begin(); i != mDeviceDetailList.end(); ++i) {
@@ -92,28 +103,35 @@
             if(available) {
                 if(((*i).mSettingForm)) {
                     //If item already exists, remove it first.
+                    BOstrace0(TRACE_FLOW, DUMMY_DEVLIST, "Setting removed");
                     mDeviceDetailView->removeItem((*i).mSettingForm);
                 }
                 (*i).mSettingForm = setting->getSettingWidget();
+                BOstrace0(TRACE_FLOW, DUMMY_DEVLIST, "Setting added");
                 //add widget
                 mDeviceDetailView->addItem((*i).mSettingForm);
             }
             else {
                 if((*i).mSettingForm) {
+                    BOstrace0(TRACE_FLOW, DUMMY_DEVLIST, "Setting removed");
                     //remove widget
                     mDeviceDetailView->removeItem((*i).mSettingForm);
                     (*i).mSettingForm = 0;
                     checkDeviceDetailSettings();
                 }
             }
+            //Notify any changes in settings availability to Device view.
+            //Based on this Device Settings button will be shown.
             notifyDeviceDetailStatus();
         }
     }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
 
 void BtCpUiDeviceDetail::checkDeviceDetailSettings()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     QList<BtDeviceDetails>::const_iterator i;
     bool devicedetail = false;
     
@@ -129,10 +147,12 @@
         mMainWindow->removeView(mDeviceDetailView); 
         mMainWindow->setCurrentView( mPreviousView );
     }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
 void BtCpUiDeviceDetail::notifyDeviceDetailStatus()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     QList<BtDeviceDetails>::const_iterator i;
     bool devicedetail = false;
     
@@ -143,31 +163,41 @@
         }
     }
     emit deviceSettingsChanged(devicedetail);
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
 void BtCpUiDeviceDetail::clearDeviceDetailList()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     QList<BtDeviceDetails>::const_iterator i;
     
     for (i = mDeviceDetailList.constBegin(); i != mDeviceDetailList.constEnd(); ++i) {
         if((*i).mSetting ) {
-            disconnect((*i).mSetting);
             delete (*i).mSetting;
         }
     }
     mDeviceDetailList.clear();
+    
+    if(mDeviceDetailView) {
+        mDeviceDetailView->removeAllItems();
+        delete mDeviceDetailView;
+        mDeviceDetailView = 0;
+    }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiDeviceDetail::createDeviceDetailsView(QString deviceName)
+void BtCpUiDeviceDetail::createDeviceDetailsView(QString& deviceName)
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     bool ret = false;
-    //Launch Device Detail View.
+    //Launch Device Detail View, this view will be created once device view
+    //is launched and will be deleted when device view is closed.
     mDeviceDetailView = new BtCpUiDeviceDetailsView();
     mDeviceDetailView->setDeviceName(deviceName);
     
     ret = connect(mDeviceDetailView, SIGNAL(aboutToClose()), this,
             SLOT(handleDeviceDetailViewClose()));
-    BTUI_ASSERT_X( ret, "BtCpUiDeviceDetail::loadDeviceDetailsView", "connect deviceDetailViewClosed() failed");
+    BTUI_ASSERT_X( ret, "BtCpUiDeviceDetail::createDeviceDetailsView", "connect deviceDetailViewClosed() failed");
 
     QList<BtDeviceDetails>::const_iterator i;
     
@@ -176,31 +206,39 @@
             mDeviceDetailView->addItem((*i).mSettingForm);
         }
     }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
 void BtCpUiDeviceDetail::loadDeviceDetailsView()
 {
-
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     mPreviousView = mMainWindow->currentView();
     mMainWindow->addView(mDeviceDetailView);
     
+    //aboutToForeground of plugin is called before launching 
+    //device settings view.
     notifyViewStatusToPlugins(AboutToShow);
     
     mMainWindow->setCurrentView( mDeviceDetailView );
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
 void BtCpUiDeviceDetail::handleDeviceDetailViewClose()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    //aboutToBackground of plugin is called before going 
+    //back to device view.
     notifyViewStatusToPlugins(AboutToHide);
     
     mMainWindow->removeView(mDeviceDetailView);
     
     mMainWindow->setCurrentView( mPreviousView );
-
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
 void BtCpUiDeviceDetail::notifyViewStatusToPlugins(BtCpUiDeviceDetail::NotifyType type)
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     QList<BtDeviceDetails>::const_iterator i;
     BtAbstractDevSetting *deviceSetting = 0;
     for (i = mDeviceDetailList.constBegin(); i != mDeviceDetailList.constEnd(); ++i) {
@@ -219,12 +257,16 @@
             }
         }
     }
-
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
 void BtCpUiDeviceDetail::sendCloseEvent()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    //aboutToClose is called before going back from
+    //device view.
     notifyViewStatusToPlugins(AboutToClose);
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
 
--- a/bluetoothengine/btui/btcpplugin/btcpuidevicedetail.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btcpplugin/btcpuidevicedetail.h	Fri Sep 03 16:17:59 2010 +0300
@@ -43,7 +43,7 @@
     
     virtual ~BtCpUiDeviceDetail();
     
-    void loadDeviceDetailPlugins(QString deviceAddress, QString deviceName);
+    void loadDeviceDetailPlugins(QString& deviceAddress, QString& deviceName);
         
     void loadDeviceDetailsView();
     
@@ -66,7 +66,7 @@
     void appendDeviceToList(BtAbstractDevSetting *devSetting);
     void clearDeviceDetailList();
     void notifyDeviceDetailStatus();
-    void createDeviceDetailsView(QString deviceName);
+    void createDeviceDetailsView(QString& deviceName);
     void notifyViewStatusToPlugins(BtCpUiDeviceDetail::NotifyType type);
     void checkDeviceDetailSettings();
     
--- a/bluetoothengine/btui/btcpplugin/btcpuidevicedetailsview.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btcpplugin/btcpuidevicedetailsview.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -33,7 +33,7 @@
 {
    
     mSoftKeyBackAction = new HbAction(Hb::BackNaviAction, this);
-    BTUI_ASSERT_X(mSoftKeyBackAction, "BtCpUiBaseView::BtCpUiBaseView", "can't create back action");
+    BTUI_ASSERT_X(mSoftKeyBackAction, "BtCpUiDeviceDetailsView::BtCpUiDeviceDetailsView", "can't create back action");
 
     // Create view for the application.
     // Set the name for the view. The name should be same as the view's
@@ -68,27 +68,49 @@
 
 void BtCpUiDeviceDetailsView::setDeviceName(const QString &deviceName)
 {
-    //todo: use Localised string Id.
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    //todo: use Localised string Id,If Loc ID is used
+    //wrong string is displayed. Need to correct text map file.
     QString heading(hbTrId("%1 details"));
     
     if(mGroupBox) {
         mGroupBox->setHeading(heading.arg(deviceName));
     }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
 void BtCpUiDeviceDetailsView::addItem(HbDataForm *item)
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     if (item && mLayout) {
         mLayout->addItem(item);
-    }    
+    }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
 void BtCpUiDeviceDetailsView::removeItem(HbDataForm *item)
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     if (item && mLayout) {
         //todo: with out this item is not removed from the view.
         item->setVisible(false);
         mLayout->removeItem(item);
+        delete item;
     }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
+void BtCpUiDeviceDetailsView::removeAllItems()
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    if(mLayout) {
+        QGraphicsLayoutItem *item;
+        int count = mLayout->count();
+        for(int i=count-1; i>=0; i--) {
+            item = mLayout->itemAt(i);
+            mLayout->removeItem(item);
+            delete item;
+        }
+    }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
+}
--- a/bluetoothengine/btui/btcpplugin/btcpuidevicedetailsview.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btcpplugin/btcpuidevicedetailsview.h	Fri Sep 03 16:17:59 2010 +0300
@@ -38,7 +38,7 @@
     void setDeviceName(const QString &deviceName);
     void addItem(HbDataForm *item);
     void removeItem(HbDataForm *item);
-
+    void removeAllItems();
     
 protected:
     HbDocumentLoader *mLoader;
--- a/bluetoothengine/btui/btcpplugin/btcpuideviceview.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btcpplugin/btcpuideviceview.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -18,7 +18,7 @@
 #include "btcpuideviceview.h"
 #include "btuiviewutil.h"
 #include <QtGui/QGraphicsLinearLayout>
-#include <HbInstance>
+#include <hbmainwindow.h>
 #include <hbdocumentloader.h>
 #include <hbdataform.h>
 #include <hbdataformmodel.h>
@@ -34,35 +34,24 @@
 #include <qstringlist>
 #include <qdebug>
 #include <bluetoothuitrace.h>
-#include "btcpuimainview.h"
 #include <btabstractdelegate.h>
 #include <btdelegatefactory.h>
-#include <QModelIndex>
 #include "btuiiconutil.h"
 #include "btuidevtypemap.h"
-
+#include "btqtconstants.h"
 #include "btcpuidevicedetail.h"
+#include "btcpuiviewmgr.h"
 
 // docml to load
 const char* BTUI_DEVICEVIEW_DOCML = ":/docml/bt-device-view.docml";
 
-
-BtCpUiDeviceView::BtCpUiDeviceView(
-        BtSettingModel &settingModel, 
+BtcpuiDeviceView::BtcpuiDeviceView(BtSettingModel &settingModel, 
         BtDeviceModel &deviceModel, 
         QGraphicsItem *parent) :
-    BtCpUiBaseView(settingModel,deviceModel,parent),
-    mPairedStatus(false), mConnectedStatus(false),mPreviousConnectedStatus(false), mTrustedStatus(false), 
-    mBlockedStatus(false), mConnectable(false), mAbstractDelegate(0), mDeviceDetail(0)   
+    BtcpuiBaseView(settingModel,deviceModel,parent),
+    mComboboxIndex(-1), mAbstractDelegate(0), mDeviceDetail(0)
 {
-    mDeviceIndex = QModelIndex();//is it needed to initialize mIndex???
-    
-    mMainView = (BtCpUiMainView *) parent;
-    
-    mMainWindow = hbInstance->allMainWindows().first();
-    
-    mSoftKeyBackAction = new HbAction(Hb::BackNaviAction, this);
-    BTUI_ASSERT_X(mSoftKeyBackAction, "BtCpUiBaseView::BtCpUiBaseView", "can't create back action");
+    mDeviceIndex = QModelIndex(); // initialize to zero
 
     // read view info from docml file
 
@@ -80,36 +69,17 @@
     
     bool ret = false;
 
-    bool ok = false;
-    mLoader->load( BTUI_DEVICEVIEW_DOCML, &ok );
+    mLoader->load( BTUI_DEVICEVIEW_DOCML, &ret );
     // Exit if the file format is invalid
-    BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file" );
-    
-    mOrientation = mMainWindow->orientation();
-        
-    if (mOrientation == Qt::Horizontal) {
-        mLoader->load(BTUI_DEVICEVIEW_DOCML, "landscape", &ok);
-        BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file: landscape section problem" );
-    }
-    else {
-        mLoader->load(BTUI_DEVICEVIEW_DOCML, "portrait", &ok);
-        BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file: landscape section problem" );        
-    }
-    
+    BTUI_ASSERT_X( ret, "bt-device-view", "Invalid docml file" );
     // listen for orientation changes
     ret = connect(mMainWindow, SIGNAL(orientationChanged(Qt::Orientation)),
             this, SLOT(changeOrientation(Qt::Orientation)));
     BTUI_ASSERT_X( ret, "BtCpUiDeviceView::BtCpUiDeviceView()", "connect orientationChanged() failed");
-
     
     // assign automatically created widgets to local variables
-    /*
-    mGroupBox = 0;
-    mGroupBox = qobject_cast<HbGroupBox *>( mLoader->findWidget( "groupBox_deviceView" ) );
-    BTUI_ASSERT_X( mGroupBox != 0, "bt-device-view", "Device groupbox not found" );
-    */
+    
     mDeviceIcon=0;
-    //can't use qobject_cast since HbIcon is not derived from QObject!
     mDeviceIcon = qobject_cast<HbLabel *>( mLoader->findWidget( "deviceIcon" ) );  
     BTUI_ASSERT_X( mDeviceIcon != 0, "bt-device-view", "Device Icon not found" );
     
@@ -127,174 +97,182 @@
     BTUI_ASSERT_X( mDeviceStatus != 0, "bt-device-view", "Device status not found" );
     
     
-    mConnectionCombobox = 0;
-    mConnectionCombobox = qobject_cast<HbDataForm *>( mLoader->findWidget( "connectionCombobox" ) );
-    BTUI_ASSERT_X( mConnectionCombobox != 0, "bt-device-view", "connection combobox not found" );
+    mConnectionDataForm = 0;
+    mConnectionDataForm = qobject_cast<HbDataForm *>( mLoader->findWidget( "connectionCombobox" ) );
+    BTUI_ASSERT_X( mConnectionDataForm != 0, "bt-device-view", "connection combobox not found" );
     
-    mConnectionComboboxModel = new HbDataFormModel();
+    mConnectionComboboxModel = new HbDataFormModel( this );
     
     mPair_Unpair=0;
-    mPair_Unpair = qobject_cast<HbPushButton *>( mLoader->findWidget( "pushButton_0" ) );
+    mPair_Unpair = qobject_cast<HbPushButton *>( mLoader->findWidget( "devicePairUnpair" ) );
     BTUI_ASSERT_X( mPair_Unpair != 0, "bt-device-view", "pair/unpair button not found" );
-    ret =  connect(mPair_Unpair, SIGNAL(clicked()), this, SLOT(pairUnpair()));
-    BTUI_ASSERT_X( ret, "BtCpUiDeviceView::BtCpUiDeviceView", "can't connect pair button" );
  
     mConnect_Disconnect=0;
-    mConnect_Disconnect = qobject_cast<HbPushButton *>( mLoader->findWidget( "pushButton_1" ) );
+    mConnect_Disconnect = qobject_cast<HbPushButton *>( mLoader->findWidget( "deviceConnectDisconnect" ) );
     BTUI_ASSERT_X( mConnect_Disconnect != 0, "bt-device-view", "connect/disconnect button not found" );
-    ret =  connect(mConnect_Disconnect, SIGNAL(clicked()), this, SLOT(connectDisconnect()));
-    BTUI_ASSERT_X( ret, "BtCpUiDeviceView::BtCpUiDeviceView", "can't connect disconnect button" );
       
     mDeviceSetting = 0;
-    mDeviceSetting = qobject_cast<HbPushButton *>( mLoader->findWidget( "pushButton_2" ) );
+    mDeviceSetting = qobject_cast<HbPushButton *>( mLoader->findWidget( "deviceSettings" ) );
     BTUI_ASSERT_X( mDeviceSetting != 0, "bt-device-view", "settings button not found" );
-    
-    
     ret = connect(mDeviceSetting, SIGNAL(clicked()), this,
             SLOT(handleDeviceSetting()));
-    BTUI_ASSERT_X( ret, "Btui, BtCpUiDeviceView::BtCpUiDeviceView", "clicked() connect failed");
+    BTUI_ASSERT_X( ret, "Btui, BtcpuiDeviceView::BtcpuiDeviceView", "clicked() connect failed");
 
     setConnectionCombobox();
-     
 }
 
-BtCpUiDeviceView::~BtCpUiDeviceView()
+BtcpuiDeviceView::~BtcpuiDeviceView()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     delete mLoader; // Also deletes all widgets that it constructed.
-    
-    delete mConnectionComboboxModel;
-    
-    setNavigationAction(0);
-    delete mSoftKeyBackAction;
-    if(mAbstractDelegate)
-    {
-        delete mAbstractDelegate;
-        mAbstractDelegate = 0;
-    }
-
+    delete mAbstractDelegate;
+    unloadDeviceDetails();
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-
-void BtCpUiDeviceView::setSoftkeyBack()
+void BtcpuiDeviceView::backToPreviousView()
 {
-    if (navigationAction() != mSoftKeyBackAction) {
-        setNavigationAction(mSoftKeyBackAction);
-        connect( mSoftKeyBackAction, SIGNAL(triggered()), this, SLOT(switchToPreviousView()) );
-    }
-}
-
-void BtCpUiDeviceView::switchToPreviousView()
-{
-    BTUI_ASSERT_X(mMainView, "BtCpUiSearchView::switchToPreviousView", "invalid mMainView");
-    mMainView->switchToPreviousView();
-
-    if(mDeviceDetail) {
-        mDeviceDetail->sendCloseEvent();
-    }
+    BtcpuiBaseView::backToPreviousView();
     unloadDeviceDetails();
 }
 
-void BtCpUiDeviceView::loadDeviceDetails()
+void BtcpuiDeviceView::loadDeviceDetails()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     bool ret(false);
-    
-    unloadDeviceDetails();
-    
+    unloadDeviceDetails();  // ToDo: is it necessary to delete the device view every time there is a change?
     mDeviceDetail = new BtCpUiDeviceDetail();
-    
     ret=connect(mDeviceDetail, SIGNAL(deviceSettingsChanged(bool)),
            this, SLOT(handleDeviceSettingsChange(bool)));
-    BTUI_ASSERT_X( ret, "Btui, BtCpUiDeviceView::loadDeviceDetails", "deviceSettingsChanged() connect failed");
+    BTUI_ASSERT_X( ret, "Btui, BtcpuiDeviceView::loadDeviceDetails", "deviceSettingsChanged() connect failed");
 
-    mDeviceDetail->loadDeviceDetailPlugins(mDeviceBdAddr.toString(), mDeviceName->text());
+    QString btAddr = mDeviceBdAddr.toString();
+    QString deviceName = mDeviceName->text();
+    mDeviceDetail->loadDeviceDetailPlugins(btAddr, deviceName);
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiDeviceView::unloadDeviceDetails()
+void BtcpuiDeviceView::unloadDeviceDetails()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     if(mDeviceDetail) {
-        disconnect(mDeviceDetail);
+        mDeviceDetail->sendCloseEvent();
         delete mDeviceDetail;
         mDeviceDetail = 0;
     }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiDeviceView::activateView( const QVariant& value, bool fromBackButton )
+void BtcpuiDeviceView::activateView( const QVariant& value, bool backNavi)
 {
-    
-    Q_UNUSED( fromBackButton );  
-    
-    mConnectedStatus = false;
-    setSoftkeyBack();
-    
-    
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    Q_UNUSED( backNavi ); 
+    // get bluetooth address of device in question
     QModelIndex index = value.value<QModelIndex>();
     mDeviceBdAddr = (mDeviceModel->data(index, BtDeviceModel::ReadableBdaddrRole));
+    QModelIndex start = mDeviceModel->index(0,0);
+    QModelIndexList indexList = mDeviceModel->match(start,BtDeviceModel::ReadableBdaddrRole, mDeviceBdAddr);
+    mDeviceIndex = indexList.at(0);
     
-    //activate view is called when device is selected
-    //clearViewData();
+    bool ret = false;
+    if (mMainWindow->orientation() == Qt::Horizontal) {
+        //mLoader->load(BTUI_DEVICEVIEW_DOCML, "landscape", &ret);
+        //BTUI_ASSERT_X( ret, "bt-device-view", "Invalid docml file: landscape section problem" );
+        int majorRole = (mDeviceModel->data(mDeviceIndex,BtDeviceModel::MajorPropertyRole)).toInt();
+        if (majorRole & BtuiDevProperty::Connectable ) {
+            mLoader->load( BTUI_DEVICEVIEW_DOCML, "landscape", &ret );
+            BTUI_ASSERT_X( ret, "bt-device-view", "Invalid docml file: landscape section problem" );  
+        }
+        else{
+            mLoader->load( BTUI_DEVICEVIEW_DOCML, "landscape2", &ret );
+            BTUI_ASSERT_X( ret, "bt-device-view", "Invalid docml file: landscape2 section problem" );  
+        }
+    }
+    else {
+        mLoader->load(BTUI_DEVICEVIEW_DOCML, "portrait", &ret);
+        BTUI_ASSERT_X( ret, "bt-device-view", "Invalid docml file: portrait section problem" );
+            
+              
+    }
+    
     updateDeviceData();
     
     mDeviceSetting->setVisible(false);
-        
-    bool ret(false);
+    loadDeviceDetails();    
+    ret = false;
     ret=connect(mDeviceModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)),
            this, SLOT(updateDeviceData()));
     BTUI_ASSERT_X( ret, "Btui, BtCpUiDeviceView::activateView", "dataChanged() connect failed");
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
+}
 
+void BtcpuiDeviceView::deactivateView()
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    disconnect(mDeviceModel, 0, this, 0);
+    unloadDeviceDetails();
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiDeviceView::handleDeviceSettingsChange(bool status)
+void BtcpuiDeviceView::handleDeviceSettingsChange(bool status)
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     mDeviceSetting->setVisible(status);
+    mDeviceSetting->setStretched(true);
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiDeviceView::handleDeviceSetting()
+void BtcpuiDeviceView::handleDeviceSetting()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     if(mDeviceDetail) {
         mDeviceDetail->loadDeviceDetailsView();
     }
-}
-
-void BtCpUiDeviceView::deactivateView()
-{
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
+
 // called due to real orientation change event coming from main window
-void BtCpUiDeviceView::changeOrientation( Qt::Orientation orientation )
+void BtcpuiDeviceView::changeOrientation( Qt::Orientation orientation )
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     bool ok = false;
-    mOrientation = orientation;
+    int majorRole = (mDeviceModel->data(mDeviceIndex,BtDeviceModel::MajorPropertyRole)).toInt();
     if( orientation == Qt::Vertical ) {
         // load "portrait" section
         mLoader->load( BTUI_DEVICEVIEW_DOCML, "portrait", &ok );
         BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file: portrait section problem" );
     } else {
         // load "landscape" section
-        mLoader->load( BTUI_DEVICEVIEW_DOCML, "landscape", &ok );
-        BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file: landscape section problem" );
+        //mLoader->load( BTUI_DEVICEVIEW_DOCML, "landscape", &ok );
+        //BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file: landscape section problem" );
+        if (majorRole & BtuiDevProperty::Connectable ) {
+            mLoader->load( BTUI_DEVICEVIEW_DOCML, "landscape", &ok );
+            BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file: landscape section problem" );  
+        }
+        else{
+            mLoader->load( BTUI_DEVICEVIEW_DOCML, "landscape2", &ok );
+            BTUI_ASSERT_X( ok, "bt-device-view", "Invalid docml file: landscape2 section problem" );  
+        }
     }
+    setTextAndVisibilityOfButtons(majorRole);
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiDeviceView::clearViewData()
+void BtcpuiDeviceView::clearViewData()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     mDeviceIcon->clear();
     mDeviceCategory->clear();
     mDeviceStatus->clear();
-    mConnectable = false;
-    /*
-    mPairedStatus = false;
-    mConnectedStatus = false;
-    mTrustedStatus = false;
-    mBlockedStatus = false;
-    
-    mConnectable = false;
-    */
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
-    
-void BtCpUiDeviceView::updateDeviceData()
+
+void BtcpuiDeviceView::updateDeviceData()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     clearViewData();
-    //Get the QModelIndex of the device using the device BDAddres
+    //Get the QModelIndex of the device using the device BDAddress
     QModelIndex start = mDeviceModel->index(0,0);
     QModelIndexList indexList = mDeviceModel->match(start,BtDeviceModel::ReadableBdaddrRole, mDeviceBdAddr);
     mDeviceIndex = indexList.at(0);
@@ -310,321 +288,391 @@
     
 	setDeviceCategory(cod, majorRole);
     setDeviceStatus(majorRole);
-    setTextAndVisibilityOfButtons();
+    setTextAndVisibilityOfButtons(majorRole);
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiDeviceView::setDeviceCategory(int cod,int majorRole)
+void BtcpuiDeviceView::setDeviceCategory(int cod,int majorRole)
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     mDeviceCategory->setPlainText( getDeviceTypeString( cod ));
     HbIcon icon =
     getBadgedDeviceTypeIcon(cod, majorRole,
                             BtuiBottomLeft | BtuiBottomRight | BtuiTopLeft | BtuiTopRight );
     mDeviceIcon->setIcon(icon);
-
-    if (majorRole & BtuiDevProperty::Connectable ) {
-        mConnectable = true;
-    } 
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiDeviceView::setDeviceStatus(int majorRole)
+void BtcpuiDeviceView::setDeviceStatus(int majorRole)
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     QString deviceStatus;
-    
-    updateStatusVariables(majorRole);  // should we use bitmap instead??
-    
+    // Avoid unnecessary actions:
+    // The device model has been modified and need to be reflected
+    // in the UI however if we don't disable the signal before the UI update
+    // the connectionPreferenceChanged function will be called and trigger
+    // unnecessary update of the model by the device view.
+    mConnectionDataForm->removeConnection(mCombobox, SIGNAL(currentIndexChanged (int)), 
+            this, SLOT(connectionPreferenceChanged(int)));
     if (majorRole & BtuiDevProperty::Bonded && 
         majorRole & BtuiDevProperty::Trusted &&
         majorRole & BtuiDevProperty::Connected ) {
         mDeviceStatus->setPlainText(hbTrId("txt_bt_info_paired_trused_connected"));
+        mCombobox->setContentWidgetData("currentIndex", ConnectionAutomatic );
+        mComboboxIndex = ConnectionAutomatic;
     } 
     else if (majorRole & BtuiDevProperty::Bonded && 
              majorRole & BtuiDevProperty::Connected ) {
         mDeviceStatus->setPlainText(hbTrId("txt_bt_info_paired_connected"));
+        mCombobox->setContentWidgetData("currentIndex", ConnectionAlwaysAsk );
+        mComboboxIndex = ConnectionAlwaysAsk;
     }
     else if (majorRole & BtuiDevProperty::Bonded && 
              majorRole & BtuiDevProperty::Trusted ) {
         mDeviceStatus->setPlainText(hbTrId("txt_bt_info_paired_trusted"));
+        mCombobox->setContentWidgetData("currentIndex", ConnectionAutomatic );
+        mComboboxIndex = ConnectionAutomatic;
+    } 
+    else if (majorRole & BtuiDevProperty::Connected && 
+             majorRole & BtuiDevProperty::Trusted ) {
+        mDeviceStatus->setPlainText(hbTrId("Trusted, Connected"));  // ToDo: missing textId!
+        mCombobox->setContentWidgetData("currentIndex", ConnectionAutomatic );
+        mComboboxIndex = ConnectionAutomatic;
+    } 
+    else if (majorRole & BtuiDevProperty::Trusted ) {
+        mDeviceStatus->setPlainText(hbTrId("Trusted"));  // ToDo: missing textId!
+        mCombobox->setContentWidgetData("currentIndex", ConnectionAutomatic );
+        mComboboxIndex = ConnectionAutomatic;
     } 
     else if (majorRole & BtuiDevProperty::Bonded) {
         mDeviceStatus->setPlainText(hbTrId("txt_bt_info_paired"));
+        mCombobox->setContentWidgetData("currentIndex", ConnectionAlwaysAsk );
+        mComboboxIndex = ConnectionAlwaysAsk;
     }
     else if (majorRole & BtuiDevProperty::Connected) {
         mDeviceStatus->setPlainText(hbTrId("txt_bt_info_connected"));
+        mCombobox->setContentWidgetData("currentIndex", ConnectionAlwaysAsk );
+        mComboboxIndex = ConnectionAlwaysAsk;
     }
     else if (majorRole & BtuiDevProperty::Blocked) {
         mDeviceStatus->setPlainText(hbTrId("txt_bt_info_blocked"));
+        mCombobox->setContentWidgetData("currentIndex", ConnectionBlocked );
+        mComboboxIndex = ConnectionBlocked;
     }
     else {
-        // device not paired, connected, trusted or blocked.  is this ok?
+        // device not paired, connected, trusted or blocked.  
+        mDeviceStatus->setPlainText(" ");
+        mCombobox->setContentWidgetData("currentIndex", ConnectionAlwaysAsk );
+        mComboboxIndex = ConnectionAlwaysAsk;
     }
-
+    mConnectionDataForm->addConnection(mCombobox, SIGNAL(currentIndexChanged (int)), 
+            this, SLOT(connectionPreferenceChanged(int)));
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiDeviceView::setConnectionCombobox(){
-    
+void BtcpuiDeviceView::setConnectionCombobox()
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     //create a model class
+    mCombobox = mConnectionComboboxModel->appendDataFormItem(
+    HbDataFormModelItem::ComboBoxItem, hbTrId("txt_bt_setlabel_connection"), 
+        mConnectionComboboxModel->invisibleRootItem());
     
-    mConnectionComboboxModel->appendDataFormItem(
-    HbDataFormModelItem::ComboBoxItem, QString("Connection"), mConnectionComboboxModel->invisibleRootItem());
-    
+    QStringList connList;
+    connList.append( hbTrId("txt_bt_setlabel_bluetooth_val_automatic") );
+    connList.append( hbTrId("txt_bt_setlabel_bluetooth_val_always_ask") );
+    connList.append( hbTrId("txt_bt_setlabel_bluetooth_val_blocked") );
+    mCombobox->setContentWidgetData( "items", connList );
+
     //set the model to the view, once model and data class are created
-    mConnectionCombobox->setModel(mConnectionComboboxModel);
-
-
-
+    mConnectionDataForm->setModel(mConnectionComboboxModel);
+    mConnectionDataForm->addConnection(mCombobox, SIGNAL(currentIndexChanged (int)), 
+            this, SLOT(connectionPreferenceChanged(int)));
+    BOstraceFunctionExit0(DUMMY_DEVLIST);    
 }
 
-
-/*!
- *  instead of using separate boolean variables we could use bitmap in single variable
- */
-void BtCpUiDeviceView::updateStatusVariables(int majorRole)
+void BtcpuiDeviceView::setTextAndVisibilityOfButtons(int majorProperty)
 {
-    mPreviousConnectedStatus = mConnectedStatus;
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    disconnect(mPair_Unpair, 0, 0, 0);
+    disconnect(mConnect_Disconnect, 0, 0, 0);
     
-    if (majorRole & BtuiDevProperty::Trusted ) {
-        mTrustedStatus = true;
-    } 
-    else {
-        mTrustedStatus = false;
+    if (majorProperty & BtuiDevProperty::Blocked) {
+        mPair_Unpair->setVisible(false);
+        mConnect_Disconnect->setVisible(false);
+        mDeviceSetting->setVisible(false);
+        return;
     }
-    if (majorRole & BtuiDevProperty::Bonded) {
-        mPairedStatus = true;
+    bool ret;
+    mPair_Unpair->setVisible(true);
+    mPair_Unpair->setStretched(true);
+    if (majorProperty & BtuiDevProperty::Bonded) {
+        updateButton(mPair_Unpair, "qtg_mono_bt_unpair", hbTrId("txt_bt_button_unpair"));
+        ret =  connect(mPair_Unpair, SIGNAL(clicked()), this, SLOT(unpairDevice()));
+        BTUI_ASSERT_X( ret, "BtcpuiDeviceView::BtcpuiDeviceView", "can't connect unpair button" );
     }
     else {
-        mPairedStatus = false;
+        updateButton(mPair_Unpair, "qtg_mono_bt_pair", hbTrId("txt_bt_button_pair"));
+        ret =  connect(mPair_Unpair, SIGNAL(clicked()), this, SLOT(pairDevice()));
+        BTUI_ASSERT_X( ret, "BtcpuiDeviceView::BtcpuiDeviceView", "can't connect pair button" );        
     }
-    if (majorRole & BtuiDevProperty::Connected) {
-        mConnectedStatus = true;
-        if (!mPreviousConnectedStatus){
-            //Loading device detail plugins after successfull connection.
-            loadDeviceDetails();
+    
+    if (majorProperty & BtuiDevProperty::Connectable ) {
+        mConnect_Disconnect->setVisible(true);
+        mConnect_Disconnect->setStretched(true);
+        if (majorProperty & BtuiDevProperty::Connected) {
+            updateButton(mConnect_Disconnect, "qtg_mono_speaker_off", hbTrId("txt_bt_button_disconnect"));
+            ret =  connect(mConnect_Disconnect, SIGNAL(clicked()), this, SLOT(disconnectDevice()));
+            BTUI_ASSERT_X( ret, "BtcpuiDeviceView::BtcpuiDeviceView", "can't connect disconnect button" );
+        }
+        else {
+            updateButton(mConnect_Disconnect, "qtg_mono_speaker", hbTrId("txt_bt_button_connect"));
+            ret =  connect(mConnect_Disconnect, SIGNAL(clicked()), this, SLOT(connectDevice()));
+            BTUI_ASSERT_X( ret, "BtcpuiDeviceView::BtcpuiDeviceView", "can't connect connect button" );
         }
     }
     else {
-        mConnectedStatus = false;
-    }
-    if (majorRole & BtuiDevProperty::Blocked) {
-        mBlockedStatus = true;
-    }
-    else {
-        mBlockedStatus = false;
-    }
-}
-
-void BtCpUiDeviceView::setTextAndVisibilityOfButtons()
-{
-    mPair_Unpair->setStretched(true);
-    if (mPairedStatus)
-    {
-        HbIcon icon("qtg_mono_bt_unpair");
-        icon.setIconName("qtg_mono_bt_unpair");
-        mPair_Unpair->setIcon(icon);
-        mPair_Unpair->setText(hbTrId("txt_bt_button_unpair"));
-				
-    }
-    else
-    {
-        HbIcon icon("qtg_mono_bt_pair");
-        icon.setIconName("qtg_mono_bt_pair");
-        mPair_Unpair->setIcon(icon);
-        mPair_Unpair->setText(hbTrId("txt_bt_button_pair"));
-    }
-    
-    if (mConnectable)
-    {
-        mConnect_Disconnect->setVisible(true);
-        mConnect_Disconnect->setStretched(true);
-        if (mConnectedStatus)
-        {
-            HbIcon icon("qtg_mono_speaker_off");
-            icon.setIconName("qtg_mono_speaker_off");
-            mConnect_Disconnect->setIcon(icon);
-            mConnect_Disconnect->setText(hbTrId("txt_bt_button_disconnect"));
-        }
-        else
-        {
-            HbIcon icon("qtg_mono_speaker");
-            icon.setIconName("qtg_mono_speaker");
-            mConnect_Disconnect->setIcon(icon);
-            mConnect_Disconnect->setText(hbTrId("txt_bt_button_connect"));
-        }
-        
-    }
-    else
-    {
         //it is not possible to connect, set the button invisible
         mConnect_Disconnect->setVisible(false);
     }
-    
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
+}
+
+void BtcpuiDeviceView::connectionPreferenceChanged(int index)
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    if ((index >= ConnectionAutomatic)&&(index != mComboboxIndex)) {
+        switch ( index )
+        {
+        case ConnectionAutomatic:
+            setDeviceAuthorised();
+            break;
+        case ConnectionAlwaysAsk:
+            setDeviceAlwaysAsk();
+            break;
+        case ConnectionBlocked:
+            setDeviceBlocked();
+            break;
+        default: 
+            BTUI_ASSERT_X( 0, "BtCpUiDeviceView::connectionPreferenceChanged()", "wrong index" );
+        }
+    }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
+}
+
+void BtcpuiDeviceView::setDeviceAuthorised()
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    if (!mAbstractDelegate){
+        //if there is no other delegate running
+        QList<QVariant>list;
+        list.append(mDeviceBdAddr);
+        
+        if (mComboboxIndex != ConnectionAutomatic) { // transition: (always ask|blocked) --> automatic
+            // unblock the device
+            list.append(QVariant(BtAuthorize));
+        }
+        else {
+            // do nothing, state is already correct
+            return;
+        }
+        mAbstractDelegate = BtDelegateFactory::newDelegate(
+                BtDelegate::TrustDevice, mSettingModel, mDeviceModel); 
+        connect( mAbstractDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), 
+                this, SLOT(unpairDelegateCompleted(int)) );
+        mAbstractDelegate->exec(QVariant(list));
+    }   
+    BOstraceFunctionExit0(DUMMY_DEVLIST);  
 }
 
-
-void BtCpUiDeviceView::pairUnpair()
+void BtcpuiDeviceView::setDeviceAlwaysAsk()
 {
-    if (mPairedStatus)
-    {
-        //if the device is paired, call unpairDevice() when the button is tabbed
-        unpairDevice();
-    }
-    else
-    {
-        //if the device is unpaired, call pairDevice() when the button is tabbed
-        pairDevice();
-
-    }
-    
-    
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    if (!mAbstractDelegate){
+        //if there is no other delegate running
+        QList<QVariant>list;
+        BtDelegate::EditorType type;
+        list.append(mDeviceBdAddr);
+        if (mComboboxIndex == ConnectionAutomatic) { // transition: automatic --> always ask
+            // unauthorize the device
+            list.append(QVariant(BtUnauthorize));
+            type = BtDelegate::UntrustDevice;
+        }
+        else if (mComboboxIndex == ConnectionBlocked) { // transition: blocked --> always ask 
+            // unblock the device
+            list.append(QVariant(BtUnblock));
+            type = BtDelegate::UnblockDevice;
+        }
+        else {
+            // do nothing, state is already correct
+            return;
+        }
+        
+        mAbstractDelegate = BtDelegateFactory::newDelegate(
+                type, mSettingModel, mDeviceModel); 
+        connect( mAbstractDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), 
+                this, SLOT(unpairDelegateCompleted(int)) );
+        mAbstractDelegate->exec(QVariant(list));
+    }   
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiDeviceView::connectDisconnect()
+void BtcpuiDeviceView::setDeviceBlocked()
 {
-    if (mConnectedStatus)
-    {
-        //if the device is connected, call disconnectDevice() when the button is tabbed
-        disconnectDevice();
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    //simple version of the delegate
+    //TODO: disconnect after blocking
+    if (!mAbstractDelegate){
+        //if there is no other delegate running
+        QList<QVariant> list;
+        list.append(mDeviceBdAddr);
+        
+        if ( mComboboxIndex == ConnectionAutomatic || 
+            mComboboxIndex == ConnectionAlwaysAsk ) {  // transition: automatic|always ask --> blocked
+            // to unauthorized the device
+            list.append(QVariant(BtBlock));
+        }
+        else{
+            // do nothing, state is already correct
+            return;
+        }
+        mAbstractDelegate = BtDelegateFactory::newDelegate(
+                BtDelegate::BlockDevice, mSettingModel, mDeviceModel); 
+        connect( mAbstractDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), 
+                this, SLOT(unpairDelegateCompleted(int)) );
+        mAbstractDelegate->exec(QVariant(list));
     }
-    else
-    {
-        //if the device is disconnected, call connectDevice() when the button is tabbed
-        connectDevice();
-
-    }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiDeviceView::pairDevice()
+void BtcpuiDeviceView::pairDevice()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     if (!mAbstractDelegate)//if there is no other delegate running
     { 
         QVariant params;
         params.setValue(mDeviceIndex);
         mAbstractDelegate = BtDelegateFactory::newDelegate(
-                BtDelegate::Pair, mSettingModel, mDeviceModel); 
-        connect( mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(pairDelegateCompleted(int)) );
+                BtDelegate::PairDevice, mSettingModel, mDeviceModel); 
+        connect( mAbstractDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), this, SLOT(pairDelegateCompleted(int)) );
         mAbstractDelegate->exec(params);
     }
-    
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiDeviceView::pairDelegateCompleted(int status)
+void BtcpuiDeviceView::pairDelegateCompleted(int status)
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     Q_UNUSED(status);
     //TODO: handle the error here
     if (mAbstractDelegate)
     {
-        disconnect(mAbstractDelegate);
         delete mAbstractDelegate;
         mAbstractDelegate = 0;
     }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiDeviceView::unpairDevice()
+void BtcpuiDeviceView::unpairDevice()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     if (!mAbstractDelegate)//if there is no other delegate running
     { 
-        QVariant params;
-        params.setValue(mDeviceIndex);
+        QList<QVariant>list;
+        list.append(mDeviceBdAddr);
+        list.append(QVariant(BtUnpair));
+        
         mAbstractDelegate = BtDelegateFactory::newDelegate(
-                BtDelegate::Unpair, mSettingModel, mDeviceModel); 
-        connect( mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(unpairDelegateCompleted(int)) );
-        mAbstractDelegate->exec(params);
+                BtDelegate::UnpairDevice, mSettingModel, mDeviceModel); 
+        connect( mAbstractDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), this, 
+                SLOT(unpairDelegateCompleted(int)) );
+        mAbstractDelegate->exec(QVariant(list));
     }
-        
-    
+    BOstraceFunctionExit0(DUMMY_DEVLIST); 
 }
 
-void BtCpUiDeviceView::unpairDelegateCompleted(int status)
+void BtcpuiDeviceView::unpairDelegateCompleted(int status)
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     Q_UNUSED(status);
     //TODO: handle the error here 
     if (mAbstractDelegate)
     {
-        disconnect(mAbstractDelegate);
         delete mAbstractDelegate;
         mAbstractDelegate = 0;
     }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiDeviceView::connectDevice()
+void BtcpuiDeviceView::connectDevice()
 {
-    
-    
-    if (!mAbstractDelegate)//if there is no other delegate running
-    { 
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+
+    if (!mAbstractDelegate) { //if there is no other delegate running
         QVariant params;
         params.setValue(mDeviceIndex);
         mAbstractDelegate = BtDelegateFactory::newDelegate(
-                BtDelegate::Connect, mSettingModel, mDeviceModel); 
-        connect( mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(connectDelegateCompleted(int)) );
+                BtDelegate::ConnectService, mSettingModel, mDeviceModel); 
+        connect( mAbstractDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), this, SLOT(connectDelegateCompleted(int)) );
         mAbstractDelegate->exec(params);
     }
-    
-    
+    BOstraceFunctionExit0(DUMMY_DEVLIST);       
 }
 
-void BtCpUiDeviceView::connectDelegateCompleted(int status)
+void BtcpuiDeviceView::connectDelegateCompleted(int status)
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     Q_UNUSED(status);
-    if (mAbstractDelegate)
-    {
-        disconnect(mAbstractDelegate);
+    if (mAbstractDelegate) {
         delete mAbstractDelegate;
         mAbstractDelegate = 0;
     }   
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiDeviceView::disconnectDevice()
+void BtcpuiDeviceView::disconnectDevice()
 {
-    if (!mAbstractDelegate)//if there is no other delegate running
-        { 
-           
-            
-            DisconnectOption discoOpt = ServiceLevel;
-                    
-            QList<QVariant>list;
-            QVariant paramFirst;
-            paramFirst.setValue(mDeviceIndex);
-            
-            QVariant paramSecond;
-            paramSecond.setValue((int)discoOpt);
-                    
-            list.append(paramFirst);
-            list.append(paramSecond);
-                    
-            QVariant params;
-            params.setValue(list);
-            
-            
-            //params.setValue(mDeviceIndex);
-            mAbstractDelegate = BtDelegateFactory::newDelegate(
-                    BtDelegate::Disconnect, mSettingModel, mDeviceModel); 
-            connect( mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(disconnectDelegateCompleted(int)) );
-            mAbstractDelegate->exec(params);
-        }
-    
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    if (!mAbstractDelegate) { //if there is no other delegate running 
+        QList<QVariant>list;
+        list.append(QVariant(ServiceLevel));
+        list.append(mDeviceBdAddr);
+        
+        mAbstractDelegate = BtDelegateFactory::newDelegate(
+                BtDelegate::DisconnectService, mSettingModel, mDeviceModel); 
+        // todo: check return value of connect
+        connect( mAbstractDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), this, SLOT(disconnectDelegateCompleted(int)) );
+        mAbstractDelegate->exec(QVariant(list));
+    }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiDeviceView::disconnectDelegateCompleted(int status)
+void BtcpuiDeviceView::disconnectDelegateCompleted(int status)
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     Q_UNUSED(status);
     if (mAbstractDelegate)
     {
-        disconnect(mAbstractDelegate);
         delete mAbstractDelegate;
         mAbstractDelegate = 0;
     }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiDeviceView::setPrevBtDeviceName()
+void BtcpuiDeviceView::setPrevBtDeviceName()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     QString deviceName = (mDeviceModel->data(mDeviceIndex, 
                 BtDeviceModel::NameAliasRole)).toString(); 
    mDeviceName->setText(deviceName);
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiDeviceView::changeBtDeviceName(){
-    if (!mAbstractDelegate)//if there is no other delegate running
-    { 
+void BtcpuiDeviceView::changeBtDeviceName()
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    if (!mAbstractDelegate){
+        //if there is no other delegate running
         QList<QVariant>list;
         
         QVariant index;
@@ -640,33 +688,35 @@
         params.setValue(list);
         
         mAbstractDelegate = BtDelegateFactory::newDelegate(
-                BtDelegate::RemoteDevName, mSettingModel, mDeviceModel); 
-        connect( mAbstractDelegate, SIGNAL(commandCompleted(int, QVariant)), this, SLOT(changeDevNameDelegateCompleted(int, QVariant)) );
+                BtDelegate::ChangeDeviceFriendlyName, mSettingModel, mDeviceModel); 
+        connect( mAbstractDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), 
+                this, SLOT(changeDevNameDelegateCompleted(int, QVariant)) );
         mAbstractDelegate->exec(params);
     }
     else {
         setPrevBtDeviceName();
     }
-    
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiDeviceView::changeDevNameDelegateCompleted(int status, QVariant param)
-{
-    
-    
-    if(KErrNone == status) {
-        mDeviceName->setText(param.toString());
-    }
-    else {
+void BtcpuiDeviceView::changeDevNameDelegateCompleted(int status)
+{   
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    if(KErrNone != status) {
         setPrevBtDeviceName();
     }
-    //TODO:Error handling has to be done.    
-    if (mAbstractDelegate)
-    {
-        disconnect(mAbstractDelegate);
+ 
+    if (mAbstractDelegate){
         delete mAbstractDelegate;
         mAbstractDelegate = 0;
-    }
-    
-    
+    }   
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
+
+void BtcpuiDeviceView::updateButton(HbPushButton *button, const QString &iconName, const QString &text)
+{
+    HbIcon icon(iconName);
+    icon.setIconName(iconName);
+    button->setIcon(icon);
+    button->setText(text);
+}
--- a/bluetoothengine/btui/btcpplugin/btcpuideviceview.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btcpplugin/btcpuideviceview.h	Fri Sep 03 16:17:59 2010 +0300
@@ -18,7 +18,6 @@
 #ifndef	BTCPUIDEVICEVIEW_H
 #define	BTCPUIDEVICEVIEW_H
 
-#include <cpbasesettingview.h>
 #include <hbaction.h>
 #include <hbtoolbar.h>
 #include "btcpuibaseview.h"
@@ -32,97 +31,81 @@
 class HbDataForm;
 
 class HbDataFormModel;
-//class HbDataFormModelItem;
+class HbDataFormModelItem;
 class CpSettingFormItemData;
 class BtAbstractDelegate;
 class BtCpUiDeviceDetail;
 
-class BtCpUiDeviceView : public BtCpUiBaseView
+class BtcpuiDeviceView : public BtcpuiBaseView
 {
     Q_OBJECT
     
 public:
-    explicit BtCpUiDeviceView(
-            BtSettingModel &settingModel, 
+    explicit BtcpuiDeviceView(BtSettingModel &settingModel, 
             BtDeviceModel &deviceModel,            
             QGraphicsItem *parent = 0);
-    virtual ~BtCpUiDeviceView();
-    virtual void activateView( const QVariant& value, bool fromBackButton );
+    
+    virtual ~BtcpuiDeviceView();
+    virtual void activateView( const QVariant& value, bool backNavi);
     virtual void deactivateView();
-    virtual void setSoftkeyBack();
         
 public slots:
     
-    virtual void switchToPreviousView();
+    void backToPreviousView();
     void changeOrientation( Qt::Orientation orientation );
     void updateDeviceData();
     void changeBtDeviceName();
-    void pairUnpair();
-    void connectDisconnect();
+    void pairDevice();
+    void unpairDevice();
+    void connectDevice();
+    void disconnectDevice();
     void pairDelegateCompleted(int status);
     void unpairDelegateCompleted(int status);
     void connectDelegateCompleted(int status);
     void disconnectDelegateCompleted(int status);
-    void changeDevNameDelegateCompleted(int status, QVariant param);
+    void changeDevNameDelegateCompleted(int status);
     void handleDeviceSetting();
     void handleDeviceSettingsChange(bool status);
+    void connectionPreferenceChanged(int index);
     
 private:
+    enum connectionSelection {
+        ConnectionAutomatic = 0,
+        ConnectionAlwaysAsk, 
+        ConnectionBlocked
+    };
     void clearViewData();
-    void pairDevice();
-    void unpairDevice();
-    void connectDevice();
-    void disconnectDevice();
     void setDeviceCategory(int cod, int majorRole);//cod:class of device
     void setDeviceStatus(int majorRole);
     void setConnectionCombobox();
-    void setTextAndVisibilityOfButtons();
-    void updateStatusVariables(int majorRole);
+    void setTextAndVisibilityOfButtons(int majorProperty);
     void loadDeviceDetails();
     void unloadDeviceDetails();
     void setPrevBtDeviceName();
+    void setDeviceAuthorised();
+    void setDeviceAlwaysAsk();
+    void setDeviceBlocked();
+    void updateButton(HbPushButton *button, const QString &iconName, const QString &text);
     
 private:
     HbDocumentLoader *mLoader;
-    //HbGroupBox *mGroupBox;
     HbLabel *mDeviceIcon;
     HbLineEdit *mDeviceName;
     HbLabel *mDeviceCategory;
     HbLabel *mDeviceStatus;
     
-    HbDataForm *mConnectionCombobox;
+    HbDataForm *mConnectionDataForm;
     HbDataFormModel *mConnectionComboboxModel;
+    HbDataFormModelItem *mCombobox;
     
     HbPushButton *mPair_Unpair;
     HbPushButton *mConnect_Disconnect;
     HbPushButton *mDeviceSetting;
     
-    
-    // data structures for switching between views
-    bool mEventFilterInstalled;
-    int mAutoCmdId;
-    Qt::Orientation mOrientation;
-    
-    HbMainWindow* mMainWindow;
-    BtCpUiBaseView* mMainView;
-    //BtCpUiBaseView* mDeviceView;
-    HbAction *mSoftKeyBackAction;
-    
     QModelIndex mDeviceIndex;
     QVariant mDeviceBdAddr;
-    
-    //true -> device is paired; false -> device is unpaired
-    bool mPairedStatus;
-    
-    //true-> device is connected; false -> device is disconnected
-    bool mConnectedStatus;
-    bool mPreviousConnectedStatus;
-    bool mTrustedStatus;
-    bool mBlockedStatus;
 
-    //true -> device is connectable
-    //e.g. not possible to connect to a phone, but possible to connect to a headset
-    bool mConnectable;
+    int mComboboxIndex;
     
     BtAbstractDelegate* mAbstractDelegate;
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btui/btcpplugin/btcpuimaingridviewitem.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,109 @@
+/*
+* Copyright (c) 2008-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:  BTUISearchListViewItem implementation
+*
+*/
+
+
+#include "btcpuimaingridviewitem.h"
+#include "btdevicemodel.h"
+#include "btuiiconutil.h"
+#include <QGraphicsGridLayout>
+#include <hbstyle.h>
+#include <bluetoothuitrace.h>
+
+BtCpUiMainGridViewItem::BtCpUiMainGridViewItem(QGraphicsItem * parent) :
+    HbGridViewItem(parent)
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    mDeviceNameLabel = 0;
+    mDevTypeIconLabel = 0;
+    mDevTypeTextLabel = 0;
+    mBtuiModelSortFilter = ((BtCpUiMainGridViewItem *)parent)->mBtuiModelSortFilter;
+    BOstraceFunctionExit0(DUMMY_DEVLIST); 
+}
+
+BtCpUiMainGridViewItem::~BtCpUiMainGridViewItem()
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
+}
+
+/*
+ * This method is called by the HbListView when it needs a new
+ * view item element.
+ *
+ */
+HbAbstractViewItem * BtCpUiMainGridViewItem::createItem()
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    HbAbstractViewItem *item = new BtCpUiMainGridViewItem(*this); 
+    BOstraceFunctionExitExt(DUMMY_DEVLIST, this, item);
+    return item;
+}
+
+/*!
+   UpdateChildItem updates the item graphics.
+   Screen elements are created once if not already done.  This may increase the overall memory 
+   consumption of the application, however, this is deemed inconsequential.  There might be a small 
+   performance improvement with current style.
+ */
+void BtCpUiMainGridViewItem::updateChildItems()
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    QModelIndex index;
+    
+    // Get device name from model
+    if (mBtuiModelSortFilter)
+        index = mBtuiModelSortFilter->mapToSource(modelIndex());
+    else
+        index = modelIndex();
+
+    // create new icon label if needed
+    if (!mDevTypeIconLabel) {
+        mDevTypeIconLabel = new HbLabel(this);
+        HbStyle::setItemName(mDevTypeIconLabel, "deviceIcon");
+    }
+   
+    // create new label if needed
+    if (!mDeviceNameLabel) {
+        mDeviceNameLabel = new HbLabel(this);
+        HbStyle::setItemName(mDeviceNameLabel, "deviceName");
+    }
+    
+    // create new label if needed
+    if (!mDevTypeTextLabel) {
+        mDevTypeTextLabel = new HbLabel(this);
+        HbStyle::setItemName(mDevTypeTextLabel, "deviceType");
+    }
+        
+    QString data = index.data(Qt::DisplayRole).toString();
+    int cod = (index.data(BtDeviceModel::CoDRole)).toInt();
+    int majorProperty = (index.data(BtDeviceModel::MajorPropertyRole)).toInt();
+    
+    mDeviceNameLabel->setPlainText(data);
+    mDevTypeTextLabel->setPlainText( getDeviceTypeString( cod ));
+    
+    HbIcon icon = 
+    getBadgedDeviceTypeIcon( cod, majorProperty, 
+            BtuiBottomLeft | BtuiBottomRight | BtuiTopLeft | BtuiTopRight );
+    mDevTypeIconLabel->setIcon(icon);
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
+}
+
+
+void BtCpUiMainGridViewItem::setModelSortFilter(BtuiModelSortFilter *filter)
+{
+    mBtuiModelSortFilter = filter;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btui/btcpplugin/btcpuimaingridviewitem.h	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,51 @@
+/*
+* Copyright (c) 2008-2009 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:  device view item
+*
+*/
+
+
+#ifndef BTCPUIMAINGRIDVIEWITEM_H
+#define BTCPUIMAINGRIDVIEWITEM_H
+
+//#include <hblistviewitem.h>
+#include <hbgridviewitem.h>
+#include <hblabel.h>
+#include <hbpushbutton.h>
+#include <QtGui/QGraphicsGridLayout>
+#include "btuimodelsortfilter.h"
+
+class BtCpUiMainGridViewItem : public HbGridViewItem
+{
+    Q_OBJECT
+    
+public:
+    BtCpUiMainGridViewItem(QGraphicsItem * parent = 0);
+    ~BtCpUiMainGridViewItem();
+    
+    HbAbstractViewItem * createItem();
+    void updateChildItems();
+    
+    void setModelSortFilter(BtuiModelSortFilter *filter);
+    
+private:
+
+    HbLabel *mDevTypeIconLabel;
+    HbLabel *mDeviceNameLabel;
+    HbLabel *mDevTypeTextLabel;
+    BtuiModelSortFilter*    mBtuiModelSortFilter;
+    
+};
+
+#endif /* BTCPUIMAINGRIDVIEWITEM_H */
--- a/bluetoothengine/btui/btcpplugin/btcpuimainlistviewitem.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,114 +0,0 @@
-/*
-* Copyright (c) 2008-2009 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:  BTUISearchListViewItem implementation
-*
-*/
-
-
-#include "btcpuimainlistviewitem.h"
-#include "btdevicemodel.h"
-#include "btuiiconutil.h"
-#include <QGraphicsGridLayout>
-
-BtCpUiMainListViewItem::BtCpUiMainListViewItem(QGraphicsItem * parent) :
-    HbListViewItem(parent), mParent(parent)
-{
-    mDeviceNameLabel = 0;
-    mDevTypeIconLabel = 0;
-    mDevTypeTextLabel = 0;
-    mBtuiModelSortFilter = ((BtCpUiMainListViewItem *)parent)->mBtuiModelSortFilter;
-    
-    mRow = 0;   
-}
-
-BtCpUiMainListViewItem::~BtCpUiMainListViewItem()
-{
-//    delete mDeviceNameLabel;
-//    delete mDevTypeIconLabel;
-//    delete mDevTypeTextLabel;
-}
-
-/*
- * This method is called by the HbListView when it needs a new
- * view item element.
- *
- */
-HbAbstractViewItem * BtCpUiMainListViewItem::createItem()
-{
-    return new BtCpUiMainListViewItem(*this); 
-}
-
-/*!
-   UpdateChildItem updates the item graphics.
-   Screen elements are created once if not already done.  This may increase the overall memory 
-   consumption of the application, however, this is deemed inconsequential.  There might be a small 
-   performance improvement with current style.
- */
-void BtCpUiMainListViewItem::updateChildItems()
-{
-    QModelIndex index;
-    
-    // Get device name from model
-    if (mBtuiModelSortFilter)
-        index = mBtuiModelSortFilter->mapToSource(modelIndex());
-    else
-        index = modelIndex();
-
-    // create new icon label if needed
-    if (!mDevTypeIconLabel) {
-        mDevTypeIconLabel = new HbLabel();
-        mDevTypeIconLabel->setPreferredSize(53.5260, 53.5260); //8un x 8un
-        mDevTypeIconLabel->setMinimumWidth(53.5260);
-    }
-    // create new label if needed
-    if (!mDeviceNameLabel) {
-        mDeviceNameLabel = new HbLabel();
-        mDeviceNameLabel->setPreferredSize(250, 26.763);
-    }
-    // create new label if needed
-    if (!mDevTypeTextLabel) {
-        mDevTypeTextLabel = new HbLabel();
-        mDevTypeTextLabel->setPreferredSize(250, 26.763);
-    }
-    // create layout if needed
-    if ( !mRow ) {
-        // Still need to create the actual layout
-        mRow = new QGraphicsGridLayout();
-        mRow->addItem(mDevTypeIconLabel,0,0,2,1);
-        mRow->addItem(mDeviceNameLabel,0,1,1,1);
-        mRow->addItem(mDevTypeTextLabel,1,1,1,1);
-        setLayout(mRow);
-    }
-        
-    QString data = index.data(Qt::DisplayRole).toString();
-    int cod = (index.data(BtDeviceModel::CoDRole)).toInt();
-    int majorProperty = (index.data(BtDeviceModel::MajorPropertyRole)).toInt();
-    
-    // ToDo:  remove clear() once Orbit bug is fixed
-    mDeviceNameLabel->clear();
-    mDeviceNameLabel->setPlainText(data);
-    mDevTypeIconLabel->clear();
-    mDevTypeTextLabel->clear();
-    mDevTypeTextLabel->setPlainText( getDeviceTypeString( cod ));
-    HbIcon icon = 
-    getBadgedDeviceTypeIcon( cod, majorProperty, 
-            BtuiBottomLeft | BtuiBottomRight | BtuiTopLeft | BtuiTopRight );
-    mDevTypeIconLabel->setIcon(icon);
-}
-
-
-void BtCpUiMainListViewItem::setModelSortFilter(BtuiModelSortFilter *filter)
-{
-    mBtuiModelSortFilter = filter;
-}
--- a/bluetoothengine/btui/btcpplugin/btcpuimainlistviewitem.h	Fri Aug 06 16:43:21 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,51 +0,0 @@
-/*
-* Copyright (c) 2008-2009 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:  device view item
-*
-*/
-
-
-#ifndef BTCPUIMAINLISTVIEWITEM_H
-#define BTCPUIMAINLISTVIEWITEM_H
-
-#include <hblistviewitem.h>
-#include <hblabel.h>
-#include <hbpushbutton.h>
-#include <QtGui/QGraphicsGridLayout>
-#include "btuimodelsortfilter.h"
-
-class BtCpUiMainListViewItem : public HbListViewItem
-{
-    Q_OBJECT
-    
-public:
-    BtCpUiMainListViewItem(QGraphicsItem * parent = 0);
-    ~BtCpUiMainListViewItem();
-    
-    HbAbstractViewItem * createItem();
-    void updateChildItems();
-    
-    void setModelSortFilter(BtuiModelSortFilter *filter);
-    
-private:
-    QGraphicsItem *mParent;
-    HbLabel *mDevTypeIconLabel;
-    HbLabel *mDeviceNameLabel;
-    HbLabel *mDevTypeTextLabel;
-    BtuiModelSortFilter*    mBtuiModelSortFilter;
-    
-    QGraphicsGridLayout *mRow;
-};
-
-#endif /* BTCPUIMAINLISTVIEWITEM_H */
--- a/bluetoothengine/btui/btcpplugin/btcpuimainview.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btcpplugin/btcpuimainview.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -11,7 +11,7 @@
 *
 * Contributors:
 *
-* Description:  BtCpUiMainView implementation
+* Description:  BtcpuiMainView implementation
 *
 */
 
@@ -35,261 +35,182 @@
 #include <hbcombobox.h>
 #include <hbgroupbox.h>
 #include <hbdataform.h>
+#include <HbStyleLoader>
+#include <bluetoothuitrace.h>
+#include <HbMessageBox>
+#include <btabstractdelegate.h>
+#include "btqtconstants.h"
+#include "btcpuimaingridviewitem.h"
+#include "btuidevtypemap.h"
+#include "btcpuiviewmgr.h"
 #include "btcpuisearchview.h"
 #include "btcpuideviceview.h"
-#include <bluetoothuitrace.h>
-#include <btdelegatefactory.h>
-#include <btabstractdelegate.h>
-#include "btqtconstants.h"
-#include "btcpuimainlistviewitem.h"
-#include "btuidevtypemap.h"
 
 // docml to load
 const char* BTUI_MAINVIEW_DOCML = ":/docml/bt-main-view.docml";
 
 /*!
     Constructs a new BtUiMainView using HBDocumentLoader.  Docml (basically xml) file
-    has been generated using Application Designer.   
-
+    has been generated using Application Designer.
  */
-BtCpUiMainView::BtCpUiMainView(        
-        BtSettingModel &settingModel, 
-        BtDeviceModel &deviceModel, 
-        QGraphicsItem *parent )
-    : BtCpUiBaseView( settingModel, deviceModel, parent ),
-      mAbstractDelegate(0), mMainFilterModel(0)
+BtcpuiMainView::BtcpuiMainView(QGraphicsItem *parent )
+    : BtcpuiBaseView(parent), mSearchView(0), mDeviceView(0)
 {
-    bool ret(false);
-
-    mMainWindow = hbInstance->allMainWindows().first();
-    mMainView = this;
-    
-    // Create view for the application.
-    // Set the name for the view. The name should be same as the view's
-    // name in docml.
-    setObjectName("view");
-
-    mLoader = new HbDocumentLoader();
-    // Pass the view to documentloader. Document loader uses this view
-    // when docml is parsed, instead of creating new view.
-    QObjectList objectList;
-    objectList.append(this);
-    mLoader->setObjectTree(objectList);
-
-    bool ok = false;
-    mLoader->load( BTUI_MAINVIEW_DOCML, &ok );
-    // Exit if the file format is invalid
-    BTUI_ASSERT_X( ok, "bt-main-view", "Invalid docml file" );
-    
-    mOrientation = mMainWindow->orientation();
-    
-    if (mOrientation == Qt::Horizontal) {
-        mLoader->load(BTUI_MAINVIEW_DOCML, "landscape", &ok);
-        BTUI_ASSERT_X( ok, "bt-main-view", "Invalid docml file: landscape section problem" );
-    }
-    else {
-        mLoader->load(BTUI_MAINVIEW_DOCML, "portrait", &ok);
-        BTUI_ASSERT_X( ok, "bt-main-view", "Invalid docml file: landscape section problem" );        
-    }
-
-    mDeviceNameEdit=0;
-    mDeviceNameEdit = qobject_cast<HbLineEdit *>( mLoader->findWidget( "lineEdit" ) );
-    BTUI_ASSERT_X( mDeviceNameEdit != 0, "bt-main-view", "Device Name not found" );
-    ret =  connect(mDeviceNameEdit, SIGNAL(editingFinished ()), this, SLOT(changeBtLocalName()));
-    
-    mPowerButton=0;
-    mPowerButton = qobject_cast<HbPushButton *>( mLoader->findWidget( "pushButton" ) );
-    BTUI_ASSERT_X( mPowerButton != 0, "bt-main-view", "power button not found" );
-    ret =  connect(mPowerButton, SIGNAL(clicked()), this, SLOT(changePowerState()));
-    BTUI_ASSERT_X( ret, "BtCpUiMainView::BtCpUiMainView", "can't connect power button" );
-    
-    mVisibilityMode=0;
-    mVisibilityMode = qobject_cast<HbComboBox *>( mLoader->findWidget( "combobox" ) );
-    BTUI_ASSERT_X( mVisibilityMode != 0, "bt-main-view", "visibility combobox not found" );
-    // add new item for temporary visibility
-    // NOTE:  translation (at least default english) gives string "(p)Visible for 5 min", 
-    // if setting 1 min --> "(s)Visible for 1 min", ie p=plural, s=singular, but these should
-    // not be shown to the user!
-    // ToDo:  change this to use translation once it starts working
-    QString tempVis(hbTrId("txt_bt_setlabel_visibility_val_visible_for_l1_min", 5));  
-    //QString tempVis(hbTrId("Visible for 5 min"));  
-    mVisibilityMode->addItem(tempVis, Qt::DisplayRole);
-        
-    mDeviceList=0;
-    mDeviceList = qobject_cast<HbListView *>( mLoader->findWidget( "listView" ) );
-    BTUI_ASSERT_X( mDeviceList != 0, "bt-main-view", "Device List (grid view) not found" );   
-    
-    ret = connect(mDeviceList, SIGNAL(activated(QModelIndex)), this, SLOT(deviceSelected(QModelIndex)));
-    BTUI_ASSERT_X( ret, "bt-search-view", "deviceSelected can't connect" ); 
-    
-    // listen for orientation changes
-    ret = connect(mMainWindow, SIGNAL(orientationChanged(Qt::Orientation)),
-            this, SLOT(changeOrientation(Qt::Orientation)));
-    BTUI_ASSERT_X( ret, "BtCpUiMainView::BtCpUiMainView()", "connect orientationChanged() failed");
-
-    // load tool bar actions
-    HbAction *discoverAction = static_cast<HbAction*>( mLoader->findObject( "discoverAction" ) );
-    BTUI_ASSERT_X( discoverAction, "bt-main-view", "discover action missing" ); 
-    ret = connect(discoverAction, SIGNAL(triggered()), this, SLOT(goToDiscoveryView()));
-    BTUI_ASSERT_X( ret, "bt-main-view", "discover action can't connect" ); 
-
-    // load tool bar actions
-    mAllAction = static_cast<HbAction*>( mLoader->findObject( "allAction" ) );
-    BTUI_ASSERT_X( mAllAction, "bt-main-view", "All action missing" ); 
-    ret = connect(mAllAction, SIGNAL(triggered()), this, SLOT(allActionTriggered()));
-    BTUI_ASSERT_X( ret, "bt-main-view", "all action can't connect" ); 
-
-    // load tool bar actions
-    mPairAction = static_cast<HbAction*>( mLoader->findObject( "pairedAction" ) );
-    BTUI_ASSERT_X( mPairAction, "bt-main-view", "Pair action missing" ); 
-    ret = connect(mPairAction, SIGNAL(triggered()), this, SLOT(pairActionTriggered()));
-    BTUI_ASSERT_X( ret, "bt-main-view", "pair action can't connect" ); 
-
-    mDataForm = qobject_cast<HbDataForm *>( mLoader->findWidget( "dataForm" ) );
-    BTUI_ASSERT_X( mDataForm != 0, "bt-main-view", "dataForm not found" ); 
-    
-        
-    // load menu
-    HbMenu *optionsMenu = qobject_cast<HbMenu *>(mLoader->findWidget("viewMenu"));
-    BTUI_ASSERT_X( optionsMenu != 0, "bt-main-view", "Options menu not found" );   
-    this->setMenu(optionsMenu);
-    
-    HbMenu *menu = this->menu();
-    mRemovePairedDevices = menu->addAction(hbTrId("txt_bt_opt_remove_paired_devices"));
-    
-    mSubMenu = new HbMenu(hbTrId("txt_bt_opt_remove"));
-    mSubMenu->addAction(hbTrId("txt_bt_opt_remove_sub_all_devices"));
-    mSubMenu->addAction(hbTrId("txt_bt_opt_remove_sub_paired_devices"));
-    mSubMenu->addAction(hbTrId("txt_bt_opt_remove_sub_blocked_devices"));
-    
-    // update display when setting data changed
-    ret = connect(mSettingModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), 
-            this, SLOT(updateSettingItems(QModelIndex,QModelIndex)));
-    BTUI_ASSERT_X( ret, "BtCpUiMainView::BtCpUiMainView", "can't connect dataChanged" );
-    
-    QModelIndex top = mSettingModel->index( BtSettingModel::LocalBtNameRow, 0 );
-    QModelIndex bottom = mSettingModel->index( BtSettingModel::AllowedInOfflineRow, 0 );
-    // update name, power and visibility rows
-    updateSettingItems( top, bottom );
-
-    //Handle Visibility Change User Interaction
-    ret = connect(mVisibilityMode, SIGNAL(currentIndexChanged (int)), 
-            this, SLOT(visibilityChanged (int)));
-    // create other views
-    createViews();
-    mCurrentView = this;
-    mCurrentViewId = MainView;
-    
-    mMainFilterModel = new BtuiModelSortFilter(this);
-    
-    mMainFilterModel->setSourceModel( mDeviceModel );
-    mDeviceList->setModel(mMainFilterModel);
-    updateDeviceListFilter(BtuiPaired);
-	    // List view item
-    BtCpUiMainListViewItem *prototype = new BtCpUiMainListViewItem(mDeviceList);
-    prototype->setModelSortFilter(mMainFilterModel);
-    mDeviceList->setItemPrototype(prototype);
-
+    loadDocument();
+    setViewMgr(this);
 }
 
 /*!
-    Destructs the BtCpUiMainView.
+    Constructs a new BtUiMainView using HBDocumentLoader.  Docml (basically xml) file
+    has been generated using Application Designer.
  */
-BtCpUiMainView::~BtCpUiMainView()
+BtcpuiMainView::BtcpuiMainView(BtSettingModel &settingModel, 
+        BtDeviceModel &deviceModel, 
+        QGraphicsItem *parent )
+    : BtcpuiBaseView(settingModel, deviceModel, parent ), mSearchView(0), mDeviceView(0)
 {
+    loadDocument();
+    setViewMgr(this);    
+}
+
+/*!
+    Destructs the BtcpuiMainView.
+ */
+BtcpuiMainView::~BtcpuiMainView()
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    delete mSearchView;
+    delete mDeviceView;
     delete mLoader; // Also deletes all widgets that it constructed.
-    mMainWindow->removeView(mSearchView);
-    mMainWindow->removeView(mDeviceView);
-	if (mAbstractDelegate) {
-        delete mAbstractDelegate;
-    }
-
+	HbStyleLoader::unregisterFilePath(":/docml/btcpuimaingridviewitem.widgetml");
+    HbStyleLoader::unregisterFilePath(":/docml/btcpuimaingridviewitem.css");
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
 /*! 
     from base class, initialize the view
  */
-void BtCpUiMainView::activateView(const QVariant& value, bool fromBackButton )
+void BtcpuiMainView::activateView(const QVariant& value, bool backNavi)
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     Q_UNUSED(value);
-    Q_UNUSED(fromBackButton);
-    
-    //Reset the device list when returning to the view, as it may have been invalidated by the device view
-    mMainFilterModel->setSourceModel( mDeviceModel );
-    mDeviceList->setModel(mMainFilterModel);
+    Q_UNUSED(backNavi);
+    QModelIndex top = mSettingModel->index( BtSettingModel::LocalBtNameRow, 0 );
+    QModelIndex bottom = mSettingModel->index( BtSettingModel::AllowedInOfflineRow, 0 );
+    // update name, power and visibility rows
+    updateSettingItems( top, bottom );
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-/*! 
+/*!
     From base class. Handle resource before the current view is deactivated.
  */
-void BtCpUiMainView::deactivateView()
+void BtcpuiMainView::deactivateView()
 {
-
-}
-
-void BtCpUiMainView::goToDiscoveryView()
-{
-    changeView( SearchView, false );
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiMainView::goToDeviceView(const QModelIndex& modelIndex)
+void BtcpuiMainView::launchDeviceDiscovery()
 {
-    //the QModelIndex of the selected device should be given as parameter here 
-    QVariant params;
-    params.setValue(modelIndex);
-    changeView( DeviceView, false, params );
-}
-
-Qt::Orientation BtCpUiMainView::orientation()
-{
-    return mOrientation;
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    // Construct the search view if it does not exist yet.
+    (void) searchView();
+    bool ok = createDelegate(BtDelegate::Inquiry, 
+            this, SLOT(handleDelegateCompleted(int,BtAbstractDelegate*)));
+    if (ok) {
+        // Connect to the signal from BtDelegateInquiry for switching to 
+        // search view when BT inquiry operation is really started.
+        ok = connect(mDelegate, SIGNAL(beginUiEditMode()), this, SLOT(goToSearchView()));
+        BTUI_ASSERT_X( ok, "BtcpuiMainView", "launchDeviceDiscovery() can't connect" );
+    }
+    if (ok) {
+        mDelegate->exec(QVariant());
+    }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiMainView::changeBtLocalName()
+void BtcpuiMainView::goToSearchView()
 {
-    //Error handling has to be done.  
-    if (!mAbstractDelegate) {
-        mAbstractDelegate = BtDelegateFactory::newDelegate(BtDelegate::DeviceName, 
-                mSettingModel, mDeviceModel); 
-        connect( mAbstractDelegate, SIGNAL(commandCompleted(int,QVariant)), this, SLOT(btNameDelegateCompleted(int,QVariant)) );
-        mAbstractDelegate->exec(mDeviceNameEdit->text ());
-    }
-    else {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    BtcpuiBaseView *search = searchView();
+    // For navigating back to this view
+    search->setPreviousView( this );
+    search->take(mDelegate);
+    mDelegate = 0;
+    switchView(this, search, QVariant(), false);
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
+}
+
+void BtcpuiMainView::changeBtLocalName()
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    bool ok = createExecuteDelegate(BtDelegate::ChangeLocalName, 
+            this, SLOT(btNameDelegateCompleted(int)), mDeviceNameEdit->text());
+    if (!ok) {
         setPrevBtLocalName();
     }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiMainView::setPrevBtLocalName()
+void BtcpuiMainView::setPrevBtLocalName()
 {
-    //ToDo: Should we notify user this as Error...?
-    //HbNotificationDialog::launchDialog(hbTrId("Error"));
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     QModelIndex index = mSettingModel->index( BtSettingModel::LocalBtNameRow,0 );
     
     mDeviceNameEdit->setText( mSettingModel->data(
             index,BtSettingModel::settingDisplayRole).toString() );
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-
-void BtCpUiMainView::btNameDelegateCompleted(int status, QVariant param)
+void BtcpuiMainView::btNameDelegateCompleted(int status)
 {
-    if(KErrNone == status) {
-        mDeviceNameEdit->setText(param.toString());
-    }
-    else {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    if(KErrNone != status) {
         setPrevBtLocalName();
     }
-    //Error handling has to be done.    
-    if (mAbstractDelegate)
-    {
-        disconnect(mAbstractDelegate);
-        delete mAbstractDelegate;
-        mAbstractDelegate = 0;
-    }
-
+    handleDelegateCompleted(status, mDelegate);
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiMainView::visibilityChanged (int index)
+void BtcpuiMainView::removeRegistryDevices(BtDelegate::EditorType type)
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    
+    if (type != BtDelegate::RemoveBlockedDevices) {
+        //Before removing devices from the list call disconnect delegate
+        //to disconnect all active connections, this is done if all/paired
+        //devices are removed.   
+        QList<QVariant> list;
+        list.append(QVariant( AllOngoingConnections ));
+        
+        (void) createExecuteDelegate(BtDelegate::DisconnectAllConnections, 
+                    this, SLOT(disconnectAllDelegateCompleted(int)), list);
+    }
+    else {
+        //In case of Blocked devices, just remove devices from list.
+        (void) createExecuteDelegate(type, 
+                this, SLOT(handleDelegateCompleted(int,BtAbstractDelegate*)), type);
+    }
+    
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
+}
+
+void BtcpuiMainView::disconnectAllDelegateCompleted(int status)
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    handleDelegateCompleted(status, mDelegate);
+    
+    //Remove Device list from registry after disconnect is done.
+    (void) createExecuteDelegate(mRemoveDevDelegateType, 
+            this, SLOT(handleDelegateCompleted(int,BtAbstractDelegate*)), mRemoveDevDelegateType);
+
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
+}
+
+void BtcpuiMainView::changeVisibility(int index)
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     QList<QVariant> list;
     
     VisibilityMode mode = indexToVisibilityMode(index);
@@ -298,57 +219,240 @@
         //Right now hardcoded to 5 Mins.
         list.append(QVariant(5));
     }
+    bool ok = createExecuteDelegate(BtDelegate::ChangeVisibility, 
+            this, SLOT(visibilityDelegateCompleted(int)), list);
     //Error handling has to be done.    
-    if ( !mAbstractDelegate ) {
-        mAbstractDelegate = BtDelegateFactory::newDelegate(BtDelegate::Visibility, 
-                mSettingModel, mDeviceModel); 
-        connect( mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(visibilityDelegateCompleted(int)) );
-        mAbstractDelegate->exec(list);
-    }
-    else {
+    if ( !ok ) {
         setPrevVisibilityMode();
     }
-
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiMainView::setPrevVisibilityMode()
+void BtcpuiMainView::setPrevVisibilityMode()
 {
-   
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     QModelIndex index = mSettingModel->index( BtSettingModel::VisibilityRow, 0 );
     
     mVisibilityMode->setCurrentIndex ( visibilityModeToIndex((VisibilityMode)
                 mSettingModel->data(index,BtSettingModel::SettingValueRole).toInt()) );
-    
+    BOstraceFunctionExit0(DUMMY_DEVLIST);   
 }
 
 
-void BtCpUiMainView::allActionTriggered()
+void BtcpuiMainView::allActionTriggered()
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+   
+    updateDeviceListFilter(BtuiAll);
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
+}
+
+void BtcpuiMainView::pairActionTriggered()
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+
+    updateDeviceListFilter(BtuiPaired);
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
+}
+
+void BtcpuiMainView::aboutToShowOptionsMenu()
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    
+    updateOptionsMenu();
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
+}
+
+void BtcpuiMainView::updateOptionsMenu()
 {
-    HbMenu *menu = this->menu();
-    menu->removeAction(mRemovePairedDevices);
-    mRemoveDevices = menu->addMenu( mSubMenu );
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    
+    if(mPairAction->isEnabled()) {
+        //All Toolbar Action is active
+        mRemovePairedDevices->setVisible(false);
+        
+        int devCount = mDeviceModel->deviceCount(BtuiDevProperty::InRegistry);      
+        bool visibility = false;
+
+        HbAction *subMenuAction = static_cast<HbAction*> (mLoader->findObject(
+                "showAction"));
 
-    updateDeviceListFilter(BtuiAll);
+        if(!devCount) {
+            //No Registry devices then return.
+            mSubMenu->menuAction()->setVisible(false);
+            subMenuAction->setVisible(false);
+            return;
+        }
+        
+        visibility = true;           
+        mSubMenu->menuAction()->setVisible(visibility);
+        subMenuAction->setVisible(visibility);
+        
+        subMenuAction = static_cast<HbAction*> (mLoader->findObject(
+                "removeAllAction"));
+        subMenuAction->setVisible(visibility);
+        
+        devCount = mDeviceModel->deviceCount(BtuiDevProperty::Bonded);
+        
+        visibility = false;   
+        if(devCount) {
+            visibility = true;           
+        }
+        subMenuAction = static_cast<HbAction*> (mLoader->findObject(
+                "removePairedAction"));
+        subMenuAction->setVisible(visibility);
+        
+        devCount = mDeviceModel->deviceCount(BtuiDevProperty::Blocked);
+        
+        visibility = false;   
+        if(devCount) {
+            visibility = true;           
+        }
+        subMenuAction = static_cast<HbAction*> (mLoader->findObject(
+                "removeBlockedAction"));
+        subMenuAction->setVisible(visibility);
+
+    }
+    else {
+        //Pair Toolbar Action is active
+        mSubMenu->menuAction()->setVisible(false);
+        
+        int devCount = mDeviceModel->deviceCount(BtuiDevProperty::Bonded);
+        bool visibility = false;
+        
+        HbAction *subMenuAction = static_cast<HbAction*> (mLoader->findObject(
+                "showAction"));
+
+        if(devCount) {
+            visibility = true;           
+        }
+        mRemovePairedDevices->setVisible(visibility);
+        subMenuAction->setVisible(visibility);
+    }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiMainView::pairActionTriggered()
+void BtcpuiMainView::menuActionTriggered(HbAction *action)
 {
-    HbMenu *menu = this->menu();
-    menu->removeAction(mRemoveDevices);
-    mRemovePairedDevices = menu->addAction(hbTrId("txt_bt_opt_remove_paired_devices"));
-    updateDeviceListFilter(BtuiPaired);
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+
+    if(!(action->text().compare(hbTrId("txt_bt_opt_advanced_settings")))) {
+        //Advance Settings is not implemented yet.
+        return;
+    }
+    
+    if(!(action->text().compare(hbTrId("txt_bt_opt_show")))) {
+        viewByDeviceTypeDialog();
+    }
+    else {
+        QString dialogtext;
+        
+        if(!(action->text().compare(hbTrId("txt_bt_opt_remove_sub_all_devices")))) {
+            mRemoveDevDelegateType = BtDelegate::RemoveAllRegistryDevices;
+            dialogtext = hbTrId("txt_bt_info_delete_all_devices_some_devices_may_b");
+        }
+        else if(!(action->text().compare(hbTrId("txt_bt_opt_remove_sub_blocked_devices")))) {
+            mRemoveDevDelegateType = BtDelegate::RemoveBlockedDevices;
+            dialogtext = hbTrId("txt_bt_info_delete_all_blocked_devices");
+        }
+        else {
+            mRemoveDevDelegateType = BtDelegate::RemovePairedDevices;
+            dialogtext = hbTrId("txt_bt_info_delete_all_paired_devices_some_device");
+        }
+
+        HbMessageBox* dialog = new HbMessageBox(HbMessageBox::MessageTypeQuestion);
+        dialog->setText(dialogtext);
+        dialog->setStandardButtons(HbMessageBox::Yes | HbMessageBox::No);
+        dialog->setAttribute(Qt::WA_DeleteOnClose);
+        
+        dialog->open(this,SLOT(onRemoveQuestionDialogClosed(int)));
+
+    }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
+}
+
+void BtcpuiMainView::onRemoveQuestionDialogClosed(int action)
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    
+    if (action == HbMessageBox::Yes) {
+        removeRegistryDevices(mRemoveDevDelegateType);
+    }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-void BtCpUiMainView::updateDeviceListFilter(BtCpUiMainView::filterType filter)
+/*!
+   Callback for HbSelectionDialog closing
+   ReImplemented Slot from Base class
+
+ */
+void BtcpuiMainView::viewByDialogClosed(HbAction* action)
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    
+    int devTypesWanted = 0;
+    
+    devTypesWanted = selectedDeviceTypes(action);
+    
+    if (devTypesWanted) {
+        mBtuiModelSortFilter->clearDeviceMajorFilters();
+        if(mAllAction->isEnabled()) {
+            mBtuiModelSortFilter->addDeviceMajorFilter(
+                    BtuiDevProperty::InRegistry | BtuiDevProperty::Bonded, 
+                    BtuiModelSortFilter::AtLeastMatch);
+        }
+        else {
+            mBtuiModelSortFilter->addDeviceMajorFilter(
+                    BtuiDevProperty::InRegistry, 
+                    BtuiModelSortFilter::AtLeastMatch);
+        }
+        mBtuiModelSortFilter->addDeviceMajorFilter(devTypesWanted,
+                BtuiModelSortFilter::RoughMatch);             // device can be any one of selected ones
+    }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
+}
+
+BtcpuiBaseView *BtcpuiMainView::searchView()
 {
-    mMainFilterModel->clearDeviceMajorFilters();
+    if (!mSearchView) {
+        mSearchView = new BtcpuiSearchView(*mSettingModel, *mDeviceModel);
+        mSearchView->setViewMgr(this);
+        mMainWindow->addView(mSearchView);
+    }
+    return mSearchView;
+}
+
+BtcpuiBaseView *BtcpuiMainView::deviceView()
+{
+    if (!mDeviceView) {
+        mDeviceView = new BtcpuiDeviceView(*mSettingModel, *mDeviceModel);
+        mDeviceView->setViewMgr(this);
+        mMainWindow->addView(mDeviceView);
+    }
+    return mDeviceView;
+}
+
+void BtcpuiMainView::switchView(
+        BtcpuiBaseView *from, BtcpuiBaseView *destination,
+        const QVariant &init, bool backNavi)
+{
+    BTUI_ASSERT_X( from && destination, "BtcpuiSettingItem::switchView", "null view" );
+    from->deactivateView();
+    mMainWindow->setCurrentView( destination );
+    destination->activateView( init, backNavi);
+}
+
+void BtcpuiMainView::updateDeviceListFilter(BtcpuiMainView::filterType filter)
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    mBtuiModelSortFilter->clearDeviceMajorFilters();
     
     switch (filter) {
         case BtuiAll:
             mDataForm->setHeading(hbTrId("txt_bt_subhead_bluetooth_all_devices"));
             mPairAction->setEnabled(true);
             mAllAction->setEnabled(false);
-            mMainFilterModel->addDeviceMajorFilter(
+            mBtuiModelSortFilter->addDeviceMajorFilter(
                     BtuiDevProperty::InRegistry, 
                     BtuiModelSortFilter::AtLeastMatch);
 
@@ -357,56 +461,62 @@
             mDataForm->setHeading(hbTrId("txt_bt_subhead_bluetooth_paired_devices"));
             mPairAction->setEnabled(false);
             mAllAction->setEnabled(true);
-            mMainFilterModel->addDeviceMajorFilter(
+            mBtuiModelSortFilter->addDeviceMajorFilter(
                     BtuiDevProperty::InRegistry | BtuiDevProperty::Bonded, 
                     BtuiModelSortFilter::AtLeastMatch);
 
             break;
     }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
-
-void BtCpUiMainView::visibilityDelegateCompleted(int status)
+void BtcpuiMainView::visibilityDelegateCompleted(int status)
 {
-    
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     //This should be mapped to Qt error
     if(KErrNone != status) {
         setPrevVisibilityMode();
     }
-    
-    //Error handling has to be done.    
-    if (mAbstractDelegate)
-    {
-        disconnect(mAbstractDelegate);
-        delete mAbstractDelegate;
-        mAbstractDelegate = 0;
-    }
-
+    handleDelegateCompleted(status, mDelegate);
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
 
 // called due to real orientation change event coming from main window
-void BtCpUiMainView::changeOrientation( Qt::Orientation orientation )
+void BtcpuiMainView::changeOrientation( Qt::Orientation orientation )
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     bool ok = false;
     mOrientation = orientation;
     if( orientation == Qt::Vertical ) {
         // load "portrait" section
         mLoader->load( BTUI_MAINVIEW_DOCML, "portrait", &ok );
         BTUI_ASSERT_X( ok, "bt-main-view", "Invalid docml file: portrait section problem" );
+        
+        mDeviceList->setColumnCount(1);
+        mDeviceList->setRowCount(4);
+        mDeviceList->setScrollDirections(Qt::Vertical);
+        mDeviceList->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded );
     } else {
         // load "landscape" section
         mLoader->load( BTUI_MAINVIEW_DOCML, "landscape", &ok );
         BTUI_ASSERT_X( ok, "bt-main-view", "Invalid docml file: landscape section problem" );
+        
+        mDeviceList->setRowCount(1);
+        mDeviceList->setColumnCount(6);
+        mDeviceList->setScrollDirections(Qt::Horizontal);
+        mDeviceList->setHorizontalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded );
     }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
 /*!
     Slot for receiving notification of local setting changes from the model.
     Identify the setting changed and update the corresponding UI item.
  */
-void BtCpUiMainView::updateSettingItems(const QModelIndex &topLeft, const QModelIndex &bottomRight)
+void BtcpuiMainView::updateSettingItems(const QModelIndex &topLeft, const QModelIndex &bottomRight)
 {   
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     bool val(false);
     
     // update only the part of the view specified by the model's row(s)
@@ -436,19 +546,21 @@
                     mSettingModel->data(index,BtSettingModel::SettingValueRole).toInt()) );
             break;
         }
-    }   
+    }
+    BOstraceFunctionExit0(DUMMY_DEVLIST);
 }
 
 /*!
     Slot for receiving notification for user interaction on power state.
     Manually update model data since HbPushButton is not linked to model directly.
  */
-void BtCpUiMainView::changePowerState()
+void BtcpuiMainView::changePowerState()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     QModelIndex index = mSettingModel->index(BtSettingModel::PowerStateRow, 0);
     PowerStateQtValue powerState = (PowerStateQtValue)mSettingModel->data(index, Qt::EditRole).toInt();
     BTUI_ASSERT_X(((powerState == BtPowerOn) || (powerState == BtPowerOff)), 
-            "BtCpUiMainView::changePowerState()", "incorrect qt power state");
+            "BtcpuiMainView::changePowerState()", "incorrect qt power state");
 
     if (powerState == BtPowerOff) {
         powerState = BtPowerOn;
@@ -456,34 +568,167 @@
     else {
         powerState = BtPowerOff;
     } 
-    
-    if (!mAbstractDelegate)//if there is no other delegate running
-    { 
-        mAbstractDelegate = BtDelegateFactory::newDelegate(BtDelegate::ManagePower, 
-                mSettingModel, mDeviceModel ); 
-        connect( mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(powerDelegateCompleted(int)) );
-        mAbstractDelegate->exec(QVariant((int)powerState));
-    }
-   
+    (void) createExecuteDelegate(BtDelegate::ManagePower, 
+            this, SLOT(handleDelegateCompleted(int,BtAbstractDelegate*)), 
+            QVariant((int)powerState));
+    BOstraceFunctionExit0(DUMMY_DEVLIST); 
 }
 
-void BtCpUiMainView::powerDelegateCompleted(int status)
+void BtcpuiMainView::loadDocument()
 {
-    Q_UNUSED(status);
-    //ToDo: Error handling here 
-    if (mAbstractDelegate)
-    {
-        disconnect(mAbstractDelegate);
-        delete mAbstractDelegate;
-        mAbstractDelegate = 0;
+    bool ret(false);
+    // Create view for the application.
+    // Set the name for the view. The name should be same as the view's
+    // name in docml.
+    setObjectName("bt_main_view");
+
+    mLoader = new HbDocumentLoader();
+    // Pass the view to documentloader. Document loader uses this view
+    // when docml is parsed, instead of creating new view.
+    QObjectList objectList;
+    objectList.append(this);
+    mLoader->setObjectTree(objectList);
+
+    bool ok = false;
+    mLoader->load( BTUI_MAINVIEW_DOCML, &ok );
+    // Exit if the file format is invalid
+    BTUI_ASSERT_X( ok, "bt-main-view", "Invalid docml file" );
+    
+    mDeviceList=0;
+    mDeviceList = qobject_cast<HbGridView *>( mLoader->findWidget( "deviceList" ) );
+    BTUI_ASSERT_X( mDeviceList != 0, "bt-main-view", "Device List (grid view) not found" );   
+    
+    ret = connect(mDeviceList, SIGNAL(activated(QModelIndex)), this, SLOT(deviceSelected(QModelIndex)));
+    BTUI_ASSERT_X( ret, "bt-main-view", "deviceSelected can't connect" ); 
+
+    ret = connect(mDeviceList,
+            SIGNAL(longPressed(HbAbstractViewItem*, QPointF)), this,
+            SLOT(showContextMenu(HbAbstractViewItem*, QPointF)));
+    BTUI_ASSERT_X( ret, "bt-main-view", "deviceSelected can't connect" ); 
+
+    mOrientation = mMainWindow->orientation();
+    
+    mDeviceList->setSwapDimensionsOnOrientationChange(false);
+    
+    if (mOrientation == Qt::Horizontal) {
+        mLoader->load(BTUI_MAINVIEW_DOCML, "landscape", &ok);
+        BTUI_ASSERT_X( ok, "bt-main-view", "Invalid docml file: landscape section problem" );
+        mDeviceList->setRowCount(1);
+        mDeviceList->setColumnCount(6);
+        mDeviceList->setScrollDirections(Qt::Horizontal);
+        mDeviceList->setHorizontalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded );
+    }
+    else {
+        mLoader->load(BTUI_MAINVIEW_DOCML, "portrait", &ok);
+        BTUI_ASSERT_X( ok, "bt-main-view", "Invalid docml file: landscape section problem" );
+        mDeviceList->setColumnCount(1);
+        mDeviceList->setRowCount(4);
+        mDeviceList->setScrollDirections(Qt::Vertical);
+        mDeviceList->setVerticalScrollBarPolicy(HbScrollArea::ScrollBarAsNeeded );
     }
-    //BTUI_ASSERT_X( status, "bt-main-view", "error in delegate complete" );  
+
+    mDeviceNameEdit=0;
+    mDeviceNameEdit = qobject_cast<HbLineEdit *>( mLoader->findWidget( "deviceNameEdit" ) );
+    BTUI_ASSERT_X( mDeviceNameEdit != 0, "bt-main-view", "Device Name not found" );
+    ret =  connect(mDeviceNameEdit, SIGNAL(editingFinished ()), this, SLOT(changeBtLocalName()));
+    
+    mPowerButton=0;
+    mPowerButton = qobject_cast<HbPushButton *>( mLoader->findWidget( "toggleBluetoothPower" ) );
+    BTUI_ASSERT_X( mPowerButton != 0, "bt-main-view", "power button not found" );
+    ret =  connect(mPowerButton, SIGNAL(clicked()), this, SLOT(changePowerState()));
+    BTUI_ASSERT_X( ret, "BtcpuiMainView::BtcpuiMainView", "can't connect power button" );
+    
+    mVisibilityMode=0;
+    mVisibilityMode = qobject_cast<HbComboBox *>( mLoader->findWidget( "visibilityMode" ) );
+    BTUI_ASSERT_X( mVisibilityMode != 0, "bt-main-view", "visibility combobox not found" );
+    // add new item for temporary visibility
+    // NOTE:  translation (at least default english) gives string "(p)Visible for 5 min", 
+    // if setting 1 min --> "(s)Visible for 1 min", ie p=plural, s=singular, but these should
+    // not be shown to the user!
+    // ToDo:  change this to use translation once it starts working
+    QString tempVis(hbTrId("txt_bt_setlabel_visibility_val_visible_for_l1_min", 5));  
+    //QString tempVis(hbTrId("Visible for 5 min"));  
+    mVisibilityMode->addItem(tempVis, Qt::DisplayRole);
+        
+    // listen for orientation changes
+    ret = connect(mMainWindow, SIGNAL(orientationChanged(Qt::Orientation)),
+            this, SLOT(changeOrientation(Qt::Orientation)));
+    BTUI_ASSERT_X( ret, "BtcpuiMainView::BtcpuiMainView()", "connect orientationChanged() failed");
+
+    // load tool bar actions
+    HbAction *discoverAction = static_cast<HbAction*>( mLoader->findObject( "discoverAction" ) );
+    BTUI_ASSERT_X( discoverAction, "bt-main-view", "discover action missing" ); 
+    ret = connect(discoverAction, SIGNAL(triggered()), this, SLOT(launchDeviceDiscovery()));
+    BTUI_ASSERT_X( ret, "bt-main-view", "discover action can't connect" ); 
+
+    // load tool bar actions
+    mAllAction = static_cast<HbAction*>( mLoader->findObject( "allAction" ) );
+    BTUI_ASSERT_X( mAllAction, "bt-main-view", "All action missing" ); 
+    ret = connect(mAllAction, SIGNAL(triggered()), this, SLOT(allActionTriggered()));
+    BTUI_ASSERT_X( ret, "bt-main-view", "all action can't connect" ); 
+
+    // load tool bar actions
+    mPairAction = static_cast<HbAction*>( mLoader->findObject( "pairedAction" ) );
+    BTUI_ASSERT_X( mPairAction, "bt-main-view", "Pair action missing" ); 
+    ret = connect(mPairAction, SIGNAL(triggered()), this, SLOT(pairActionTriggered()));
+    BTUI_ASSERT_X( ret, "bt-main-view", "pair action can't connect" ); 
+
+    mDataForm = qobject_cast<HbDataForm *>( mLoader->findWidget( "bluetoothHeading" ) );
+    BTUI_ASSERT_X( mDataForm != 0, "bt-main-view", "dataForm not found" ); 
+    
+        
+    // load menu
+    HbMenu *optionsMenu = qobject_cast<HbMenu *>(mLoader->findWidget("viewMenu"));
+    BTUI_ASSERT_X( optionsMenu != 0, "bt-main-view", "Options menu not found" );
+    ret = connect(optionsMenu, SIGNAL(triggered(HbAction *)), this, SLOT(menuActionTriggered(HbAction *)));
+    BTUI_ASSERT_X( ret, "bt-main-view", "Menu can't connect" );
+
+    ret = connect(optionsMenu, SIGNAL(aboutToShow()), this, SLOT(aboutToShowOptionsMenu()));
+    BTUI_ASSERT_X( ret, "bt-main-view", "Menu aboutToShow() can't connect" );
+
+    mSubMenu = qobject_cast<HbMenu *>(mLoader->findWidget("removeSubMenu"));
+    BTUI_ASSERT_X( optionsMenu != 0, "bt-main-view", "Options Sub menu not found" );
+    
+    mRemovePairedDevices = static_cast<HbAction*>( mLoader->findObject( "viewRemovePairedAction" ) );
+            
+    // update display when setting data changed
+    ret = connect(mSettingModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), 
+            this, SLOT(updateSettingItems(QModelIndex,QModelIndex)));
+    BTUI_ASSERT_X( ret, "BtcpuiMainView::BtcpuiMainView", "can't connect dataChanged" );
+    
+    QModelIndex top = mSettingModel->index( BtSettingModel::LocalBtNameRow, 0 );
+    QModelIndex bottom = mSettingModel->index( BtSettingModel::AllowedInOfflineRow, 0 );
+    // update name, power and visibility rows
+    updateSettingItems( top, bottom );
+
+    //Handle Visibility Change User Interaction
+    ret = connect(mVisibilityMode, SIGNAL(currentIndexChanged (int)), 
+            this, SLOT(changeVisibility(int)));
+    
+    bool regStatus(false);
+    regStatus = HbStyleLoader::registerFilePath(":/docml/btcpuimaingridviewitem.widgetml");
+    BTUI_ASSERT_X( regStatus, "BtcpuiMainView::BtcpuiMainView", "registerFilePath Widgetml Failed" );
+    regStatus = HbStyleLoader::registerFilePath(":/docml/btcpuimaingridviewitem.css");
+    BTUI_ASSERT_X( regStatus, "BtcpuiMainView::BtcpuiMainView", "registerFilePath CSS Failed" );
+    
+    mBtuiModelSortFilter = new BtuiModelSortFilter(this);
+    
+    mBtuiModelSortFilter->setSourceModel( mDeviceModel );
+    mDeviceList->setModel(mBtuiModelSortFilter);
+    mDeviceList->setLayoutName("portrait");
+    updateDeviceListFilter(BtuiPaired);
+    
+    mSubMenu->menuAction()->setVisible(false);
+        // Grid view item
+    BtCpUiMainGridViewItem *prototype = new BtCpUiMainGridViewItem(mDeviceList);
+    prototype->setModelSortFilter(mBtuiModelSortFilter);
+    mDeviceList->setItemPrototype(prototype);
 }
 
 /*!
  * Mapping from visibility mode UI row to VisibilityMode
  */
-VisibilityMode BtCpUiMainView::indexToVisibilityMode(int index)
+VisibilityMode BtcpuiMainView::indexToVisibilityMode(int index)
 {
     VisibilityMode mode = BtVisibilityUnknown;
     switch(index) {
@@ -497,7 +742,7 @@
         mode = BtTemporary;
         break;
     default:
-        BTUI_ASSERT_X(false, "BtCpUiMainView::indexToVisibilityMode", "invalid mode");
+        BTUI_ASSERT_X(false, "BtcpuiMainView::indexToVisibilityMode", "invalid mode");
     }
     return mode;
 }
@@ -505,7 +750,7 @@
 /*!
  * Mapping from VisibilityMode to visibility mode UI row  
  */
-int BtCpUiMainView::visibilityModeToIndex(VisibilityMode mode)
+int BtcpuiMainView::visibilityModeToIndex(VisibilityMode mode)
 {
     int uiRow = UiRowBtUnknown;
     switch(mode) {
@@ -519,106 +764,17 @@
         uiRow = UiRowBtTemporary;
         break;
     default:
-        BTUI_ASSERT_X(false, "BtCpUiMainView::visibilityModeToIndex", "invalid mode");
+        BTUI_ASSERT_X(false, "BtcpuiMainView::visibilityModeToIndex", "invalid mode");
     }
     return uiRow;
 }
 
-
-
-/*!
-    Create views(main view, device view and search view).
-    Add them to MainWindow.  All views are long-lived and are deleted only when exiting the application 
-    (or when main view is deleted).
- */
-void BtCpUiMainView::createViews()
-{
-    Qt::Orientation orientation = mMainWindow->orientation();
-    // Create other views
-    mSearchView = new BtCpUiSearchView( *mSettingModel, *mDeviceModel, this );
-    mMainWindow->addView(mSearchView);
-    
-    mDeviceView = new BtCpUiDeviceView( *mSettingModel, *mDeviceModel, this );  
-    mMainWindow->addView(mDeviceView);
-    
-    mCurrentView = this;
-    mCurrentViewId = MainView;
-
-    
-    // QList<int> stores the previous view ids for each view.
-    for( int i=0; i < LastView; i++ ) {
-        mPreviousViewIds.append( 0 );
-    }
-}
-
-/*!
-    Switch between the views.  
-    Parameter "value" is optional except for GadgetView, 
-    which needs the QModelIndex of device
- */
-void BtCpUiMainView::changeView(int targetViewId, bool fromBackButton, 
-        const QVariant& value )
-{
-    mCurrentView->deactivateView();
-
-    // update the previous view Id in QList<int> 
-    // If launching the target view from back softkey, 
-    // the previous viewId of target view should not be changed. 
-    // Otherwise, loop happens between two views.
-    if(!fromBackButton) {
-        // normal case:  return to previous view
-        mPreviousViewIds[ targetViewId ] = mCurrentViewId;
+void BtcpuiMainView::createContextMenuActions(int majorRole)
+{  
+    if (majorRole & BtuiDevProperty::Connected) {
+        mContextMenu->addAction(hbTrId("txt_bt_menu_disconnect"));
     }
-
-    // set the new current view 
-    mCurrentView = idToView(targetViewId);
-    mCurrentViewId = targetViewId;
-    mMainWindow->setCurrentView( mCurrentView );
-
-    // do preparation or some actions when new view is activated 
-    mCurrentView->activateView( value, fromBackButton );
-}
- 
-
-void BtCpUiMainView::deviceSelected(const QModelIndex& modelIndex)
-{
-    QModelIndex index = mMainFilterModel->mapToSource(modelIndex);
-    
-    QVariant params;
-    params.setValue(index);
-    
-    changeView( DeviceView, false, params );
+    else {
+        mContextMenu->addAction(hbTrId("txt_bt_menu_connect"));
+    }   
 }
-
-BtCpUiBaseView * BtCpUiMainView::idToView(int targetViewId)
-{
-    switch (targetViewId) {
-    case MainView:
-        return mMainView;
-    case SearchView:
-        return mSearchView;
-    case DeviceView:
-        return mDeviceView;
-    default :
-        BTUI_ASSERT_X(false, "BtCpUiMainView::idToView", "invalid view id");
-    }
-    return 0;
-}
-
-void BtCpUiMainView::setSoftkeyBack()
-{
-    // not needed in main view
-}
-
-/*!
-   Jump to previous view.  This function is used when back button is pressed.
-   semantics slightly different than in other views, since this is called by other
-   views when a view switch is needed
- */
-void BtCpUiMainView::switchToPreviousView()
-{
-    BTUI_ASSERT_X( (mCurrentViewId >= 0) && (mCurrentViewId < LastView), 
-            "BtCpUiMainView::switchToPreviousView", "invalid view id");
-    changeView( mPreviousViewIds[mCurrentViewId], true );
-}
-
--- a/bluetoothengine/btui/btcpplugin/btcpuimainview.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btcpplugin/btcpuimainview.h	Fri Sep 03 16:17:59 2010 +0300
@@ -20,7 +20,8 @@
 
 #include "btcpuibaseview.h"
 #include <btqtconstants.h>
-#include <btuimodelsortfilter.h>
+#include <btdelegateconsts.h>
+#include "btcpuiviewmgr.h"
 
 class HbLabel;
 class HbLineEdit;
@@ -34,48 +35,60 @@
 class HbGroupBox;
 class HbDataForm;
 
-class BtCpUiMainView : public BtCpUiBaseView
+class BtcpuiMainView : public BtcpuiBaseView, public BtcpuiViewMgr
 {
     Q_OBJECT
 
 public:
-    explicit BtCpUiMainView(
-            BtSettingModel &settingModel, 
+    
+    explicit BtcpuiMainView(QGraphicsItem *parent = 0 );    
+    
+    explicit BtcpuiMainView(BtSettingModel &settingModel, 
             BtDeviceModel &deviceModel, 
             QGraphicsItem *parent = 0 );
-    ~BtCpUiMainView();
-    // from view manager
-    void createViews();
+    
+    ~BtcpuiMainView();
 
-    Qt::Orientation  orientation();
-
-    // from base class BtCpUiBaseView
-    virtual void setSoftkeyBack();
-    virtual void activateView( const QVariant& value, bool fromBackButton );
+    // from base class BtcpuiBaseView
+    virtual void activateView( const QVariant& value, bool backNavi);
+    
     virtual void deactivateView();
 
+    virtual void createContextMenuActions(int majorRole);
+    
 public slots: 
     void changeOrientation( Qt::Orientation orientation );
     void changePowerState();
-    void visibilityChanged (int index);
+    void changeVisibility(int index);
     void changeBtLocalName();
     
     void updateSettingItems(const QModelIndex &topLeft, const QModelIndex &bottomRight);
-    void deviceSelected(const QModelIndex& modelIndex);
-    void goToDiscoveryView();
-    void goToDeviceView(const QModelIndex& modelIndex);
-    virtual void switchToPreviousView();
+
+    void launchDeviceDiscovery();
+    
+    void goToSearchView();
 
     //from delegate classes
-    void powerDelegateCompleted(int status);
     void visibilityDelegateCompleted(int status);
-    void btNameDelegateCompleted(int status, QVariant param);
+    void btNameDelegateCompleted(int status);
     void allActionTriggered();
-    void pairActionTriggered();
+    void pairActionTriggered(); 
+    void menuActionTriggered(HbAction *action);
+    virtual void viewByDialogClosed(HbAction* action);
+    
+    void disconnectAllDelegateCompleted(int status);
+    void onRemoveQuestionDialogClosed(int action);
+    void aboutToShowOptionsMenu();
     
-private slots:
-    void changeView(int targetViewId, bool fromBackButton, const QVariant& value = 0 );    
-
+    // returns the search view instance.
+    BtcpuiBaseView *searchView();
+    
+    // From BtcpuiViewMgr
+    BtcpuiBaseView *deviceView();
+    
+    void switchView(BtcpuiBaseView *from, BtcpuiBaseView *destination,
+            const QVariant &init, bool backNavi);
+    
 private:
     enum filterType {
         BtuiAll = 0,
@@ -83,45 +96,44 @@
     };
     
 private:
+    
+    void loadDocument();
+    
     VisibilityMode indexToVisibilityMode(int index);
     int visibilityModeToIndex(VisibilityMode mode);
-    BtCpUiBaseView * idToView(int targetViewId);
     
     //Functions to set the Previous Local settings in case of error
     void setPrevBtLocalName();
     void setPrevVisibilityMode();
+    void removeRegistryDevices(BtDelegate::EditorType type);
     
-    void updateDeviceListFilter(BtCpUiMainView::filterType filter);
+    void updateDeviceListFilter(BtcpuiMainView::filterType filter);
+    
+    void updateOptionsMenu();
     
 private:
 
+    // search view. Owned
+    BtcpuiBaseView *mSearchView;
+    // device view. Owned.
+    BtcpuiBaseView *mDeviceView;
+    
     HbDocumentLoader *mLoader;
 
     HbLineEdit *mDeviceNameEdit;
     HbPushButton *mPowerButton;
     HbComboBox *mVisibilityMode;
-    HbListView *mDeviceList;
+    HbGridView *mDeviceList;
 
     Qt::Orientation mOrientation;
     
-    // from view manager
-    HbMainWindow* mMainWindow;
-    BtCpUiBaseView* mMainView;
-    BtCpUiBaseView* mDeviceView;
-    BtCpUiBaseView* mSearchView;
-    BtCpUiBaseView* mCurrentView;
-    int mCurrentViewId;
-    QList<int> mPreviousViewIds;
-    
-    //poiter to abstract delegate, and it is instantiated at runtime
-    BtAbstractDelegate* mAbstractDelegate;
-    BtuiModelSortFilter *mMainFilterModel;
-    
     HbAction *mAllAction;
     HbAction *mPairAction;
     HbDataForm *mDataForm;
     HbAction* mRemovePairedDevices;
     HbAction* mRemoveDevices;
     HbMenu* mSubMenu;
+    BtDelegate::EditorType mRemoveDevDelegateType;
+    
 };
 #endif // BTCPUIMAINVIEW_H 
--- a/bluetoothengine/btui/btcpplugin/btcpuisearchlistviewitem.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btcpplugin/btcpuisearchlistviewitem.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -20,23 +20,21 @@
 #include "btdevicemodel.h"
 #include "btuiiconutil.h"
 #include <QGraphicsGridLayout>
+#include <hbstyle.h>
 
 BtCpUiSearchListViewItem::BtCpUiSearchListViewItem(QGraphicsItem * parent) :
-    HbListViewItem(parent), mParent(parent)
+    HbListViewItem(parent)
 {
     mDeviceNameLabel = 0;
     mDevTypeIconLabel = 0;
-    mDevTypeTextLabel = 0;
+    
     mBtuiModelSortFilter = ((BtCpUiSearchListViewItem *)parent)->mBtuiModelSortFilter;
-    
-    mRow = 0;   
+      
 }
 
 BtCpUiSearchListViewItem::~BtCpUiSearchListViewItem()
 {
-//    delete mDeviceNameLabel;
-//    delete mDevTypeIconLabel;
-//    delete mDevTypeTextLabel;
+
 }
 
 /*
@@ -68,40 +66,21 @@
 
     // create new icon label if needed
     if (!mDevTypeIconLabel) {
-        mDevTypeIconLabel = new HbLabel();
-        mDevTypeIconLabel->setPreferredSize(53.5260, 53.5260); //8un x 8un
-        mDevTypeIconLabel->setMinimumWidth(53.5260);
+        mDevTypeIconLabel = new HbLabel(this);
+        HbStyle::setItemName(mDevTypeIconLabel, "btDeviceIcon");
     }
     // create new label if needed
     if (!mDeviceNameLabel) {
-        mDeviceNameLabel = new HbLabel();
-        mDeviceNameLabel->setPreferredSize(250, 26.763);
-    }
-    // create new label if needed
-    if (!mDevTypeTextLabel) {
-        mDevTypeTextLabel = new HbLabel();
-        mDevTypeTextLabel->setPreferredSize(250, 26.763);
-    }
-    // create layout if needed
-    if ( !mRow ) {
-        // Still need to create the actual layout
-        mRow = new QGraphicsGridLayout();
-        mRow->addItem(mDevTypeIconLabel,0,0,2,1);
-        mRow->addItem(mDeviceNameLabel,0,1,1,1);
-        mRow->addItem(mDevTypeTextLabel,1,1,1,1);
-        setLayout(mRow);
+        mDeviceNameLabel = new HbLabel(this);
+        HbStyle::setItemName(mDeviceNameLabel, "btDeviceName");
     }
         
     QString data = index.data(Qt::DisplayRole).toString();
     int cod = (index.data(BtDeviceModel::CoDRole)).toInt();
     int majorProperty = (index.data(BtDeviceModel::MajorPropertyRole)).toInt();
     
-    // ToDo:  remove clear() once Orbit bug is fixed
-    mDeviceNameLabel->clear();
     mDeviceNameLabel->setPlainText(data);
-    mDevTypeIconLabel->clear();
-    mDevTypeTextLabel->clear();
-    mDevTypeTextLabel->setPlainText( getDeviceTypeString( cod ));
+
     HbIcon icon = 
     getBadgedDeviceTypeIcon(cod, majorProperty,
             BtuiBottomLeft | BtuiBottomRight | BtuiTopLeft | BtuiTopRight );
--- a/bluetoothengine/btui/btcpplugin/btcpuisearchlistviewitem.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btcpplugin/btcpuisearchlistviewitem.h	Fri Sep 03 16:17:59 2010 +0300
@@ -39,13 +39,12 @@
     void setModelSortFilter(BtuiModelSortFilter *filter);
     
 private:
-    QGraphicsItem *mParent;
+
     HbLabel *mDevTypeIconLabel;
     HbLabel *mDeviceNameLabel;
-    HbLabel *mDevTypeTextLabel;
+
     BtuiModelSortFilter*    mBtuiModelSortFilter;
     
-    QGraphicsGridLayout *mRow;
 };
 
 #endif /* BTCPUISEARCHLISTVIEWITEM_H */
--- a/bluetoothengine/btui/btcpplugin/btcpuisearchview.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btcpplugin/btcpuisearchview.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -16,8 +16,9 @@
  */
 
 #include "btcpuisearchview.h"
-#include "btuiviewutil.h"
+#include <HbStyleLoader>
 #include <QtGui/QGraphicsLinearLayout>
+#include <HbAction>
 #include <HbInstance>
 #include <HbDocumentLoader>
 #include <HbDataForm>
@@ -31,41 +32,30 @@
 #include <QStringList>
 #include <QDebug>
 #include <bluetoothuitrace.h>
-#include "btcpuimainview.h"
-#include "btdelegatefactory.h"
 #include "btabstractdelegate.h"
 #include "btcpuisearchlistviewitem.h"
 #include "btuidevtypemap.h"
-
+#include "btuimodelsortfilter.h"
+#include "btuiviewutil.h"
+#include "btcpuiviewmgr.h"
 
 // docml to load
 const char* BTUI_SEARCHVIEW_DOCML = ":/docml/bt-search-view.docml";
 
-BtCpUiSearchView::BtCpUiSearchView(
-        BtSettingModel &settingModel, 
+BtcpuiSearchView::BtcpuiSearchView(BtSettingModel &settingModel, 
         BtDeviceModel &deviceModel, 
         QGraphicsItem *parent) :
-    BtCpUiBaseView(settingModel,deviceModel, parent), mAbstractDelegate(0), mBtuiModelSortFilter(0)
+    BtcpuiBaseView(settingModel,deviceModel, parent)
 {
     bool ret(false);
-    
-    mQuery = 0;
-    mLoader = 0;
-    mSoftKeyBackAction = 0;
-    
-    mMainView = (BtCpUiMainView *) parent;
-    mMainWindow = hbInstance->allMainWindows().first();
-    
-    mSoftKeyBackAction = new HbAction(Hb::BackNaviAction, this);
-    BTUI_ASSERT_X(mSoftKeyBackAction, "BtCpUiSearchView::BtCpUiSearchView", "can't create back action");
-    
+
     // Create view for the application.
     // Set the name for the view. The name should be same as the view's
     // name in docml.
     setObjectName("bt_search_view");
 
     mLoader = new HbDocumentLoader();
-    BTUI_ASSERT_X( mLoader != 0, "BtCpUiSearchView::BtCpUiSearchView", "can't create mLoader" );
+    BTUI_ASSERT_X( mLoader != 0, "BtcpuiSearchView::BtcpuiSearchView", "can't create mLoader" );
     // Pass the view to documentloader. Document loader uses this view
     // when docml is parsed, instead of creating new view.
     QObjectList objectList;
@@ -86,77 +76,79 @@
 
     mDeviceIcon=0;
     // can't use qobject_cast since HbIcon is not derived from QObject!
-    mDeviceIcon = qobject_cast<HbLabel *>( mLoader->findWidget( "icon" ) );  
-    BTUI_ASSERT_X( mDeviceIcon != 0, "BtCpUiSearchView::BtCpUiSearchView", "Device Icon not found" );
+    mDeviceIcon = qobject_cast<HbLabel *>( mLoader->findWidget( "searchIcon" ) );  
+    BTUI_ASSERT_X( mDeviceIcon != 0, "BtcpuiSearchView::BtcpuiSearchView", "Device Icon not found" );
     
     mDataForm=0;
-    mDataForm = qobject_cast<HbDataForm *>( mLoader->findWidget( "dataForm" ) );
-    BTUI_ASSERT_X( mDataForm != 0, "BtCpUiSearchView::BtCpUiSearchView", "dataForm not found" );
+    mDataForm = qobject_cast<HbDataForm *>( mLoader->findWidget( "searchHeading" ) );
+    BTUI_ASSERT_X( mDataForm != 0, "BtcpuiSearchView::BtcpuiSearchView", "dataForm not found" );
     mDataForm->setHeading(hbTrId("txt_bt_subhead_bluetooth_found_devices"));
 
     mLabelSearching=0;
-    mLabelSearching = qobject_cast<HbLabel *>( mLoader->findWidget( "label_searching" ) );
-    BTUI_ASSERT_X( mLabelSearching != 0, "BtCpUiSearchView::BtCpUiSearchView", "Searching not found" );
+    mLabelSearching = qobject_cast<HbLabel *>( mLoader->findWidget( "searchStatus" ) );
+    BTUI_ASSERT_X( mLabelSearching != 0, "BtcpuiSearchView::BtcpuiSearchView", "Searching not found" );
     mLabelSearching->setPlainText(hbTrId("txt_bt_subhead_searching"));
     
     mDeviceList=0;
     mDeviceList = qobject_cast<HbListView *>( mLoader->findWidget( "deviceList" ) );
-    BTUI_ASSERT_X( mDeviceList != 0, "BtCpUiSearchView::BtCpUiSearchView", "Device List not found" );   
+    BTUI_ASSERT_X( mDeviceList != 0, "BtcpuiSearchView::BtcpuiSearchView", "Device List not found" );   
     
-    
+    ret = connect(mDeviceList,
+            SIGNAL(longPressed(HbAbstractViewItem*, QPointF)), this,
+            SLOT(showContextMenu(HbAbstractViewItem*, QPointF)));
+    BTUI_ASSERT_X( ret, "bt-search-view", "deviceSelected can't connect" ); 
+
     mDeviceList->setSelectionMode( HbAbstractItemView::SingleSelection );
     
     // read landscape orientation section from docml file if needed
     mOrientation = mMainWindow->orientation();
     
     if (mOrientation == Qt::Horizontal) {
-        mLoader->load(BTUI_SEARCHVIEW_DOCML, "landscape_ui", &ok);
-        BTUI_ASSERT_X( ok, "BtCpUiSearchView::BtCpUiSearchView", "Invalid docml file: landscape section problem" );
+        mLoader->load(BTUI_SEARCHVIEW_DOCML, "landscape", &ok);
+        BTUI_ASSERT_X( ok, "BtcpuiSearchView::BtcpuiSearchView", "Invalid docml file: landscape section problem" );
     } else {
-        mLoader->load(BTUI_SEARCHVIEW_DOCML, "portrait_ui", &ok);
-        BTUI_ASSERT_X( ok, "BtCpUiSearchView::BtCpUiSearchView", "Invalid docml file: portrait section problem" );        
+        mLoader->load(BTUI_SEARCHVIEW_DOCML, "portrait", &ok);
+        BTUI_ASSERT_X( ok, "BtcpuiSearchView::BtcpuiSearchView", "Invalid docml file: portrait section problem" );        
     }
 
     // listen for orientation changes
     ret = connect(mMainWindow, SIGNAL(orientationChanged(Qt::Orientation)),
             this, SLOT(changeOrientation(Qt::Orientation)));
-    BTUI_ASSERT_X( ret, "BtCpUiSearchView::BtCpUiSearchView()", "connect orientationChanged() failed");
+    BTUI_ASSERT_X( ret, "BtcpuiSearchView::BtcpuiSearchView()", "connect orientationChanged() failed");
     
     // load tool bar actions
     mViewBy = static_cast<HbAction*>( mLoader->findObject( "viewByAction" ) );
-    BTUI_ASSERT_X( mViewBy, "BtCpUiSearchView::BtCpUiSearchView", "view by action missing" ); 
+    BTUI_ASSERT_X( mViewBy, "BtcpuiSearchView::BtcpuiSearchView", "view by action missing" ); 
     ret = connect(mViewBy, SIGNAL(triggered()), this, SLOT(viewByDeviceTypeDialog()));
-    BTUI_ASSERT_X( ret, "BtCpUiSearchView::BtCpUiSearchView", "viewByAction can't connect" ); 
+    BTUI_ASSERT_X( ret, "BtcpuiSearchView::BtcpuiSearchView", "viewByAction can't connect" ); 
 
     mStop = static_cast<HbAction*>( mLoader->findObject( "stopAction" ) );
-    BTUI_ASSERT_X( mStop, "BtCpUiSearchView::BtCpUiSearchView", "stopAction missing" ); 
+    BTUI_ASSERT_X( mStop, "BtcpuiSearchView::BtcpuiSearchView", "stopAction missing" ); 
     ret = connect(mStop, SIGNAL(triggered()), this, SLOT(stopSearching()));
-    BTUI_ASSERT_X( ret, "BtCpUiSearchView::BtCpUiSearchView", "stopAction can't connect" ); 
+    BTUI_ASSERT_X( ret, "BtcpuiSearchView::BtcpuiSearchView", "stopAction can't connect" ); 
     mStop->setEnabled(true);
     
     mRetry = static_cast<HbAction*>( mLoader->findObject( "retryAction" ) );
-    BTUI_ASSERT_X( mRetry, "BtCpUiSearchView::BtCpUiSearchView", "retryAction missing" ); 
+    BTUI_ASSERT_X( mRetry, "BtcpuiSearchView::BtcpuiSearchView", "retryAction missing" ); 
     ret = connect(mRetry, SIGNAL(triggered()), this, SLOT(retrySearch()));
-    BTUI_ASSERT_X( ret, "BtCpUiSearchView::BtCpUiSearchView", "retryAction can't connect" ); 
+    BTUI_ASSERT_X( ret, "BtcpuiSearchView::BtcpuiSearchView", "retryAction can't connect" ); 
     // Disable for initial search
     mRetry->setEnabled(false);
     
     // load menu
     HbMenu *optionsMenu = qobject_cast<HbMenu *>(mLoader->findWidget("viewMenu"));
-    BTUI_ASSERT_X( optionsMenu != 0, "BtCpUiSearchView::BtCpUiSearchView", "Options menu not found" );   
+    BTUI_ASSERT_X( optionsMenu != 0, "BtcpuiSearchView::BtcpuiSearchView", "Options menu not found" );   
     this->setMenu(optionsMenu);      
     
     ret = connect(mDeviceList, SIGNAL(activated(QModelIndex)), this, SLOT(deviceSelected(QModelIndex)));
-    BTUI_ASSERT_X( ret, "BtCpUiSearchView::BtCpUiSearchView", "deviceSelected can't connect" ); 
+    BTUI_ASSERT_X( ret, "BtcpuiSearchView::BtcpuiSearchView", "deviceSelected can't connect" ); 
     
-    // initialize device type list for "view by" option
-    // Note:  this list needs to be in the same order as enum devTypeSelectionList
-    mDevTypeList << hbTrId("txt_bt_list_audio_devices")
-            << hbTrId("txt_bt_list_computers") 
-            << hbTrId("txt_bt_list_input_devices") 
-            << hbTrId("txt_bt_list_phones") 
-            << hbTrId("txt_bt_list_other_devices");
-    
+    bool regStatus(false);
+    regStatus = HbStyleLoader::registerFilePath(":/docml/btcpuisearchlistviewitem.widgetml");
+    BTUI_ASSERT_X( regStatus, "BtcpuiSearchView::BtcpuiSearchView", "registerFilePath Widgetml Failed" );
+    regStatus = HbStyleLoader::registerFilePath(":/docml/btcpuisearchlistviewitem.css");
+    BTUI_ASSERT_X( regStatus, "BtcpuiSearchView::BtcpuiSearchView", "registerFilePath CSS Failed" );
+
     // initialize sort model & create
     // inquiry delegate
     // Sort is set to dynamic sort filter = true in the class, will sort automatically
@@ -165,6 +157,7 @@
     mBtuiModelSortFilter->addDeviceMajorFilter(
             BtuiDevProperty::InRange, BtuiModelSortFilter::AtLeastMatch);
     mDeviceList->setModel(mBtuiModelSortFilter);
+    mDeviceList->setLayoutName("custom-list");
     // add sort order to show devices in the order they are found
     mBtuiModelSortFilter->setSortRole(BtDeviceModel::SeqNumRole);
     // Sort according to the first column (and the only column) in the listview - sorted according SeqNumRole
@@ -173,34 +166,17 @@
     BtCpUiSearchListViewItem *prototype = new BtCpUiSearchListViewItem(mDeviceList);
     prototype->setModelSortFilter(mBtuiModelSortFilter);
     mDeviceList->setItemPrototype(prototype);
-
-    // Create the inquiry delegate.
-    mAbstractDelegate = BtDelegateFactory::newDelegate(BtDelegate::Inquiry, mSettingModel, mDeviceModel );
-    
-
 }
 
-BtCpUiSearchView::~BtCpUiSearchView()
+BtcpuiSearchView::~BtcpuiSearchView()
 {
     delete mLoader; // Also deletes all widgets that it constructed.
-    
-    setNavigationAction(0);
-    disconnect( mSoftKeyBackAction );
-    delete mSoftKeyBackAction;
-    
-    if(mAbstractDelegate) {
-        disconnect(mAbstractDelegate);   
-        delete mAbstractDelegate;
-    }
-    if(mBtuiModelSortFilter) {
-        delete mBtuiModelSortFilter;
-    }
-    if ( mQuery ) {
-        delete mQuery;
-    }
+    delete mBtuiModelSortFilter;
+    HbStyleLoader::unregisterFilePath(":/docml/btcpuisearchlistviewitem.widgetml");
+    HbStyleLoader::unregisterFilePath(":/docml/btcpuisearchlistviewitem.css");
 }
 
-void BtCpUiSearchView::changeOrientation( Qt::Orientation orientation )
+void BtcpuiSearchView::changeOrientation( Qt::Orientation orientation )
 {
     // ToDo:  this does not handle redrawing list view items differently for portrait/landscape
     bool ok = false;
@@ -208,181 +184,119 @@
 
     if( orientation == Qt::Vertical ) {
         // load "portrait" section
-        mLoader->load( BTUI_SEARCHVIEW_DOCML, "portrait_ui", &ok );
-        BTUI_ASSERT_X( ok, "BtCpUiSearchView::changeOrientation", "Invalid docml file: portrait section problem" );
+        mLoader->load( BTUI_SEARCHVIEW_DOCML, "portrait", &ok );
+        BTUI_ASSERT_X( ok, "BtcpuiSearchView::changeOrientation", "Invalid docml file: portrait section problem" );
     } else {
         // load "landscape" section
-        mLoader->load( BTUI_SEARCHVIEW_DOCML, "landscape_ui", &ok );
-        BTUI_ASSERT_X( ok, "BtCpUiSearchView::changeOrientation", "Invalid docml file: landscape section problem" );
+        mLoader->load( BTUI_SEARCHVIEW_DOCML, "landscape", &ok );
+        BTUI_ASSERT_X( ok, "BtcpuiSearchView::changeOrientation", "Invalid docml file: landscape section problem" );
     }
 }
 
-
-void BtCpUiSearchView::viewByDeviceTypeDialog()
-{
-    if ( !mQuery ) {
-        mQuery = new HbSelectionDialog;
-        mQuery->setStringItems(mDevTypeList, 0);
-        mQuery->setSelectionMode(HbAbstractItemView::MultiSelection);
-    
-        QList<QVariant> current;
-        current.append(QVariant(0));
-        mQuery->setSelectedItems(current);
-    
-        // Set the heading for the dialog.
-        HbLabel *headingLabel = new HbLabel(hbTrId("txt_bt_title_show"), mQuery);
-        mQuery->setHeadingWidget(headingLabel);
-    }
-    mQuery->open(this,SLOT(viewByDialogClosed(HbAction*)));
-}
 /*!
    Callback for HbSelectionDialog closing
+   ReImplemented Slot from Base class
 
  */
-void BtCpUiSearchView::viewByDialogClosed(HbAction* action)
+void BtcpuiSearchView::viewByDialogClosed(HbAction* action)
+{
+    int devTypesWanted = 0;
+    
+    devTypesWanted = selectedDeviceTypes(action);
+    
+    if (devTypesWanted) {
+        mBtuiModelSortFilter->clearDeviceMajorFilters();
+        mBtuiModelSortFilter->addDeviceMajorFilter(BtuiDevProperty::InRange,
+                        BtuiModelSortFilter::AtLeastMatch);   // device must be in range
+        mBtuiModelSortFilter->addDeviceMajorFilter(devTypesWanted,
+                BtuiModelSortFilter::RoughMatch);             // device can be any one of selected ones
+    }
+}
+
+void BtcpuiSearchView::stopSearching()
 {
-    disconnect( mQuery );  // remove slot
-    if (action == mQuery->actions().first()) {  // user pressed "Ok"
-        // Get selected items.
-        QList<QVariant> selections;
-        selections = mQuery->selectedItems();
-        
-        int devTypesWanted = 0;
-        
-        for (int i=0; i < selections.count(); i++) {
-            switch (selections.at(i).toInt()) {
-            case BtUiDevAudioDevice:
-                devTypesWanted |= BtuiDevProperty::AVDev;
-                break;
-            case BtUiDevComputer:
-                devTypesWanted |= BtuiDevProperty::Computer;
-                break;
-            case BtUiDevInputDevice:
-                devTypesWanted |= BtuiDevProperty::Peripheral;
-                break;
-            case BtUiDevPhone:
-                devTypesWanted |= BtuiDevProperty::Phone;
-                break;
-            case BtUiDevOtherDevice:
-                devTypesWanted |= (BtuiDevProperty::LANAccessDev |
-                        BtuiDevProperty::Toy |
-                        BtuiDevProperty::WearableDev |
-                        BtuiDevProperty::ImagingDev |
-                        BtuiDevProperty::HealthDev |
-                        BtuiDevProperty::UncategorizedDev);
-                break;
-            default:
-                // should never get here
-                BTUI_ASSERT_X(false, "BtCpUiSearchView::viewByDialogClosed()", 
-                        "wrong device type in viewBy dialog!");
-            }
-        }
-        if (devTypesWanted) {
-            mBtuiModelSortFilter->clearDeviceMajorFilters();
-            mBtuiModelSortFilter->addDeviceMajorFilter(BtuiDevProperty::InRange,
-                            BtuiModelSortFilter::AtLeastMatch);   // device must be in range
-            mBtuiModelSortFilter->addDeviceMajorFilter(devTypesWanted,
-                    BtuiModelSortFilter::RoughMatch);             // device can be any one of selected ones
+    // Stop searching
+    if (mDelegate) {
+        mDelegate->cancel();
+        // update the states of view items 
+        deviceSearchCompleted(KErrNone);
+    }
+}
+
+void BtcpuiSearchView::take(BtAbstractDelegate *delegate)
+{
+    mDelegate = delegate;
+    if (mDelegate) {
+        disconnect(mDelegate, 0, 0, 0);
+        if (mDelegate->supportedEditorTypes() & BtDelegate::Inquiry) {
+            connect(mDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)),
+                    this, SLOT(deviceSearchCompleted(int)));
+        } else {
+            connect(mDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)),
+                this, SLOT(handleDelegateCompleted(int)));
         }
     }
 }
 
-void BtCpUiSearchView::stopSearching()
+void BtcpuiSearchView::startSearchDelegate()
 {
-    // Stop searching
-
-    // Stop search delegate
-    mAbstractDelegate->cancel();
-    // reset view 
-    deviceSearchCompleted(KErrNone);      
+    (void) createExecuteDelegate(BtDelegate::Inquiry, 
+            this, SLOT(deviceSearchCompleted(int)), QVariant());
 }
 
-void BtCpUiSearchView::startSearchDelegate ()
-{
-    bool ret = false;
-    
-    // Connect to the signal from the BtDelegateInquiry for completion of the search request
-    ret = connect(mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(searchDelegateCompleted(int)));
-    BTUI_ASSERT_X( ret, "BtCpUiSearchView::BtCpUiSearchView", "searchDelegateCompleted can't connect" );
-    
-    // Connect to the signal from the BtuiModel when the search has been completed.
-    ret = connect(mDeviceModel, SIGNAL(deviceSearchCompleted(int)), this, SLOT(deviceSearchCompleted(int)));
-    BTUI_ASSERT_X( ret, "BtCpUiSearchView::BtCpUiSearchView", "deviceSearchCompleted can't connect" );     
-
-    mAbstractDelegate->exec(QVariant());
-}
-
-void BtCpUiSearchView::retrySearch()
+void BtcpuiSearchView::retrySearch()
 {
     // Retry search
-
     // Change label and buttons to reflect status
     mLabelSearching->setPlainText(hbTrId("txt_bt_subhead_searching"));
     mRetry->setEnabled(false);
     mStop->setEnabled(true);
     
     // Make use of the delegate and start the search.
-    startSearchDelegate ();
-}
-
-void BtCpUiSearchView::setSoftkeyBack()
-{
-    if (navigationAction() != mSoftKeyBackAction) {
-        setNavigationAction(mSoftKeyBackAction);
-        connect( mSoftKeyBackAction, SIGNAL(triggered()), this, SLOT(switchToPreviousView()) );
-    }
+    startSearchDelegate();
 }
 
-void BtCpUiSearchView::switchToPreviousView()
-{
-    BTUI_ASSERT_X(mMainView, "BtCpUiSearchView::switchToPreviousView", "invalid mMainView");
-    mMainView->switchToPreviousView();
-}
-
-void BtCpUiSearchView::activateView( const QVariant& value, bool fromBackButton )
+void BtcpuiSearchView::activateView( const QVariant& value, bool backNavi)
 {
     Q_UNUSED(value);
-
+    if (!backNavi) {
+        retrySearch();
+    }
+    
     // ToDo:  consider whether orientation should be updated here rather than when orientation really changes;
     // advantage:  if orientation changes temporarily in another view, but returns to previous setting before
     // search is reactived, there is no processing overhead
-    
-    setSoftkeyBack();
-            
-    if ( !fromBackButton ) {
-        // Sets the label and toolbar buttons
-        retrySearch();
-    }
 }
 
-void BtCpUiSearchView::deactivateView()
+void BtcpuiSearchView::deactivateView()
 {
-    mAbstractDelegate->cancel();          // Stop searching when leaving view
-    deviceSearchCompleted(KErrNone);      // reset view 
+    stopSearching();
 }
-
-void BtCpUiSearchView::searchDelegateCompleted(int error)
+void BtcpuiSearchView::deviceSearchCompleted(int error)
 {
     Q_UNUSED(error);
-    
-}
-
-void BtCpUiSearchView::deviceSearchCompleted(int error)
-{
-    //TODO - handle error.
-    Q_UNUSED(error);
-    
     mLabelSearching->setPlainText(hbTrId("txt_bt_subhead_search_done"));
     mRetry->setEnabled(true);
     mStop->setEnabled(false);
-    
-    // disconnect signals
-    disconnect(mAbstractDelegate);
-    disconnect(mDeviceModel);
+    handleDelegateCompleted(error, mDelegate);
 }
 
-void BtCpUiSearchView::deviceSelected(const QModelIndex& modelIndex)
+void BtcpuiSearchView::createContextMenuActions(int majorRole)
 {
-    QModelIndex index = mBtuiModelSortFilter->mapToSource(modelIndex);
-    static_cast<BtCpUiMainView*>(mMainView)->goToDeviceView(index);
+    if (majorRole & BtuiDevProperty::Connected) {
+        if(majorRole & BtuiDevProperty::AVDev) {
+            mContextMenu->addAction(hbTrId("txt_bt_menu_disconnect_audio"));
+        }
+        else {
+            mContextMenu->addAction(hbTrId("txt_bt_menu_disconnect"));
+        }
+    }
+    else {
+        if(majorRole & BtuiDevProperty::AVDev) {
+            mContextMenu->addAction(hbTrId("txt_bt_menu_connect_audio"));
+        }
+        else {
+            mContextMenu->addAction(hbTrId("txt_bt_menu_connect"));
+        }
+    }  
 }
--- a/bluetoothengine/btui/btcpplugin/btcpuisearchview.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btcpplugin/btcpuisearchview.h	Fri Sep 03 16:17:59 2010 +0300
@@ -18,11 +18,7 @@
 #ifndef	BTCPUISEARCHVIEW_H
 #define	BTCPUISEARCHVIEW_H
 
-#include <cpbasesettingview.h>
-#include <hbaction.h>
-#include <hbtoolbar.h>
 #include "btcpuibaseview.h"
-#include "btuimodelsortfilter.h"
 
 class HbLabel;
 class HbPushButton;
@@ -30,68 +26,46 @@
 class HbDocumentLoader;
 class HbListView;
 class BtAbstractDelegate;
-class HbSelectionDialog;
 class HbGroupBox;
 class HbDataForm;
 
-class BtCpUiSearchView : public BtCpUiBaseView
+class BtcpuiSearchView : public BtcpuiBaseView
 {
     Q_OBJECT
     
 public:
 
-    explicit BtCpUiSearchView(
-            BtSettingModel &settingModel, 
+    explicit BtcpuiSearchView(BtSettingModel &settingModel, 
             BtDeviceModel &deviceModel, 
             QGraphicsItem *parent = 0);
-    virtual ~BtCpUiSearchView();
-    virtual void activateView( const QVariant& value, bool fromBackButton );
+    virtual ~BtcpuiSearchView();
+    virtual void activateView( const QVariant& value, bool backNavi);
     virtual void deactivateView();
-    virtual void setSoftkeyBack();
-    
+    virtual void createContextMenuActions(int majorRole);
 public slots:
-    virtual void switchToPreviousView();
     void changeOrientation( Qt::Orientation orientation );
     void stopSearching();
     void retrySearch();
-    void viewByDeviceTypeDialog();
-    void viewByDialogClosed(HbAction* action);
-    void searchDelegateCompleted(int error);
+    virtual void viewByDialogClosed(HbAction* action);
     void deviceSearchCompleted(int error);
-    void deviceSelected(const QModelIndex& modelIndex);
-    
+        
 private:
+    virtual void take(BtAbstractDelegate *delegate);
     void startSearchDelegate();
     
 private:
-    enum devTypeSelectionList {
-        BtUiDevAudioDevice = 0,
-        BtUiDevComputer,
-        BtUiDevInputDevice,
-        BtUiDevPhone,
-        BtUiDevOtherDevice
-    };
-private:
     HbDocumentLoader *mLoader;
     HbLabel *mDeviceIcon;
     HbDataForm *mDataForm;
     HbLabel *mLabelSearching;        
     HbListView *mDeviceList;
-    QStringList mDevTypeList;
-    HbSelectionDialog *mQuery;
     
     Qt::Orientation mOrientation;
-    
-    HbMainWindow*           mMainWindow;
-    BtCpUiBaseView*         mMainView;
-    HbAction *              mSoftKeyBackAction;
-    HbAction*               mViewBy;
-    HbAction*               mStop;
-    HbAction*               mRetry;
 
-    //pointer to abstract delegate, and it is instantiated at runtime
-    BtAbstractDelegate*     mAbstractDelegate;
-    BtuiModelSortFilter*    mBtuiModelSortFilter;
+    HbAction* mViewBy;
+    HbAction* mStop;
+    HbAction* mRetry;
+
 };
 
 #endif//	BTCPUISEARCHVIEW_H
--- a/bluetoothengine/btui/btcpplugin/btcpuisettingitem.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btcpplugin/btcpuisettingitem.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -18,70 +18,64 @@
 #include "btcpuisettingitem.h"
 #include <cpitemdatahelper.h>
 #include <bluetoothuitrace.h>
-
+#include <btsettingmodel.h>
+#include <btdevicemodel.h>
 #include <HbInstance>
 #include <HbTranslator>
+#include <HbView>
+#include "btcpuimainview.h"
 
-BtCpUiSettingItem::BtCpUiSettingItem(CpItemDataHelper &itemDataHelper) :
-    CpSettingFormEntryItemData(itemDataHelper)
+BtcpuiSettingItem::BtcpuiSettingItem(CpItemDataHelper &itemDataHelper) :
+    CpSettingFormEntryItemData(itemDataHelper), mMainView(0)
 {
     bool ret(false);
     loadTranslators();
     mSettingModel = new BtSettingModel(this);
     mDeviceModel = new BtDeviceModel(this);
-    
+    mMainWindow = hbInstance->allMainWindows().first();
     ret = connect(mSettingModel, SIGNAL(dataChanged(QModelIndex,QModelIndex)), 
             this, SLOT(handleDataChanged(QModelIndex,QModelIndex)));
-    BTUI_ASSERT_X( ret, "BtCpUiSettingItem::BtCpUiSettingItem", "can't connect dataChanged" );
+    BTUI_ASSERT_X( ret, "BtcpuiSettingItem::BtcpuiSettingItem", "can't connect dataChanged" );
 
     this->setDescription(hbTrId("txt_cp_dblist_bluetooth"));
     updateStatus();
 }
 
-BtCpUiSettingItem::~BtCpUiSettingItem()
+BtcpuiSettingItem::~BtcpuiSettingItem()
 {
+    delete mMainView;
     delete mViewTranslator;
     delete mDialogTranslator;
 }
 
-void BtCpUiSettingItem::loadTranslators()
+void BtcpuiSettingItem::onLaunchView()
 {
-    mViewTranslator = new HbTranslator("btviews");
-    mDialogTranslator = new HbTranslator("btdialogs");
+    // Main view will be launched when the user clicked the Bluetooth setting item in CP.
+
+    // We need to save the pointer of the view from which the main view is launched, 
+    // for navigating back to CP when the main view is closed.
+    mCpView = mMainWindow->currentView();
+    mMainView = new BtcpuiMainView(*mSettingModel, *mDeviceModel);
+    mMainWindow->addView(mMainView);
+    connect(mMainView, SIGNAL(aboutToClose()), this, SLOT(handleCloseMainView()));
+    mMainWindow->setCurrentView(mMainView);
 }
 
-void BtCpUiSettingItem::onLaunchView()
+void BtcpuiSettingItem::handleCloseMainView()
 {
-  
-    mMainWindow = hbInstance->allMainWindows().first();
-    
-    mBtMainView = new BtCpUiMainView(*mSettingModel, *mDeviceModel);
-      
-    mCpView = mMainWindow->currentView();
-    
-    mMainWindow->addView(mBtMainView);
-    mMainWindow->setCurrentView(mBtMainView);
-    
-    connect(mBtMainView, SIGNAL(aboutToClose()), this, SLOT(handleCloseView()));
-    
-}
-
-void BtCpUiSettingItem::handleCloseView()
-{
-    mBtMainView->deactivateView();
+    if (mMainView) {
+        mMainWindow->removeView(mMainView);
+        delete mMainView;
+        mMainView = 0;
+    }
     mMainWindow->setCurrentView(mCpView);
-    
-    mMainWindow->removeView(mBtMainView);
-    delete mBtMainView;
-    mBtMainView = 0;
-    
 }
 
 /*!
     Slot for receiving notification of local setting changes from the model.
     Identify the setting changed and update the corresponding UI item.
  */
-void BtCpUiSettingItem::handleDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
+void BtcpuiSettingItem::handleDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight)
 {     
     // update only the part of the view specified by the model's row(s)
     for (int i=topLeft.row(); i <= bottomRight.row(); i++) {
@@ -96,7 +90,12 @@
     }   
 }
 
-void BtCpUiSettingItem::updateStatus()
+CpBaseSettingView *BtcpuiSettingItem::createSettingView() const
+{
+    return 0;
+}
+
+void BtcpuiSettingItem::updateStatus()
 {
     QString btStatusText;
     HbIcon btStatusIcon;
@@ -121,7 +120,7 @@
                 btStatusIcon.setIconName("qtg_large_bluetooth");
                 break;
             default:
-                BTUI_ASSERT_X(false, "BtCpUiSettingItem::updateStatus", "invalid visibility mode");
+                BTUI_ASSERT_X(false, "BtcpuiSettingItem::updateStatus", "invalid visibility mode");
         }
     }
     else {
@@ -129,12 +128,14 @@
         btStatusText = hbTrId("txt_cp_dblist_bluetooth_val_off");
         btStatusIcon.setIconName("qtg_large_bluetooth_off");
     }
-        
     this->setDescription(btStatusText);
     this->setEntryItemIcon(btStatusIcon);
 }
 
-CpBaseSettingView *BtCpUiSettingItem::createSettingView() const
+
+void BtcpuiSettingItem::loadTranslators()
 {
-	return 0;
+    mViewTranslator = new HbTranslator("btviews");
+    mDialogTranslator = new HbTranslator("btdialogs");
 }
+
--- a/bluetoothengine/btui/btcpplugin/btcpuisettingitem.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btcpplugin/btcpuisettingitem.h	Fri Sep 03 16:17:59 2010 +0300
@@ -19,31 +19,40 @@
 #define BTCPUISETTINGITEM_H
 
 #include <cpsettingformentryitemdata.h>
-#include <btsettingmodel.h>
-#include <btdevicemodel.h>
+
 
-#include "btcpuimainview.h"
-
+class BtSettingModel;
+class BtDeviceModel;
+class BtcpuiBaseView;
 class HbTranslator;
+class HbMainWindow;
+class HbView;
 
-class BtCpUiSettingItem : public CpSettingFormEntryItemData
+class BtcpuiSettingItem : public CpSettingFormEntryItemData
 {
 	Q_OBJECT
 public:
-	explicit BtCpUiSettingItem(CpItemDataHelper &itemDataHelper);	 
-	virtual ~BtCpUiSettingItem();
+	explicit BtcpuiSettingItem(CpItemDataHelper &itemDataHelper);	 
+	virtual ~BtcpuiSettingItem();
+	
 private slots:
 	void onLaunchView();
-	void handleCloseView();
+	void handleCloseMainView();
 	void handleDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
+	
+private: 
+	// From CpSettingFormEntryItemData
+	virtual CpBaseSettingView *createSettingView() const;
+    
 private:
-	virtual CpBaseSettingView *createSettingView() const;
+	
 	void updateStatus();
 	void loadTranslators();
+	
 private:
 	HbMainWindow* mMainWindow;
 	
-	BtCpUiMainView *mBtMainView;
+	BtcpuiBaseView *mMainView;
 	
 	//Owns this model.
 	BtSettingModel *mSettingModel;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btui/btcpplugin/btcpuiviewmgr.h	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 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:  
+ *
+ */
+
+#ifndef BTCPUIVIEWMGR_H
+#define BTCPUIVIEWMGR_H
+
+#include <qglobal.h>
+
+class BtcpuiBaseView;
+class BtAbstractDelegate;
+
+/*!
+    \class BtcpuiViewMgr
+    \brief the view management interface of Bluetooth CP plugin
+ */
+class BtcpuiViewMgr
+{
+
+public:
+
+    /*!
+     * Gets the device view instance.
+     */
+    virtual BtcpuiBaseView *deviceView() = 0;
+    
+    virtual void switchView(BtcpuiBaseView *from, BtcpuiBaseView *destination,
+            const QVariant &init, bool backNavi) = 0;
+    
+};
+
+#endif // BTCPUIVIEWMGR_H
--- a/bluetoothengine/btui/btcpplugin/docml/bt-device-details-view.docml	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btcpplugin/docml/bt-device-details-view.docml	Fri Sep 03 16:17:59 2010 +0300
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <hbdocument version="1.1">
-    <object name="exit" type="HbAction">
+    <object name="exitAction" type="HbAction">
         <string locid="txt_common_opt_exit" name="text" value="Exit"/>
     </object>
     <widget name="bt_device_details_view" type="HbView">
--- a/bluetoothengine/btui/btcpplugin/docml/bt-device-view.docml	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btcpplugin/docml/bt-device-view.docml	Fri Sep 03 16:17:59 2010 +0300
@@ -5,7 +5,7 @@
     </object>
     <widget name="bt_device_view" type="HbView">
         <widget name="content" role="HbView:widget" type="HbWidget">
-            <widget name="dataForm_deviceView" type="HbDataForm">
+            <widget name="deviceViewHeading" type="HbDataForm">
                 <real name="z" value="1"/>
                 <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Preferred" verticalStretch="0"/>
                 <sizehint height="7.8806un" type="PREFERRED" width="53.73134un"/>
@@ -44,35 +44,29 @@
                 <string name="description"/>
                 <string name="heading"/>
             </widget>
-            <widget name="pushButton_0" type="HbPushButton">
-                <icon iconName="qtg_mono_bt_unpair" name="icon"/>
+            <widget name="devicePairUnpair" type="HbPushButton">
                 <real name="z" value="5"/>
                 <sizehint height="9un" type="PREFERRED"/>
                 <enums name="orientation" value="Horizontal"/>
-                <string name="text" value="Unpair"/>
             </widget>
-            <widget name="pushButton_1" type="HbPushButton">
-                <icon iconName="qtg_mono_disconnect" name="icon"/>
+            <widget name="deviceConnectDisconnect" type="HbPushButton">
                 <real name="z" value="6"/>
                 <sizehint height="9un" type="PREFERRED"/>
                 <enums name="orientation" value="Horizontal"/>
-                <string name="text" value="Disconnect"/>
             </widget>
-            <widget name="pushButton_2" type="HbPushButton">
-                <icon iconName="qtg_mono_settings" name="icon"/>
+            <widget name="deviceSettings" type="HbPushButton">
                 <real name="z" value="7"/>
                 <sizehint height="9un" type="PREFERRED"/>
                 <enums name="orientation" value="Horizontal"/>
-                <string name="text" value="Settings"/>
             </widget>
             <layout type="anchor">
-                <anchoritem dst="dataForm_deviceView" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
-                <anchoritem dst="dataForm_deviceView" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
-                <anchoritem dst="dataForm_deviceView" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="deviceViewHeading" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
+                <anchoritem dst="deviceViewHeading" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
+                <anchoritem dst="deviceViewHeading" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
                 <anchoritem dst="deviceIcon" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="" srcEdge="LEFT"/>
-                <anchoritem dst="deviceIcon" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="dataForm_deviceView" srcEdge="BOTTOM"/>
+                <anchoritem dst="deviceIcon" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="deviceViewHeading" srcEdge="BOTTOM"/>
                 <anchoritem dst="deviceName" dstEdge="LEFT" spacing="2un" src="deviceIcon" srcEdge="RIGHT"/>
-                <anchoritem dst="deviceName" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="dataForm_deviceView" srcEdge="BOTTOM"/>
+                <anchoritem dst="deviceName" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="deviceViewHeading" srcEdge="BOTTOM"/>
                 <anchoritem dst="deviceName" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
                 <anchoritem dst="deviceStatus" dstEdge="LEFT" spacing="12un" src="" srcEdge="LEFT"/>
                 <anchoritem dst="deviceStatus" dstEdge="TOP" spacing="var(hb-param-margin-gene-bottom)" src="deviceCategory" srcEdge="BOTTOM"/>
@@ -80,18 +74,18 @@
                 <anchoritem dst="deviceCategory" dstEdge="LEFT" spacing="2un" src="deviceIcon" srcEdge="RIGHT"/>
                 <anchoritem dst="deviceCategory" dstEdge="TOP" spacing="var(hb-param-margin-gene-middle-vertical)" src="deviceName" srcEdge="BOTTOM"/>
                 <anchoritem dst="deviceCategory" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
-                <anchoritem dst="pushButton_2" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-left) )" src="" srcEdge="LEFT"/>
-                <anchoritem dst="pushButton_2" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-bottom) )" src="pushButton_1" srcEdge="BOTTOM"/>
-                <anchoritem dst="pushButton_2" dstEdge="RIGHT" spacing="-expr(var(hb-param-margin-gene-right) )" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="deviceSettings" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-left) )" src="" srcEdge="LEFT"/>
+                <anchoritem dst="deviceSettings" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-bottom) )" src="deviceConnectDisconnect" srcEdge="BOTTOM"/>
+                <anchoritem dst="deviceSettings" dstEdge="RIGHT" spacing="-expr(var(hb-param-margin-gene-right) )" src="" srcEdge="RIGHT"/>
                 <anchoritem dst="connectionCombobox" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
                 <anchoritem dst="connectionCombobox" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-top) )" src="deviceStatus" srcEdge="BOTTOM"/>
                 <anchoritem dst="connectionCombobox" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
-                <anchoritem dst="pushButton_1" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-left) )" src="" srcEdge="LEFT"/>
-                <anchoritem dst="pushButton_1" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-middle-vertical) )" src="pushButton_0" srcEdge="BOTTOM"/>
-                <anchoritem dst="pushButton_1" dstEdge="RIGHT" spacing="-expr(var(hb-param-margin-gene-right) )" src="" srcEdge="RIGHT"/>
-                <anchoritem dst="pushButton_0" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-left) )" src="" srcEdge="LEFT"/>
-                <anchoritem dst="pushButton_0" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-top) )" src="connectionCombobox" srcEdge="BOTTOM"/>
-                <anchoritem dst="pushButton_0" dstEdge="RIGHT" spacing="-expr(var(hb-param-margin-gene-right) )" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="deviceConnectDisconnect" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-left) )" src="" srcEdge="LEFT"/>
+                <anchoritem dst="deviceConnectDisconnect" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-middle-vertical) )" src="devicePairUnpair" srcEdge="BOTTOM"/>
+                <anchoritem dst="deviceConnectDisconnect" dstEdge="RIGHT" spacing="-expr(var(hb-param-margin-gene-right) )" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="devicePairUnpair" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-left) )" src="" srcEdge="LEFT"/>
+                <anchoritem dst="devicePairUnpair" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-top) )" src="connectionCombobox" srcEdge="BOTTOM"/>
+                <anchoritem dst="devicePairUnpair" dstEdge="RIGHT" spacing="-expr(var(hb-param-margin-gene-right) )" src="" srcEdge="RIGHT"/>
             </layout>
         </widget>
         <widget name="viewMenu" role="HbView:menu" type="HbMenu">
@@ -100,46 +94,77 @@
         <string locid="txt_cp_title_control_panel" name="title" value="Control Panel"/>
     </widget>
     <section name="landscape">
+        <widget name="deviceConnectDisconnect" type="HbPushButton">
+            <sizehint height="8un" type="PREFERRED"/>
+            <string name="text"/>
+        </widget>
         <widget name="content" role="HbView:widget" type="HbWidget">
             <layout type="anchor">
-                <anchoritem dst="dataForm_deviceView" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
-                <anchoritem dst="dataForm_deviceView" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
-                <anchoritem dst="dataForm_deviceView" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
-                <anchoritem dst="deviceIcon" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="" srcEdge="LEFT"/>
-                <anchoritem dst="deviceIcon" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="dataForm_deviceView" srcEdge="BOTTOM"/>
-                <anchoritem dst="deviceName" dstEdge="LEFT" spacing="2un" src="deviceIcon" srcEdge="RIGHT"/>
-                <anchoritem dst="deviceName" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="dataForm_deviceView" srcEdge="BOTTOM"/>
-                <anchoritem dst="deviceName" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
-                <anchoritem dst="deviceCategory" dstEdge="LEFT" spacing="2un" src="deviceIcon" srcEdge="RIGHT"/>
-                <anchoritem dst="deviceCategory" dstEdge="TOP" spacing="var(hb-param-margin-gene-middle-vertical)" src="deviceName" srcEdge="BOTTOM"/>
-                <anchoritem dst="deviceStatus" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-middle-horizontal) )" src="deviceCategory" srcEdge="RIGHT"/>
-                <anchoritem dst="deviceStatus" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-middle-vertical) )" src="deviceName" srcEdge="BOTTOM"/>
-                <anchoritem dst="deviceStatus" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="deviceViewHeading" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
+                <anchoritem dst="deviceViewHeading" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
+                <anchoritem dst="deviceViewHeading" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
                 <anchoritem dst="connectionCombobox" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
                 <anchoritem dst="connectionCombobox" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-bottom)  )" src="deviceStatus" srcEdge="BOTTOM"/>
                 <anchoritem dst="connectionCombobox" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
-                <anchoritem dst="pushButton_0" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-left) )" src="" srcEdge="LEFT"/>
-                <anchoritem dst="pushButton_0" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-top) )" src="connectionCombobox" srcEdge="BOTTOM"/>
-                <anchoritem dst="pushButton_0" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="CENTERH"/>
-                <anchoritem dst="pushButton_1" dstEdge="LEFT" spacing="var(hb-param-margin-gene-middle-horizontal)" src="pushButton_0" srcEdge="RIGHT"/>
-                <anchoritem dst="pushButton_1" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-top) )" src="connectionCombobox" srcEdge="BOTTOM"/>
-                <anchoritem dst="pushButton_1" dstEdge="RIGHT" spacing="-expr(var(hb-param-margin-gene-right) )" src="" srcEdge="RIGHT"/>
-                <anchoritem dst="pushButton_2" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-left) )" src="" srcEdge="LEFT"/>
-                <anchoritem dst="pushButton_2" dstEdge="TOP" spacing="var(hb-param-margin-gene-middle-vertical)" src="pushButton_1" srcEdge="BOTTOM"/>
-                <anchoritem dst="pushButton_2" dstEdge="RIGHT" spacing="-expr(var(hb-param-margin-gene-right) )" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="deviceStatus" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-middle-horizontal) )" src="deviceName" srcEdge="RIGHT"/>
+                <anchoritem dst="deviceStatus" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-middle-vertical) )" src="deviceCategory" srcEdge="BOTTOM"/>
+                <anchoritem dst="deviceStatus" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="devicePairUnpair" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-left) )" src="" srcEdge="LEFT"/>
+                <anchoritem dst="devicePairUnpair" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-middle-vertical)  )" src="connectionCombobox" srcEdge="BOTTOM"/>
+                <anchoritem dst="devicePairUnpair" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="CENTERH"/>
+                <anchoritem dst="deviceConnectDisconnect" dstEdge="LEFT" spacing="var(hb-param-margin-gene-middle-horizontal)" src="devicePairUnpair" srcEdge="RIGHT"/>
+                <anchoritem dst="deviceConnectDisconnect" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-middle-horizontal) )" src="connectionCombobox" srcEdge="BOTTOM"/>
+                <anchoritem dst="deviceConnectDisconnect" dstEdge="RIGHT" spacing="expr(-var(hb-param-margin-gene-right) )" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="deviceSettings" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-left) )" src="" srcEdge="LEFT"/>
+                <anchoritem dst="deviceSettings" dstEdge="TOP" spacing="var(hb-param-margin-gene-middle-vertical)" src="deviceConnectDisconnect" srcEdge="BOTTOM"/>
+                <anchoritem dst="deviceSettings" dstEdge="RIGHT" spacing="expr(-var(hb-param-margin-gene-right) )" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="deviceSettings" dstEdge="BOTTOM" spacing="expr(-var(hb-param-margin-gene-middle-vertical)  )" src="" srcEdge="BOTTOM"/>
+                <anchoritem dst="deviceIcon" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="" srcEdge="LEFT"/>
+                <anchoritem dst="deviceIcon" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-middle-vertical) )" src="deviceViewHeading" srcEdge="BOTTOM"/>
+                <anchoritem dst="deviceName" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-middle-horizontal) )" src="deviceIcon" srcEdge="RIGHT"/>
+                <anchoritem dst="deviceName" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-middle-vertical) )" src="deviceViewHeading" srcEdge="BOTTOM"/>
+                <anchoritem dst="deviceCategory" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-middle-horizontal) )" src="deviceName" srcEdge="RIGHT"/>
+                <anchoritem dst="deviceCategory" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-middle-vertical) )" src="deviceViewHeading" srcEdge="BOTTOM"/>
             </layout>
         </widget>
+        <widget name="devicePairUnpair" type="HbPushButton">
+            <sizehint height="8un" type="PREFERRED"/>
+            <string name="text"/>
+        </widget>
+        <widget name="deviceViewHeading" type="HbDataForm">
+            <sizehint height="6un" type="PREFERRED" width="53.73134un"/>
+        </widget>
+        <widget name="deviceName" type="HbLineEdit">
+            <sizehint height="6.25un" type="PREFERRED" width="39.70149un"/>
+        </widget>
+        <widget name="deviceStatus" type="HbLabel">
+            <sizehint height="expr(var(hb-param-text-height-tiny) )" type="PREFERRED" width="39.70149un"/>
+        </widget>
+        <widget name="deviceCategory" type="HbLabel">
+            <sizehint height="expr(var(hb-param-text-height-tiny) )" type="PREFERRED" width="39.70149un"/>
+        </widget>
+        <widget name="connectionCombobox" type="HbDataForm">
+            <sizehint height="4.02985un" type="PREFERRED" width="95.52239un"/>
+        </widget>
+        <widget name="deviceSettings" type="HbPushButton">
+            <sizehint height="8un" type="PREFERRED"/>
+            <string locid="txt_bt_button_device_settings" name="text"/>
+            <icon iconName="qtg_mono_details" name="icon"/>
+        </widget>
     </section>
     <section name="portrait">
+        <widget name="deviceConnectDisconnect" type="HbPushButton">
+            <string name="text"/>
+        </widget>
         <widget name="content" role="HbView:widget" type="HbWidget">
             <layout type="anchor">
-                <anchoritem dst="dataForm_deviceView" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
-                <anchoritem dst="dataForm_deviceView" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
-                <anchoritem dst="dataForm_deviceView" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="deviceViewHeading" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
+                <anchoritem dst="deviceViewHeading" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
+                <anchoritem dst="deviceViewHeading" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
                 <anchoritem dst="deviceIcon" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="" srcEdge="LEFT"/>
-                <anchoritem dst="deviceIcon" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="dataForm_deviceView" srcEdge="BOTTOM"/>
+                <anchoritem dst="deviceIcon" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="deviceViewHeading" srcEdge="BOTTOM"/>
                 <anchoritem dst="deviceName" dstEdge="LEFT" spacing="2un" src="deviceIcon" srcEdge="RIGHT"/>
-                <anchoritem dst="deviceName" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="dataForm_deviceView" srcEdge="BOTTOM"/>
+                <anchoritem dst="deviceName" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="deviceViewHeading" srcEdge="BOTTOM"/>
                 <anchoritem dst="deviceName" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
                 <anchoritem dst="deviceStatus" dstEdge="LEFT" spacing="12un" src="" srcEdge="LEFT"/>
                 <anchoritem dst="deviceStatus" dstEdge="TOP" spacing="var(hb-param-margin-gene-bottom)" src="deviceCategory" srcEdge="BOTTOM"/>
@@ -147,24 +172,93 @@
                 <anchoritem dst="deviceCategory" dstEdge="LEFT" spacing="2un" src="deviceIcon" srcEdge="RIGHT"/>
                 <anchoritem dst="deviceCategory" dstEdge="TOP" spacing="var(hb-param-margin-gene-middle-vertical)" src="deviceName" srcEdge="BOTTOM"/>
                 <anchoritem dst="deviceCategory" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
-                <anchoritem dst="pushButton_2" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-left) )" src="" srcEdge="LEFT"/>
-                <anchoritem dst="pushButton_2" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-bottom) )" src="pushButton_1" srcEdge="BOTTOM"/>
-                <anchoritem dst="pushButton_2" dstEdge="RIGHT" spacing="-expr(var(hb-param-margin-gene-right) )" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="deviceSettings" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-left) )" src="" srcEdge="LEFT"/>
+                <anchoritem dst="deviceSettings" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-bottom) )" src="deviceConnectDisconnect" srcEdge="BOTTOM"/>
+                <anchoritem dst="deviceSettings" dstEdge="RIGHT" spacing="-expr(var(hb-param-margin-gene-right) )" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="deviceConnectDisconnect" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-left) )" src="" srcEdge="LEFT"/>
+                <anchoritem dst="deviceConnectDisconnect" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-middle-vertical) )" src="devicePairUnpair" srcEdge="BOTTOM"/>
+                <anchoritem dst="deviceConnectDisconnect" dstEdge="RIGHT" spacing="-expr(var(hb-param-margin-gene-right) )" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="devicePairUnpair" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-left) )" src="" srcEdge="LEFT"/>
+                <anchoritem dst="devicePairUnpair" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-top) )" src="connectionCombobox" srcEdge="BOTTOM"/>
+                <anchoritem dst="devicePairUnpair" dstEdge="RIGHT" spacing="-expr(var(hb-param-margin-gene-right) )" src="" srcEdge="RIGHT"/>
                 <anchoritem dst="connectionCombobox" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
-                <anchoritem dst="connectionCombobox" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-top) )" src="deviceStatus" srcEdge="BOTTOM"/>
+                <anchoritem dst="connectionCombobox" dstEdge="TOP" spacing="29un" src="" srcEdge="TOP"/>
                 <anchoritem dst="connectionCombobox" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
-                <anchoritem dst="pushButton_1" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-left) )" src="" srcEdge="LEFT"/>
-                <anchoritem dst="pushButton_1" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-middle-vertical) )" src="pushButton_0" srcEdge="BOTTOM"/>
-                <anchoritem dst="pushButton_1" dstEdge="RIGHT" spacing="-expr(var(hb-param-margin-gene-right) )" src="" srcEdge="RIGHT"/>
-                <anchoritem dst="pushButton_0" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-left) )" src="" srcEdge="LEFT"/>
-                <anchoritem dst="pushButton_0" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-top) )" src="connectionCombobox" srcEdge="BOTTOM"/>
-                <anchoritem dst="pushButton_0" dstEdge="RIGHT" spacing="-expr(var(hb-param-margin-gene-right) )" src="" srcEdge="RIGHT"/>
             </layout>
         </widget>
+        <widget name="devicePairUnpair" type="HbPushButton">
+            <string name="text"/>
+        </widget>
+        <widget name="deviceSettings" type="HbPushButton">
+            <string locid="txt_bt_button_device_settings" name="text" value="Device Details"/>
+            <icon iconName="qtg_mono_details" name="icon"/>
+        </widget>
     </section>
-    <metadata activeUIState="Common ui state" display="NHD-3.2-inch_portrait" unit="un">
+    <section name="landscape2">
+        <widget name="deviceConnectDisconnect" type="HbPushButton">
+            <sizehint height="0un" type="PREFERRED"/>
+            <sizehint height="0un" type="MINIMUM"/>
+            <sizehint height="0un" type="MAXIMUM"/>
+            <string name="text"/>
+        </widget>
+        <widget name="content" role="HbView:widget" type="HbWidget">
+            <layout type="anchor">
+                <anchoritem dst="deviceViewHeading" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
+                <anchoritem dst="deviceViewHeading" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
+                <anchoritem dst="deviceViewHeading" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="connectionCombobox" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
+                <anchoritem dst="connectionCombobox" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-bottom)  )" src="deviceStatus" srcEdge="BOTTOM"/>
+                <anchoritem dst="connectionCombobox" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="deviceStatus" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-middle-horizontal) )" src="deviceName" srcEdge="RIGHT"/>
+                <anchoritem dst="deviceStatus" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-middle-vertical) )" src="deviceCategory" srcEdge="BOTTOM"/>
+                <anchoritem dst="deviceStatus" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="deviceConnectDisconnect" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-left) )" src="" srcEdge="LEFT"/>
+                <anchoritem dst="deviceConnectDisconnect" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-middle-vertical) )" src="devicePairUnpair" srcEdge="BOTTOM"/>
+                <anchoritem dst="deviceConnectDisconnect" dstEdge="RIGHT" spacing="-expr(var(hb-param-margin-gene-right) )" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="deviceSettings" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-left) )" src="" srcEdge="LEFT"/>
+                <anchoritem dst="deviceSettings" dstEdge="TOP" spacing="var(hb-param-margin-gene-middle-vertical)" src="devicePairUnpair" srcEdge="BOTTOM"/>
+                <anchoritem dst="deviceSettings" dstEdge="RIGHT" spacing="expr(-var(hb-param-margin-gene-right) )" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="deviceSettings" dstEdge="BOTTOM" spacing="expr(-var(hb-param-margin-gene-middle-vertical)  )" src="" srcEdge="BOTTOM"/>
+                <anchoritem dst="devicePairUnpair" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-left) )" src="" srcEdge="LEFT"/>
+                <anchoritem dst="devicePairUnpair" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-middle-vertical)  )" src="connectionCombobox" srcEdge="BOTTOM"/>
+                <anchoritem dst="devicePairUnpair" dstEdge="RIGHT" spacing="expr(-var(hb-param-margin-gene-right) )" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="deviceIcon" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="" srcEdge="LEFT"/>
+                <anchoritem dst="deviceIcon" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-middle-vertical) )" src="deviceViewHeading" srcEdge="BOTTOM"/>
+                <anchoritem dst="deviceName" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-middle-horizontal) )" src="deviceIcon" srcEdge="RIGHT"/>
+                <anchoritem dst="deviceName" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-middle-vertical) )" src="deviceViewHeading" srcEdge="BOTTOM"/>
+                <anchoritem dst="deviceCategory" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-middle-horizontal) )" src="deviceName" srcEdge="RIGHT"/>
+                <anchoritem dst="deviceCategory" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-middle-vertical) )" src="deviceViewHeading" srcEdge="BOTTOM"/>
+            </layout>
+        </widget>
+        <widget name="devicePairUnpair" type="HbPushButton">
+            <sizehint height="8un" type="PREFERRED"/>
+            <string name="text"/>
+        </widget>
+        <widget name="deviceViewHeading" type="HbDataForm">
+            <sizehint height="6un" type="PREFERRED" width="53.73134un"/>
+        </widget>
+        <widget name="deviceName" type="HbLineEdit">
+            <sizehint height="6.25un" type="PREFERRED" width="39.70149un"/>
+        </widget>
+        <widget name="deviceStatus" type="HbLabel">
+            <sizehint height="expr(var(hb-param-text-height-tiny) )" type="PREFERRED" width="39.70149un"/>
+        </widget>
+        <widget name="deviceCategory" type="HbLabel">
+            <sizehint height="expr(var(hb-param-text-height-tiny) )" type="PREFERRED" width="39.70149un"/>
+        </widget>
+        <widget name="connectionCombobox" type="HbDataForm">
+            <sizehint height="4.02985un" type="PREFERRED" width="95.52239un"/>
+        </widget>
+        <widget name="deviceSettings" type="HbPushButton">
+            <sizehint height="8un" type="PREFERRED"/>
+            <string locid="txt_bt_button_device_settings" name="text"/>
+            <icon iconName="qtg_mono_details" name="icon"/>
+        </widget>
+    </section>
+    <metadata activeUIState="portrait" display="NHD-3.2-inch_portrait" unit="un">
         <uistate name="Common ui state" sections="#common"/>
         <uistate name="landscape" sections="#common landscape"/>
         <uistate name="portrait" sections="#common portrait"/>
+        <uistate name="landscape2" sections="#common landscape2"/>
     </metadata>
 </hbdocument>
--- a/bluetoothengine/btui/btcpplugin/docml/bt-main-view.docml	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btcpplugin/docml/bt-main-view.docml	Fri Sep 03 16:17:59 2010 +0300
@@ -12,28 +12,40 @@
         <icon iconName="qtg_mono_search" name="icon"/>
         <string name="text"/>
     </object>
-    <object name="advanceSettings" type="HbAction">
-        <string locid="txt_bt_opt_advanced_settings" name="text" value="Advanced Settings"/>
+    <object name="advanceSettingsAction" type="HbAction">
+        <string locid="txt_bt_opt_advanced_settings" name="text"/>
+    </object>
+    <object name="showAction" type="HbAction">
+        <string locid="txt_bt_opt_show" name="text"/>
+    </object>
+    <object name="removeAllAction" type="HbAction">
+        <string locid="txt_bt_opt_remove_sub_all_devices" name="text"/>
     </object>
-    <object name="showOnly" type="HbAction">
-        <string locid="txt_bt_opt_show" name="text" value="Show only"/>
+    <object name="removeBlockedAction" type="HbAction">
+        <string locid="txt_bt_opt_remove_sub_blocked_devices" name="text"/>
+    </object>
+    <object name="removePairedAction" type="HbAction">
+        <string locid="txt_bt_opt_remove_sub_paired_devices" name="text"/>
     </object>
-    <widget name="view" type="HbView">
-        <widget name="content" role="HbView:widget" type="HbWidget">
+    <object name="viewRemovePairedAction" type="HbAction">
+        <string locid="txt_bt_opt_remove_paired_devices" name="text"/>
+    </object>
+    <widget name="bt_main_view" type="HbView">
+        <widget name="viewContent" role="HbView:widget" type="HbWidget">
             <widget name="toolBar" type="HbToolBar">
                 <sizehint height="7.46269un" type="PREFERRED" width="22.38806un"/>
                 <ref object="allAction" role="HbWidget:addAction"/>
                 <ref object="pairedAction" role="HbWidget:addAction"/>
                 <ref object="discoverAction" role="HbWidget:addAction"/>
             </widget>
-            <widget name="container_1" type="HbWidget">
-                <widget name="dataForm" type="HbDataForm">
+            <widget name="mainContainer" type="HbWidget">
+                <widget name="bluetoothHeading" type="HbDataForm">
                     <widget name="dataformviewItemPrototype" role="HbAbstractView:prototype" type="HbDataFormViewItem"/>
                     <sizehint height="7.8806un" type="MINIMUM"/>
                     <string locid="txt_bt_subhead_bluetooth_paired_devices" name="heading" value="Bluetooth"/>
                 </widget>
-                <widget name="container" type="HbWidget">
-                    <widget name="icon" type="HbLabel">
+                <widget name="subContainer" type="HbWidget">
+                    <widget name="deviceIcon" type="HbLabel">
                         <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
                         <icon iconName="qtg_large_mobile" name="icon"/>
                         <real name="z" value="1"/>
@@ -41,13 +53,13 @@
                         <sizehint height="var(hb-param-graphic-size-primary-large)" type="PREFERRED" width="var(hb-param-graphic-size-primary-large)"/>
                         <enums name="elideMode" value="ElideNone"/>
                     </widget>
-                    <widget name="pushButton" type="HbPushButton">
+                    <widget name="toggleBluetoothPower" type="HbPushButton">
                         <real name="z" value="2"/>
                         <sizehint height="var(hb-param-graphic-size-primary-large)" type="PREFERRED" width="var(hb-param-graphic-size-primary-large)"/>
                         <sizehint height="var(hb-param-graphic-size-primary-large)" type="MAXIMUM" width="var(hb-param-graphic-size-primary-large)"/>
                         <string name="text"/>
                     </widget>
-                    <widget name="combobox" type="HbComboBox">
+                    <widget name="visibilityMode" type="HbComboBox">
                         <container name="items" type="stringlist">
                             <string locid="txt_bt_setlabel_visibility_val_hidden" value="Hidden"/>
                             <string locid="txt_bt_setlabel_visibility_val_visible" value="Visible"/>
@@ -56,7 +68,7 @@
                         <sizepolicy horizontalPolicy="Preferred" horizontalStretch="0" verticalPolicy="Preferred" verticalStretch="0"/>
                         <sizehint height="var(hb-param-graphic-size-primary-large)" type="PREFERRED" width="36un"/>
                     </widget>
-                    <widget name="lineEdit" type="HbLineEdit">
+                    <widget name="deviceNameEdit" type="HbLineEdit">
                         <real name="z" value="3"/>
                         <sizehint height="var(hb-param-graphic-size-primary-large)" type="PREFERRED" width="34un"/>
                         <string name="text" value="Text"/>
@@ -66,109 +78,114 @@
                     <real name="z" value="0"/>
                     <sizehint height="23.8806un" type="PREFERRED" width="23.8806un"/>
                     <layout type="anchor">
-                        <anchoritem dst="icon" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="" srcEdge="LEFT"/>
-                        <anchoritem dst="icon" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="" srcEdge="TOP"/>
-                        <anchoritem dst="lineEdit" dstEdge="LEFT" spacing="2un" src="icon" srcEdge="RIGHT"/>
-                        <anchoritem dst="lineEdit" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="" srcEdge="TOP"/>
-                        <anchoritem dst="lineEdit" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
-                        <anchoritem dst="combobox" dstEdge="LEFT" spacing="2un" src="pushButton" srcEdge="RIGHT"/>
-                        <anchoritem dst="combobox" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="lineEdit" srcEdge="BOTTOM"/>
-                        <anchoritem dst="combobox" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
-                        <anchoritem dst="combobox" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
-                        <anchoritem dst="pushButton" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="" srcEdge="LEFT"/>
-                        <anchoritem dst="pushButton" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="icon" srcEdge="BOTTOM"/>
-                        <anchoritem dst="pushButton" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
+                        <anchoritem dst="deviceIcon" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="" srcEdge="LEFT"/>
+                        <anchoritem dst="deviceIcon" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="" srcEdge="TOP"/>
+                        <anchoritem dst="deviceNameEdit" dstEdge="LEFT" spacing="2un" src="deviceIcon" srcEdge="RIGHT"/>
+                        <anchoritem dst="deviceNameEdit" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="" srcEdge="TOP"/>
+                        <anchoritem dst="deviceNameEdit" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
+                        <anchoritem dst="visibilityMode" dstEdge="LEFT" spacing="2un" src="toggleBluetoothPower" srcEdge="RIGHT"/>
+                        <anchoritem dst="visibilityMode" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="deviceNameEdit" srcEdge="BOTTOM"/>
+                        <anchoritem dst="visibilityMode" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
+                        <anchoritem dst="visibilityMode" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
+                        <anchoritem dst="toggleBluetoothPower" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="" srcEdge="LEFT"/>
+                        <anchoritem dst="toggleBluetoothPower" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="deviceIcon" srcEdge="BOTTOM"/>
+                        <anchoritem dst="toggleBluetoothPower" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
                     </layout>
                 </widget>
                 <real name="z" value="0"/>
                 <sizehint height="23.8806un" type="PREFERRED" width="11.9403un"/>
                 <layout orientation="Vertical" spacing="0un" type="linear">
                     <contentsmargins bottom="0un" left="0un" right="0un" top="0un"/>
-                    <linearitem itemname="dataForm"/>
-                    <linearitem itemname="container"/>
+                    <linearitem itemname="bluetoothHeading"/>
+                    <linearitem itemname="subContainer"/>
                 </layout>
             </widget>
-            <widget name="listView" type="HbListView">
-                <widget name="listItemPrototype" role="HbAbstractView:prototype" type="HbListViewItem"/>
-                <enums name="selectionMode" value="NoSelection"/>
-                <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Preferred" verticalStretch="0"/>
-                <sizehint height="47.7612un" type="PREFERRED" width="35.8209un"/>
+            <widget name="deviceList" type="HbGridView">
+                <widget name="gridItemPrototype" role="HbAbstractView:prototype" type="HbGridViewItem"/>
+                <sizehint height="47.7612un" type="PREFERRED" width="47.7612un"/>
             </widget>
             <layout orientation="Vertical" spacing="var(hb-param-margin-gene-middle-vertical)" type="linear">
                 <contentsmargins bottom="0un" left="0un" right="0un" top="0un"/>
-                <linearitem itemname="container_1"/>
-                <linearitem itemname="listView"/>
+                <linearitem itemname="mainContainer"/>
+                <linearitem itemname="deviceList"/>
                 <linearitem itemname="toolBar"/>
             </layout>
         </widget>
         <widget name="viewMenu" role="HbView:menu" type="HbMenu">
-            <ref object="advanceSettings" role="HbWidget:addAction"/>
-            <ref object="showOnly" role="HbWidget:addAction"/>
+            <ref object="advanceSettingsAction" role="HbWidget:addAction"/>
+            <ref object="showAction" role="HbWidget:addAction"/>
+            <widget name="removeSubMenu" role="HbMenu:menu" type="HbMenu">
+                <ref object="removeAllAction" role="HbWidget:addAction"/>
+                <ref object="removePairedAction" role="HbWidget:addAction"/>
+                <ref object="removeBlockedAction" role="HbWidget:addAction"/>
+                <string locid="txt_bt_opt_remove" name="title"/>
+            </widget>
+            <ref object="viewRemovePairedAction" role="HbWidget:addAction"/>
         </widget>
         <string locid="txt_cp_title_control_panel" name="title" value="Control Panel"/>
     </widget>
     <section name="portrait">
-        <widget name="combobox" type="HbComboBox">
+        <widget name="visibilityMode" type="HbComboBox">
             <sizehint height="var(hb-param-graphic-size-primary-large)" type="PREFERRED" width="31.34328un"/>
         </widget>
-        <widget name="content" role="HbView:widget" type="HbWidget">
+        <widget name="viewContent" role="HbView:widget" type="HbWidget">
             <layout orientation="Vertical" spacing="var(hb-param-margin-gene-middle-vertical)" type="linear">
                 <contentsmargins bottom="0un" left="0un" right="0un" top="0un"/>
-                <linearitem itemname="dataForm"/>
-                <linearitem itemname="container"/>
-                <linearitem itemname="listView"/>
+                <linearitem itemname="bluetoothHeading"/>
+                <linearitem itemname="subContainer"/>
+                <linearitem itemname="deviceList"/>
                 <linearitem itemname="toolBar"/>
             </layout>
         </widget>
-        <widget name="lineEdit" type="HbLineEdit">
+        <widget name="deviceNameEdit" type="HbLineEdit">
             <sizehint type="PREFERRED" width="29.25373un"/>
         </widget>
-        <widget name="pushButton" type="HbPushButton">
+        <widget name="toggleBluetoothPower" type="HbPushButton">
             <sizehint height="var(hb-param-graphic-size-primary-large)" type="PREFERRED" width="var(hb-param-graphic-size-primary-large)"/>
             <sizehint height="var(hb-param-graphic-size-primary-large)" type="MAXIMUM" width="var(hb-param-graphic-size-primary-large)"/>
         </widget>
-        <widget name="icon" type="HbLabel">
+        <widget name="deviceIcon" type="HbLabel">
             <sizehint height="var(hb-param-graphic-size-primary-large)" type="PREFERRED" width="var(hb-param-graphic-size-primary-large)"/>
             <sizehint height="var(hb-param-graphic-size-primary-large)" type="MAXIMUM" width="var(hb-param-graphic-size-primary-large)"/>
         </widget>
-        <widget name="container" type="HbWidget">
+        <widget name="subContainer" type="HbWidget">
             <layout type="anchor">
-                <anchoritem dst="icon" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="" srcEdge="LEFT"/>
-                <anchoritem dst="icon" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="" srcEdge="TOP"/>
-                <anchoritem dst="lineEdit" dstEdge="LEFT" spacing="2un" src="icon" srcEdge="RIGHT"/>
-                <anchoritem dst="lineEdit" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="" srcEdge="TOP"/>
-                <anchoritem dst="lineEdit" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
-                <anchoritem dst="combobox" dstEdge="LEFT" spacing="2un" src="pushButton" srcEdge="RIGHT"/>
-                <anchoritem dst="combobox" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="lineEdit" srcEdge="BOTTOM"/>
-                <anchoritem dst="combobox" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
-                <anchoritem dst="combobox" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
-                <anchoritem dst="pushButton" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="" srcEdge="LEFT"/>
-                <anchoritem dst="pushButton" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="icon" srcEdge="BOTTOM"/>
-                <anchoritem dst="pushButton" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
+                <anchoritem dst="deviceIcon" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="" srcEdge="LEFT"/>
+                <anchoritem dst="deviceIcon" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="" srcEdge="TOP"/>
+                <anchoritem dst="deviceNameEdit" dstEdge="LEFT" spacing="2un" src="deviceIcon" srcEdge="RIGHT"/>
+                <anchoritem dst="deviceNameEdit" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="" srcEdge="TOP"/>
+                <anchoritem dst="deviceNameEdit" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="visibilityMode" dstEdge="LEFT" spacing="2un" src="toggleBluetoothPower" srcEdge="RIGHT"/>
+                <anchoritem dst="visibilityMode" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="deviceNameEdit" srcEdge="BOTTOM"/>
+                <anchoritem dst="visibilityMode" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="visibilityMode" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
+                <anchoritem dst="toggleBluetoothPower" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="" srcEdge="LEFT"/>
+                <anchoritem dst="toggleBluetoothPower" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="deviceIcon" srcEdge="BOTTOM"/>
+                <anchoritem dst="toggleBluetoothPower" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
             </layout>
         </widget>
     </section>
     <section name="landscape">
-        <widget name="combobox" type="HbComboBox">
+        <widget name="visibilityMode" type="HbComboBox">
             <sizehint height="var(hb-param-graphic-size-primary-large)" type="PREFERRED" width="34.92537un"/>
         </widget>
-        <widget name="lineEdit" type="HbLineEdit">
+        <widget name="deviceNameEdit" type="HbLineEdit">
             <sizehint height="var(hb-param-graphic-size-primary-large)" type="PREFERRED" width="33un"/>
         </widget>
-        <widget name="icon" type="HbLabel">
+        <widget name="deviceIcon" type="HbLabel">
             <sizehint height="var(hb-param-graphic-size-primary-large)" type="PREFERRED" width="var(hb-param-graphic-size-primary-large)"/>
         </widget>
-        <widget name="container" type="HbWidget">
+        <widget name="subContainer" type="HbWidget">
             <layout type="anchor">
-                <anchoritem dst="icon" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="" srcEdge="LEFT"/>
-                <anchoritem dst="icon" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="" srcEdge="TOP"/>
-                <anchoritem dst="lineEdit" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="" srcEdge="TOP"/>
-                <anchoritem dst="lineEdit" dstEdge="LEFT" spacing="1.97885un" src="icon" srcEdge="RIGHT"/>
-                <anchoritem dst="combobox" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-middle-horizontal) )" src="pushButton" srcEdge="RIGHT"/>
-                <anchoritem dst="combobox" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-top) )" src="" srcEdge="TOP"/>
-                <anchoritem dst="combobox" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
-                <anchoritem dst="pushButton" dstEdge="LEFT" spacing="2un" src="lineEdit" srcEdge="RIGHT"/>
-                <anchoritem dst="pushButton" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-top) )" src="" srcEdge="TOP"/>
+                <anchoritem dst="deviceIcon" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="" srcEdge="LEFT"/>
+                <anchoritem dst="deviceIcon" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="" srcEdge="TOP"/>
+                <anchoritem dst="deviceNameEdit" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="" srcEdge="TOP"/>
+                <anchoritem dst="deviceNameEdit" dstEdge="LEFT" spacing="1.97885un" src="deviceIcon" srcEdge="RIGHT"/>
+                <anchoritem dst="visibilityMode" dstEdge="LEFT" spacing="expr(var(hb-param-margin-gene-middle-horizontal) )" src="toggleBluetoothPower" srcEdge="RIGHT"/>
+                <anchoritem dst="visibilityMode" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-top) )" src="" srcEdge="TOP"/>
+                <anchoritem dst="visibilityMode" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="toggleBluetoothPower" dstEdge="LEFT" spacing="2un" src="deviceNameEdit" srcEdge="RIGHT"/>
+                <anchoritem dst="toggleBluetoothPower" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-top) )" src="" srcEdge="TOP"/>
             </layout>
         </widget>
     </section>
@@ -177,6 +194,6 @@
         <uistate name="portrait" sections="#common"/>
         <uistate name="portrait_UI" sections="#common portrait"/>
         <uistate name="landscape" sections="#common landscape"/>
-        <dummydata objectName="listView" section="#common" value="app_list_template5"/>
+        <dummydata objectName="deviceList" section="#common" value="app_grid_template2"/>
     </metadata>
 </hbdocument>
--- a/bluetoothengine/btui/btcpplugin/docml/bt-search-view.docml	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btcpplugin/docml/bt-search-view.docml	Fri Sep 03 16:17:59 2010 +0300
@@ -19,7 +19,7 @@
     <widget name="bt_search_view" type="HbView">
         <widget name="search_view_content" role="HbView:widget" type="HbWidget">
             <widget name="search_container" type="HbWidget">
-                <widget name="icon" type="HbLabel">
+                <widget name="searchIcon" type="HbLabel">
                     <enums name="alignment" value="AlignVCenter|AlignHCenter"/>
                     <icon iconName="qtg_anim_small_loading.axml" name="icon"/>
                     <real name="z" value="2"/>
@@ -27,35 +27,34 @@
                     <sizehint height="var(hb-param-graphic-size-primary-large)" type="MAXIMUM" width="var(hb-param-graphic-size-primary-large)"/>
                     <bool name="visible" value="TRUE"/>
                 </widget>
-                <widget name="label_searching" type="HbLabel">
+                <widget name="searchStatus" type="HbLabel">
                     <real name="z" value="3"/>
                     <sizehint height="var(hb-param-graphic-size-primary-large)" type="PREFERRED" width="38.20896un"/>
                     <bool name="visible" value="TRUE"/>
                     <string locid="txt_bt_subhead_searching" name="plainText" value="Searching..."/>
                 </widget>
-                <widget name="dataForm" type="HbDataForm">
+                <widget name="searchHeading" type="HbDataForm">
                     <widget name="dataformviewItemPrototype" role="HbAbstractView:prototype" type="HbDataFormViewItem"/>
                     <real name="z" value="4"/>
-                    <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Expanding" verticalStretch="0"/>
-                    <sizehint type="PREFERRED" width="25un"/>
+                    <sizehint height="7.8806un" type="MINIMUM"/>
                     <string locid="txt_bt_subhead_bluetooth_found_devices" name="heading" value="Found devices"/>
                 </widget>
                 <real name="z" value="0"/>
-                <sizepolicy horizontalPolicy="Preferred" horizontalStretch="0" verticalPolicy="Expanding" verticalStretch="0"/>
+                <sizepolicy horizontalPolicy="Preferred" horizontalStretch="0" verticalPolicy="Preferred" verticalStretch="0"/>
                 <sizehint height="12.784un" type="PREFERRED" width="51.19403un"/>
                 <sizehint height="14.784un" type="MAXIMUM"/>
                 <bool name="visible" value="TRUE"/>
                 <layout type="anchor">
-                    <anchoritem dst="dataForm" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
-                    <anchoritem dst="dataForm" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
-                    <anchoritem dst="dataForm" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
-                    <anchoritem dst="label_searching" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="icon" srcEdge="RIGHT"/>
-                    <anchoritem dst="label_searching" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-middle-vertical) )" src="dataForm" srcEdge="BOTTOM"/>
-                    <anchoritem dst="label_searching" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
-                    <anchoritem dst="label_searching" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
-                    <anchoritem dst="icon" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="" srcEdge="LEFT"/>
-                    <anchoritem dst="icon" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-top) )" src="dataForm" srcEdge="BOTTOM"/>
-                    <anchoritem dst="icon" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
+                    <anchoritem dst="searchHeading" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
+                    <anchoritem dst="searchHeading" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
+                    <anchoritem dst="searchHeading" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
+                    <anchoritem dst="searchStatus" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="searchIcon" srcEdge="RIGHT"/>
+                    <anchoritem dst="searchStatus" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-middle-vertical) )" src="searchHeading" srcEdge="BOTTOM"/>
+                    <anchoritem dst="searchStatus" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
+                    <anchoritem dst="searchStatus" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
+                    <anchoritem dst="searchIcon" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="" srcEdge="LEFT"/>
+                    <anchoritem dst="searchIcon" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-top) )" src="searchHeading" srcEdge="BOTTOM"/>
+                    <anchoritem dst="searchIcon" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
                 </layout>
             </widget>
             <widget name="toolBar" type="HbToolBar">
@@ -80,41 +79,48 @@
         <string locid="txt_cp_title_control_panel" name="title" value="Control Panel"/>
         <real name="z" value="1"/>
     </widget>
+    <section name="portrait">
+        <widget name="search_container" type="HbWidget">
+            <layout type="anchor">
+                <anchoritem dst="searchHeading" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
+                <anchoritem dst="searchHeading" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
+                <anchoritem dst="searchHeading" dstEdge="RIGHT" spacing="0un" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="searchStatus" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="searchIcon" srcEdge="RIGHT"/>
+                <anchoritem dst="searchStatus" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-middle-vertical) )" src="searchHeading" srcEdge="BOTTOM"/>
+                <anchoritem dst="searchStatus" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="searchStatus" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
+                <anchoritem dst="searchIcon" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="" srcEdge="LEFT"/>
+                <anchoritem dst="searchIcon" dstEdge="TOP" spacing="expr(var(hb-param-margin-gene-top) )" src="searchHeading" srcEdge="BOTTOM"/>
+                <anchoritem dst="searchIcon" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
+            </layout>
+    
+    	</widget>
+    </section>
     <section name="landscape">
-        <widget name="icon" type="HbLabel">
-            <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Preferred" verticalStretch="0"/>
-        </widget>
-        <widget name="dataForm" type="HbDataForm">
-            <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Expanding" verticalStretch="0"/>
-            <sizehint type="PREFERRED" width="51.19403un"/>
-        </widget>
-        <widget name="label_searching" type="HbLabel">
-            <sizepolicy horizontalPolicy="Expanding" horizontalStretch="0" verticalPolicy="Preferred" verticalStretch="0"/>
-        </widget>
         <widget name="search_container" type="HbWidget">
             <sizepolicy horizontalPolicy="Preferred" horizontalStretch="0" verticalPolicy="Ignored" verticalStretch="0"/>
             <sizehint height="12un" type="PREFERRED" width="51.19403un"/>
             <sizehint height="12.75un" type="MAXIMUM"/>
             <layout type="anchor">
-                <anchoritem dst="icon" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
-                <anchoritem dst="icon" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
-                <anchoritem dst="label_searching" dstEdge="BOTTOM" spacing="-var(hb-param-margin-gene-bottom)" src="" srcEdge="BOTTOM"/>
-                <anchoritem dst="label_searching" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
-                <anchoritem dst="label_searching" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="" srcEdge="TOP"/>
-                <anchoritem dst="label_searching" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="icon" srcEdge="RIGHT"/>
-                <anchoritem dst="icon" dstEdge="LEFT" spacing="0un" src="dataForm" srcEdge="RIGHT"/>
-                <anchoritem dst="icon" dstEdge="RIGHT" spacing="0un" src="label_searching" srcEdge="LEFT"/>
-                <anchoritem dst="dataForm" dstEdge="RIGHT" spacing="0un" src="icon" srcEdge="LEFT"/>
-                <anchoritem dst="dataForm" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
-                <anchoritem dst="dataForm" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
-                <anchoritem dst="dataForm" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
+                <anchoritem dst="searchIcon" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
+                <anchoritem dst="searchIcon" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
+                <anchoritem dst="searchStatus" dstEdge="BOTTOM" spacing="-var(hb-param-margin-gene-bottom)" src="" srcEdge="BOTTOM"/>
+                <anchoritem dst="searchStatus" dstEdge="RIGHT" spacing="-var(hb-param-margin-gene-right)" src="" srcEdge="RIGHT"/>
+                <anchoritem dst="searchStatus" dstEdge="TOP" spacing="var(hb-param-margin-gene-top)" src="" srcEdge="TOP"/>
+                <anchoritem dst="searchStatus" dstEdge="LEFT" spacing="var(hb-param-margin-gene-left)" src="searchIcon" srcEdge="RIGHT"/>
+                <anchoritem dst="searchIcon" dstEdge="LEFT" spacing="0un" src="searchHeading" srcEdge="RIGHT"/>
+                <anchoritem dst="searchIcon" dstEdge="RIGHT" spacing="0un" src="searchStatus" srcEdge="LEFT"/>
+                <anchoritem dst="searchHeading" dstEdge="RIGHT" spacing="0un" src="searchIcon" srcEdge="LEFT"/>
+                <anchoritem dst="searchHeading" dstEdge="LEFT" spacing="0un" src="" srcEdge="LEFT"/>
+                <anchoritem dst="searchHeading" dstEdge="TOP" spacing="0un" src="" srcEdge="TOP"/>
+                <anchoritem dst="searchHeading" dstEdge="BOTTOM" spacing="0un" src="" srcEdge="BOTTOM"/>
             </layout>
         </widget>
     </section>
     <metadata activeUIState="landscape_ui" display="NHD-3.2-inch_landscape" unit="un">
         <uistate name="Common ui state" sections="#common"/>
         <uistate name="landscape_ui" sections="#common landscape"/>
-        <uistate name="portrait_ui" sections="#common"/>
+        <uistate name="portrait_ui" sections="#common portrait"/>
         <uistate name="landscape" sections="#common landscape"/>
         <dummydata objectName="deviceList" section="#common" value="0"/>
     </metadata>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btui/btcpplugin/docml/btcpuimaingridviewitem.css	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,50 @@
+BtCpUiMainGridViewItem:portrait
+ {
+   layout:portrait;
+ }
+
+BtCpUiMainGridViewItem:landscape
+ {
+   layout:landscape;
+ }
+
+BtCpUiMainGridViewItem::deviceIcon
+ {
+ 	top: -0un;
+ 	left: -var(hb-param-margin-gene-left);
+  	fixed-height: 10.0un;
+  	fixed-width: 8.0un;
+ }
+
+BtCpUiMainGridViewItem::deviceIcon:landscape
+ {
+ 	top: -0un;
+ 	left: -var(hb-param-margin-gene-left);
+  	fixed-height: 10.0un;
+  	fixed-width: 20.0un;
+ }
+
+BtCpUiMainGridViewItem::deviceName
+ {
+ 	 top: -1un;
+ 	 text-height: var(hb-param-text-height-primary);
+	 fixed-width: 40.0un;
+ }
+
+BtCpUiMainGridViewItem::deviceName:landscape
+ {
+ 	 text-height: var(hb-param-text-height-secondary);
+	 fixed-width: 12.0un;
+ }
+
+BtCpUiMainGridViewItem::deviceType
+ {
+ 	 text-height: var(hb-param-text-height-secondary);
+	 fixed-width: 40.0un;
+ }
+
+BtCpUiMainGridViewItem::deviceType:landscape
+ {
+	fixed-width: 0un;
+ }
+ 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btui/btcpplugin/docml/btcpuimaingridviewitem.widgetml	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,28 @@
+<hbwidget version="0.1" type="BtCpUiMainGridViewItem">
+	<layout name="portrait" type="mesh">
+
+		<meshitem src="deviceIcon" srcEdge="TOP" dst="" dstEdge="TOP" />
+		<meshitem src="deviceIcon" srcEdge="LEFT" dst="" dstEdge="LEFT" />
+		<meshitem src="deviceIcon" srcEdge="BOTTOM" dst="" dstEdge="BOTTOM" />
+	
+		<meshitem src="deviceName" srcEdge="TOP" dst="deviceIcon" dstEdge="TOP" />
+		<meshitem src="deviceName" srcEdge="LEFT" dst="deviceIcon" dstEdge="RIGHT" />
+		
+		<meshitem src="deviceType" srcEdge="LEFT" dst="deviceName" dstEdge="LEFT" />
+		<meshitem src="deviceType" srcEdge="TOP" dst="deviceName" dstEdge="BOTTOM" />
+
+	</layout>
+	
+	<layout name="landscape" type="mesh">
+	
+		<meshitem src="deviceIcon" srcEdge="TOP" dst="" dstEdge="TOP" />
+		<meshitem src="deviceIcon" srcEdge="LEFT" dst="" dstEdge="LEFT" />
+	
+		<meshitem src="deviceName" srcEdge="LEFT" dst="deviceIcon" dstEdge="LEFT"/>
+		<meshitem src="deviceName" srcEdge="TOP" dst="deviceIcon" dstEdge="BOTTOM" spacing="-var(hb-param-margin-gene-middle-vertical)" />
+		<meshitem src="deviceName" srcEdge="BOTTOM" dst="" dstEdge="BOTTOM"/>
+	
+		<meshitem src="deviceType" srcEdge="LEFT" dst="deviceIcon" dstEdge="LEFT"/>
+	</layout>
+	
+</hbwidget>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btui/btcpplugin/docml/btcpuisearchlistviewitem.css	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,20 @@
+BtCpUiSearchListViewItem
+ {
+   layout:custom-list;
+ }
+
+BtCpUiSearchListViewItem::btDeviceIcon
+ {
+ 	top:-var(hb-param-margin-gene-top);
+ 	left: -var(hb-param-margin-gene-left);
+ 	fixed-width: var(hb-param-graphic-size-primary-large);
+ 	fixed-height: var(hb-param-graphic-size-primary-large);
+ 	
+  }
+
+BtCpUiSearchListViewItem::btDeviceName
+ {
+ 	 top: -2.0un;
+  	 text-height: var(hb-param-text-height-primary);
+	 fixed-width: 40.0un;
+ } 
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btui/btcpplugin/docml/btcpuisearchlistviewitem.widgetml	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,14 @@
+<hbwidget version="0.1" type="BtCpUiSearchListViewItem">
+
+	<layout name="custom-list" type="mesh">
+
+		<meshitem src="btDeviceIcon" srcEdge="TOP" dst="" dstEdge="TOP" />
+		<meshitem src="btDeviceIcon" srcEdge="LEFT" dst="" dstEdge="LEFT" />
+		<meshitem src="btDeviceIcon" srcEdge="BOTTOM" dst="" dstEdge="BOTTOM" />
+
+		<meshitem src="btDeviceName" srcEdge="TOP" dst="btDeviceIcon" dstEdge="TOP" />
+		<meshitem src="btDeviceName" srcEdge="LEFT" dst="btDeviceIcon" dstEdge="RIGHT" />
+						
+	</layout>
+	
+</hbwidget>
--- a/bluetoothengine/btui/btuidelegate/btabstractdelegate.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/btabstractdelegate.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -15,19 +15,20 @@
 *
 */
 
-
 #include "btabstractdelegate.h"
 #include "btqtconstants.h"
-
 #include <btsettingmodel.h>
 #include <btdevicemodel.h>
+#include <btengsettings.h>
+#include <bluetoothuitrace.h>
 
 /*!
     Constructor.
  */
 BtAbstractDelegate::BtAbstractDelegate( BtSettingModel *settingModel, 
         BtDeviceModel *deviceModel, QObject *parent )
-    : QObject( parent ), mSettingModel(settingModel),mDeviceModel(deviceModel)
+    : QObject( parent ), mSettingModel(settingModel), mDeviceModel(deviceModel),
+      mExecuting(false)
 {
 }
 
@@ -38,28 +39,50 @@
 {
 }
 
-BtSettingModel *BtAbstractDelegate::getSettingModel()
+bool BtAbstractDelegate::isExecuting()
+{
+    return mExecuting;
+}
+
+BtSettingModel *BtAbstractDelegate::settingModel()
 {
     return mSettingModel;
 }
 
-BtDeviceModel *BtAbstractDelegate::getDeviceModel()
+BtDeviceModel *BtAbstractDelegate::deviceModel()
 {
     return mDeviceModel;
 }
 
 void BtAbstractDelegate::cancel()
 {
-    
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    BOstraceFunctionExit0( DUMMY_DEVLIST );
 }
 
 bool BtAbstractDelegate::isBtPowerOn()
 {
-    QModelIndex powerIndex = getSettingModel()->index(BtSettingModel::PowerStateRow, 0);
-    PowerStateQtValue powerState = (PowerStateQtValue)getSettingModel()->data(powerIndex, BtSettingModel::SettingValueRole).toInt();
-    
-    return (BtPowerOn == powerState);
+    TBTPowerStateValue state(EBTPowerOff);
+    CBTEngSettings *settings(0);
+    TRAP_IGNORE(settings = CBTEngSettings::NewL());
+    if (settings) {
+        // error on function call is treated as BT OFF
+        (void) settings->GetPowerState(state);
+        delete settings;
+    }
+   BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, state);
+   return (EBTPowerOn == state);
 }
 
+void BtAbstractDelegate::completeDelegateExecution(int error)
+{
+    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, error);
+    setExecuting(false);
+    emit delegateCompleted(error, this);
+    BOstraceFunctionExit0( DUMMY_DEVLIST );
+}
 
-
+void BtAbstractDelegate::setExecuting(bool status)
+{
+    mExecuting = status;
+}
--- a/bluetoothengine/btui/btuidelegate/btabstractdelegate.h	Fri Aug 06 16:43:21 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,80 +0,0 @@
-/*
-* Copyright (c) 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: 
-*
-*/
-
-#ifndef BTABSTRACTDELEGATE_H
-#define BTABSTRACTDELEGATE_H
-
-#include <QObject>
-#include <QVariant>
-#include <QModelIndex>
-
-class BtSettingModel;
-class BtDeviceModel;
-
-#ifdef BUILD_BTUIDELEGATE
-#define BTUIDELEGATE_IMEXPORT Q_DECL_EXPORT
-#else
-#define BTUIDELEGATE_IMEXPORT Q_DECL_IMPORT
-#endif
-
-
-/*!
-    \class BtAbstractDelegate
-    \brief the base class for handling user requests from BT application.
-
-
-    \\sa btuidelegate
- */
-class BTUIDELEGATE_IMEXPORT BtAbstractDelegate : public QObject
-{
-    Q_OBJECT
-
-public:
-    explicit BtAbstractDelegate( BtSettingModel* settingModel, 
-            BtDeviceModel* deviceModel, QObject *parent = 0 );
-    
-    virtual ~BtAbstractDelegate();
-
-    virtual void exec( const QVariant &params ) = 0;
-
-    virtual void cancel();
-    
-signals:
-    void commandCompleted(int status, QVariant params = QVariant() );
-    
-protected:
-    
-    BtSettingModel *getSettingModel();
-    BtDeviceModel *getDeviceModel();
-    
-    bool isBtPowerOn();
-    
-public slots:
-
-private:
-    
-    // pointer to models. do not own. 
-    BtSettingModel *mSettingModel;
-    BtDeviceModel *mDeviceModel;
-    
-    Q_DISABLE_COPY(BtAbstractDelegate)
-
-};
-
-Q_DECLARE_METATYPE(QModelIndex)
-
-#endif // BTABSTRACTDELEGATE_H
--- a/bluetoothengine/btui/btuidelegate/btdelegateconnect.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/btdelegateconnect.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -36,12 +36,24 @@
     BtAbstractDelegate(settingModel, deviceModel, parent), mBtengConnMan(0),
     mAbstractDelegate(0), mActiveHandling(false)
 {
-    
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );   
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
 BtDelegateConnect::~BtDelegateConnect()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );   
     delete mBtengConnMan;
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
+}
+
+/*!
+    Returns the supported editor types.
+    \return the sum of supported editor types
+ */
+int BtDelegateConnect::supportedEditorTypes() const
+{
+    return BtDelegate::ConnectService;
 }
 
 /*!
@@ -50,16 +62,20 @@
  */
 void BtDelegateConnect::exec( const QVariant &params )
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );  
     if ( mActiveHandling ) {
-        emit commandCompleted( KErrAlreadyExists );
+        emit delegateCompleted( KErrAlreadyExists, this );
+        BOstraceFunctionExit1( DUMMY_DEVLIST, this );
         return;
     }
     mIndex = params.value<QModelIndex>();
     mActiveHandling = true;
     // save needed values from model
     mDeviceName = (mIndex.data(BtDeviceModel::NameAliasRole)).toString();
+    BtTraceQString1( TRACE_DEBUG, DUMMY_DEVLIST, "device name=", mDeviceName);
     QString addrStr = (mIndex.data(BtDeviceModel::ReadableBdaddrRole)).toString(); 
     addrReadbleStringToSymbian( addrStr, mAddr );  
+    BtTraceBtAddr1( TRACE_DEBUG, DUMMY_DEVLIST, "device addr=", mAddr );
     
     mCod = (mIndex.data(BtDeviceModel::CoDRole)).toInt();
     mMajorProperty = (mIndex.data(BtDeviceModel::MajorPropertyRole)).toInt();
@@ -69,8 +85,8 @@
         if (!mAbstractDelegate) //if there is no other delegate running
         { 
             mAbstractDelegate = BtDelegateFactory::newDelegate(BtDelegate::ManagePower, 
-                    getSettingModel(), getDeviceModel() ); 
-            connect( mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(powerDelegateCompleted(int)) );
+                    settingModel(), deviceModel() ); 
+            connect( mAbstractDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), this, SLOT(powerDelegateCompleted(int)) );
             mAbstractDelegate->exec(QVariant(BtPowerOn));
         }
     } 
@@ -78,6 +94,7 @@
         // power is already on
         exec_connect();
     }
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
 /*!
@@ -85,9 +102,9 @@
  */
 void BtDelegateConnect::powerDelegateCompleted(int status)
 {
+    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, status );  
     if (mAbstractDelegate)
     {
-        disconnect(mAbstractDelegate);
         delete mAbstractDelegate;
         mAbstractDelegate = 0;
     }
@@ -99,6 +116,7 @@
         // error
         emitCommandComplete(status);
     }
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
 /*!
@@ -106,6 +124,7 @@
  */
 void BtDelegateConnect::exec_connect()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );  
     int error = KErrNone;
     
     if ( ! mBtengConnMan ){
@@ -120,6 +139,7 @@
     if( error ) {
         emitCommandComplete(error);
     }
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
 /*!
@@ -128,24 +148,31 @@
 void BtDelegateConnect::ConnectComplete( TBTDevAddr& aAddr, TInt aErr, 
                                    RBTDevAddrArray* aConflicts )
 {
+    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aErr );  
+    BtTraceBtAddr1( TRACE_DEBUG, DUMMY_DEVLIST, "device addr=", aAddr );
     // It is possible that another audio device has just connected to phone when we are
     // connecting to this audio device. Or a device is connected while this command
     // is idle. No handling for these cases.
     if ( mAddr != aAddr || !mActiveHandling ) {  
+        BOstraceFunctionExit1( DUMMY_DEVLIST, this );
         return;
     }
     
+    QModelIndex conflictDevIndex;
     // conflict could occur as well if another audio device is already connected
     // since currently we don't support multiple audio device connections.
     if ( aErr && aConflicts && aConflicts->Count() ) {
         // get the display name of the device that is 
         // causing the conflict 
-        QString conflictDevAddr;
-        addrSymbianToReadbleString(conflictDevAddr, (*aConflicts)[0] );
-        QModelIndex start = getDeviceModel()->index(0,0);
-        QModelIndexList indexList = getDeviceModel()->match(start, BtDeviceModel::ReadableBdaddrRole, conflictDevAddr);
+        
+        addrSymbianToReadbleString(mConflictDevAddr, (*aConflicts)[0] );
+        QModelIndex start = deviceModel()->index(0,0);
+        QModelIndexList indexList = deviceModel()->match(start, BtDeviceModel::ReadableBdaddrRole, 
+                QVariant(mConflictDevAddr));
+        // ToDo:  change assert to normal error handling;  
+        // is it possible that device is not in model or registry?
         BTUI_ASSERT_X(indexList.count(), "BtDelegateConnect::ConnectComplete()", "device missing from model!");
-        mConflictDevIndex = indexList.at(0);
+        conflictDevIndex = indexList.at(0);
       
         // check if conflict device is being used in a call
         // Note:  actually only checking if *any* audio device is involved in a call, not necessarily the
@@ -157,19 +184,20 @@
         }
         else {
             // no call, check if user wants to disconnect conflict device 
-            QString conflictDevName = (mConflictDevIndex.data(BtDeviceModel::NameAliasRole)).toString();    
+            QString conflictDevName = (conflictDevIndex.data(BtDeviceModel::NameAliasRole)).toString();    
     
             QString questionText(hbTrId("txt_bt_info_to_connect_1_2_needs_to_be_disconnec")
                     .arg(mDeviceName).arg(conflictDevName));
             
             HbMessageBox::question( questionText, this, SLOT(handleUserAnswer(int)), 
-                    HbMessageBox::Continue | HbMessageBox::Cancel );       
+                    HbMessageBox::Continue | HbMessageBox::Cancel );
         }
     }
     else {
         // command is finished
         emitCommandComplete(aErr);
     }
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
 /*!
@@ -177,27 +205,27 @@
  */
 void BtDelegateConnect::handleUserAnswer( int answer )
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );  
     if( answer == HbMessageBox::Continue ) { 
         // Continue, ie. disconnect conflict device and then try reconnecting again
         if (!mAbstractDelegate) //if there is no other delegate running
         { 
             QList<QVariant>list;
-            QVariant paramFirst;
-            paramFirst.setValue(mConflictDevIndex);    
-            QVariant paramSecond(ServiceLevel);
-            list.append(paramFirst);
+            QVariant paramSecond;
+            paramSecond.setValue(mConflictDevAddr);    
+            list.append(QVariant(ServiceLevel));
             list.append(paramSecond);
-            QVariant paramsList(list);
-            mAbstractDelegate = BtDelegateFactory::newDelegate(BtDelegate::Disconnect, 
-                    getSettingModel(), getDeviceModel() ); 
-            connect( mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(disconnectDelegateCompleted(int)) );
-            mAbstractDelegate->exec(paramsList);
+            mAbstractDelegate = BtDelegateFactory::newDelegate(BtDelegate::DisconnectService, 
+                    settingModel(), deviceModel() ); 
+            connect( mAbstractDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), this, SLOT(disconnectDelegateCompleted(int)) );
+            mAbstractDelegate->exec(QVariant(list));
         }
     }
     else {
         // Cancel connect operation
         emitCommandComplete(KErrCancel);
     }
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
 /*!
@@ -205,15 +233,19 @@
  */
 bool BtDelegateConnect::callOngoing()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );  
     // ToDo:  check if there exists Qt PS key for ongoing call
     int callState;
+    bool retVal;
     int err = RProperty::Get(KPSUidCtsyCallInformation, KCTsyCallState, callState);
     if (!err && (callState == EPSCTsyCallStateNone || callState == EPSCTsyCallStateUninitialized)) {
-        return false;
+        retVal = false;
     }
     else {
-        return true;
+        retVal =  true;
     }
+    BOstraceFunctionExitExt( DUMMY_DEVLIST, this, retVal );
+    return retVal;
 }
 
 /*!
@@ -221,9 +253,9 @@
  */
 void BtDelegateConnect::disconnectDelegateCompleted(int status)
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );  
     if (mAbstractDelegate)
     {
-        disconnect(mAbstractDelegate);
         delete mAbstractDelegate;
         mAbstractDelegate = 0;
     }
@@ -235,6 +267,7 @@
         // disconnect failed, abort
         emitCommandComplete( status );
     }
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
 /*!
@@ -242,8 +275,11 @@
  */
 void BtDelegateConnect::DisconnectComplete( TBTDevAddr& aAddr, TInt aErr )
 {
+    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aErr );  
+    BtTraceBtAddr1( TRACE_DEBUG, DUMMY_DEVLIST, "device addr=", aAddr );
     Q_UNUSED(aAddr);
     Q_UNUSED(aErr);    
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
 /*!
@@ -252,9 +288,11 @@
  */
 void BtDelegateConnect::cancel()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );  
     if ( mBtengConnMan ) {
         mBtengConnMan->CancelConnect(mAddr);
     }
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
 /*!
@@ -263,26 +301,15 @@
  */
 void BtDelegateConnect::emitCommandComplete(int error)
 {
-    if ( error == KErrNone ) {
-        // success, show indicator with connection status
-        
-        HbIcon icon = getBadgedDeviceTypeIcon( mCod, mMajorProperty, BtuiNoCorners); 
-        QString str(hbTrId("txt_bt_dpopinfo_connected_to_1"));
-        HbNotificationDialog::launchDialog( icon, hbTrId("txt_bt_dpophead_connected"), 
-            str.arg(mDeviceName) );  
-    }
-    else if ( error == KErrCancel ) {
+    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, error );  
+    if ( error == KErrCancel ) {
         // no user note, return success since cancel operation completed successfully
         error = KErrNone;
     }
-    else {
-        // failure to connect, show user note
-        QString err(hbTrId("txt_bt_info_unable_to_connect_with_bluetooth"));
-        HbMessageBox::warning(err.arg(mDeviceName));
-    }
     mActiveHandling = false;
     
-    emit commandCompleted(error);
+    emit delegateCompleted(error, this);
+    BOstraceFunctionExitExt( DUMMY_DEVLIST, this, error );
 }
 
 
--- a/bluetoothengine/btui/btuidelegate/btdelegateconnect.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/btdelegateconnect.h	Fri Sep 03 16:17:59 2010 +0300
@@ -41,6 +41,9 @@
             QObject *parent = 0 );
     
     virtual ~BtDelegateConnect();
+    
+    int supportedEditorTypes() const;
+    
     virtual void exec( const QVariant &params );
     virtual void cancel();
     
@@ -65,7 +68,7 @@
     
 private:
     QModelIndex mIndex;
-    QModelIndex mConflictDevIndex;
+    QString mConflictDevAddr;
     CBTEngConnMan *mBtengConnMan;
     QString mDeviceName;
     int mMajorProperty;
--- a/bluetoothengine/btui/btuidelegate/btdelegateconsts.h	Fri Aug 06 16:43:21 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,40 +0,0 @@
-/*
-* Copyright (c) 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: 
-*
-*/
-
-#ifndef BTDELEGATECONSTS_H
-#define BTDELEGATECONSTS_H
-
-#include <QObject>
-
-namespace BtDelegate
-    {
-    enum Command
-        {
-        Undefined,
-        ManagePower,
-        DeviceName,
-        Visibility,
-        Inquiry,
-        Connect,
-        Pair,
-        Disconnect,
-        Unpair,
-        RemoteDevName
-        };
-    }
-
-#endif // BTDELEGATECONSTS_H
--- a/bluetoothengine/btui/btuidelegate/btdelegatedevname.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/btdelegatedevname.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -34,6 +34,15 @@
 }
 
 /*!
+    Returns the supported editor types.
+    \return the sum of supported editor types
+ */
+int BtDelegateDevName::supportedEditorTypes() const
+{
+    return BtDelegate::ChangeLocalName;
+}
+
+/*!
     Validate the bluetooth device name given by the user:
     Extra spaces (' ', '\n', '\t' and '\r') from the beginning, 
     middle and the end of the name are always removed;
@@ -70,7 +79,7 @@
         btName.Close();
     }
     
-    emit commandCompleted(error, btDevName);
+    emit delegateCompleted(error, this);
 }
 
 
--- a/bluetoothengine/btui/btuidelegate/btdelegatedevname.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/btdelegatedevname.h	Fri Sep 03 16:17:59 2010 +0300
@@ -37,6 +37,8 @@
     
     virtual ~BtDelegateDevName();
 
+    int supportedEditorTypes() const;
+    
     virtual void exec( const QVariant &params );
     
 public slots:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btui/btuidelegate/btdelegatedevremove.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,195 @@
+/*
+* Copyright (c) 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: 
+*
+*/
+#include "btdelegatedevremove.h"
+#include "btqtconstants.h"
+#include "btuiutil.h"
+#include "btuidevtypemap.h"
+#include <QModelIndex>
+#include <btsettingmodel.h>
+#include <btdevicemodel.h>
+#include <btdelegatefactory.h>
+#include "btqtconstants.h"
+#include "btuiutil.h"
+#include <bluetoothuitrace.h>
+
+BtDelegateDevRemove::BtDelegateDevRemove(BtSettingModel* settingModel,
+        BtDeviceModel* deviceModel, QObject *parent) :
+    BtAbstractDelegate(settingModel, deviceModel, parent), mBtEngDevMan(0),
+            mOngoingBlockExec(false)
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );   
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
+}
+
+BtDelegateDevRemove::~BtDelegateDevRemove()
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );  
+    if (mBtEngDevMan) {
+        delete mBtEngDevMan;
+    }
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
+}
+
+
+/*!
+    Returns the supported editor types.
+    \return the sum of supported editor types
+ */
+int BtDelegateDevRemove::supportedEditorTypes() const
+{
+    return BtDelegate::RemoveAllRegistryDevices
+           | BtDelegate::RemovePairedDevices
+           | BtDelegate::RemoveBlockedDevices;
+}
+
+/*!
+ * Performs device deletion operation from registry based on
+ * params passed.
+ * params of type int holds the value of type DeviceRemovalType enum 
+ */
+void BtDelegateDevRemove::exec( const QVariant &params )
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );  
+    
+    int error = 0;
+    
+    if( !mBtEngDevMan) {
+        TRAP( error, (mBtEngDevMan = CBTEngDevMan::NewL( this )));
+        if (error) {
+            emitCommandComplete( KErrNoMemory ); 
+            BOstraceFunctionExitExt( DUMMY_DEVLIST, this, KErrNoMemory );
+            return;
+        }
+    }
+    BtDelegate::EditorType editor = (BtDelegate::EditorType) params.toInt();
+    TBTRegistrySearch searchPattern; 
+    switch(editor) {
+        case BtDelegate::RemoveAllRegistryDevices:
+            searchPattern.FindAll();
+            error = mBtEngDevMan->DeleteDevices(searchPattern);
+            break;
+        case BtDelegate::RemovePairedDevices:
+            searchPattern.FindBonded();
+            error = mBtEngDevMan->DeleteDevices(searchPattern);
+            break;
+        case BtDelegate::RemoveBlockedDevices:
+            mOngoingBlockExec = true;
+            if(isBlockedDeviceExists()) {
+                error = removeBlockedDevice();
+            }
+            else {
+                //No Blocked Device exists return success.
+                emitCommandComplete(0);
+            }
+            break;
+        default:
+            // error
+            BTUI_ASSERT_X(false, "BtDelegateDevRemove::exec", "Invalid Parameter");
+    }
+    if (error) {
+        // complete command with error
+        emitCommandComplete(error);
+    }
+
+
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
+}
+
+int BtDelegateDevRemove::removeBlockedDevice()
+{
+    //todo:This is temporary solution, TBTRegistrySearch should support
+    //fecthing blocked devices.
+    int error = 0;
+
+    QModelIndex index = mBlockedindexList.at(0);
+    TBTDevAddr btDeviceAddr;
+    QString addrStr = (index.data(BtDeviceModel::ReadableBdaddrRole)).toString(); 
+    addrReadbleStringToSymbian( addrStr, btDeviceAddr );  
+    TBTRegistrySearch searchPattern; 
+    
+    searchPattern.FindAddress(btDeviceAddr);
+    error = mBtEngDevMan->DeleteDevices(searchPattern);
+    
+    return error;
+}
+
+bool BtDelegateDevRemove::isBlockedDeviceExists()
+{
+    QModelIndex start = deviceModel()->index(0,0);
+    mBlockedindexList.clear();
+    mBlockedindexList = deviceModel()->match(start,
+            BtDeviceModel::MajorPropertyRole, BtuiDevProperty::Blocked,
+            Qt::MatchContains);
+    if(mBlockedindexList.count()) {
+        return true;
+    }
+    return false;
+}
+
+void BtDelegateDevRemove::cancel()
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); 
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
+}
+
+void BtDelegateDevRemove::HandleDevManComplete( TInt aErr )
+{
+    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aErr );
+    
+    if(mOngoingBlockExec) {
+        //In this case aErr is not checked, as device removal is not
+        //updated immediately in the model. This causes unnecessary 
+        //function calls as it is repeated until model is updated with 
+        //blocked devices.
+        if(isBlockedDeviceExists()) {
+            int error = 0;
+            error = removeBlockedDevice();
+            if(error) {
+                emitCommandComplete(error);
+                mOngoingBlockExec = false;
+            }
+            return;
+        }
+        else {
+            mOngoingBlockExec = false;
+        }
+    }
+    emitCommandComplete(aErr);
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
+    
+}
+
+void BtDelegateDevRemove::HandleGetDevicesComplete( TInt aErr, CBTDeviceArray* aDeviceArray )
+{
+    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aErr );  
+    Q_UNUSED(aErr);
+    Q_UNUSED(aDeviceArray);
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
+}
+
+void BtDelegateDevRemove::emitCommandComplete(int error)
+{
+    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, error );  
+    
+    emit delegateCompleted(error, this);
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
+}
+
+
+
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btui/btuidelegate/btdelegatedevremove.h	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,77 @@
+/*
+* Copyright (c) 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: 
+*
+*/
+
+#ifndef BTDELEGATEDEVREMOVE_H
+#define BTDELEGATEDEVREMOVE_H
+
+#include <e32base.h>
+#include <btengdevman.h>
+#include "btabstractdelegate.h"
+
+class BtuiModel;
+
+/*!
+    \class BtDelegateDevRemove
+    \brief This class will remove the specific device from the registry.
+ */
+class BtDelegateDevRemove : public BtAbstractDelegate,
+        public MBTEngDevManObserver 
+{
+    Q_OBJECT
+
+public:
+    explicit BtDelegateDevRemove( 
+            BtSettingModel* settingModel, 
+            BtDeviceModel* deviceModel, 
+            QObject *parent = 0 );
+    
+    virtual ~BtDelegateDevRemove();
+
+    int supportedEditorTypes() const;
+    
+    virtual void exec( const QVariant &params );
+    
+    virtual void cancel();
+
+private:
+    
+public slots:
+
+protected:
+    //From MBTEngDevManObserver
+    virtual void HandleDevManComplete( TInt aErr );
+    virtual void HandleGetDevicesComplete( TInt aErr, CBTDeviceArray* aDeviceArray );
+
+    void emitCommandComplete(int error);
+    
+    int removeBlockedDevice();
+    bool isBlockedDeviceExists();
+    
+private:
+
+    CBTEngDevMan *mBtEngDevMan;
+    
+    QModelIndexList mBlockedindexList;
+    
+    bool mOngoingBlockExec;
+    
+    Q_DISABLE_COPY(BtDelegateDevRemove)
+
+};
+
+
+#endif /* BTDELEGATEDEVREMOVE_H */
--- a/bluetoothengine/btui/btuidelegate/btdelegatedevsecurity.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/btdelegatedevsecurity.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -21,129 +21,308 @@
 #include <btdevicemodel.h>
 #include <btdelegatefactory.h>
 #include <hbnotificationdialog.h>
+#include "btqtconstants.h"
+#include "btuiutil.h"
+#include <bluetoothuitrace.h>
+#include <btengconnman.h>
 
 BtDelegateDevSecurity::BtDelegateDevSecurity(            
         BtSettingModel* settingModel, 
         BtDeviceModel* deviceModel, 
         QObject *parent) :
-    BtAbstractDelegate(settingModel, deviceModel, parent), mBtEngDevMan(0), mBtengConnMan(0), mDisconnectDelegate(0)
+    BtAbstractDelegate(settingModel, deviceModel, parent), mBtEngDevMan(0),
+    mDisconnectDelegate(0), mBtEngAddr(0), mRegDevArray(0), mOperation(0), 
+    mDevice(0),mNewDev(0), mActiveHandling(false),mAddingBlockedDev(false)
 {
-    
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); 
+    mRegDevArray = new CBTDeviceArray(1);
+    BTUI_ASSERT_X( mRegDevArray, "BtDelegateDevSecurity::BtDelegateDevSecurity()", 
+            "can't allocate regdevarray");
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
 BtDelegateDevSecurity::~BtDelegateDevSecurity()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );  
     delete mBtEngDevMan;
-    delete mBtengConnMan;
     delete mDisconnectDelegate;
+    delete mRegDevArray;
+    delete mNewDev;
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
 
+/*!
+    Returns the supported editor types.
+    \return the sum of supported editor types
+ */
+int BtDelegateDevSecurity::supportedEditorTypes() const
+{
+    return BtDelegate::UnpairDevice 
+           | BtDelegate::BlockDevice
+           | BtDelegate::UnblockDevice
+           | BtDelegate::TrustDevice
+           | BtDelegate::UntrustDevice;
+}
+
+/*!
+ * performs operations on remote device:  unpair, authorize/unauthorize, block/unblock
+ * params of type QList<QVariant>: 
+ *         1) remote device address (QString)
+ *         2) DeviceSecurityService operation 
+ */
 void BtDelegateDevSecurity::exec( const QVariant &params )
 {
-    int error = KErrNone;
-    QModelIndex index = params.value<QModelIndex>();
-    
-    QString strBtAddr = getDeviceModel()->data(index,
-            BtDeviceModel::ReadableBdaddrRole).toString();
-    
-    mdeviceName = getDeviceModel()->data(index,BtDeviceModel::NameAliasRole).toString();
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    // check if in use already
+    if ( mActiveHandling ) {
+        emit delegateCompleted(KErrInUse, this);
+        BOstraceFunctionExitExt( DUMMY_DEVLIST, this, KErrInUse );
+        return;
+    }
+    mActiveHandling = true;
     
-    TBTDevAddr symaddr;
-    TBuf<KBTDevAddrSize * 2> buffer(strBtAddr.utf16());
-    symaddr.SetReadable( buffer );
+    // check parameters
+    QList<QVariant> paramList = params.value< QList<QVariant> >(); 
+    if (paramList.count() != 2) {
+        // wrong parameters
+        emitCommandComplete( KErrArgument ); 
+        BOstraceFunctionExitExt( DUMMY_DEVLIST, this, KErrArgument );
+        return;
+    }
     
-    // Disconnect if paired device was connected 
-    if ( ! mBtengConnMan ){
-        TRAP( error, mBtengConnMan = CBTEngConnMan::NewL(this) );
+    int error = 0;
+    TRAP( error, {
+        if( !mBtEngDevMan) {
+            mBtEngDevMan = CBTEngDevMan::NewL( this );
+        }
+    });
+    if (error) {
+        emitCommandComplete( KErrNoMemory ); 
+        BOstraceFunctionExitExt( DUMMY_DEVLIST, this, KErrNoMemory );
+        return;
     }
-    TBTEngConnectionStatus connstatus;
-    if ( !error && mBtengConnMan->IsConnected(symaddr, connstatus ) == KErrNone) {
-        if ( connstatus == EBTEngConnected) {
-            if (! mDisconnectDelegate){
-                mDisconnectDelegate = BtDelegateFactory::newDelegate(
-                                        BtDelegate::Disconnect, getSettingModel(), getDeviceModel()); 
-                connect( mDisconnectDelegate, SIGNAL(commandCompleted(int)), this, SLOT(disconnectDelegateCompleted(int)) );
-                
-            }
-            QList<QVariant>list;
-            QVariant paramFirst;
-            paramFirst.setValue(index);            
-            QVariant paramSecond;
-            DisconnectOption discoOpt = ServiceLevel;
-            paramSecond.setValue((int)discoOpt);
-            list.append(paramFirst);
-            list.append(paramSecond);
-            QVariant paramsList;
-            paramsList.setValue(list);
-            mDisconnectDelegate->exec(paramsList);
+    
+    mStrBtAddr = paramList.at(0).value<QString>();  // device to operate on
+    mOperation = paramList.at(1).toInt();                   // operation
+    
+    addrReadbleStringToSymbian( mStrBtAddr, mBtEngAddr );
+    BtTraceBtAddr1( TRACE_DEBUG, DUMMY_DEVLIST, "device addr=", mBtEngAddr );
+    
+
+    // get device from registry since it is needed for all operations
+    mSearchPattern.FindAddress( mBtEngAddr );
+    mRegDevArray->ResetAndDestroy();
+    mBtEngDevMan->GetDevices(mSearchPattern, mRegDevArray); // callback is HandleGetDevicesComplete()
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
+}
+
+
+void BtDelegateDevSecurity::unpair()
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );  
+    int error = KErrNone;
+    
+    // unpair first since malicious device might try to connect/pair again 
+    // immediately after disconnecting
+    mDevice->SetPaired(EFalse);
+    mDevice->DeleteLinkKey();
+
+    // untrust the device also
+    TBTDeviceSecurity security = mDevice->GlobalSecurity();
+    security.SetNoAuthorise( EFalse );
+    mDevice->SetGlobalSecurity( security );
+
+    error = mBtEngDevMan->ModifyDevice( *mDevice );  // see callback for possible disconnect
+    
+    if ( error ) {
+        emitCommandComplete(error);
+    }
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
+}
+
+void BtDelegateDevSecurity::authorizeOrBlock()
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); 
+    BOstraceExt1( TRACE_NORMAL, DUMMY_DEVLIST, "operation (Unpair|Block|Unblock|Authorize|Unauthorize)=%d", 
+            mOperation);
+    int error = KErrNone;
+    
+    TBTDeviceSecurity security = mDevice->GlobalSecurity();
+    switch ( mOperation ) {
+    case BtAuthorize:
+        security.SetNoAuthorise( ETrue ); // set trust status to true
+        security.SetBanned( EFalse );
+        break;
+    case BtUnauthorize:
+        security.SetNoAuthorise( EFalse );
+        break;
+    case BtUnblock:
+        security.SetBanned( EFalse );
+        break;
+    case BtBlock:
+        security.SetBanned( ETrue );
+        security.SetNoAuthorise( EFalse ); // set trust status to false
+        break;
+    }
+
+    mDevice->SetGlobalSecurity( security );
+    if ( (mOperation == BtBlock) || (mOperation == BtUnblock) ) {
+        // deleting link key for executing unblock is safe as no 
+        // link key shall exist if the device has been blocked. 
+        mDevice->DeleteLinkKey();
+        if ( mOperation == BtBlock ) {
+            mDevice->SetPaired(EFalse);
         }
     }
-
-    // Set device as unpaired
-    CBTDevice *symBtDevice = 0;
-    TRAP( error, {
-            symBtDevice = CBTDevice::NewL( symaddr );
-            if( !mBtEngDevMan) {
-                mBtEngDevMan = CBTEngDevMan::NewL( this );
-            }
-    });
-    
-    if ( !error ) {
-        symBtDevice->SetPaired(EFalse);
-        // deleting link key for executing unpair is safe as no 
-        // link key shall exist if the device has been unpaired. 
-        symBtDevice->DeleteLinkKey();
-        error = mBtEngDevMan->ModifyDevice( *symBtDevice );
-    }
-    delete symBtDevice;
+    error = mBtEngDevMan->ModifyDevice( *mDevice );
     
     if ( error ) {
         emitCommandComplete(error);
     }
+    BOstraceFunctionExitExt( DUMMY_DEVLIST, this, error );
 }
 
 void BtDelegateDevSecurity::cancel()
 {
-    
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this ); 
+    if ( mActiveHandling ) {
+        mAddingBlockedDev = false;
+        emitCommandComplete(KErrNone);
+    }
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
 void BtDelegateDevSecurity::disconnectDelegateCompleted( int err )
 {
-    Q_UNUSED(err);
+    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, err );  
+    if (mDisconnectDelegate) {
+        delete mDisconnectDelegate;
+        mDisconnectDelegate = 0;
+    }
+    emitCommandComplete(err);
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
+}
+
+void BtDelegateDevSecurity::HandleDevManComplete( TInt err )
+{
+    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, err );  
+
+    if ( !mActiveHandling ) {
+        BOstraceFunctionExit1( DUMMY_DEVLIST, this );
+        return;
+    }
+    if ( !err ) {
+        if ( mAddingBlockedDev ) {
+            // blocked a device which was not in the registry originally
+            mAddingBlockedDev = false;
+            delete mNewDev;
+            mNewDev = 0;
+        }
+        else if ( mOperation == BtBlock || mOperation == BtUnpair) {  
+            // disconnect after blocking/unpairing if device is connected;
+            // disconnect done after block/unpair, instead of before, to prevent a malicious device 
+            // from reconnecting/"re-pairing"
+            CBTEngConnMan *connMan(0);
+            TRAP( err, connMan = CBTEngConnMan::NewL() );
+            TBTEngConnectionStatus connstatus(EBTEngNotConnected);
+            if (!err) {
+                err = connMan->IsConnected(mBtEngAddr, connstatus );
+                delete connMan;
+            }
+            if ( !err && connstatus == EBTEngConnected ) {
+                if (! mDisconnectDelegate){
+                    mDisconnectDelegate = BtDelegateFactory::newDelegate(
+                                            BtDelegate::DisconnectService, settingModel(), deviceModel()); 
+                    connect( mDisconnectDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), this, 
+                            SLOT(disconnectDelegateCompleted(int)) );
+                }
+                QList<QVariant>list;
+                list.append(QVariant(ServiceLevel));
+                list.append(QVariant(mStrBtAddr));
+                mDisconnectDelegate->exec(QVariant(list)); // see callback for continuation
+                return;
+            }
+        }
+    }
+    emitCommandComplete(err);
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
-void BtDelegateDevSecurity::HandleDevManComplete( TInt aErr )
+void BtDelegateDevSecurity::HandleGetDevicesComplete( TInt err, CBTDeviceArray* aDeviceArray )
 {
-    emitCommandComplete(aErr);
-}
-
-void BtDelegateDevSecurity::HandleGetDevicesComplete( TInt aErr, CBTDeviceArray* aDeviceArray )
-{
-    Q_UNUSED(aErr);
-    Q_UNUSED(aDeviceArray);
+    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, err );  
+    
+    if ( mActiveHandling ) {
+        if ( !err && aDeviceArray->Count() ) { 
+            mDevice = aDeviceArray->At( 0 );
+            switch ( mOperation ) {
+            case BtUnpair:
+                unpair();
+                break;
+            case BtAuthorize:
+            case BtUnauthorize:
+            case BtUnblock:
+            case BtBlock:
+                authorizeOrBlock();
+                break;
+            default:
+                // wrong parameter
+                emitCommandComplete( KErrArgument );
+            }
+        }
+        else if ( err == KErrNotFound && mOperation == BtBlock) {  // device not in registry, need to add it
+            mAddingBlockedDev = true;
+            TRAP( err, {
+                    mNewDev = CBTDevice::NewL( mBtEngAddr );
+            });
+            if ( !err ) {
+                // get needed info about device from model, e.g. name, cod
+                QString btStringAddr;
+                addrSymbianToReadbleString(btStringAddr, mBtEngAddr);
+                QModelIndex start = deviceModel()->index(0,0);
+                QModelIndexList indexList = deviceModel()->match(start,
+                        BtDeviceModel::ReadableBdaddrRole, btStringAddr);
+                // ToDo:  can we be sure that device will always be found in the model?
+                QModelIndex index = indexList.at(0);
+                QString devName = deviceModel()->data(index,BtDeviceModel::NameAliasRole).toString();
+                BtTraceQString1( TRACE_DEBUG, DUMMY_DEVLIST, "device name=", devName);
+                TBuf<KMaxBCBluetoothNameLen> buf( devName.utf16() );
+                TRAP( err, mNewDev->SetDeviceNameL( BTDeviceNameConverter::ToUTF8L( buf ) ));
+                if( !err ) {
+                    int cod = (index.data(BtDeviceModel::CoDRole)).toInt();
+                    mNewDev->SetDeviceClass(cod);
+                    TBTDeviceSecurity security = mNewDev->GlobalSecurity();
+                    security.SetBanned( ETrue );
+                    security.SetNoAuthorise( EFalse ); // set trust status to false
+                    mNewDev->SetGlobalSecurity( security );
+                    mNewDev->DeleteLinkKey();
+                    mNewDev->SetPaired(EFalse);
+                    err = mBtEngDevMan->AddDevice( *mNewDev );  // see callback HandleDevManComplete()
+                }
+            }
+        }
+        if (err) {
+            mAddingBlockedDev = false;
+            emitCommandComplete( err );
+        }
+    }
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
 void BtDelegateDevSecurity::emitCommandComplete(int error)
 {
+    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, error );  
     // no dialogs here since stack provides "unpaired to %1" dialog
     // and failures are not reported
-    
-    emit commandCompleted(error);
-}
-
-void BtDelegateDevSecurity::ConnectComplete( TBTDevAddr& aAddr, TInt aErr, 
-                                   RBTDevAddrArray* aConflicts )
-{
-    Q_UNUSED(aAddr);
-    Q_UNUSED(aErr);
-    Q_UNUSED(aConflicts);  
-}
-
-void BtDelegateDevSecurity::DisconnectComplete( TBTDevAddr& aAddr, TInt aErr )
-{
-    Q_UNUSED(aAddr);
-    Q_UNUSED(aErr);    
+    mActiveHandling = false;
+    mAddingBlockedDev = false;
+    if ( mNewDev ) {
+        delete mNewDev;
+        mNewDev = 0;
+    }
+    emit delegateCompleted(error, this);
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
 
--- a/bluetoothengine/btui/btuidelegate/btdelegatedevsecurity.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/btdelegatedevsecurity.h	Fri Sep 03 16:17:59 2010 +0300
@@ -19,7 +19,6 @@
 #define BTDELEGATEDEVSECURITY_H
 
 #include <e32base.h>
-#include <btengconnman.h>
 #include <btengdevman.h>
 #include "btabstractdelegate.h"
 
@@ -30,7 +29,7 @@
     \brief the base class for Unpairing Bluetooth Connection.
  */
 class BtDelegateDevSecurity : public BtAbstractDelegate,
-        public MBTEngDevManObserver, public MBTEngConnObserver 
+        public MBTEngDevManObserver
 {
     Q_OBJECT
 
@@ -42,6 +41,8 @@
     
     virtual ~BtDelegateDevSecurity();
 
+    int supportedEditorTypes() const;
+    
     virtual void exec( const QVariant &params );
     
     virtual void cancel();
@@ -53,20 +54,27 @@
     //From MBTEngDevManObserver
     virtual void HandleDevManComplete( TInt aErr );
     virtual void HandleGetDevicesComplete( TInt aErr, CBTDeviceArray* aDeviceArray );
-    //From MBTEngConnObserver
-    virtual void ConnectComplete( TBTDevAddr& aAddr, TInt aErr, 
-                                   RBTDevAddrArray* aConflicts );
-    virtual void DisconnectComplete( TBTDevAddr& aAddr, TInt aErr );    
 
     void emitCommandComplete(int error);
+ 
+private:
+    void unpair();
+    void authorizeOrBlock();
     
 private:
 
     CBTEngDevMan *mBtEngDevMan;
-    QString mdeviceName;
-    CBTEngConnMan *mBtengConnMan;
     BtAbstractDelegate* mDisconnectDelegate;
-    
+    TBTDevAddr mBtEngAddr;  // Symbian BT address for target device
+    QString mStrBtAddr;     // QT BT address for target device
+    TBTRegistrySearch mSearchPattern; 
+    CBTDeviceArray *mRegDevArray;
+    int mOperation;
+    CBTDevice *mDevice;
+    CBTDevice *mNewDev;
+    int mActiveHandling;
+    QModelIndex mIndex;
+    bool mAddingBlockedDev;
     Q_DISABLE_COPY(BtDelegateDevSecurity)
 
 };
--- a/bluetoothengine/btui/btuidelegate/btdelegatedisconnect.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/btdelegatedisconnect.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -22,134 +22,175 @@
 #include <btsettingmodel.h>
 #include <btdevicemodel.h>
 #include <hbnotificationdialog.h>
+#include <bluetoothuitrace.h>
 
 BtDelegateDisconnect::BtDelegateDisconnect(            
         BtSettingModel* settingModel, 
         BtDeviceModel* deviceModel, QObject *parent) :
     BtAbstractDelegate(settingModel, deviceModel, parent), mBtengConnMan(0), mPhyLinks(0),
-	 mMajorRole(0), mActiveHandling(false), mAddrArrayIndex(0), mDisconOpt(DisconUnknown)
+	 mActiveHandling(false), mAddrArrayIndex(0), mDisconOpt(DisconUnknown)
 {
-    
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );   
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
 BtDelegateDisconnect::~BtDelegateDisconnect()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );   
     delete mBtengConnMan;
     delete mPhyLinks;
     mSocketServ.Close();
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
+}
+
+
+/*!
+    Returns the supported editor types.
+    \return the sum of supported editor types
+ */
+int BtDelegateDisconnect::supportedEditorTypes() const
+{
+    return BtDelegate::DisconnectService
+           | BtDelegate::DisconnectAllConnections;
 }
 
+/*!
+ * disconnects remote device(s) from local device
+ * params of type QList<QVariant>: 
+ *         1) DisconnectOption (either ServiceLevel, PhysicalLink or AllOngoingConnections)
+ *         2) remote device address (QString, not needed for AllOngoingConnections)
+ */
 void BtDelegateDisconnect::exec( const QVariant &params )
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );   
     int err;
+    
+    // check if in use already
+    if ( mActiveHandling ) {
+        emit delegateCompleted(KErrInUse, this);
+        BOstraceFunctionExitExt( DUMMY_DEVLIST, this, KErrInUse);
+        return;
+    }
+    
+    // check parameters
+    QList<QVariant> paramList = params.value< QList<QVariant> >(); 
+    if (!((paramList.count() == 1) || (paramList.count() == 2))) {
+        // wrong parameter count
+        emit delegateCompleted( KErrArgument, this ); 
+        BOstraceFunctionExitExt( DUMMY_DEVLIST, this, KErrArgument );
+        return;
+    }
+    
+    // create btengconnman
     if ( ! mBtengConnMan ){
         TRAP( err, mBtengConnMan = CBTEngConnMan::NewL(this) );
     }
-    if(err) {
-        emit commandCompleted(err);
+    if( err ) {
+        emit delegateCompleted(err, this);
+        BOstraceFunctionExitExt( DUMMY_DEVLIST, this, err );
         return;
     }
-    if (params.canConvert<int>()){
-        mDisconOpt = (DisconnectOption)params.toInt();
-        mActiveHandling = true;
-        
-        if (mDisconOpt == AllOngoingConnections){
-            err = mBtengConnMan->GetConnectedAddresses(mDevAddrArray);
-            disconnectAllConnections_service();
+    
+    mDisconOpt = (DisconnectOption)paramList.at(0).toInt();    // DisconnectOption
+    
+    if ( (mDisconOpt == ServiceLevel) || (mDisconOpt == PhysicalLink) ) {
+        // check 2nd parameter is ok
+        if ((paramList.count() != 2) || !paramList.at(1).canConvert<QString>()) {
+            emit delegateCompleted( KErrArgument, this ); 
+            BOstraceFunctionExitExt( DUMMY_DEVLIST, this, KErrArgument );
+            return;
         }
-        if(err) {
-            emit commandCompleted(err);
-        }
-    }
-    else{
-        QList<QVariant> paramList = params.value< QList<QVariant> >(); 
-        QVariant indexVariant = paramList.at(0); 
-        QModelIndex index = indexVariant.value<QModelIndex>();
-        QVariant optionVariant = paramList.at(1); 
-        mDisconOpt = (DisconnectOption)optionVariant.toInt();
-        int error = KErrNone;
+        QString strBtAddr = paramList.at(1).toString();  // remote device to operate on
+        BtTraceQString1( TRACE_DEBUG, DUMMY_DEVLIST, "device addr=", strBtAddr);
+        addrReadbleStringToSymbian( strBtAddr, mBtEngAddr );
         
         mActiveHandling = true;
-        mDeviceName = getDeviceModel()->data(index,BtDeviceModel::NameAliasRole).toString();
-        mMajorRole = (index.data(BtDeviceModel::MajorPropertyRole)).toInt();
-        
-        QString strBtAddr = getDeviceModel()->data(index,BtDeviceModel::ReadableBdaddrRole).toString();
-        
-        // todo: address converting should be simplified. check other delegates for example.
-        
-        TPtrC ptrName(reinterpret_cast<const TText*>(strBtAddr.constData()));
-            
-        RBuf16 btName;
-        error = btName.Create(ptrName.Length());
+
+        if (mDisconOpt == ServiceLevel){
+            disconnectServiceLevel();
+        }
+        else if (mDisconOpt == PhysicalLink){
+            disconnectPhysicalLink();       
+        }
+    } 
+    else if ( mDisconOpt == AllOngoingConnections ) {
+        err = mBtengConnMan->GetConnectedAddresses(mDevAddrArray);
+        //Added this condition because GetConnectedAddresses returns 0 even if no addresses
+        //are returned.
+        if(err || !(mDevAddrArray.Count())) {
+            emit delegateCompleted(err, this);
+            BOstraceFunctionExitExt( DUMMY_DEVLIST, this, err );
+            return;
+        }
         
-        if(error == KErrNone) {
-            btName.Copy(ptrName);
-            mBtEngAddr.SetReadable(btName);
-            if (mDisconOpt == ServiceLevel){
-                disconnectSeviceLevel();
-            }
-            else if (mDisconOpt == PhysicalLink){
-                disconnectPhysicalLink();       
-            }
-        }
-        btName.Close();
+        mActiveHandling = true;
         
-        if(error) {
-            emit commandCompleted(error);
-        }
-    }  
+        disconnectAllConnections_service();
+    } 
+    else {
+        BTUI_ASSERT_X( 0, "BtDelegateDisconnect::exec()", "incorrect parameter" );
+    }
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
 
-void BtDelegateDisconnect::disconnectAllConnections_service(){
+void BtDelegateDisconnect::disconnectAllConnections_service() 
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );   
+    QString btStringAddr;
+    addrSymbianToReadbleString( btStringAddr, mDevAddrArray[mAddrArrayIndex] );
+    QModelIndex start = deviceModel()->index(0,0);
+    QModelIndexList indexList = deviceModel()->match(start,BtDeviceModel::ReadableBdaddrRole, btStringAddr);
+    // ToDo:  what happens if device not found from the model?  error handling needed!
+    QModelIndex index = indexList.at(0);
     
-        TBuf<KBTDevAddrSize*3> addrBuf;
-        mDevAddrArray[mAddrArrayIndex].GetReadable(addrBuf);
-        QString btStringAddr= QString::fromUtf16( addrBuf.Ptr(), addrBuf.Length());
-        QModelIndex start = getDeviceModel()->index(0,0);
-        QModelIndexList indexList = getDeviceModel()->match(start,BtDeviceModel::ReadableBdaddrRole, btStringAddr);
-        QModelIndex index = indexList.at(0);
-        
-        mDeviceName = getDeviceModel()->data(index,BtDeviceModel::NameAliasRole).toString();
-        mBtEngAddr = mDevAddrArray[mAddrArrayIndex];
-        mMajorRole = (index.data(BtDeviceModel::MajorPropertyRole)).toInt();
-        
-        disconnectSeviceLevel();        
+    mBtEngAddr = mDevAddrArray[mAddrArrayIndex];
+    
+    disconnectServiceLevel(); 
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
-void BtDelegateDisconnect::disconnectAllConnections_physical(){
+void BtDelegateDisconnect::disconnectAllConnections_physical()
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );   
+    QString btStringAddr;
+    addrSymbianToReadbleString( btStringAddr, mDevAddrArray[mAddrArrayIndex] );
+    QModelIndex start = deviceModel()->index(0,0);
+    QModelIndexList indexList = deviceModel()->match(start,BtDeviceModel::ReadableBdaddrRole, btStringAddr);
+    // ToDo:  what happens if device not found from the model?  error handling needed!
+    QModelIndex index = indexList.at(0);
     
-        TBuf<KBTDevAddrSize*3> addrBuf;
-        mDevAddrArray[mAddrArrayIndex].GetReadable(addrBuf);
-        QString btStringAddr= QString::fromUtf16( addrBuf.Ptr(), addrBuf.Length());
-        QModelIndex start = getDeviceModel()->index(0,0);
-        QModelIndexList indexList = getDeviceModel()->match(start,BtDeviceModel::ReadableBdaddrRole, btStringAddr);
-        QModelIndex index = indexList.at(0);
-        
-        mDeviceName = getDeviceModel()->data(index,BtDeviceModel::NameAliasRole).toString();
-        mBtEngAddr = mDevAddrArray[mAddrArrayIndex];
-        
-        disconnectPhysicalLink();
-        
+    mBtEngAddr = mDevAddrArray[mAddrArrayIndex];
+    
+    disconnectPhysicalLink();
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
-void BtDelegateDisconnect::disconnectSeviceLevel(){
+
+void BtDelegateDisconnect::disconnectServiceLevel()
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );   
     int err;
     TBTEngConnectionStatus connStatus = EBTEngNotConnected;
+    BtTraceBtAddr1( TRACE_DEBUG, DUMMY_DEVLIST, "calling btengconnman->isConnected() with device addr=", mBtEngAddr );
     err = mBtengConnMan->IsConnected(mBtEngAddr, connStatus);
-    if (connStatus == EBTEngConnected){
-        err = mBtengConnMan->Disconnect(mBtEngAddr, EBTDiscGraceful);
+    BOstraceExt2( TRACE_DEBUG, DUMMY_DEVLIST, "isConnected() ret = %d, conn status (0/2) = %d",  err, connStatus);
+    
+    //if ( !err && (connStatus == EBTEngConnected) ) {
+        // asynchronous call, see callback DisconnectComplete()
+        BtTraceBtAddr1( TRACE_DEBUG, DUMMY_DEVLIST, "btengconnman->Disconnect() with param device addr=", mBtEngAddr );
+        err = mBtengConnMan->Disconnect(mBtEngAddr, EBTDiscGraceful);  
+        BOstraceExt1( TRACE_DEBUG, DUMMY_DEVLIST, "Disconnect() ret = %d",  err);
+    //}
+    if (err) {
+        // handle error
+        disconnectServiceLevelCompleted(err);
     }
-    if(err) {
-        if (mDisconOpt == AllOngoingConnections){
-            disconnectServiceLevelCompleted(err);
-        }
-        else{ 
-            emit commandCompleted(err);
-        }
-    }
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
         
-void BtDelegateDisconnect::disconnectPhysicalLink(){
+void BtDelegateDisconnect::disconnectPhysicalLink()
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );   
     int err;
     if ( !mSocketServ.Handle() ) {
         err = mSocketServ.Connect();
@@ -157,126 +198,138 @@
     if ( !err && !mPhyLinks ) {
         TRAP( err, 
             mPhyLinks = CBluetoothPhysicalLinks::NewL( *this, mSocketServ ) );
-        Q_CHECK_PTR( mPhyLinks );
-    }
-    err = mPhyLinks->Disconnect( mBtEngAddr );
-    if(err) {
-        if (mDisconOpt == AllOngoingConnections){
-            disconnectPhysicalLinkCompleted(err);
-        }
-        else{ 
-            emit commandCompleted(err);
+        if (err) {
+            disconnectPhysicalLinkCompleted(err); // handle error
         }
     }
-    
+    // ToDo:  consider using DisconnectAll()
+    BtTraceBtAddr1( TRACE_DEBUG, DUMMY_DEVLIST, "phy->Disconnect() with param device addr=", mBtEngAddr );
+    err = mPhyLinks->Disconnect( mBtEngAddr );  // async call, see callback HandleDisconnectCompleteL()
+    BOstraceExt1( TRACE_DEBUG, DUMMY_DEVLIST, "Phy Disconnect() ret = %d",  err);
+    if (err) {
+        disconnectPhysicalLinkCompleted(err);  // handle error
+    }
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
-void BtDelegateDisconnect::disconnectServiceLevelCompleted(int err){
+void BtDelegateDisconnect::disconnectServiceLevelCompleted(int err)
+{
+    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, err );   
     if (mDisconOpt == ServiceLevel){
         mActiveHandling = false;
-        emit commandCompleted(err);
+        emit delegateCompleted(err, this);
     }
     else if (mDisconOpt == AllOngoingConnections){
         if (err){
             mActiveHandling = false;
-            emit commandCompleted(err);
+            emit delegateCompleted(err, this);
         }
         else{
             mAddrArrayIndex++;
-            if ( mAddrArrayIndex < mDevAddrArray.Count()){
-                disconnectAllConnections_service();
+            if ( mAddrArrayIndex < mDevAddrArray.Count()) {
+                disconnectAllConnections_service();  // recursive call
             }
-            else{
+            else {
                 mDevAddrArray.Reset();
+                mAddrArrayIndex = 0;
                 err = mBtengConnMan->GetConnectedAddresses(mDevAddrArray);
                 if(err) {
-                    emit commandCompleted(err);
+                    mActiveHandling = false;
+                    emit delegateCompleted(err, this);
+                    BOstraceFunctionExitExt( DUMMY_DEVLIST, this, err );
                     return;
                 }
-                mAddrArrayIndex = 0;
-                //connect( mDisconnectDelegate, SIGNAL(commandCompleted(int)), this, SLOT(disconnectPhysicalLinkCompleted(int)) );         
                 disconnectAllConnections_physical();
             }
         }
     }
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
-void BtDelegateDisconnect::disconnectPhysicalLinkCompleted(int err){
+void BtDelegateDisconnect::disconnectPhysicalLinkCompleted(int err)
+{
+    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, err );   
     if (mDisconOpt == PhysicalLink){
-        //emitCommandComplete(err);
         mActiveHandling = false;
-        emit commandCompleted(err);
+        emit delegateCompleted(err, this);
     }
-    else if (mDisconOpt == AllOngoingConnections){
-        if (err){
+    else if (mDisconOpt == AllOngoingConnections) {
+        if (err) {
             mActiveHandling = false;
-            emit commandCompleted(err);
+            emit delegateCompleted(err, this);
         }
         else{
             mAddrArrayIndex++;
-            if ( mAddrArrayIndex < mDevAddrArray.Count()){
-                disconnectAllConnections_physical();
+            if ( mAddrArrayIndex < mDevAddrArray.Count()) {
+                disconnectAllConnections_physical();  // recursive call
             }
-            else{
-                //TODO: check if there is still ongoing connection from BTEngVonnMan. and close them again if there is any new 
+            else {  // DONE!
+                //TODO: check if there is still ongoing connection from BTEngConnMan. and close them again if there is any new 
                 mActiveHandling = false;
-                emit commandCompleted(err);
+                emit delegateCompleted(KErrNone, this);
             }
         }
-        
     }
-    
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
+
 void BtDelegateDisconnect::ConnectComplete( TBTDevAddr& aAddr, TInt aErr, 
                                    RBTDevAddrArray* aConflicts )
 {
+    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aErr );  
+    BtTraceBtAddr1( TRACE_DEBUG, DUMMY_DEVLIST, "device addr=", aAddr );
     Q_UNUSED(aAddr);
     Q_UNUSED(aConflicts);  
     Q_UNUSED(aErr);
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
 void BtDelegateDisconnect::DisconnectComplete( TBTDevAddr& aAddr, TInt aErr )
 {
-    if ( mBtEngAddr != aAddr || !mActiveHandling ) {  
+    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, aErr );  
+    BtTraceBtAddr1( TRACE_DEBUG, DUMMY_DEVLIST, "device addr=", aAddr );
+    if ( mBtEngAddr != aAddr || !mActiveHandling ) { 
+        BOstraceFunctionExit1( DUMMY_DEVLIST, this );
         return;
     }
-    DisplayCommandCompleteNotif(aErr);
-    disconnectServiceLevelCompleted(aErr);    
+    disconnectServiceLevelCompleted(aErr);  
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
 
 void BtDelegateDisconnect::cancel()
 {
-    
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );  
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
-void BtDelegateDisconnect::HandleCreateConnectionCompleteL( TInt err ){
+void BtDelegateDisconnect::HandleCreateConnectionCompleteL( TInt err )
+{
+    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, err );   
     Q_UNUSED( err );
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
-void BtDelegateDisconnect::HandleDisconnectCompleteL( TInt err ){
-    if ( !mActiveHandling ) {  
+// callback for CBluetoothPhysicalLinks::Disconnect()
+void BtDelegateDisconnect::HandleDisconnectCompleteL( TInt err )
+{
+    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, err );  
+    if ( !mActiveHandling ) {
+        BOstraceFunctionExit1( DUMMY_DEVLIST, this );
         return;
     } 
     disconnectPhysicalLinkCompleted(err);
-          
-}
-
-void BtDelegateDisconnect::HandleDisconnectAllCompleteL( TInt err ){
-    Q_UNUSED( err );
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
-void BtDelegateDisconnect::DisplayCommandCompleteNotif(int error)
+// callback for CBluetoothPhysicalLinks::DisconnectAll()
+void BtDelegateDisconnect::HandleDisconnectAllCompleteL( TInt err )
 {
-    
-    if(error == KErrNone) {
-        // success, show indicator with connection status
-        HbIcon icon = getBadgedDeviceTypeIcon( mCod, mMajorRole, 0 );  // no badging required, only icon
-        QString str( hbTrId("txt_bt_dpopinfo_disconnected_from_1") );
-        HbNotificationDialog::launchDialog( icon, hbTrId("txt_bt_dpophead_disconnected"), 
-            str.arg(mDeviceName) );  
-    }
-	
+    BOstraceFunctionEntryExt( DUMMY_DEVLIST, this, err );   
+    Q_UNUSED( err );
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
 
+
+
--- a/bluetoothengine/btui/btuidelegate/btdelegatedisconnect.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/btdelegatedisconnect.h	Fri Sep 03 16:17:59 2010 +0300
@@ -41,11 +41,11 @@
     
     virtual ~BtDelegateDisconnect();
 
+    int supportedEditorTypes() const;
+    
     virtual void exec( const QVariant &params );
     
     virtual void cancel();
-    
-
 
 protected:
     //From MBTEngConnObserver
@@ -68,7 +68,7 @@
     
     void disconnectAllConnections_physical();
     
-    void disconnectSeviceLevel();
+    void disconnectServiceLevel();
         
     void disconnectPhysicalLink();
     
@@ -79,22 +79,15 @@
     
     
 private:
-
     CBTEngConnMan *mBtengConnMan;
-
     CBluetoothPhysicalLinks *mPhyLinks;
 
-    int mMajorRole;
     bool mActiveHandling;
-    
     int mAddrArrayIndex;
     DisconnectOption mDisconOpt;
 
     RBTDevAddrArray mDevAddrArray;
     TBTDevAddr mBtEngAddr;
-    
-    QString mDeviceName;
-    int mCod;
       
     RSocketServ mSocketServ;
        
--- a/bluetoothengine/btui/btuidelegate/btdelegatefactory.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/btdelegatefactory.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -28,35 +28,45 @@
 #include "btdelegatepair.h"
 #include "btdelegatedisconnect.h"
 #include "btdelegatedevsecurity.h"
+#include "btdelegatedevremove.h"
 
 /*!
     Constructor.
  */
-BtAbstractDelegate * BtDelegateFactory::newDelegate(
-        BtDelegate::Command cmd,             
+BtAbstractDelegate *BtDelegateFactory::newDelegate(
+        BtDelegate::EditorType editor,             
         BtSettingModel* settingModel, 
         BtDeviceModel* deviceModel, 
         QObject *parent )
 {
-    switch ( cmd ) {
+    switch ( editor ) {
         case BtDelegate::ManagePower:
             return new BtDelegatePower( settingModel, deviceModel, parent );
-        case BtDelegate::DeviceName:
+        case BtDelegate::ChangeLocalName:
             return new BtDelegateDevName( parent );
-        case BtDelegate::Visibility:
+        case BtDelegate::ChangeVisibility:
             return new BtDelegateVisibility( parent );
         case BtDelegate::Inquiry:
             return new BtDelegateInquiry( settingModel, deviceModel, parent );
-        case BtDelegate::Connect:
+        case BtDelegate::ConnectService:
             return new BtDelegateConnect( settingModel, deviceModel, parent );
-        case BtDelegate::Pair:
+        case BtDelegate::DisconnectService:
+        case BtDelegate::DisconnectAllConnections:
+            return new BtDelegateDisconnect( settingModel, deviceModel, parent );
+        case BtDelegate::PairDevice:
             return new BtDelegatePair( settingModel, deviceModel, parent );
-        case BtDelegate::Disconnect:
-            return new BtDelegateDisconnect( settingModel, deviceModel, parent );
-        case BtDelegate::Unpair:
+        case BtDelegate::UnpairDevice:
+        case BtDelegate::BlockDevice:
+        case BtDelegate::UnblockDevice:
+        case BtDelegate::TrustDevice:
+        case BtDelegate::UntrustDevice:
             return new BtDelegateDevSecurity( settingModel, deviceModel, parent );
-        case BtDelegate::RemoteDevName:
+        case BtDelegate::ChangeDeviceFriendlyName:
             return new BtDelegateRemoteDevName( settingModel, deviceModel, parent );
+        case BtDelegate::RemoveAllRegistryDevices:
+        case BtDelegate::RemovePairedDevices:
+        case BtDelegate::RemoveBlockedDevices:
+            return new BtDelegateDevRemove( settingModel, deviceModel, parent );
     }
     return 0;
 }
--- a/bluetoothengine/btui/btuidelegate/btdelegatefactory.h	Fri Aug 06 16:43:21 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,52 +0,0 @@
-/*
-* Copyright (c) 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: 
-*
-*/
-
-#ifndef BTDELEGATEFACTORY_H
-#define BTDELEGATEFACTORY_H
-
-#include <QObject>
-#include "btdelegateconsts.h"
-
-class BtAbstractDelegate;
-class BtSettingModel;
-class BtDeviceModel;
-
-#ifdef BUILD_BTUIDELEGATE
-#define BTUIDELEGATE_IMEXPORT Q_DECL_EXPORT
-#else
-#define BTUIDELEGATE_IMEXPORT Q_DECL_IMPORT
-#endif
-
-/*!
-    \class BtDelegateFactory
-    \brief the base class for creating concrete delegate instances
-
-    \\sa btuidelegate
- */
-class BTUIDELEGATE_IMEXPORT BtDelegateFactory
-{
-
-public:
-    static BtAbstractDelegate *newDelegate( 
-            BtDelegate::Command cmd, 
-            BtSettingModel* settingModel, 
-            BtDeviceModel* deviceModel, 
-            QObject *parent = 0 );
-
-};
-
-#endif // BTDELEGATEFACTORY_H
--- a/bluetoothengine/btui/btuidelegate/btdelegateinquiry.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/btdelegateinquiry.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -14,73 +14,114 @@
 * Description: 
 *
 */
-
-
 #include "btdelegateinquiry.h"
-#include "btdelegatefactory.h"
+#include "btdelegatepower.h"
 #include "btqtconstants.h"
-
 #include <btsettingmodel.h>
 #include <btdevicemodel.h>
 #include <bluetoothuitrace.h>
 
-
 BtDelegateInquiry::BtDelegateInquiry(
         BtSettingModel* settingModel, 
         BtDeviceModel* deviceModel, QObject* parent )
     :BtAbstractDelegate( settingModel, deviceModel, parent )
 {
-    mAbstractDelegate = NULL;
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    BOstraceFunctionExit0( DUMMY_DEVLIST );
 }
 
 BtDelegateInquiry::~BtDelegateInquiry()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    if (isExecuting()) {
+        deviceModel()->cancelSearchDevice();
+    }
+    BOstraceFunctionExit0( DUMMY_DEVLIST );
+}
 
+/*!
+    Returns the supported editor types.
+    \return the sum of supported editor types
+ */
+int BtDelegateInquiry::supportedEditorTypes() const
+{
+    return BtDelegate::Inquiry;
 }
 
 void BtDelegateInquiry::exec( const QVariant& params )
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     Q_UNUSED(params);
+    BTUI_ASSERT_X(!isExecuting(), "BtDelegateInquiry::exec", "operation ongoing!");
+    bool ok(false);
     
-    if(isBtPowerOn()) {
-        exec_inquiry();
-    }
-    else {
-        //If Bt Power is off, switch it on and then perform pairing.
-        //todo: Do we ask for user confirmation here..?
-        if (!mAbstractDelegate) { 
-            mAbstractDelegate = BtDelegateFactory::newDelegate(BtDelegate::ManagePower, 
-                    getSettingModel(), getDeviceModel() ); 
-            connect( mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(powerDelegateCompleted(int)) );
-            mAbstractDelegate->exec(QVariant(BtPowerOn));
+    setExecuting(true);
+    // Inquiry needs BT to be on.
+    if(!isBtPowerOn()) {
+        mPowerDelegate = new BtDelegatePower(settingModel(), deviceModel(), this);
+        ok = connect(
+                mPowerDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), 
+            this, SLOT(handleManagePowerCompleted(int)));
+        if (ok ) {
+            mPowerDelegate->exec(QVariant(BtPowerOn));
         }
+    } else {
+        // No power management is required. Start inquiry immediately
+        ok = startInquiry();
     }
-}
-
-void BtDelegateInquiry::powerDelegateCompleted(int error)
-{
-    if (mAbstractDelegate) {
-        disconnect(mAbstractDelegate);
-        delete mAbstractDelegate;
-        mAbstractDelegate = 0;
+    if (!ok) {
+        completeDelegateExecution(KErrGeneral);
     }
-    if ( error == KErrNone ) {
-        exec_inquiry();
-    } 
-    else {
-        // error
-        emit commandCompleted(error);
-    }
-}
-
-void BtDelegateInquiry::exec_inquiry()
-{
-    bool err = getDeviceModel()->searchDevice();
-
-    emit commandCompleted(err);  // in case of error, passing original error back
+    BOstraceFunctionExit0( DUMMY_DEVLIST );
 }
 
 void BtDelegateInquiry::cancel()
 {
-    getDeviceModel()->cancelSearchDevice();
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    if (isExecuting()) {
+        deviceModel()->cancelSearchDevice();
+        setExecuting(false);
+    }
+    BOstraceFunctionExit0( DUMMY_DEVLIST );
+}
+
+void BtDelegateInquiry::handleManagePowerCompleted(int error)
+{
+    if (isExecuting()) {
+        delete mPowerDelegate;
+        bool ok = (error == KErrNone);
+        if (ok) {
+            ok = startInquiry();
+        }
+        if (!ok) {
+            completeDelegateExecution(KErrGeneral);
+        }
+    }
+    BOstraceFunctionExit0( DUMMY_DEVLIST );
 }
+
+void BtDelegateInquiry::handleSearchCompleted(int error)
+{
+    completeDelegateExecution(error? KErrGeneral : KErrNone);
+    BOstraceFunctionExit0( DUMMY_DEVLIST );
+}
+
+bool BtDelegateInquiry::startInquiry()
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    // Make sure this connects the signal only once:
+    disconnect(deviceModel(), 0, this, 0);
+    bool ok = connect(deviceModel(), SIGNAL(deviceSearchCompleted(int)),
+            this, SLOT(handleSearchCompleted(int)));
+    if (ok ) {
+        ok = deviceModel()->searchDevice();
+    }
+    if (ok) {
+        // Inform the client that inquiry really starts now. With
+        // this signal, the client can thus prepare for showing inquiry results:
+        emit beginUiEditMode();
+    }
+    BOstraceFunctionExit0( DUMMY_DEVLIST );
+    return ok;
+}
+
--- a/bluetoothengine/btui/btuidelegate/btdelegateinquiry.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/btdelegateinquiry.h	Fri Sep 03 16:17:59 2010 +0300
@@ -38,19 +38,21 @@
     
     virtual ~BtDelegateInquiry();
     
+    int supportedEditorTypes() const;
+    
     virtual void exec( const QVariant &params );
     
     virtual void cancel();
     
 public slots:
-    void powerDelegateCompleted(int error);
+    void handleManagePowerCompleted(int error);
+    void handleSearchCompleted(int error);
     
 private:
-    void exec_inquiry();
+    bool startInquiry();
     
 private:
-    BtAbstractDelegate* mAbstractDelegate;
-    
+    BtAbstractDelegate *mPowerDelegate;
 };
 
 #endif /* BTDELEGATEINQUIRY_H */
--- a/bluetoothengine/btui/btuidelegate/btdelegatepair.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/btdelegatepair.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -47,6 +47,15 @@
     delete mLoader;
 }
 
+/*!
+    Returns the supported editor types.
+    \return the sum of supported editor types
+ */
+int BtDelegatePair::supportedEditorTypes() const
+{
+    return BtDelegate::PairDevice;
+}
+
 void BtDelegatePair::exec( const QVariant &params )
 {
     
@@ -60,8 +69,8 @@
         //todo: Do we ask for user confirmation here..?
         if (!mAbstractDelegate) { 
             mAbstractDelegate = BtDelegateFactory::newDelegate(BtDelegate::ManagePower, 
-                    getSettingModel(), getDeviceModel() ); 
-            connect( mAbstractDelegate, SIGNAL(commandCompleted(int)), this, SLOT(powerDelegateCompleted(int)) );
+                    settingModel(), deviceModel() ); 
+            connect( mAbstractDelegate, SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), this, SLOT(powerDelegateCompleted(int)) );
             mAbstractDelegate->exec(QVariant(BtPowerOn));
         }
     }
@@ -71,7 +80,6 @@
 void BtDelegatePair::powerDelegateCompleted(int error)
 {
     if (mAbstractDelegate) {
-        disconnect(mAbstractDelegate);
         delete mAbstractDelegate;
         mAbstractDelegate = 0;
     }
@@ -87,10 +95,10 @@
 void BtDelegatePair::exec_pair()
 {
     int error = KErrNone;
-    mdeviceName = getDeviceModel()->data(deviceIndex,BtDeviceModel::NameAliasRole).toString();
+    mdeviceName = deviceModel()->data(deviceIndex,BtDeviceModel::NameAliasRole).toString();
     
-    QString strBtAddr = getDeviceModel()->data(deviceIndex,BtDeviceModel::ReadableBdaddrRole).toString();
-    int cod = getDeviceModel()->data(deviceIndex,BtDeviceModel::CoDRole).toInt();
+    QString strBtAddr = deviceModel()->data(deviceIndex,BtDeviceModel::ReadableBdaddrRole).toString();
+    int cod = deviceModel()->data(deviceIndex,BtDeviceModel::CoDRole).toInt();
     
     if ( ! mBtengConnMan ){
         TRAP( error, mBtengConnMan = CBTEngConnMan::NewL(this) );
@@ -166,7 +174,7 @@
 void BtDelegatePair::emitCommandComplete(int error)
 {
 
-    emit commandCompleted(error);
+    emit delegateCompleted(error, this);
 }
 
 void BtDelegatePair::cancel()
--- a/bluetoothengine/btui/btuidelegate/btdelegatepair.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/btdelegatepair.h	Fri Sep 03 16:17:59 2010 +0300
@@ -41,6 +41,8 @@
             BtDeviceModel* deviceModel, QObject *parent = 0 );
     
     virtual ~BtDelegatePair();
+    
+    int supportedEditorTypes() const;
 
     virtual void exec( const QVariant &params );
     
--- a/bluetoothengine/btui/btuidelegate/btdelegatepower.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/btdelegatepower.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -18,7 +18,7 @@
 
 #include "btdelegatepower.h"
 #include "btqtconstants.h"
-#include <btabstractdelegate.h>
+#include <btdelegatedisconnect.h>
 #include <btdelegatefactory.h>
 #include <btsettingmodel.h>
 #include <btdevicemodel.h>
@@ -35,9 +35,10 @@
     : BtAbstractDelegate( settingModel, deviceModel, parent ),
       mDisconnectDelegate(0)
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );   
     TRAP_IGNORE( mBtengSettings = CBTEngSettings::NewL(this) );
     Q_CHECK_PTR( mBtengSettings );
-    mActiveHandling = false;
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
 /*!
@@ -45,8 +46,18 @@
  */
 BtDelegatePower::~BtDelegatePower()
 {
-    delete mDisconnectDelegate;
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     delete mBtengSettings;
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
+}
+
+/*!
+    Returns the supported editor types.
+    \return the sum of supported editor types
+ */
+int BtDelegatePower::supportedEditorTypes() const
+{
+    return BtDelegate::ManagePower;
 }
 
 /*!
@@ -55,216 +66,153 @@
  */
 void BtDelegatePower::exec( const QVariant &powerState )
 {   
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    BTUI_ASSERT_X(!isExecuting(), "BtDelegatePower::exec", "operation ongoing!");
+
     mReqPowerState = BtEngPowerState((PowerStateQtValue)powerState.toInt());
     BTUI_ASSERT_X( (mReqPowerState == EBTPowerOff) || (mReqPowerState == EBTPowerOn), 
             "BtDelegatePower::exec()", "wrong power state value" );
     
     // get current power status
     TBTPowerStateValue curPowerState(EBTPowerOff);
-    mBtengSettings->GetPowerState( curPowerState );
-    
-    // verify requested power is not the same as current status
-    if ( mReqPowerState == curPowerState ) {
-        // no need to do anything
-        emit commandCompleted( KErrNone );
-        return;
-    }
+    int err = mBtengSettings->GetPowerState( curPowerState );
     
-    // perform power on/off operation
-    if ( mReqPowerState == EBTPowerOff ){ 
-        switchBTOff();     
+    if (!err && mReqPowerState != curPowerState) {
+        setExecuting(true);
+        // perform power on/off operation
+        if ( mReqPowerState == EBTPowerOff ){ 
+            switchBTOff();     
+        }
+        else if ( mReqPowerState == EBTPowerOn ) {
+            switchBTOn();
+        }
+    } else {
+        // no need to do anything
+        completeDelegateExecution(err);
     }
-    else if ( mReqPowerState == EBTPowerOn ) {
-        switchBTOn();
-    }
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
-       
-    
 
 void BtDelegatePower::switchBTOn()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     int err = 0;
-    
+
     //check if device is in OFFLINE mode first
     bool btEnabledInOffline = false;
     if (checkOfflineMode(btEnabledInOffline)){  // offline mode is active
         if (btEnabledInOffline){
             // BT is allowed to be enabled in offline mode, show query.
             HbMessageBox::question( hbTrId("txt_bt_info_trun_bluetooth_on_ini_offline_mode" ),this, 
-							SLOT(btOnQuestionClose(int)), HbMessageBox::Yes | HbMessageBox::No );
-
-        }
-        else{
+				SLOT(btOnQuestionClose(int)), HbMessageBox::Yes | HbMessageBox::No );
+        } else {
             //if BT is not allowed to be enabled in offline mode, show message and complete
             HbMessageBox::warning( hbTrId("txt_bt_info_bluetooth_not_allowed_to_be_turned_on" ),this, 
 				SLOT(btOnWarningClose()));
         }
-        
     }
     else { // offline mode is not active
-        mActiveHandling = true;
         err = mBtengSettings->SetPowerState(EBTPowerOn);
-    }
-    
+    }    
     if ( err ) {
-        //TODO: handle the error here
-        emit commandCompleted(KErrGeneral);
+        completeDelegateExecution(err);
     }
-    
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
 void BtDelegatePower::btOnQuestionClose(int action)
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     int err = 0;
-    if(action == HbMessageBox::Yes) 
-    {
+    if(action == HbMessageBox::Yes) {
         //user chooses "yes" for using BT in offline 
-        mActiveHandling = true;
         err = mBtengSettings->SetPowerState(EBTPowerOn);
+    } else {
+        err = KErrCancel;
     }
-    else
-    {
-        //if user chooses "NO", emits the signal
-        emit commandCompleted(KErrNone);
-           
-    }     
     if ( err ) {
-        //TODO: handle the error here
-        emit commandCompleted(KErrGeneral);
+        completeDelegateExecution(err);
     }
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
 void BtDelegatePower::btOnWarningClose()
 {
-    emit commandCompleted(KErrNone);        
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    completeDelegateExecution(KErrPermissionDenied);
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
-
-
 void BtDelegatePower::switchBTOff()
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     int err = 0;
     
-    CBTEngConnMan *btengConnMan = 0;
-    TRAP(err, btengConnMan = CBTEngConnMan::NewL(this));
-    Q_CHECK_PTR( btengConnMan );
+    CBTEngConnMan *btengConnMan(0);
+    TRAP(err, btengConnMan = CBTEngConnMan::NewL());
     RBTDevAddrArray devAddrArray;
-    err = btengConnMan->GetConnectedAddresses(devAddrArray);
-    if ( err != KErrNone) {
-       //TODO: handle the error here
-       emit commandCompleted(err);
-       return;
+    if (!err) {
+        err = btengConnMan->GetConnectedAddresses(devAddrArray);
     }
-    int count = devAddrArray.Count();
+    if (!err && devAddrArray.Count()) {
+        disconnectConnections(); 
+    } else if ( !err ) {
+        err = mBtengSettings->SetPowerState(EBTPowerOff);
+    }
     devAddrArray.Close();
     delete btengConnMan;
-    if( count> 0 ){
-        mActiveHandling = true;
-        disconnectOngoingConnections(); 
+    
+    if (err) {
+        completeDelegateExecution(err);
     }
-    else{
-        mActiveHandling = true;
-        err = mBtengSettings->SetPowerState(EBTPowerOff);
-        
-        if ( err ) {
-           //TODO: handle the error here
-           emit commandCompleted(KErrGeneral);
-        }
-        
-    }    
-}
-/*
-void BtDelegatePower::btOffDialogClose(HbAction *action)
-{
-    HbMessageBox *dlg = static_cast<HbMessageBox*>(sender());
-    if(action == dlg->actions().at(0)) 
-    {
-        //user chooses "yes" for closing active connection before power off
-        mActiveHandling = true;
-        disconnectOngoingConnections();
-    }
-    else
-    {
-        //if user chooses "NO", emits the signal
-        emit commandCompleted(KErrNone);
-           
-    }     
-    
-}
-*/
-void BtDelegatePower::disconnectOngoingConnections(){
-    if (! mDisconnectDelegate){
-        mDisconnectDelegate = BtDelegateFactory::newDelegate(
-                                                BtDelegate::Disconnect, getSettingModel(), getDeviceModel()); 
-        connect( mDisconnectDelegate, SIGNAL(commandCompleted(int)), this, SLOT(disconnectDelegateCompleted(int)) );
-            
-    
-    DisconnectOption discoOpt = AllOngoingConnections;
-    QVariant param;
-    param.setValue((int)discoOpt);
-    mDisconnectDelegate->exec(param);
-    }
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
-void BtDelegatePower::disconnectDelegateCompleted(int err)
+void BtDelegatePower::disconnectConnections()
 {
-    Q_UNUSED( err );
-    //TODO: handle the return error here
-    
-    int error = mBtengSettings->SetPowerState(EBTPowerOff);
-    if ( error ) {
-        //TODO: handle the error here
-        emit commandCompleted(KErrGeneral);
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    if (! mDisconnectDelegate) {
+        mDisconnectDelegate = new BtDelegateDisconnect(
+                settingModel(), deviceModel(), this);
+        (void) connect(mDisconnectDelegate, 
+                SIGNAL(delegateCompleted(int,BtAbstractDelegate*)), 
+                this, SLOT(disconnectCompleted(int,BtAbstractDelegate*)));
     }
-    
-    
+    QList<QVariant> list;
+    list.append(QVariant( AllOngoingConnections ));
+    mDisconnectDelegate->exec(QVariant(list));
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
+void BtDelegatePower::disconnectCompleted(int err, BtAbstractDelegate *delegate)
+{
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
+    // We will turn off power even an error was returned from disconnection.
+    Q_UNUSED(delegate);
+    err = mBtengSettings->SetPowerState(EBTPowerOff);
+    if ( err ) {
+        completeDelegateExecution(err);
+    }
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
+}
 
 void BtDelegatePower::PowerStateChanged( TBTPowerStateValue aPowerState )
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     // It is possible that others change power: no handling for these cases.
-    if ( !mActiveHandling ) {
-        return;
+    if ( isExecuting() ) {
+        int err = ( mReqPowerState == aPowerState ) ? KErrNone : KErrGeneral;
+        completeDelegateExecution(err);
     } 
-    mActiveHandling = false;
-    
-    if ( mReqPowerState == aPowerState ) {
-        // power state changed successfully
-        emit commandCompleted( KErrNone );
-    }
-    else {
-        // the actual power state is not the same as we requested,
-        // command failed:
-        // ToDo:  show error note?
-        emit commandCompleted( KErrGeneral );
-    }
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
 //Method derived from MBTEngSettingsObserver, no need to be implemented here
 void BtDelegatePower::VisibilityModeChanged( TBTVisibilityMode aState )
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     Q_UNUSED( aState );
-}
-
-void BtDelegatePower::ConnectComplete( TBTDevAddr& aAddr, TInt aErr, 
-                                   RBTDevAddrArray* aConflicts )
-{
-    Q_UNUSED(aAddr);
-    Q_UNUSED(aErr);
-    Q_UNUSED(aConflicts);  
-    /*
-    if ( mBtEngAddr != aAddr ) {  // callback coming for some other device
-        return;
-    }
-    emitCommandComplete(aErr);
-    */
-}
-
-void BtDelegatePower::DisconnectComplete( TBTDevAddr& aAddr, TInt aErr )
-{
-    Q_UNUSED(aAddr);
-    Q_UNUSED(aErr);    
+    BOstraceFunctionExit1( DUMMY_DEVLIST, this );
 }
 
 /*!
@@ -273,12 +221,14 @@
  */
 bool BtDelegatePower::checkOfflineMode(bool& btEnabledInOffline)
 {
+    BOstraceFunctionEntry1( DUMMY_DEVLIST, this );
     TCoreAppUIsNetworkConnectionAllowed offLineMode; 
     TBTEnabledInOfflineMode btEnabled;
    
     mBtengSettings->GetOfflineModeSettings(offLineMode, btEnabled);
     
     btEnabledInOffline = (btEnabled == EBTEnabledInOfflineMode);
+    BOstraceFunctionExitExt( DUMMY_DEVLIST, this, offLineMode == ECoreAppUIsNetworkConnectionNotAllowed);
     return (offLineMode == ECoreAppUIsNetworkConnectionNotAllowed);
 }
 
--- a/bluetoothengine/btui/btuidelegate/btdelegatepower.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/btdelegatepower.h	Fri Sep 03 16:17:59 2010 +0300
@@ -32,8 +32,7 @@
 
     \\sa btuidelegate
  */
-class BtDelegatePower : public BtAbstractDelegate, public MBTEngSettingsObserver, 
-        public MBTEngConnObserver 
+class BtDelegatePower : public BtAbstractDelegate, public MBTEngSettingsObserver
 {
     Q_OBJECT
 
@@ -43,29 +42,23 @@
             BtDeviceModel* deviceModel, QObject *parent = 0 );
     
     virtual ~BtDelegatePower();
-
+    
+    int supportedEditorTypes() const;
+    
     virtual void exec( const QVariant &params );
     
     //from MBTEngSettingsObserver
     
-    virtual void PowerStateChanged( TBTPowerStateValue aState );
+    virtual void PowerStateChanged( TBTPowerStateValue state );
 
-    virtual void VisibilityModeChanged( TBTVisibilityMode aState );
+    virtual void VisibilityModeChanged( TBTVisibilityMode state );
     
 public slots:
     void btOnQuestionClose(int action);
     
     void btOnWarningClose();
     
-    void disconnectDelegateCompleted(int err);
-    
-    
-protected:
-    //From MBTEngConnObserver
-    virtual void ConnectComplete( TBTDevAddr& aAddr, TInt aErr, 
-                                   RBTDevAddrArray* aConflicts );
-    virtual void DisconnectComplete( TBTDevAddr& aAddr, TInt aErr );
-    
+    void disconnectCompleted(int err, BtAbstractDelegate *delegate);
     
 private:
     void switchBTOn();
@@ -74,17 +67,13 @@
     
     bool checkOfflineMode(bool& btEnabledInOffline);
     
-    void disconnectOngoingConnections();
+    void disconnectConnections();
     
-
 private:
     CBTEngSettings* mBtengSettings;
-    bool mActiveHandling; 
-    TBTPowerStateValue mReqPowerState;
-    
+    TBTPowerStateValue mReqPowerState; 
     BtAbstractDelegate* mDisconnectDelegate;
-    
-    
+
 private:
 
     Q_DISABLE_COPY(BtDelegatePower)
--- a/bluetoothengine/btui/btuidelegate/btdelegateremotedevname.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/btdelegateremotedevname.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -41,6 +41,15 @@
 }
 
 /*!
+    Returns the supported editor types.
+    \return the sum of supported editor types
+ */
+int BtDelegateRemoteDevName::supportedEditorTypes() const
+{
+    return BtDelegate::ChangeDeviceFriendlyName;
+}
+
+/*!
     Validate the bluetooth device name given by the user:
     Extra spaces (' ', '\n', '\t' and '\r') from the beginning, 
     middle and the end of the name are always removed;
@@ -72,18 +81,11 @@
     QString btRemoteDevName = nameVariant.toString();
     
     if (!validateName(btRemoteDevName)){
-            emit commandCompleted(KErrBadName);
+            emit delegateCompleted(KErrBadName, this);
             return;
     }
     mNewName = btRemoteDevName;
-    /*
-    QModelIndex start = getDeviceModel()->index(0,0);
-    QModelIndexList indexList = getDeviceModel()->match(start,BtDeviceModel::NameAliasRole, mNewName);
-    if (indexList.size() > 1){
-        emit commandCompleted(KErrBadName, mNewName);
-        return;
-    }
-    */
+
     int error = KErrNone;
     TPtrC ptrName(reinterpret_cast<const TText*>(btRemoteDevName.constData()));
   
@@ -94,11 +96,11 @@
         mSymName.Copy(ptrName);
     }
     else{
-        emit commandCompleted(error,mNewName);
+        emit delegateCompleted(error,this);
         return;
     }
     
-    QString strBtAddr = getDeviceModel()->data(index,
+    QString strBtAddr = deviceModel()->data(index,
            BtDeviceModel::ReadableBdaddrRole).toString();
 
     TBuf<KBTDevAddrSize * 2> buffer(strBtAddr.utf16());
@@ -106,13 +108,13 @@
      
     error = mBtRegServ.Connect();
     if ( error != KErrNone && error != KErrAlreadyExists) {
-        emit commandCompleted(error,mNewName);
+        emit delegateCompleted(error,this);
         return;
     }
 
     error = mBtRegistry.Open( mBtRegServ ) ;
     if ( error != KErrNone && error != KErrAlreadyExists) {
-        emit commandCompleted(error,mNewName);
+        emit delegateCompleted(error,this);
         return;
     }
     mRegistryOpened = true;
@@ -122,14 +124,14 @@
         TRAP(error, mRegistryActive = CBtSimpleActive::NewL(
                        *this, requestId));
         if(error!=KErrNone) {
-            emit commandCompleted(KErrGeneral);
+            emit delegateCompleted(KErrGeneral, this);
             return;
         }
     }
     //first check if this device is already in the registry
     
-    int majorRole = (getDeviceModel()->data(index,BtDeviceModel::MajorPropertyRole)).toInt();
-    int cod = (getDeviceModel()->data(index,BtDeviceModel::CoDRole)).toInt();
+    int majorRole = (deviceModel()->data(index,BtDeviceModel::MajorPropertyRole)).toInt();
+    int cod = (deviceModel()->data(index,BtDeviceModel::CoDRole)).toInt();
     if (!(majorRole & BtuiDevProperty::InRegistry)) {
         CBTDevice *symBtDevice;
         TRAP( error, {
@@ -151,7 +153,7 @@
         });
     }
     if ( error != KErrNone ) {
-        emit commandCompleted(error,mNewName);
+        emit delegateCompleted(error,this);
     }
   
 }
@@ -159,7 +161,7 @@
 void BtDelegateRemoteDevName::RequestCompletedL( CBtSimpleActive* aActive, TInt aStatus ){
     
     if(aStatus != KErrNone){
-        emit commandCompleted(aStatus, mNewName);
+        emit delegateCompleted(aStatus, this);
         return;
     }
     int error = KErrNone;
@@ -171,11 +173,11 @@
                 mRegistryActive->GoActive();
         });
         if(error != KErrNone){
-            emit commandCompleted(error, mNewName);
+            emit delegateCompleted(error, this);
         }
     }
     else if ( aActive->RequestId() == ModifyFriendlyName ){
-        emit commandCompleted(error, mNewName);
+        emit delegateCompleted(error, this);
     }
     
 }
@@ -183,7 +185,7 @@
 void BtDelegateRemoteDevName::CancelRequest( TInt aRequestId ){
     if ( aRequestId == 1 ){
         mBtRegistry.CancelRequest(mRegistryActive->RequestStatus());
-        emit commandCompleted(KErrCancel, mNewName);
+        emit delegateCompleted(KErrCancel, this);
     }
     
 }
@@ -192,5 +194,5 @@
     //TODO: handle the error here
     Q_UNUSED( aActive );
     Q_UNUSED( aError );
-    emit commandCompleted(KErrGeneral,mNewName);
+    emit delegateCompleted(KErrGeneral,this);
 }
--- a/bluetoothengine/btui/btuidelegate/btdelegateremotedevname.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/btdelegateremotedevname.h	Fri Sep 03 16:17:59 2010 +0300
@@ -47,6 +47,8 @@
     
     virtual ~BtDelegateRemoteDevName();
 
+    int supportedEditorTypes() const;
+    
     virtual void exec( const QVariant &params );
    
     // from MBtSimpleActiveObserver
--- a/bluetoothengine/btui/btuidelegate/btdelegatevisibility.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/btdelegatevisibility.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -44,6 +44,17 @@
 {
     delete mBtengSettings;
 }
+
+
+/*!
+    Returns the supported editor types.
+    \return the sum of supported editor types
+ */
+int BtDelegateVisibility::supportedEditorTypes() const
+{
+    return BtDelegate::ChangeVisibility;
+}
+
 /*!
  * executes visibility delegate functionality, ie. calls CBTEngSettings to set the visibility mode;
  * when operation completes, emits commandCompleted signal
@@ -56,7 +67,7 @@
 
     if (mActiveHandling) {
         // complete command with error
-        emit commandCompleted(KErrInUse);
+        emit delegateCompleted(KErrInUse, this);
         return;
     } 
     mActiveHandling = true;
@@ -71,12 +82,12 @@
     err = mBtengSettings->GetVisibilityMode( visibilityMode );
     if (err) {
         mActiveHandling = false;
-        emit commandCompleted(err);
+        emit delegateCompleted(err, this);
         return;
     }
     if (visibilityMode == mOperation) {
         mActiveHandling = false;
-        emit commandCompleted(KErrNone);
+        emit delegateCompleted(KErrNone, this);
         return;
     }
     
@@ -101,7 +112,7 @@
     if (err) {
         // complete command with error
         mActiveHandling = false;
-        emit commandCompleted(err);
+        emit delegateCompleted(err, this);
     }
 }
 
@@ -122,10 +133,10 @@
         //Error handling has to be done, if value is not set properly.
         mActiveHandling = false;
         if (mOperation == aState) {
-            emit commandCompleted(KErrNone);
+            emit delegateCompleted(KErrNone, this);
         }
         else {
-            emit commandCompleted(KErrUnknown);
+            emit delegateCompleted(KErrUnknown, this);
         }
     }
 }
--- a/bluetoothengine/btui/btuidelegate/btdelegatevisibility.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/btdelegatevisibility.h	Fri Sep 03 16:17:59 2010 +0300
@@ -39,10 +39,10 @@
     
     virtual ~BtDelegateVisibility();
 
+    int supportedEditorTypes() const;
+
     virtual void exec( const QVariant &params );
-    
 
-    
 public slots:
 
 private:
--- a/bluetoothengine/btui/btuidelegate/btuidelegate.pro	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/btuidelegate.pro	Fri Sep 03 16:17:59 2010 +0300
@@ -26,10 +26,10 @@
 CONFIG += qt \
     hb \
     dll
-HEADERS += btdelegateconsts.h \
-    btdelegatepower.h \
-    btdelegatefactory.h \
-    btabstractdelegate.h \
+    
+HEADERS += btdelegatepower.h \
+    ../inc/btdelegatefactory.h \
+    ../inc/btabstractdelegate.h \
     btdelegatevisibility.h \
     btdelegatedevname.h \
     btdelegateinquiry.h \
@@ -37,7 +37,8 @@
     btdelegatepair.h \
     btdelegatedisconnect.h \
     btdelegatedevsecurity.h \
-    btdelegateremotedevname.h
+    btdelegateremotedevname.h \
+    btdelegatedevremove.h
     
 SOURCES += btdelegatepower.cpp \
     btdelegatefactory.cpp \
@@ -49,16 +50,14 @@
     btdelegatepair.cpp \
     btdelegatedisconnect.cpp \
     btdelegatedevsecurity.cpp \
-    btdelegateremotedevname.cpp
+    btdelegateremotedevname.cpp \
+    btdelegatedevremove.cpp
 
 defFilePath = .
     
 symbian: { 
     SYMBIAN_PLATFORMS = WINSCW \
         ARMV5
-    BLD_INF_RULES.prj_exports += "btdelegatefactory.h |../inc/btdelegatefactory.h"
-    BLD_INF_RULES.prj_exports += "btabstractdelegate.h |../inc/btabstractdelegate.h"
-    BLD_INF_RULES.prj_exports += "btdelegateconsts.h |../inc/btdelegateconsts.h"
     TARGET.EPOCALLOWDLLDATA = 1
     TARGET.UID3 = 0xEE02434F
     TARGET.CAPABILITY = CAP_GENERAL_DLL
--- a/bluetoothengine/btui/btuidelegate/bwins/btuidelegateu.def	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/bwins/btuidelegateu.def	Fri Sep 03 16:17:59 2010 +0300
@@ -1,20 +1,25 @@
 EXPORTS
 	?qt_metacall@BtAbstractDelegate@@UAEHW4Call@QMetaObject@@HPAPAX@Z @ 1 NONAME ; int BtAbstractDelegate::qt_metacall(enum QMetaObject::Call, int, void * *)
-	??1BtAbstractDelegate@@UAE@XZ @ 2 NONAME ; BtAbstractDelegate::~BtAbstractDelegate(void)
-	?metaObject@BtAbstractDelegate@@UBEPBUQMetaObject@@XZ @ 3 NONAME ; struct QMetaObject const * BtAbstractDelegate::metaObject(void) const
-	?tr@BtAbstractDelegate@@SA?AVQString@@PBD0H@Z @ 4 NONAME ; class QString BtAbstractDelegate::tr(char const *, char const *, int)
-	?newDelegate@BtDelegateFactory@@SAPAVBtAbstractDelegate@@W4Command@BtDelegate@@PAVBtSettingModel@@PAVBtDeviceModel@@PAVQObject@@@Z @ 5 NONAME ; class BtAbstractDelegate * BtDelegateFactory::newDelegate(enum BtDelegate::Command, class BtSettingModel *, class BtDeviceModel *, class QObject *)
-	?tr@BtAbstractDelegate@@SA?AVQString@@PBD0@Z @ 6 NONAME ; class QString BtAbstractDelegate::tr(char const *, char const *)
-	?qt_metacast@BtAbstractDelegate@@UAEPAXPBD@Z @ 7 NONAME ; void * BtAbstractDelegate::qt_metacast(char const *)
-	?getStaticMetaObject@BtAbstractDelegate@@SAABUQMetaObject@@XZ @ 8 NONAME ; struct QMetaObject const & BtAbstractDelegate::getStaticMetaObject(void)
-	??0BtAbstractDelegate@@QAE@PAVBtSettingModel@@PAVBtDeviceModel@@PAVQObject@@@Z @ 9 NONAME ; BtAbstractDelegate::BtAbstractDelegate(class BtSettingModel *, class BtDeviceModel *, class QObject *)
-	?staticMetaObject@BtAbstractDelegate@@2UQMetaObject@@B @ 10 NONAME ; struct QMetaObject const BtAbstractDelegate::staticMetaObject
-	??_EBtAbstractDelegate@@UAE@I@Z @ 11 NONAME ; BtAbstractDelegate::~BtAbstractDelegate(unsigned int)
-	?commandCompleted@BtAbstractDelegate@@IAEXHVQVariant@@@Z @ 12 NONAME ; void BtAbstractDelegate::commandCompleted(int, class QVariant)
-	?cancel@BtAbstractDelegate@@UAEXXZ @ 13 NONAME ; void BtAbstractDelegate::cancel(void)
-	?trUtf8@BtAbstractDelegate@@SA?AVQString@@PBD0@Z @ 14 NONAME ; class QString BtAbstractDelegate::trUtf8(char const *, char const *)
-	?getSettingModel@BtAbstractDelegate@@IAEPAVBtSettingModel@@XZ @ 15 NONAME ; class BtSettingModel * BtAbstractDelegate::getSettingModel(void)
-	?getDeviceModel@BtAbstractDelegate@@IAEPAVBtDeviceModel@@XZ @ 16 NONAME ; class BtDeviceModel * BtAbstractDelegate::getDeviceModel(void)
-	?trUtf8@BtAbstractDelegate@@SA?AVQString@@PBD0H@Z @ 17 NONAME ; class QString BtAbstractDelegate::trUtf8(char const *, char const *, int)
-	?isBtPowerOn@BtAbstractDelegate@@IAE_NXZ @ 18 NONAME ; bool BtAbstractDelegate::isBtPowerOn(void)
+	?beginUiEditMode@BtAbstractDelegate@@IAEXXZ @ 2 NONAME ; void BtAbstractDelegate::beginUiEditMode(void)
+	?delegateCompleted@BtAbstractDelegate@@IAEXHPAV1@@Z @ 3 NONAME ; void BtAbstractDelegate::delegateCompleted(int, class BtAbstractDelegate *)
+	?settingModel@BtAbstractDelegate@@IAEPAVBtSettingModel@@XZ @ 4 NONAME ; class BtSettingModel * BtAbstractDelegate::settingModel(void)
+	??1BtAbstractDelegate@@UAE@XZ @ 5 NONAME ; BtAbstractDelegate::~BtAbstractDelegate(void)
+	?metaObject@BtAbstractDelegate@@UBEPBUQMetaObject@@XZ @ 6 NONAME ; struct QMetaObject const * BtAbstractDelegate::metaObject(void) const
+	?deviceModel@BtAbstractDelegate@@IAEPAVBtDeviceModel@@XZ @ 7 NONAME ; class BtDeviceModel * BtAbstractDelegate::deviceModel(void)
+	?tr@BtAbstractDelegate@@SA?AVQString@@PBD0H@Z @ 8 NONAME ; class QString BtAbstractDelegate::tr(char const *, char const *, int)
+	?tr@BtAbstractDelegate@@SA?AVQString@@PBD0@Z @ 9 NONAME ; class QString BtAbstractDelegate::tr(char const *, char const *)
+	?qt_metacast@BtAbstractDelegate@@UAEPAXPBD@Z @ 10 NONAME ; void * BtAbstractDelegate::qt_metacast(char const *)
+	?getStaticMetaObject@BtAbstractDelegate@@SAABUQMetaObject@@XZ @ 11 NONAME ; struct QMetaObject const & BtAbstractDelegate::getStaticMetaObject(void)
+	??0BtAbstractDelegate@@QAE@PAVBtSettingModel@@PAVBtDeviceModel@@PAVQObject@@@Z @ 12 NONAME ; BtAbstractDelegate::BtAbstractDelegate(class BtSettingModel *, class BtDeviceModel *, class QObject *)
+	?staticMetaObject@BtAbstractDelegate@@2UQMetaObject@@B @ 13 NONAME ; struct QMetaObject const BtAbstractDelegate::staticMetaObject
+	?newDelegate@BtDelegateFactory@@SAPAVBtAbstractDelegate@@W4EditorType@BtDelegate@@PAVBtSettingModel@@PAVBtDeviceModel@@PAVQObject@@@Z @ 14 NONAME ; class BtAbstractDelegate * BtDelegateFactory::newDelegate(enum BtDelegate::EditorType, class BtSettingModel *, class BtDeviceModel *, class QObject *)
+	?endUiEditMode@BtAbstractDelegate@@IAEXXZ @ 15 NONAME ; void BtAbstractDelegate::endUiEditMode(void)
+	??_EBtAbstractDelegate@@UAE@I@Z @ 16 NONAME ; BtAbstractDelegate::~BtAbstractDelegate(unsigned int)
+	?isExecuting@BtAbstractDelegate@@QAE_NXZ @ 17 NONAME ; bool BtAbstractDelegate::isExecuting(void)
+	?setExecuting@BtAbstractDelegate@@IAEX_N@Z @ 18 NONAME ; void BtAbstractDelegate::setExecuting(bool)
+	?isBtPowerOn@BtAbstractDelegate@@IAE_NXZ @ 19 NONAME ; bool BtAbstractDelegate::isBtPowerOn(void)
+	?completeDelegateExecution@BtAbstractDelegate@@IAEXH@Z @ 20 NONAME ; void BtAbstractDelegate::completeDelegateExecution(int)
+	?cancel@BtAbstractDelegate@@UAEXXZ @ 21 NONAME ; void BtAbstractDelegate::cancel(void)
+	?trUtf8@BtAbstractDelegate@@SA?AVQString@@PBD0@Z @ 22 NONAME ; class QString BtAbstractDelegate::trUtf8(char const *, char const *)
+	?trUtf8@BtAbstractDelegate@@SA?AVQString@@PBD0H@Z @ 23 NONAME ; class QString BtAbstractDelegate::trUtf8(char const *, char const *, int)
 
--- a/bluetoothengine/btui/btuidelegate/eabi/btuidelegateu.def	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuidelegate/eabi/btuidelegateu.def	Fri Sep 03 16:17:59 2010 +0300
@@ -1,19 +1,24 @@
 EXPORTS
-	_ZN17BtDelegateFactory11newDelegateEN10BtDelegate7CommandEP14BtSettingModelP13BtDeviceModelP7QObject @ 1 NONAME
-	_ZN18BtAbstractDelegate11qt_metacallEN11QMetaObject4CallEiPPv @ 2 NONAME
-	_ZN18BtAbstractDelegate11qt_metacastEPKc @ 3 NONAME
-	_ZN18BtAbstractDelegate14getDeviceModelEv @ 4 NONAME
-	_ZN18BtAbstractDelegate15getSettingModelEv @ 5 NONAME
-	_ZN18BtAbstractDelegate16commandCompletedEi8QVariant @ 6 NONAME
-	_ZN18BtAbstractDelegate16staticMetaObjectE @ 7 NONAME DATA 16
-	_ZN18BtAbstractDelegate19getStaticMetaObjectEv @ 8 NONAME
-	_ZN18BtAbstractDelegate6cancelEv @ 9 NONAME
-	_ZN18BtAbstractDelegateC2EP14BtSettingModelP13BtDeviceModelP7QObject @ 10 NONAME
-	_ZN18BtAbstractDelegateD0Ev @ 11 NONAME
-	_ZN18BtAbstractDelegateD1Ev @ 12 NONAME
-	_ZN18BtAbstractDelegateD2Ev @ 13 NONAME
-	_ZNK18BtAbstractDelegate10metaObjectEv @ 14 NONAME
-	_ZTI18BtAbstractDelegate @ 15 NONAME
-	_ZTV18BtAbstractDelegate @ 16 NONAME
-	_ZN18BtAbstractDelegate11isBtPowerOnEv @ 17 NONAME
+	_ZN17BtDelegateFactory11newDelegateEN10BtDelegate10EditorTypeEP14BtSettingModelP13BtDeviceModelP7QObject @ 1 NONAME
+	_ZN18BtAbstractDelegate11deviceModelEv @ 2 NONAME
+	_ZN18BtAbstractDelegate11isBtPowerOnEv @ 3 NONAME
+	_ZN18BtAbstractDelegate11isExecutingEv @ 4 NONAME
+	_ZN18BtAbstractDelegate11qt_metacallEN11QMetaObject4CallEiPPv @ 5 NONAME
+	_ZN18BtAbstractDelegate11qt_metacastEPKc @ 6 NONAME
+	_ZN18BtAbstractDelegate12setExecutingEb @ 7 NONAME
+	_ZN18BtAbstractDelegate12settingModelEv @ 8 NONAME
+	_ZN18BtAbstractDelegate13endUiEditModeEv @ 9 NONAME
+	_ZN18BtAbstractDelegate15beginUiEditModeEv @ 10 NONAME
+	_ZN18BtAbstractDelegate16staticMetaObjectE @ 11 NONAME DATA 16
+	_ZN18BtAbstractDelegate17delegateCompletedEiPS_ @ 12 NONAME
+	_ZN18BtAbstractDelegate19getStaticMetaObjectEv @ 13 NONAME
+	_ZN18BtAbstractDelegate25completeDelegateExecutionEi @ 14 NONAME
+	_ZN18BtAbstractDelegate6cancelEv @ 15 NONAME
+	_ZN18BtAbstractDelegateC2EP14BtSettingModelP13BtDeviceModelP7QObject @ 16 NONAME
+	_ZN18BtAbstractDelegateD0Ev @ 17 NONAME
+	_ZN18BtAbstractDelegateD1Ev @ 18 NONAME
+	_ZN18BtAbstractDelegateD2Ev @ 19 NONAME
+	_ZNK18BtAbstractDelegate10metaObjectEv @ 20 NONAME
+	_ZTI18BtAbstractDelegate @ 21 NONAME
+	_ZTV18BtAbstractDelegate @ 22 NONAME
 
--- a/bluetoothengine/btui/btuimodel/btdevicemodel.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuimodel/btdevicemodel.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -18,6 +18,7 @@
 #include <btdevicemodel.h>
 #include "btdevicemodel_p.h"
 #include "bluetoothuitrace.h"
+#include "btuidevtypemap.h"
 
 /*!
     This Constructor creates new instances of model data structure.
@@ -128,6 +129,53 @@
     return  d.data()->itemData( index.row(), index.column() );
 }
 
+/*!
+    \Reimplemented just to match the model based on major property
+ */
+QModelIndexList BtDeviceModel::match(const QModelIndex & start, int role,
+        const QVariant & value, int hits, Qt::MatchFlags flags ) const
+{
+    DevDataRole propRole = (DevDataRole)role;
+    if(BtDeviceModel::MajorPropertyRole == propRole) {
+        BtuiDevProperty::DevMajorProperty propValue = (BtuiDevProperty::DevMajorProperty)value.toInt();
+        QModelIndexList indexList;
+        int count = rowCount();
+        if (count && (start.row() < count)) {
+            for(int row = start.row(); row < count; row++) {
+                QModelIndex modelIndex = index(row,0);
+                int majorPropRole = data(modelIndex,BtDeviceModel::MajorPropertyRole).toInt();
+                if (majorPropRole & propValue) {
+                    indexList.append(modelIndex);
+                }
+            }
+        }
+        return indexList;
+    }
+    
+    return QAbstractItemModel::match(start, role, value, hits, flags);
+}
+
+
+/*!
+    Returns device count of devices having majorProperty.
+ */
+int BtDeviceModel::deviceCount(int majorProperty)
+{
+    int deviceCount = 0;
+    int count = rowCount();
+    BtuiDevProperty::DevMajorProperty propValue = (BtuiDevProperty::DevMajorProperty)majorProperty;
+    
+    for(int row = 0; row < count; row++) {
+        QModelIndex modelIndex = index(row,0);
+        int majorPropRole = data(modelIndex,BtDeviceModel::MajorPropertyRole).toInt();
+        if (majorPropRole & propValue) {
+            deviceCount++;
+        }
+    }
+
+    return deviceCount;
+}
+
 
 /*!
     emits dataChanged signal.
--- a/bluetoothengine/btui/btuimodel/btdevicemodel_p.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuimodel/btdevicemodel_p.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -158,7 +158,7 @@
         if(isDeviceInRange(qtdev)) {
             if(isDeviceInRegistry(qtdev)) {
                 // we cannot remove this device as it is in registry.
-                // remove it in-range property.
+                // remove its in-range property.
                 setMajorProperty(mData[i], BtuiDevProperty::InRange, false);
                 updateRssi(mData[i], RssiInvalid);
                 updateSeqNum(mData[i], -1);
@@ -278,7 +278,6 @@
         const TInquirySockAddr& inqAddr, const TDesC& name )
 {
     int pos = indexOf( inqAddr.BTAddr() );
-    const CBtDevExtension* dev = mDeviceRepo->Device( inqAddr.BTAddr() );
     
     //RssiRole
     int rssi( RssiInvalid ); // initialize to an invalid value.
@@ -419,9 +418,6 @@
     // device type is mapped according to CoD:
     BtuiDevProperty::mapDeiveType(majorDeviceType, minorDeviceType, cod);
 
-
-
-    
     qtdev[BtDeviceModel::MajorPropertyRole] = 
             QVariant( qtdev[BtDeviceModel::MajorPropertyRole].toInt() | majorDeviceType );
     qtdev[BtDeviceModel::MinorPropertyRole] = QVariant( minorDeviceType );
--- a/bluetoothengine/btui/btuimodel/btsettingmodel_p.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuimodel/btsettingmodel_p.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -15,7 +15,6 @@
 *
 */
 
-
 #include "btsettingmodel_p.h"
 #include <btdevice.h>
 #include <btmanclient.h>
@@ -33,7 +32,7 @@
     {
     int err( 0 );
     if (!err ) {
-        err = mLocalDeviceKey.Attach( KPropertyUidBluetoothCategory, 
+        err = mLocalDeviceKey.Attach( KPropertyUidBluetoothCategory,
                     KPropertyKeyBluetoothGetRegistryTableChange );
     }
     
@@ -56,17 +55,15 @@
     mLocalDeviceKey.Subscribe( mLocalDeviceWatcher->RequestStatus() );
     mLocalDeviceWatcher->GoActive();
     
-    // Get the device name
-    TBTDeviceName  deviceName;
-    (void) mBtengSetting->GetLocalName( deviceName );
-    updateDeviceName( QString::fromUtf16( deviceName.Ptr(), deviceName.Length() ) );
+    // At initialization, we do not need to handle the return value
+    (void) updateLocalDeviceName();
     
-    // Get the power setting.
+    // Initialize the power setting.
     TBTPowerStateValue power( EBTPowerOff );
     (void) mBtengSetting->GetPowerState( power );
     setPowerSetting( power );
     
-    // Get the visibility mode
+    // Initialize the visibility mode
     TBTVisibilityMode visibilityMode( EBTVisibilityModeNoScans );
     (void) mBtengSetting->GetVisibilityMode( visibilityMode );
     setVisibilityMode( visibilityMode );
@@ -180,7 +177,15 @@
     if ( active->RequestId() == KLocalDeviceNameWatcher ) {
         mLocalDeviceKey.Subscribe( mLocalDeviceWatcher->RequestStatus() );
         mLocalDeviceWatcher->GoActive();
-        updateDeviceName( QString() );
+        // Refresh local name of this model only when the local device table is changed.
+        TInt changedTable;
+        TInt err = mLocalDeviceKey.Get( changedTable );
+        if( !err && changedTable == KRegistryChangeLocalTable ) {
+            bool updated = updateLocalDeviceName();
+            if (updated) {
+                emit settingDataChanged( BtSettingModel::LocalBtNameRow, this );
+            }
+        }
     }
 }
 
@@ -193,6 +198,9 @@
     }
 }
 
+/*!
+    AO's RunL() cannot leave in Qt applications. No handling.
+ */
 void BtSettingModelPrivate::HandleError( CBtSimpleActive* active, TInt error ) {
     Q_UNUSED( active );
     Q_UNUSED( error );
@@ -200,28 +208,20 @@
 
 /*!
     Update local Bluetooth device name in the data store.
-    @param name the latest Bluetooth name.
+    \return true if the local name is really updated in this model; false, otherwise.
  */
-void BtSettingModelPrivate::updateDeviceName( const QString &name ) 
+bool BtSettingModelPrivate::updateLocalDeviceName() 
 {
-    // To-do: the data structure initialization is not impled yet in the model
-    BtuiModelDataItem& item = 
-            mData[ BtSettingModel::LocalBtNameRow ];
-    
-    bool setByUser = !name.isEmpty();
-    
-    // The additional parameter is the flag indicating whether the 
-    // Bluetooth name has been set by the user.
-    // The flag is set to true if the name has been set.    
-    // item[ BtSettingModel::SettingValueParamRole ] = QVariant( setByUser );
-    
-    QString resolvedName( name );
-    if ( resolvedName.isEmpty() ) {
-        // We get the default name as suggestion for the user to set.
-        getNameFromRegistry( resolvedName );
+    QString nameInReg;
+    getNameFromRegistry( nameInReg );
+    QString currentName = mData.at(BtSettingModel::LocalBtNameRow).value(
+                    BtSettingModel::settingDisplayRole).toString();
+    if ( nameInReg != currentName ) {
+        mData[BtSettingModel::LocalBtNameRow][BtSettingModel::settingDisplayRole] = QVariant(nameInReg);
+        mData[BtSettingModel::LocalBtNameRow][BtSettingModel::SettingValueRole] = QVariant(nameInReg);
+        return true;
     }
-    item[ BtSettingModel::settingDisplayRole ] = QVariant( resolvedName );
-    item[ BtSettingModel::SettingValueRole ] = QVariant( resolvedName );
+    return false;
 }
 
 /*!
@@ -229,17 +229,12 @@
  */
 void BtSettingModelPrivate::setPowerSetting( TBTPowerStateValue state )
 {
-    BtuiModelDataItem& item = 
-            mData[ BtSettingModel::PowerStateRow ];
-    
-    item[ BtSettingModel::SettingValueRole ] = QVariant( QtPowerMode(state) );
+    mData[BtSettingModel::PowerStateRow][BtSettingModel::SettingValueRole] = QVariant(QtPowerMode(state));
 }
 
 void BtSettingModelPrivate::setVisibilityMode( TBTVisibilityMode state )
 {
-    BtuiModelDataItem& item = mData[ BtSettingModel::VisibilityRow ];
-
-    item [ BtSettingModel::SettingValueRole ] = QVariant( QtVisibilityMode(state) );
+    mData[BtSettingModel::VisibilityRow][BtSettingModel::SettingValueRole] = QVariant(QtVisibilityMode(state));
 }
 
 /*!
--- a/bluetoothengine/btui/btuimodel/btsettingmodel_p.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuimodel/btsettingmodel_p.h	Fri Sep 03 16:17:59 2010 +0300
@@ -78,7 +78,8 @@
 private:
 
     void setVisibilityMode( TBTVisibilityMode state );
-    void updateDeviceName( const QString &name );
+    
+    bool updateLocalDeviceName();
     
     void setPowerSetting( TBTPowerStateValue state );
     
--- a/bluetoothengine/btui/btuimodel/bwins/btuimodelu.def	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuimodel/bwins/btuimodelu.def	Fri Sep 03 16:17:59 2010 +0300
@@ -72,4 +72,6 @@
 	?data@BtDeviceModel@@UBE?AVQVariant@@ABVQModelIndex@@H@Z @ 71 NONAME ; class QVariant BtDeviceModel::data(class QModelIndex const &, int) const
 	?connectModelSignals@BtDeviceModel@@AAEXXZ @ 72 NONAME ; void BtDeviceModel::connectModelSignals(void)
 	?connectModelSignals@BtSettingModel@@AAEXXZ @ 73 NONAME ; void BtSettingModel::connectModelSignals(void)
+	?match@BtDeviceModel@@UBE?AV?$QList@VQModelIndex@@@@ABVQModelIndex@@HABVQVariant@@HV?$QFlags@W4MatchFlag@Qt@@@@@Z @ 74 NONAME ; class QList<class QModelIndex> BtDeviceModel::match(class QModelIndex const &, int, class QVariant const &, int, class QFlags<enum Qt::MatchFlag>) const
+	?deviceCount@BtDeviceModel@@QAEHH@Z @ 75 NONAME ; int BtDeviceModel::deviceCount(int)
 
--- a/bluetoothengine/btui/btuimodel/eabi/btuimodelu.def	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/btuimodel/eabi/btuimodelu.def	Fri Sep 03 16:17:59 2010 +0300
@@ -74,4 +74,6 @@
 	_ZTV19BtuiModelSortFilter @ 73 NONAME
 	_ZN14BtSettingModel19connectModelSignalsEv @ 74 NONAME
 	_ZN13BtDeviceModel19connectModelSignalsEv @ 75 NONAME
+	_ZNK13BtDeviceModel5matchERK11QModelIndexiRK8QVarianti6QFlagsIN2Qt9MatchFlagEE @ 76 NONAME
+	_ZN13BtDeviceModel11deviceCountEi @ 77 NONAME
 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btui/inc/btabstractdelegate.h	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,136 @@
+/*
+* Copyright (c) 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: 
+*
+*/
+
+#ifndef BTABSTRACTDELEGATE_H
+#define BTABSTRACTDELEGATE_H
+
+#include <QObject>
+#include <QVariant>
+#include <QModelIndex>
+#include <btdelegateconsts.h>
+
+class BtSettingModel;
+class BtDeviceModel;
+
+#ifdef BUILD_BTUIDELEGATE
+#define BTUIDELEGATE_IMEXPORT Q_DECL_EXPORT
+#else
+#define BTUIDELEGATE_IMEXPORT Q_DECL_IMPORT
+#endif
+
+
+/*!
+    \class BtAbstractDelegate
+    \brief the base class for handling user requests from BT application.
+
+
+    \\sa btuidelegate
+ */
+class BTUIDELEGATE_IMEXPORT BtAbstractDelegate : public QObject
+{
+    Q_OBJECT
+
+public:
+    explicit BtAbstractDelegate( BtSettingModel* settingModel, 
+            BtDeviceModel* deviceModel, QObject *parent = 0 );
+    
+    virtual ~BtAbstractDelegate();
+
+    /*!
+     * Tells whether this is executing an operation.
+     */
+    bool isExecuting();
+    
+    /*!
+     * Returns the sum of supported editor types
+     */
+    virtual int supportedEditorTypes() const = 0;
+
+    /*!
+     * Execute an operation, e.g., powering BT.
+     * \param params the parameters which is specific per
+     * delegate.
+     */
+    virtual void exec( const QVariant &params ) = 0;
+
+    /*!
+     * Cancels an ongoing operation upon receiving the cancelling 
+     * request from end user.
+     */
+    virtual void cancel();
+    
+signals:
+
+    /*!
+     * Signal for informing the relevant party that Ui Edit mode
+     * for the current operation should be activated.
+     */
+    void beginUiEditMode();
+    
+    /*!
+     * Signal for informing the relevant party that Ui Edit mode
+     * for the current operation should be deactivated.
+     */
+    void endUiEditMode();
+    
+    /*!
+     * Signal for informing that this delegate has completed the operation.
+     * \param error the result of the operation - 0 if the operation
+     * was successful; some error code, otherwise.
+     */
+    void delegateCompleted(int error, BtAbstractDelegate *delegate);
+    
+protected:
+    
+    /*!
+     * access to setting model.
+     */
+    BtSettingModel *settingModel();
+    
+    /*!
+     * access to device model.
+     */
+    BtDeviceModel *deviceModel();
+    
+    /*!
+     * Tells whether BT is on.
+     * \return true if BT is on; false otherwise
+     */
+    bool isBtPowerOn();
+    
+    void completeDelegateExecution(int error);
+    
+    void setExecuting(bool executing);
+    
+public slots:
+
+private:
+
+    // pointer to models. do not own. 
+    BtSettingModel *mSettingModel;
+    
+    BtDeviceModel *mDeviceModel;
+    
+    bool mExecuting;
+    
+    Q_DISABLE_COPY(BtAbstractDelegate)
+
+};
+
+Q_DECLARE_METATYPE(QModelIndex)
+
+#endif // BTABSTRACTDELEGATE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btui/inc/btdelegateconsts.h	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,48 @@
+/*
+* Copyright (c) 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: 
+*
+*/
+
+#ifndef BTDELEGATECONSTS_H
+#define BTDELEGATECONSTS_H
+
+#include <QObject>
+
+namespace BtDelegate
+    {
+    enum EditorType
+        {
+        InvalidEditor =            0x000000, // invalid editor type
+        ManagePower =              0x000001,
+        ChangeLocalName =          0x000002,
+        ChangeVisibility =         0x000004,
+        Inquiry =                  0x000008,
+        ConnectService =           0x000010,
+        DisconnectService =        0x000020,
+        DisconnectAllConnections = 0x000040,
+        PairDevice =               0x000080,
+        UnpairDevice =             0x000100,
+        BlockDevice =              0x000200,
+        UnblockDevice =            0x000400,
+        TrustDevice =              0x000800,
+        UntrustDevice =            0x001000,
+        ChangeDeviceFriendlyName = 0x002000,
+        RemoveAllRegistryDevices = 0x004000,
+        RemovePairedDevices =      0x008000,
+        RemoveBlockedDevices =     0x010000,
+        };
+    }
+
+#endif // BTDELEGATECONSTS_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btui/inc/btdelegatefactory.h	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,52 @@
+/*
+* Copyright (c) 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: 
+*
+*/
+
+#ifndef BTDELEGATEFACTORY_H
+#define BTDELEGATEFACTORY_H
+
+#include <QObject>
+#include "btdelegateconsts.h"
+
+class BtAbstractDelegate;
+class BtSettingModel;
+class BtDeviceModel;
+
+#ifdef BUILD_BTUIDELEGATE
+#define BTUIDELEGATE_IMEXPORT Q_DECL_EXPORT
+#else
+#define BTUIDELEGATE_IMEXPORT Q_DECL_IMPORT
+#endif
+
+/*!
+    \class BtDelegateFactory
+    \brief the base class for creating concrete delegate instances
+
+    \\sa btuidelegate
+ */
+class BTUIDELEGATE_IMEXPORT BtDelegateFactory
+{
+
+public:
+    static BtAbstractDelegate *newDelegate( 
+            BtDelegate::EditorType editor, 
+            BtSettingModel* settingModel, 
+            BtDeviceModel* deviceModel, 
+            QObject *parent = 0 );
+
+};
+
+#endif // BTDELEGATEFACTORY_H
--- a/bluetoothengine/btui/inc/btdevicemodel.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/inc/btdevicemodel.h	Fri Sep 03 16:17:59 2010 +0300
@@ -86,6 +86,8 @@
     
     void removeTransientDevices();
     
+    int deviceCount(int majorProperty);
+    
     // from QAbstractItemModel
     virtual QModelIndex index( int row, int column, const QModelIndex &parent = QModelIndex() ) const;
     
@@ -99,6 +101,10 @@
 
     virtual QMap<int, QVariant> itemData( const QModelIndex & index ) const;
     
+    virtual QModelIndexList match(const QModelIndex & start, int role,
+            const QVariant & value, int hits = 1, Qt::MatchFlags flags =
+                    Qt::MatchFlags(Qt::MatchStartsWith | Qt::MatchWrap)) const;
+    
 signals:
 
     void deviceSearchCompleted(int error);
@@ -120,7 +126,7 @@
 private:
     
     void connectModelSignals();
-    
+       
 private:
     QSharedPointer<BtDeviceModelPrivate> d;
 };
--- a/bluetoothengine/btui/inc/btqtconstants.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/inc/btqtconstants.h	Fri Sep 03 16:17:59 2010 +0300
@@ -39,6 +39,15 @@
     BtPowerUnknown  // only for error situations
 };
 
+enum DeviceSecurityService {
+    BtUnpair = 0,
+    BtBlock,     
+    BtUnblock,
+    BtAuthorize,
+    BtUnauthorize,
+    ServiceUnknown
+};
+
 enum DisconnectOption {
     ServiceLevel = 0,
     PhysicalLink, 
--- a/bluetoothengine/btui/inc/traceconfig.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/bluetoothengine/btui/inc/traceconfig.h	Fri Sep 03 16:17:59 2010 +0300
@@ -66,7 +66,7 @@
  * Tracing media configuration
  */  
 #ifdef BLUETOOTHTRACE_ENABLED
-    #ifdef __WINS__
+    #if 0 //#ifdef__WINS__
     #define BLUETOOTHTRACE_MEDIA_FILE
     #else 
     // RDEBUG is used for tracing output before we migrate to OST tracing.
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btxqservice/btxqservice.pro	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,62 @@
+#
+# Copyright (c) 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: 
+#
+
+TEMPLATE = app
+TARGET = btxqservice
+CONFIG += hb \
+    service
+MOC_DIR = moc
+OBJECTS_DIR = obj
+symbian:
+ { 
+    TARGET.UID3 = 0xA89FB238
+    TARGET.CAPABILITY = ALL -TCB
+}
+LIBS += -lhbcore \
+    -lxqservice \
+    -lxqserviceutil \
+    -lbluetooth \
+    -lbtengsettings \
+    -lxqutils
+SERVICE.FILE = xml/btxqservice_conf.xml
+
+SERVICE.OPTIONS = embeddable \
+    hidden
+    
+libFiles.path = "!:\sys\bin"
+DEPLOYMENT += libFiles
+
+HEADERS += inc/btxqaddrservice.h \
+           inc/btxqpowerservice.h \
+           inc/btxqdutservice.h \
+           inc/btxqsspdebugservice.h
+           
+SOURCES += src/btxqaddrservice.cpp \
+           src/main.cpp \
+           src/btxqpowerservice.cpp \
+           src/btxqdutservice.cpp \
+           src/btxqsspdebugservice.cpp
+
+INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE \
+               ../inc \
+               /epoc32/include/platform/mw/btservices
+
+BLD_INF_RULES.prj_exports += \
+  "$${LITERAL_HASH}include <platform_paths.hrh>" \
+  "inc/btxqserviceapi.h  MW_LAYER_PLATFORM_EXPORT_PATH(btxqserviceapi.h)" \
+  "rom/btxqservice.iby   CORE_MW_LAYER_IBY_EXPORT_PATH(btxqservice.iby)"
+  
+  
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btxqservice/inc/btxqaddrservice.h	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 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:  
+ *
+ */
+
+
+#ifndef BTXQADDRSERVICE_H
+#define BTXQADDRSERVICE_H
+
+#include <xqserviceprovider.h>
+
+class HbDeviceDialog;
+
+
+class BtxqAddrService : public XQServiceProvider
+{
+    Q_OBJECT
+    
+public:
+    BtxqAddrService( QObject *parent = 0 );
+    ~BtxqAddrService();
+
+public slots:
+    void showBTAddr();
+    
+public slots:
+    void handleshowBTAddrCompleted();
+    
+private:
+    HbDeviceDialog* mDialog;
+    int mCurrentRequestIndex;
+    int mError;
+};
+
+#endif // BTXQADDRSERVICE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btxqservice/inc/btxqdutservice.h	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2009 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:  
+ *
+ */
+
+
+#ifndef BTXQDUTSERVICE_H
+#define BTXQDUTSERVICE_H
+
+#include <xqserviceprovider.h>
+
+class HbDeviceDialog;
+
+
+class BtxqDutService : public XQServiceProvider
+{
+    Q_OBJECT
+    
+public:
+    BtxqDutService( QObject *parent = 0 );
+    ~BtxqDutService();
+
+public slots:
+    void activateDeviceTestMode();
+    
+public slots:
+    void dutModeActivated();
+    
+private:
+    HbDeviceDialog* mNotificationDialog;
+    int mCurrentRequestIndex;
+    int mError;
+};
+
+#endif /* BTXQDUTSERVICE_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btxqservice/inc/btxqpowerservice.h	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 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:  
+ *
+ */
+
+
+#ifndef BTXQPOWERSERVICE_H
+#define BTXQPOWERSERVICE_H
+
+#include <xqserviceprovider.h>
+#include <btserversdkcrkeys.h>
+#include <btengsettings.h>
+
+class HbDeviceDialog;
+
+
+class BtxqPowerService: public XQServiceProvider, public MBTEngSettingsObserver
+    {
+    Q_OBJECT
+    
+public:
+    BtxqPowerService(QObject *parent = 0);
+    ~BtxqPowerService();
+    
+public slots:
+    void togglePower();
+    void handleDialogClosed();
+    void handleDataReceived(QVariantMap data);
+    
+private:
+    void changeBtPowerMode(TBTPowerStateValue aNewPowerState);
+    bool checkOfflineMode();
+    void showBTStatusNotification(TBool powerState);
+    void showOfflineDialog();
+    
+private: // from MBTEngSettingsObserver
+    void PowerStateChanged( TBTPowerStateValue aState );
+    void VisibilityModeChanged( TBTVisibilityMode aState );
+    
+private:
+    //CBtToggleDi* mBtToggle;
+    CBTEngSettings* mSettings;
+    int mCurrentRequestIndex;
+    HbDeviceDialog* mNotificationDialog;
+    HbDeviceDialog* mOfflineDialog;
+    bool            mOfflineQueryShown;
+    };
+
+#endif 
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btxqservice/inc/btxqserviceapi.h	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,96 @@
+/*
+ * Copyright (c) 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: Bluetooth-services APIs through Qt Service Framework
+ *
+ */
+
+#ifndef BTXQSERVICEAPI_H
+#define BTXQSERVICEAPI_H
+
+#include <qstring.h>
+
+/*!
+ todo: this API may need to move to plat_ API folder of its destination package.
+ */
+
+/*!
+ The Bluetooth service name.
+ */
+static const QString BluetoothServiceName("btxqservice");
+
+/*!
+ The interface of showing the local Bluetooth device address in a dialog
+ */
+static const QString BluetoothInterfaceShowLocalAddress("com.nokia.symbian.IShowLocalDeviceAddress");
+
+/*!
+ The operation used for showing the local Bluetooth device address in a dialog
+ */
+static const QString BluetoothShowLocalAddress("showBTAddr()");
+
+/*!
+ The full service name of showing the local Bluetooth device address in a dialog
+ */
+static const QString BluetoothServiceShowLocalAddress = 
+        BluetoothServiceName + "." + BluetoothInterfaceShowLocalAddress;
+
+/*!
+ The interface of toggling Bluetooth power
+ */
+static const QString BluetoothInterfaceTogglePower("com.nokia.symbian.ITogglePower");
+
+/*!
+ The operation used for toggling the Bluetooth power
+ */
+static const QString BluetoothTogglePower("togglePower()");
+
+/*!
+ The full service name of toggling Bluetooth power
+ */
+static const QString BluetoothServiceTogglePower = 
+        BluetoothServiceName + "." + BluetoothInterfaceTogglePower;
+
+/*!
+ The interface of activating Bluetooth device test mode (DUT mode)
+ */
+static const QString BluetoothInterfaceActivateDutMode("com.nokia.symbian.IActivateDutMode");
+
+/*!
+ The operation used for activating the Bluetooth device test mode (DUT mode) 
+ */
+static const QString ActivateDutMode("activateDeviceTestMode()");
+
+/*!
+ The full service name of activating Bluetooth device test mode (DUT mode)
+ */
+static const QString BluetoothServiceActivateDutMode = 
+        BluetoothServiceName + "." + BluetoothInterfaceActivateDutMode;
+
+/*!
+ The interface of toggling Bluetooth SSP debug mode
+ */
+static const QString BluetoothInterfaceToggleSspDebugMode("com.nokia.symbian.IToggleSspDebugMode");
+
+/*!
+ The operation used for toggling the Bluetooth SSP debug mode 
+ */
+static const QString ToggleSspDebugMode("toggleSspDebugMode()");
+
+/*!
+ The full service name of toggling Bluetooth SSP debug mode
+ */
+static const QString BluetoothServiceToggleSspDebugMode = 
+        BluetoothServiceName + "." + BluetoothInterfaceToggleSspDebugMode;
+
+#endif // BTXQSERVICEAPI_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btxqservice/inc/btxqsspdebugservice.h	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,41 @@
+/*
+ * Copyright (c) 2009 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:  
+ *
+ */
+
+
+#ifndef BTXQSSPDEBUGSERVICE_H_
+#define BTXQSSPDEBUGSERVICE_H_
+
+#include <xqserviceprovider.h>
+
+
+class BtxqSspDebugService : public XQServiceProvider
+{
+    Q_OBJECT
+    
+public:
+    BtxqSspDebugService( QObject *parent = 0 );
+    ~BtxqSspDebugService();
+
+public slots:
+    void toggleSspDebugMode();
+    
+private:
+    int mCurrentRequestIndex;
+    int mError;
+};
+
+#endif /* BTXQSSPDEBUGSERVICE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btxqservice/rom/btxqservice.iby	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,25 @@
+/*
+ * Copyright (c) 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:  
+ *
+ */
+
+
+#ifndef BTXQSERVICE_IBY
+#define BTXQSERVICE_IBY
+
+file=ABI_DIR\UREL\btxqservice.exe               SHARED_LIB_DIR\btxqservice.exe
+data=DATAZ_\resource\apps\btxqservice.rsc                      resource\apps\btxqservice.rsc
+data=DATAZ_\private\10003a3f\import\apps\btxqservice_reg.rsc   private\10003a3f\import\apps\btxqservice_reg.rsc
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btxqservice/rom/btxqservice.pkg	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,36 @@
+;
+; Copyright (c) 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:  
+;
+;
+
+
+; Language
+&EN
+
+; SIS header: name, uid, version
+#{"btxqservice"},(0xE219A7EC),1,0,0
+
+; Localised Vendor name
+%{"Nokia, Qt Software"}
+
+; Unique Vendor name
+:"Nokia, Qt Software"
+
+; Executable and default resource files
+"/epoc32/release/armv5/urel/btxqservice.exe"    - "!:\sys\bin\btxqservice.exe"
+"/epoc32/data/z/resource/apps/btxqservice.rsc"    - "!:\resource\apps\btxqservice.rsc"
+"/epoc32/data/z/private/10003a3f/import/apps/btxqservice_reg.rsc"    - "!:\private\10003a3f\import\apps\btxqservice_reg.rsc"
+
+; Manual PKG post-rules from PRO files
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btxqservice/src/btxqaddrservice.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 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:  
+ *
+ */
+
+#include "btxqaddrservice.h"
+#include <btxqserviceapi.h>
+#include <bttypes.h>
+#include <bt_subscribe.h>
+#include <xqconversions.h>
+#include <hbapplication.h>
+#include <bluetoothdevicedialogs.h>
+#include <hbdevicedialog.h>
+
+const QString deviceDialogType = "com.nokia.hb.btdevicedialog/1.0";
+
+
+BtxqAddrService::BtxqAddrService(QObject* parent)
+: XQServiceProvider(BluetoothServiceShowLocalAddress, parent), mDialog(0), 
+mCurrentRequestIndex(0),
+mError(0)
+{
+    publishAll();
+    connect(this, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
+}
+
+BtxqAddrService::~BtxqAddrService()
+{
+    delete mDialog;    
+}
+
+void BtxqAddrService::showBTAddr()
+{
+    mCurrentRequestIndex = setCurrentRequestAsync();
+    
+    TBuf<KBTDevAddrSize * 3> btAddr;
+    TPckgBuf<TBTDevAddr> aDevAddrPckg;
+    // Get the local device's Bluetooth address
+    TInt err = RProperty::Get(KUidSystemCategory, 
+    KPropertyKeyBluetoothGetLocalDeviceAddress, aDevAddrPckg);
+ 
+    aDevAddrPckg().GetReadable(btAddr, KNullDesC, _L(":"), KNullDesC);
+    btAddr.UpperCase();
+    
+    mError = err;
+    
+    // Prepare and show the dialog.
+    if(!mDialog)
+        {
+        mDialog = new HbDeviceDialog();
+        }
+ 
+    connect(mDialog, SIGNAL(deviceDialogClosed()), this, SLOT(handleshowBTAddrCompleted()));
+    QVariantMap parameters;
+    
+    parameters.insert(QString::number(TBluetoothDialogParams::EDialogType), 
+          QString::number(TBluetoothDialogParams::EInformationDialog));
+    
+    parameters.insert(QString::number(TBluetoothDialogParams::EDialogTitle),
+          QString::number(TBluetoothDialogParams::EBTAddress));
+    
+    parameters.insert(QString::number(TBluetoothDeviceDialog::ELocalAddress),
+          XQConversions::s60DescToQString(btAddr));
+    
+    mDialog->show(deviceDialogType, parameters);    
+}
+
+void BtxqAddrService::handleshowBTAddrCompleted()
+{
+    // The dialog has been closed.
+    // Complete the service request.
+    QVariant retVal(mError);
+    completeRequest(mCurrentRequestIndex, retVal);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btxqservice/src/btxqdutservice.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,94 @@
+/*
+ * Copyright (c) 2009 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:  
+ *
+ */
+
+#include "btxqdutservice.h"
+#include <btxqserviceapi.h>
+#include <hbapplication.h>
+#include <hbdevicedialog.h>
+#include <bluetoothdevicedialogs.h>
+#include <btengdomainpskeys.h>
+#include <e32property.h>
+
+const QString deviceDialogType = "com.nokia.hb.btdevicedialog/1.0";
+
+
+BtxqDutService::BtxqDutService(QObject* parent)
+: XQServiceProvider(BluetoothServiceActivateDutMode,parent), mNotificationDialog(0), 
+  mCurrentRequestIndex(0),
+  mError(0)
+{
+    publishAll();
+    connect(this, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
+}
+
+BtxqDutService::~BtxqDutService()
+{
+    delete mNotificationDialog;
+}
+
+void BtxqDutService::activateDeviceTestMode()
+{
+    mCurrentRequestIndex = setCurrentRequestAsync();
+    
+    TInt currentDUTModeStatus( EBTDutOff );
+    
+    // Get current status of BT loopback
+    TInt err = RProperty::Get( KPSUidBluetoothDutMode, KBTDutEnabled, 
+            currentDUTModeStatus );
+    
+    // If the DUT mode is not already activated, activate it.
+    if ( currentDUTModeStatus == EBTDutOff && err == KErrNone )
+        {
+        err = RProperty::Set( KPSUidBluetoothDutMode,
+                KBTDutEnabled,
+                EBTDutOn );
+        }
+    
+    mError = err;
+    
+    if(!mError)
+        {
+        // Prepare and show the dialog.
+        if(!mNotificationDialog)
+            {
+            mNotificationDialog = new HbDeviceDialog();
+            }
+        
+        connect(mNotificationDialog, SIGNAL(deviceDialogClosed()), this, SLOT(dutModeActivated()));
+        QVariantMap parameters;
+        
+        parameters.insert(QString::number(TBluetoothDialogParams::EDialogType), 
+              QString::number(TBluetoothDialogParams::EGlobalNotif));
+        
+        parameters.insert(QString::number(TBluetoothDialogParams::EResource),
+                QString::number(EBluetoothTestMode));
+        
+        mNotificationDialog->show(deviceDialogType, parameters);    
+        }
+    else
+        {
+        // If there is an error in activating the DUT mode, complete the service request with error code.
+        dutModeActivated();
+        }
+}
+
+void BtxqDutService::dutModeActivated()
+{
+    // Completes the service request.
+    QVariant retVal(mError);
+    completeRequest(mCurrentRequestIndex, retVal);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btxqservice/src/btxqpowerservice.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,220 @@
+/*
+ * Copyright (c) 2009 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:  
+ *
+ */
+
+#include "btxqpowerservice.h"
+#include <btxqserviceapi.h>
+#include <bluetoothdevicedialogs.h>
+#include <hbapplication.h>
+#include <hbdevicedialog.h>
+#include <btnotif.h>
+
+const QString deviceDialogType = "com.nokia.hb.btdevicedialog/1.0";
+
+
+BtxqPowerService::BtxqPowerService(QObject *parent)
+: XQServiceProvider(BluetoothServiceTogglePower, parent),
+mSettings(0), mCurrentRequestIndex(0), mNotificationDialog(0), 
+mOfflineDialog(0), mOfflineQueryShown(false)
+{
+    publishAll();
+    connect(this, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
+}
+
+BtxqPowerService::~BtxqPowerService()
+{
+    delete mSettings;
+    delete mNotificationDialog;
+    delete mOfflineDialog;
+}
+
+void BtxqPowerService::togglePower()
+{
+    mCurrentRequestIndex = setCurrentRequestAsync();
+    
+    TRAPD(err, mSettings = CBTEngSettings::NewL(this));
+    if(err < 0)
+        {
+        // Error creating CBTEngSettings. Complete the service request with error.
+        QVariant retVal(err);
+        completeRequest(mCurrentRequestIndex, retVal);
+        return;
+        }
+    
+    // Get the current power state.
+    TBTPowerStateValue state; 
+    err = mSettings->GetPowerState(state);
+    if(err < 0)
+        {
+        // Error getting the current power state. Complete the service request with error.
+        QVariant retVal(err);
+        completeRequest(mCurrentRequestIndex, retVal);
+        return;
+        }
+    
+    if (EBTPowerOff == state)
+        {
+        // Bluetooth is currently turned off.
+        bool isInOffline = checkOfflineMode(); 
+        
+        if (isInOffline) 
+            {
+            // Device is in offline mode.
+            // Ask user if he/she wants Bluetooth to be turned on in offline mode.
+            showOfflineDialog();
+            }
+        
+        else 
+            {
+            // Device is not in offline mode.
+            // Turn Bluetooth on.
+            changeBtPowerMode(EBTPowerOn);
+            }               
+        }         
+    
+    else 
+        {  
+        // Bluetooth is currently turned on.
+        // Switch Bluetooth on.
+        changeBtPowerMode(EBTPowerOff);
+        }
+}
+
+void BtxqPowerService::changeBtPowerMode(TBTPowerStateValue aNewPowerState)
+{   
+    // Set the new Bluetooth power state.
+    TInt error = mSettings->SetPowerState(aNewPowerState);
+    if(error != KErrNone)
+        {
+        // Error setting the new Bluetooth power state.
+        // Complete the service request with error.
+        QVariant retVal(error);
+        completeRequest(mCurrentRequestIndex, retVal);
+        }
+}
+
+bool BtxqPowerService::checkOfflineMode()
+{
+    // Check if the device is in offline mode.
+    TCoreAppUIsNetworkConnectionAllowed offline = ECoreAppUIsNetworkConnectionAllowed;  
+    TBTEnabledInOfflineMode enabledInOffline; 
+    mSettings->GetOfflineModeSettings(offline, enabledInOffline); 
+    
+    //todo: Check if activation of Bluetooth is allowed in offline mode.
+    return !offline;  
+}
+
+void BtxqPowerService::showBTStatusNotification(TBool powerState)
+{
+    // Prepare new power state notification dialog.
+    if(!mNotificationDialog)
+        {
+        mNotificationDialog = new HbDeviceDialog();
+        }
+    
+    connect(mNotificationDialog, SIGNAL(deviceDialogClosed()), this, SLOT(handleDialogClosed()));
+    QVariantMap parameters;
+    
+    parameters.insert(QString::number(TBluetoothDialogParams::EDialogType), 
+          QString::number(TBluetoothDialogParams::EGlobalNotif));
+    
+    parameters.insert(QString::number(TBluetoothDialogParams::EResource),
+            QString::number(EGenericInfo));
+    
+    if(powerState)
+        {
+        // Show dialog with power on notification.
+        parameters.insert(QString::number(TBluetoothDeviceDialog::EAdditionalInt),
+              QString::number(EBTSwitchedOn));
+        }
+    else
+        {
+        // Show dialog with power off notification.
+        parameters.insert(QString::number(TBluetoothDeviceDialog::EAdditionalInt),
+              QString::number(EBTSwitchedOff));
+        }
+    
+    mNotificationDialog->show(deviceDialogType, parameters);    
+}
+
+void BtxqPowerService::showOfflineDialog()
+{
+    // Prepare and show the offline query dialog.
+    if(!mOfflineDialog)
+        {
+        mOfflineDialog = new HbDeviceDialog();
+        }
+    
+    connect(mOfflineDialog, SIGNAL(dataReceived(QVariantMap)), 
+          this, SLOT(handleDataReceived(QVariantMap)));
+    connect(mOfflineDialog, SIGNAL(deviceDialogClosed()), 
+          this, SLOT(handleDialogClosed()));
+    
+    QVariantMap parameters;
+    
+    parameters.insert(QString::number(TBluetoothDialogParams::EDialogType), 
+          QString::number(TBluetoothDialogParams::EInformationDialog));
+    
+    parameters.insert(QString::number(TBluetoothDialogParams::EDialogTitle),
+          QString::number(TBluetoothDialogParams::EOfflineQuery));
+    
+    mOfflineQueryShown = true;
+    mOfflineDialog->show(deviceDialogType, parameters);    
+}
+
+void BtxqPowerService::handleDialogClosed()
+{
+    // Handle the dialog closed.
+    if(mOfflineQueryShown)
+        {
+        mOfflineDialog->cancel();
+        mOfflineQueryShown = false;
+        changeBtPowerMode(EBTPowerOn);
+        }
+    else
+        {
+        QVariant retVal(0);
+        completeRequest(mCurrentRequestIndex, retVal);
+        }
+}
+
+void BtxqPowerService::handleDataReceived(QVariantMap data)
+{
+    // Handle the user selection in the dialog.
+    mOfflineDialog->cancel();
+    if(data.value(QString("actionResult")).toBool())
+        {
+        changeBtPowerMode(EBTPowerOn);
+        }
+    else
+        {
+        QVariant retVal(0);
+        completeRequest(mCurrentRequestIndex, retVal);
+        }
+}
+
+void BtxqPowerService::PowerStateChanged( TBTPowerStateValue aState )
+{
+    // Call-back from CBTEngSettings confirming the power change to the new power state.
+    (aState == EBTPowerOn) ? showBTStatusNotification(true) : showBTStatusNotification(false);
+}
+
+void BtxqPowerService::VisibilityModeChanged( TBTVisibilityMode aState )
+{
+    // This call-back is not used.
+    (void) aState;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btxqservice/src/btxqsspdebugservice.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 2009 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:  
+ *
+ */
+
+#include "btxqsspdebugservice.h"
+#include <btxqserviceapi.h>
+#include <hbapplication.h>
+#include <btengdomainpskeys.h>
+#include <e32property.h>
+
+
+BtxqSspDebugService::BtxqSspDebugService(QObject* parent)
+: XQServiceProvider(BluetoothServiceToggleSspDebugMode,parent),
+  mCurrentRequestIndex(0),
+  mError(0)
+{
+    publishAll();
+    connect(this, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
+}
+
+BtxqSspDebugService::~BtxqSspDebugService()
+{
+
+}
+
+void BtxqSspDebugService::toggleSspDebugMode()
+{
+    mCurrentRequestIndex = setCurrentRequestAsync();
+    
+    TInt sspDebugMode( EBTSspDebugModeOff );
+    
+    // Get current status
+    TInt err = RProperty::Get( KPSUidBluetoothDutMode, KBTSspDebugmode, 
+            sspDebugMode );
+    
+    if ( !err )
+        {
+        if( sspDebugMode == EBTDutOff )
+            {
+            // The Ssp debug mode is turned off, turn it on.
+            err = RProperty::Set( KPSUidBluetoothDutMode,
+                    KBTSspDebugmode,
+                    EBTSspDebugModeOn );
+            }
+        else
+            {
+            // The Ssp debug mode is turned on, turn it off.
+            err = RProperty::Set( KPSUidBluetoothDutMode,
+                    KBTSspDebugmode,
+                    EBTSspDebugModeOff );
+            }
+        }
+    
+    mError = err;
+    
+    // Complete the service request with error code, if any.
+    QVariant retVal(mError);
+    completeRequest(mCurrentRequestIndex, retVal);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btxqservice/src/main.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,44 @@
+/*
+ * Copyright (c) 2009 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:  
+ *
+ */
+
+
+#include <qcoreapplication.h>
+#include "btxqaddrservice.h"
+#include "btxqpowerservice.h"
+#include "btxqdutservice.h"
+#include "btxqsspdebugservice.h"
+
+
+int main(int argc, char **argv)
+{
+    QCoreApplication a( argc, argv );
+    
+    BtxqAddrService* btAddrService = new BtxqAddrService();
+    BtxqPowerService* btToggleService = new BtxqPowerService();
+    BtxqDutService* btDutService = new BtxqDutService();
+    BtxqSspDebugService* btSspDebugService = new BtxqSspDebugService();
+
+    int retVal = a.exec();
+    
+    delete btSspDebugService;
+    delete btDutService;
+    delete btToggleService;
+    delete btAddrService;
+    
+    return retVal;
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/bluetoothengine/btxqservice/xml/btxqservice_conf.xml	Fri Sep 03 16:17:59 2010 +0300
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<service name="btxqservice"  filepath="must-not-be-empty" >
+  <description>BT XQ services</description>
+  <interface name="com.nokia.symbian.IShowLocalDeviceAddress" version="1.0">
+    <description>Display the local Bluetooth device address</description>
+  </interface>
+  <interface name="com.nokia.symbian.ITogglePower" version="1.0">
+    <description>Toggle BT power state</description>
+  </interface>
+  <interface name="com.nokia.symbian.IActivateDutMode" version="1.0">
+  	<description>Activates the Device test mode (DUT)</description>
+  </interface>
+  <interface name="com.nokia.symbian.IToggleSspDebugMode" version="1.0">
+  	<description>Toggle the Bluetooth SSP debug mode</description>
+  </interface>
+</service>
\ No newline at end of file
--- a/btobexprofiles/inc/BTServiceParameterList.h	Fri Aug 06 16:43:21 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,239 +0,0 @@
-/*
-* 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:  Parameter list
-*
-*/
-
-
-#ifndef BT_SERVICE_PARAMETER_LIST_H
-#define BT_SERVICE_PARAMETER_LIST_H
-
-// INCLUDES
-#include <e32std.h>
-#include <badesca.h>    // CDesCArray
-#include <f32file.h>
-
-// CONSTANTS
-
-// DATA TYPES
-
-struct TBTSUXhtmlParam
-    {
-    TDesC* iFileName;
-    CDesCArray* iRefObjectList;
-    };
-
-struct TBTSUImageParam
-    {    
-    RFile   iFile; 
-    TDesC*  iDisplayName;
-    TDesC8* iMimeType;
-    TSize   iPixelSize;
-    TInt    iFileSize;    
-    TBool   iSend;
-    
-    };
-    
-
-// CLASS DECLARATION
-
-/**
-*  A class holding paths to different types of files. 
-*
-*  In case of an XHTML file the list collects paths 
-*  to objects referenced in the file.
-*
-*  In case of an image the list resolves the MIME types and
-*  displayable names of the images.
-*
-*  @lib BtServiceUtils.lib
-*  @since Series 60 2.6
-*/
-class CBTServiceParameterList : public CBase
-    {
-    public: // Constructors and destructor
-        
-        /**
-        * Two-phased constructor.
-        */
-        IMPORT_C static CBTServiceParameterList* NewL();
-        IMPORT_C static CBTServiceParameterList* NewLC();
-        
-        /**
-        * Destructor.
-        */
-        virtual ~CBTServiceParameterList();
-
-    public: // New functions
-
-        /**
-        * Adds an xhtml file path to the list.
-        * @since Series 60 2.6
-        * @param aFilePath A full path and file name.
-        * @return None.
-        */
-        IMPORT_C void AddXhtmlL( const TDesC& aFilePath );
-
-        /**
-        * Adds an image file path to the list.
-        * @since Series 60 2.6
-        * @param aFilePath A full path and file name.
-        * @return None.
-        */
-        IMPORT_C void AddImageL( const TDesC& aFilePath );
-        
-        /**
-        * Adds an image file path to the list.
-        * @since Series 60 2.6
-        * @param aFile file handle to be send.
-        * @return None.
-        */
-        IMPORT_C void AddImageL( RFile aFile );
-
-        /**
-        * Adds an object file path to the list.
-        * @since Series 60 2.6
-        * @param aFilePath A full path and file name.
-        * @return None.
-        */
-        IMPORT_C void AddObjectL( const TDesC& aFilePath );
-        
-        /**
-        * Adds an object file path to the list.
-        * @since Series 60 2.6
-        * @param aFile file handle to be send .
-        * @return None.
-        */
-        IMPORT_C void AddObjectL( RFile aFile );
-
-    public: // New functions (not exported)
-        
-        /**
-        * Return the number of xhtml file paths in the list.
-        * @return The count.
-        */
-        TInt XhtmlCount() const;
-
-        /**
-        * Return the number of image file paths in the list.
-        * @return The count.
-        */
-        TInt ImageCount() const;
-
-        /**
-        * Return the number of object file paths in the list.
-        * @return The count.
-        */
-        TInt ObjectCount() const;
-        
-        /**
-        * Returns a copy of an element of the list from the given index.
-        * @param aIndex The index.
-        * @return The element.
-        */
-        TBTSUXhtmlParam XhtmlAt( TInt aIndex ) const;
-
-        /**
-        * Returns a copy of an element of the list from the given index.
-        * @param aIndex The index.
-        * @return The element.
-        */
-        TBTSUImageParam ImageAtL( TInt aIndex ) const;
-
-        /**
-        * Returns a copy of an element of the list from the given index.
-        * @param aIndex The index.
-        * @return The element.
-        */
-        RFile& ObjectAtL( TInt aIndex );
-
-        /**
-        * Checks whether the list has any xhtml-files with referenced objects.
-        * @return A boolean according to result.
-        */
-        TBool HasAnyReferencedObjects() const;
-
-        /**
-        * Return the size of objects in the list.
-        * @return The count.
-        */
-        TInt ObjectListSizeL() const;
-        
-        /**
-        * Return the size of images in the list.
-        * @return The count.
-        */
-        
-        TInt ImageListSize() const;
-        
-        /**
-        * Remove image from list.
-        * @param aIndex The index.
-        * @return None.
-        */
-        void RemoveImageL(TInt aIndex);
-        
-        /**
-        * Return count of removed image        
-        * @return The count of removed images.
-        */
-        TInt RemovedImageCount();
-        
-        /**
-        * Reset image filehandle
-        * @param aIndex The index.
-        * @return None.
-        */
-        void ResetImageHandleL(TInt aIndex);
-        
-        /**
-        * Reset object filehandle
-        * @param aIndex The index.
-        * @return None.
-        */
-        void ResetObjectHandleL(TInt aIndex);  
-        
-        
-        /**
-        * Reset image filehandle
-        * @param aIndex The index.
-        * @return None.
-        */
-        void MarkAsSendL(TInt aIndex);        
-                
-
-    private:
-
-        /**
-        * C++ default constructor.
-        */
-        CBTServiceParameterList();
-
-        /**
-        * By default Symbian 2nd phase constructor is private.
-        */
-        void ConstructL();
-
-    private: // Data
-
-        RArray<TBTSUXhtmlParam> iXhtmlList;
-        RArray<TBTSUImageParam> iImageList;
-        RArray<RFile> iObjectList;
-        RFs iFileSession;        
-        TInt iRemovedImageCount;
-    };
-
-#endif      // BT_SERVICE_PARAMETER_LIST_H
-            
-// End of File
--- a/btobexprofiles/inc/btserviceapi.h	Fri Aug 06 16:43:21 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,105 +0,0 @@
-/*
-* 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:  API for sending services
-*
-*/
-
-
-
-#ifndef BT_SERVICE_API_H
-#define BT_SERVICE_API_H
-
-//  INCLUDES
-#include "BTServiceParameterList.h"
-
-// CONSTANTS
-
-// DATA TYPES
-
-enum TBTServiceType
-    {
-    EBTSendingService,
-    EBTPrintingService,
-    EBTObjectPushService // use this if support for only OPP is wanted
-    };
-
-// FORWARD DECLARATIONS
-class CBTServiceStarter;
-
-// CLASS DECLARATION
-
-/**
-*  An API for starting Bluetooth services.
-*
-*  @lib BtServiceUtils.lib
-*  @since Series 60 2.6
-*/
-class CBTServiceAPI : public CBase
-    {
-    public:  // Constructors and destructor
-        
-        /**
-        * Two-phased constructor.
-        */
-        IMPORT_C static CBTServiceAPI* NewL();
-        
-        /**
-        * Destructor.
-        */
-        virtual ~CBTServiceAPI();
-
-    public: // New functions
-        
-        /**
-        * Starts the given service.
-        * Returns when service is started.
-        * @since Series 60 2.6
-        * @param aService The service to be started.
-        * @param aList Parameters for the service.
-        * @return None.
-        */
-        IMPORT_C void StartServiceL( TBTServiceType aService, 
-                                     CBTServiceParameterList* aList );
-
-        /**
-        * Starts the given service.
-        * Returns when service is completed.
-        * @since Series 60 2.6
-        * @param aService The service to be started.
-        * @param aList Parameters for the service.
-        * @return None.
-        */
-        IMPORT_C void StartSynchronousServiceL( TBTServiceType aService, 
-                                     CBTServiceParameterList* aList );
-    private:
-
-        /**
-        * C++ default constructor.
-        */
-        CBTServiceAPI();
-
-        /**
-        * By default Symbian 2nd phase constructor is private.
-        */
-        void ConstructL();
-
-    private:    // Data
-
-        CBTServiceStarter*      iStarter;
-        CActiveSchedulerWait    iSyncWaiter;
-    };
-
-#endif      // BT_SERVICE_API_H
-            
-// End of File
--- a/btobexprofiles/inc/obexutilsdialog.h	Fri Aug 06 16:43:21 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,271 +0,0 @@
-/*
-* Copyright (c) 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: 
-*
-*/
-
-
-#ifndef COBEXUTILSDIALOG_H
-#define COBEXUTILSDIALOG_H
-
-#include    <e32base.h>
-
-#include <hbdeviceprogressdialogsymbian.h>
-#include <hbdevicedialogsymbian.h>
-#include <hbdevicemessageboxsymbian.h>
-#include <hbsymbianvariant.h>
-
-class CObexUtilsDialogTimer;
-
-enum TButtonId
-    {
-    ECancelButton = -1,
-    EYesButton,
-    ENoButton
-    };
-/**
-*  An observer interface for asking progress status of an operation using 
-*  a progress dialog.
-*/
-NONSHARABLE_CLASS(  MObexUtilsProgressObserver )
-    {
-    public:
-
-        /**
-        * Returns the progress status of the operation.
-        * @since 2.6
-        * @return A progress value relative to final value.
-        */
-        virtual TInt GetProgressStatus() = 0;
-    };
-
-// CLASS DECLARATION
-
-/**
-*  An observer interface for informing about dialog events.
-*/
-NONSHARABLE_CLASS(  MObexUtilsDialogObserver )
-    {
-    public:
-
-        /**
-        * Informs the observer that a dialog has been dismissed.
-        * @since 2.6
-        * todo check whether the parameter is required
-        * @param aButtonId The button that was used to dismiss the dialog.
-        */
-        virtual void DialogDismissed(TInt aButtonId) = 0; //TInt aButtonId
-    };
-
-
-// CLASS DECLARATION
-
-/**
-*  A class for launching and managing dialogs.
-*/
-NONSHARABLE_CLASS( CObexUtilsDialog ) : public CBase, 
-                                        public MHbDeviceProgressDialogObserver,
-                                        public MHbDeviceDialogObserver,
-                                        public MHbDeviceMessageBoxObserver
-    {
-    public:// Constructors and destructor
-
-        /**
-        * Two-phased constructor.
-        */
-        IMPORT_C static CObexUtilsDialog* NewL( 
-            MObexUtilsDialogObserver* aObserverPtr );        
-        
-        IMPORT_C static CObexUtilsDialog* NewLC( 
-            MObexUtilsDialogObserver* aObserverPtr );
-
-        /**
-        * Destructor.
-        */
-        virtual ~CObexUtilsDialog();
-   
-    public: // New functions
-        
-        
-        /**
-        * Launches a progress dialog.
-        * @param aObserverPtr A pointer to progress observer. A NULL pointer if 
-                              the progress dialog is updated manually.
-        * @param aFileCount Total number of files to be sent.
-        * @param aDeviceName Device Name to which files to be sent.
-        * @param aTimeoutValue A value telling how often should the dialog be
-                               updated. Relevant only if observer is given.
-        */
-        IMPORT_C void LaunchProgressDialogL( 
-            MObexUtilsProgressObserver* aObserverPtr, TInt aFileCount, 
-            const TDesC& aDeviceName, TInt aTimeoutValue );
-        
-        /**
-        * Updates the progress dialog with new file information when multiples files are sent.
-        * @param aFileSize Size of the file to be sent
-        * @param aFileIndex Index of the file to be sent
-        * @param aFileName Name of the file to be sent.
-        */
-        IMPORT_C void UpdateProgressNoteL( TInt aFileSize,TInt aFileIndex, const TDesC& aFileName );    
-        
-        /**
-        * Launches a wait dialog.
-        * @param aDisplayText Text that needs to be displayed.
-        */
-        IMPORT_C void LaunchWaitDialogL( const TDesC& aDisplayText );
-        
-        /**
-        * Cancels a wait dialog if one exists.
-        * @since 2.6        
-        * @return None.
-        */
-        IMPORT_C void CancelWaitDialog();
-        
-        /**
-        * Cancels a wait progress dialog if one exists.
-        * @since 2.6       
-        * @return None.
-        */
-        IMPORT_C void CancelProgressDialog();
-        
-        /**
-        * Updates a progress dialog with the latest progress value 
-        * @param aValue A progress value relative to final value.
-        * @return None
-        */
-        IMPORT_C void UpdateProgressDialogL( TInt aProgressValue );
-        
-        /**
-        * Show a query note
-        * @param aConfirmText text for the note.
-        * @return None		
-        */
-        IMPORT_C void LaunchQueryDialogL( const TDesC& aConfirmText );
-
-        /**
-        * Shows an error note.
-        * @param aTextId A resource id for the note.
-        * @return None.
-        */
-        IMPORT_C void ShowErrorNoteL( const TDesC& aErrorText );
-
-        /**
-        * Shows an information note.
-        * @param aTextId A resource id for the note.
-        * @return None.
-        */
-        IMPORT_C void ShowInformationNoteL( const TDesC& aInfoText );
-
-    public: // New functions (not exported)
-
-        /**
-        * Updates the progress dialog.
-        * @return None.
-        */
-        void UpdateProgressDialog();
-
-    private: // Functions from base classes
-        
-        /**
-        * From MHbDeviceProgressDialogObserver called when dialog is closed by pressing the "cancel" button
-        * @param aDialog Pointer to dialog that was cancelled.
-        * @return None.
-        */
-        void ProgressDialogCancelled(const CHbDeviceProgressDialogSymbian* aDialog);
-        
-        /**
-        * From MHbDeviceProgressDialogObserver called when a device progress dialog is has closed
-        * @param aDialog Pointer to dialog instance that has closed.
-        * @return None.
-        */
-        void ProgressDialogClosed(const CHbDeviceProgressDialogSymbian* aDialog )  ; 
-        
-        /**
-          * From MHbDeviceDialogObserver called when data is received from a device dialog
-          * @param aDialog Pointer to dialog instance that has closed.
-          * @return None.
-          */
-        void DataReceived(CHbSymbianVariantMap& aData);
-       
-        /**
-          * From MHbDeviceDialogObserver called when a device dialog is closed
-          * @param  aData contains data from the dialog plugin.
-          * @return None.
-          */
-         void DeviceDialogClosed(TInt aCompletionCode);
-        
-        /**
-        * from base class MHbDeviceMessageBoxObserver
-        * @param aMessageBox Pointer to dialog instance that has closed.
-        * @param aButton the id of the button the user pressed
-        */    
-        void  MessageBoxClosed(const CHbDeviceMessageBoxSymbian *aMessageBox, 
-                CHbDeviceMessageBoxSymbian::TButtonId aButton); 
-
-    private:
-
-        /**
-        * C++ default constructor.
-        */
-        CObexUtilsDialog( MObexUtilsDialogObserver* aObserverPtr );
-	
-        /**
-        * By default Symbian OS constructor is private.
-        */
-        void ConstructL();
-
-        /**
-         * Add a data item into the given CHbSymbianVariantMap.
-         * @param aMap the instance to which the data item will be added.
-         * @param aKey the key of the data item.
-         * @param aData the value of the data item
-         * @param aDataType the data-type of the data item
-         */
-        void AddDataL(CHbSymbianVariantMap* aMap, const TDesC& aKey, 
-                const TAny* aData, CHbSymbianVariant::TType aDataType);
-        
-        /**
-         * Creates and shows a message box.
-         * @param aType the type of the message box to create.
-         * @param aText the text to be shown in the message box
-         * @param aObserver the observer that receives the events from the 
-         *         message box
-         * @param aTimeout the timeout value of the message box 
-         */
-        CHbDeviceMessageBoxSymbian* CreateAndShowMessageBoxL(
-                CHbDeviceMessageBoxSymbian::TType aType,
-                const TDesC& aText, 
-                MHbDeviceMessageBoxObserver* aObserver,
-                TInt aTimeout );
-        
-    private: // Data
-
-        CHbDeviceDialogSymbian *iProgressDialog;
-        CHbDeviceProgressDialogSymbian* iWaitDialog;
-        CHbDeviceMessageBoxSymbian* iMessageBox;
-        
-        CObexUtilsDialogTimer*      iObexDialogTimer;
-        TInt                        iFileIndex;
-        TInt                        iFileCount;
-        RBuf                        iDeviceName;
-
-        // Not Owned
-        //
-        MObexUtilsProgressObserver* iProgressObserverPtr;
-        MObexUtilsDialogObserver*   iDialogObserverPtr;
-    };
-
-#endif      // COBEXUTILSDIALOG_H
-            
-// End of File
--- a/btobexprofiles/inc/obexutilspropertynotifier.h	Fri Aug 06 16:43:21 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,127 +0,0 @@
-/*
-* Copyright (c) 2004 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 disk status watcher class for ObexUtils.
-*
-*/
-
-
-
-#ifndef _OBEXUTILSPROPERTYNOTIFIER_H
-#define _OBEXUTILSPROPERTYNOTIFIER_H
-
-// INCLUDES
-#include <e32base.h>
-#include <e32property.h>
-#include <UikonInternalPSKeys.h>
-
-// CLASS DECLARATION
-
-	/**
-	Type of memory property check, 
-	@param  ECheckPhoneMemory, phone memory is checked, default value if not mentioned explicitly.	
-    @param  ECheckMMCMemory, MMC memory is checked.	
-	*/
-
-enum TMemoryPropertyCheckType
-	{
-	ECheckPhoneMemory,
-	ECheckMMCMemory
-	};
-
-	/**
-	A callback interface for informing content change of disk status. Client must derive 
-    from this class and implement HandleNotifyL() method. When disk space will cross warning
-    level or critical level this method will be call back.
-    */
-
-NONSHARABLE_CLASS(  MObexUtilsPropertyNotifyHandler )
-	{
-	public:
-        /**
-        * Callback method for disk status change
-        * @param aUid  UID identifying a shared data file where notify came from.
-        * @param aKey  keyword of which value was changed
-        */
-        virtual void HandleNotifyL( TMemoryPropertyCheckType aCheckType ) =0;
-	};
-
-NONSHARABLE_CLASS( CObexUtilsPropertyNotifier ) : public CActive
-	{
-public:  // NewL, Constructors and destructor
-
-    /*
-    * Two-phased constructor.
-    * @param aHandler -Pointer to the MObexUtilsPropertyNotifyHandler derived class
-    * @param aCheckType -Constant defining type of memory checking to be done (phone/MMC)
-    * @return CObexUtilsPropertyNotifier* -Initialized object.
-    */
-
-	IMPORT_C static CObexUtilsPropertyNotifier* NewL(
-	    MObexUtilsPropertyNotifyHandler* aHandler,
-	    TMemoryPropertyCheckType aCheckType=ECheckPhoneMemory );
-
-    /**
-    * Destructor.
-    */
-
-	virtual ~CObexUtilsPropertyNotifier();
-private:  // Functions from base classes
-
-    /**
-    * Constructor.
-    * @param aHandler -Pointer to the MObexUtilsPropertyNotifyHandler derived class
-    * @param aCheckType -Constant defining type of memory checking to be done (phone/MMC)
-    */
-
-	CObexUtilsPropertyNotifier(
-	    MObexUtilsPropertyNotifyHandler* aHandler,
-	    TMemoryPropertyCheckType aCheckType );
-
-	void ConstructL();
-
-	/**
-	Subscribes to a property and sets active
-	*/
-	void Subscribe();
-
-    /**
-    * From CActive Gets called when CActive::Cancel is called, 
-    *              cancels disk status watching.
-    *
-    * @param None.
-    * @return None.
-    */
-
-	void DoCancel();
-
-    /**
-    * From CActive Gets called when content of disk status is changed, 
-    *              calls MObexUtilsPropertyNotifyHandler::HandleNotify.
-    *
-    * @param None.
-    * @return None.
-    */
-
-	void RunL();
-
-private:
-	// Reference to observer
-	MObexUtilsPropertyNotifyHandler* iHandler;
-	// Type of memory check (phone/MMC)
-	TMemoryPropertyCheckType iCheckType;
-	// Database handle	
-	RProperty iProperty;
-	};
-
-#endif  // _OBEXUTILSPROPERTYNOTIFIER_H
--- a/btobexprofiles/obexreceiveservices/bip/group/obexservicebip.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexreceiveservices/bip/group/obexservicebip.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -39,7 +39,7 @@
 
 
 USERINCLUDE ../inc
-SYSTEMINCLUDE  ../../../inc ../../../../inc
+SYSTEMINCLUDE	../../../obexserviceman/utils/inc
 MW_LAYER_SYSTEMINCLUDE
 SYSTEMINCLUDE  /epoc32/include/mw/hb/hbcore
 SYSTEMINCLUDE  /epoc32/include/mw/hb/hbwidgets
--- a/btobexprofiles/obexreceiveservices/bip/inc/BIPController.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexreceiveservices/bip/inc/BIPController.h	Fri Sep 03 16:17:59 2010 +0300
@@ -30,7 +30,6 @@
 #include <obexutilspropertynotifier.h>
 #include <btengsettings.h>
 #include "btengdevman.h"
-#include <obexutilsdialog.h>
 #include <hbdevicedialogsymbian.h>
 #include <hbsymbianvariant.h>
 
@@ -58,8 +57,7 @@
 *  The main controller for Basic Imaging Profile.
 */
 NONSHARABLE_CLASS (CBIPController): public CSrcsInterface, public MObexServerNotify,
-                                    public MObexUtilsPropertyNotifyHandler, 
-                                    public MObexUtilsDialogObserver,
+                                    public MObexUtilsPropertyNotifyHandler,
                                     public MBTEngDevManObserver,
                                     public MHbDeviceDialogObserver
     {
@@ -94,9 +92,6 @@
 private: // from MBTEngDevManObserver
     void HandleGetDevicesComplete(TInt aErr, CBTDeviceArray* aDeviceArray);
     
-private: //from MObexUtilsDialogObserver
-    void DialogDismissed(TInt aButtonId);
-    
 private:
     CBIPController();
     void ConstructL();
@@ -118,6 +113,11 @@
     TBool IsBackupRunning();
     TBool ProcessExists( const TSecureId& aSecureId );
     
+    void LaunchFailureDialogL();
+    void LaunchMemoryFullDialogL(TInt aDrive);
+    void AddParamL(const TInt aKey, const TAny* aValue, 
+            CHbSymbianVariant::TType aValueType, CHbSymbianVariantMap& aVariantMap);
+    
 private:
     void DataReceived(CHbSymbianVariantMap& aData);
     void DeviceDialogClosed(TInt aCompletionCode);
@@ -161,13 +161,14 @@
     TBTDeviceName               iRemoteDeviceName;
     TFileName                   iReceivingFileName;
     TFileName                   iCenRepFolder;
-    CObexUtilsDialog*           iDialog;
     CHbDeviceDialogSymbian*     iProgressDialog;
     TBool                       iDialogActive;
     TInt                        iFileCount;
+    CHbDeviceDialogSymbian*     iFailureDialog;
     TBool                       iReceivingFailed;
     CHbDeviceDialogSymbian*     iRecvDoneDialog;
     TBool                       iShowRecvCompleteDialog;
+    CHbDeviceDialogSymbian*     iMemoryFullDailog;
     };
     
 _LIT(KBipPanicCategory, "BIP");
--- a/btobexprofiles/obexreceiveservices/bip/src/BIPController.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexreceiveservices/bip/src/BIPController.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -34,15 +34,14 @@
 #include    <msvids.h>
 #include    "debug.h"
 #include    <bluetoothdevicedialogs.h>
-#include <hbtextresolversymbian.h>
         
 // CONSTANTS
 _LIT8(KBipCapabilityType, "x-bt/img-capabilities\0");
 const TInt KFileManagerUID3 = 0x101F84EB; /// File Manager application UID3
 const TInt    KBufferSize = 0x10000;  // 64 kB
 _LIT( KBTDevDialogId, "com.nokia.hb.btdevicedialog/1.0" );
-_LIT(KLocFileName, "btdialogs_");
-_LIT(KPath, "z:/resource/qt/translations/");  
+const TInt KMaxDisplayFileName = 20; 
+const TInt KMinStringSize = 11;
 
 
 // ================= MEMBER FUNCTIONS =======================
@@ -78,12 +77,6 @@
     iResultArray = new(ELeave) CBTDeviceArray(1);
     // Get default folder from CenRep 
     TObexUtilsMessageHandler::GetCenRepKeyStringValueL(KCRUidBluetoothEngine, KLCReceiveFolder, iCenRepFolder);
-    iDialog = CObexUtilsDialog::NewL(this);
-    TBool ok = HbTextResolverSymbian::Init(KLocFileName, KPath);
-    if (!ok) 
-        {
-        User::Leave( KErrNotFound );
-        }
     TRACE_FUNC_EXIT
     }
 
@@ -108,9 +101,12 @@
         delete iResultArray;
         }
     iFs.Close();
-    delete iDialog;
+    
     delete iProgressDialog;
+    delete iFailureDialog;
     delete iRecvDoneDialog;
+    delete iMemoryFullDailog;
+    
     TRACE_FUNC_EXIT    
     }
 
@@ -144,17 +140,16 @@
     iShowRecvCompleteDialog = EFalse;
     if( iBTTransferState == ETransferPut || (!aAbort && iBTTransferState == ETransferPutDiskError) )
         {
+        CancelTransfer();
+
+        TRAP_IGNORE( 
+                    LaunchFailureDialogL();
+                );
+        
         if(iBTObject)
             {
             iBTObject->Reset();
             }
-        CancelTransfer();
-
-        TRAP_IGNORE( 
-                HBufC* note = HbTextResolverSymbian::LoadLC(_L("txt_bt_dpophead_receiving_failed"));
-                iDialog->ShowErrorNoteL(note->Des());
-                CleanupStack::PopAndDestroy(note); 
-                );
         } 
     delete iBuf;
     iBuf = NULL;
@@ -253,6 +248,20 @@
     TRACE_FUNC  
     if(!iReceivingFailed && iShowRecvCompleteDialog)
         {
+        TFileName shortname;
+        if ( iReceivingFileName.Length() > KMaxDisplayFileName ) 
+            {
+            // Filename is too long, 
+            // We make it shorter. Hiding the chars in the middle part of filename. 
+            shortname = iReceivingFileName.Mid(0,KMaxDisplayFileName/2);
+            shortname.Append(_L("..."));
+            shortname.Append(iReceivingFileName.Mid(iReceivingFileName.Length() - KMaxDisplayFileName/2, KMaxDisplayFileName/2));
+            }
+        else
+            {
+            shortname.Copy(iReceivingFileName);
+            }
+
         //Launch recevice completed dialog.
         iRecvDoneDialog = CHbDeviceDialogSymbian::NewL();
         iRecvDoneDialog->SetObserver(this);
@@ -261,46 +270,28 @@
         CleanupStack::PushL(variantMap);
         
         TInt dialogIdx = TBluetoothDialogParams::EReceiveDone;
-        CHbSymbianVariant* dialogType = CHbSymbianVariant::NewL( (TAny*) &(dialogIdx), 
-                                                            CHbSymbianVariant::EInt );
-        CleanupStack::PushL(dialogType);
-        TBuf16<6> dialogTypeKey;
-        dialogTypeKey.Num(TBluetoothDialogParams::EDialogType);
-        User::LeaveIfError(variantMap->Add(dialogTypeKey, dialogType));
-        CleanupStack::Pop(dialogType);
+        AddParamL(TBluetoothDialogParams::EDialogType, (TAny*) &dialogIdx,
+                CHbSymbianVariant::EInt, *variantMap);
         
-        CHbSymbianVariant* deviceName = CHbSymbianVariant::NewL( (TAny*) (&iRemoteDeviceName), 
-                                                            CHbSymbianVariant::EDes );
-        CleanupStack::PushL(deviceName);
-        TBuf16<6> deviceNameKey;
-        deviceNameKey.Num(TBluetoothDeviceDialog::EDeviceName);
-        User::LeaveIfError(variantMap->Add(deviceNameKey, deviceName));
-        CleanupStack::Pop(deviceName);
+        AddParamL(TBluetoothDeviceDialog::EDeviceName, (TAny*) &iRemoteDeviceName,
+                CHbSymbianVariant::EDes, *variantMap);
+        
+        AddParamL(TBluetoothDeviceDialog::EReceivingFileName, (TAny*) &shortname,
+                CHbSymbianVariant::EDes, *variantMap);
         
-        CHbSymbianVariant* fileName = CHbSymbianVariant::NewL( (TAny*) (&iReceivingFileName), 
-                                                            CHbSymbianVariant::EDes );
-        CleanupStack::PushL(fileName);
-        TBuf16<6> fileNameKey;
-        fileNameKey.Num(TBluetoothDeviceDialog::EReceivingFileName);
-        User::LeaveIfError(variantMap->Add(fileNameKey, fileName));
-        CleanupStack::Pop(fileName);
+        AddParamL(TBluetoothDeviceDialog::EReceivingFileSize, (TAny*) &iTotalSizeByte,
+                CHbSymbianVariant::EInt, *variantMap);
+        
+        AddParamL(TBluetoothDeviceDialog::EReceivedFileCount, (TAny*) &iFileCount,
+                CHbSymbianVariant::EInt, *variantMap);
         
-        CHbSymbianVariant* fileSz = CHbSymbianVariant::NewL( (TAny*) &iTotalSizeByte, 
-                                                            CHbSymbianVariant::EInt );
-        CleanupStack::PushL(fileSz);
-        TBuf16<6> fileSzKey;
-        fileSzKey.Num(TBluetoothDeviceDialog::EReceivingFileSize);
-        User::LeaveIfError(variantMap->Add(fileSzKey, fileSz));
-        CleanupStack::Pop(fileSz);
-        
-        CHbSymbianVariant* fileCnt = CHbSymbianVariant::NewL( (TAny*) &iFileCount, 
-                                                            CHbSymbianVariant::EInt );
-        CleanupStack::PushL(fileCnt);
-        TBuf16<6> fileCntKey;
-        fileCntKey.Num(TBluetoothDeviceDialog::EReceivedFileCount);
-        User::LeaveIfError(variantMap->Add(fileCntKey, fileCnt));
-        CleanupStack::Pop(fileCnt);
-        
+        TBuf<KMinStringSize> key(_L("OpenCnvView"));
+        TBool option = ETrue;
+        CHbSymbianVariant* value = CHbSymbianVariant::NewL( (TAny*) &option, CHbSymbianVariant::EBool );
+        CleanupStack::PushL(value);
+        variantMap->Add(key, value);
+        CleanupStack::Pop(value);
+
         iRecvDoneDialog->Show( KBTDevDialogId(), *variantMap, this );
         CleanupStack::PopAndDestroy(variantMap);
         
@@ -383,8 +374,9 @@
                 {
                 //TRAP_IGNORE(TObexUtilsUiLayer::ShowGlobalConfirmationQueryL(R_OUT_OF_MEMORY));
                 //todo: Need to use Localized string.
-                _LIT(KText, "Not enough memory to execute operation. Delete some documents and try again.");
-                TRAP_IGNORE(iDialog->ShowErrorNoteL(KText));
+                //_LIT(KText, "Not enough memory to execute operation. Delete some documents and try again.");
+                //TRAP_IGNORE(iDialog->ShowErrorNoteL(KText));
+                LaunchMemoryFullDialogL(iDrive);
     
                 return KErrDiskFull;
                 }
@@ -592,9 +584,10 @@
         {
         //TRAP_IGNORE(TObexUtilsUiLayer::ShowGlobalConfirmationQueryL(R_OUT_OF_MEMORY));
         //todo: Need to use Localized string.
-        _LIT(KText, "Not enough memory to execute operation. Delete some documents and try again.");
-        TRAP_IGNORE(iDialog->ShowErrorNoteL(KText));
-    
+        //_LIT(KText, "Not enough memory to execute operation. Delete some documents and try again.");
+        //TRAP_IGNORE(iDialog->ShowErrorNoteL(KText));
+        
+        LaunchMemoryFullDialogL(iDrive);
         User::Leave(KErrGeneral);
         }
     
@@ -831,6 +824,20 @@
         {
         if(iReceivingFileName.Length() > 0)
             {
+            TFileName shortname;
+            if ( iReceivingFileName.Length() > KMaxDisplayFileName ) 
+                {
+                // Filename is too long, 
+                // We make it shorter. Hiding the chars in the middle part of filename. 
+                shortname = iReceivingFileName.Mid(0,KMaxDisplayFileName/2);
+                shortname.Append(_L("..."));
+                shortname.Append(iReceivingFileName.Mid(iReceivingFileName.Length() - KMaxDisplayFileName/2, KMaxDisplayFileName/2));
+                }
+            else
+                {
+                shortname.Copy(iReceivingFileName);
+                }
+
             iProgressDialog = CHbDeviceDialogSymbian::NewL();
             iProgressDialog->SetObserver(this);
     
@@ -838,46 +845,21 @@
             CleanupStack::PushL(variantMap);
             
             TInt dialogIdx = TBluetoothDialogParams::EReceiveProgress;
-            CHbSymbianVariant* dialogType = CHbSymbianVariant::NewL( (TAny*) &(dialogIdx), 
-                                                                CHbSymbianVariant::EInt );
-            CleanupStack::PushL(dialogType);
-            TBuf16<6> dialogTypeKey;
-            dialogTypeKey.Num(TBluetoothDialogParams::EDialogType);
-            User::LeaveIfError(variantMap->Add(dialogTypeKey, dialogType));
-            CleanupStack::Pop(dialogType);
+            AddParamL(TBluetoothDialogParams::EDialogType, (TAny*) &dialogIdx, 
+                    CHbSymbianVariant::EInt, *variantMap);
             
-            CHbSymbianVariant* deviceName = CHbSymbianVariant::NewL( (TAny*) (&iRemoteDeviceName), 
-                                                                CHbSymbianVariant::EDes );
-            CleanupStack::PushL(deviceName);
-            TBuf16<6> deviceNameKey;
-            deviceNameKey.Num(TBluetoothDeviceDialog::EDeviceName);
-            User::LeaveIfError(variantMap->Add(deviceNameKey, deviceName));
-            CleanupStack::Pop(deviceName);
+            AddParamL(TBluetoothDeviceDialog::EDeviceName, (TAny*) &iRemoteDeviceName,
+                    CHbSymbianVariant::EDes, *variantMap);
             
-            CHbSymbianVariant* fileName = CHbSymbianVariant::NewL( (TAny*) (&iReceivingFileName), 
-                                                                CHbSymbianVariant::EDes );
-            CleanupStack::PushL(fileName);
-            TBuf16<6> fileNameKey;
-            fileNameKey.Num(TBluetoothDeviceDialog::EReceivingFileName);
-            User::LeaveIfError(variantMap->Add(fileNameKey, fileName));
-            CleanupStack::Pop(fileName);
+            AddParamL(TBluetoothDeviceDialog::EReceivingFileName, (TAny*) &shortname,
+                    CHbSymbianVariant::EDes, *variantMap);
             
-            CHbSymbianVariant* fileSz = CHbSymbianVariant::NewL( (TAny*) &iTotalSizeByte, 
-                                                                CHbSymbianVariant::EInt );
-            CleanupStack::PushL(fileSz);
-            TBuf16<6> fileSzKey;
-            fileSzKey.Num(TBluetoothDeviceDialog::EReceivingFileSize);
-            User::LeaveIfError(variantMap->Add(fileSzKey, fileSz));
-            CleanupStack::Pop(fileSz);
+            AddParamL(TBluetoothDeviceDialog::EReceivingFileSize, (TAny*) &iTotalSizeByte,
+                    CHbSymbianVariant::EInt, *variantMap);
             
-            CHbSymbianVariant* fileCnt = CHbSymbianVariant::NewL( (TAny*) &iFileCount, 
-                                                                CHbSymbianVariant::EInt );
-            CleanupStack::PushL(fileCnt);
-            TBuf16<6> fileCntKey;
-            fileCntKey.Num(TBluetoothDeviceDialog::EReceivedFileCount);
-            User::LeaveIfError(variantMap->Add(fileCntKey, fileCnt));
-            CleanupStack::Pop(fileCnt);
-        
+            AddParamL(TBluetoothDeviceDialog::EReceivedFileCount, (TAny*) &iFileCount,
+                    CHbSymbianVariant::EInt, *variantMap);
+
             iDialogActive = ETrue;
             iProgressDialog->Show( KBTDevDialogId(), *variantMap, this );
             CleanupStack::PopAndDestroy(variantMap);
@@ -911,7 +893,7 @@
         CleanupStack::PushL(progress);
         User::LeaveIfError(variantMap->Add(_L("progress"), progress));
         CleanupStack::Pop(progress);
-        
+
         iProgressDialog->Update(*variantMap);
         CleanupStack::PopAndDestroy(variantMap);
         }
@@ -1054,11 +1036,6 @@
      return EFalse;
      }
  
- void CBIPController::DialogDismissed(TInt aButtonId)
-     {
-     (void) aButtonId;
-     }
-
  void CBIPController::DataReceived(CHbSymbianVariantMap& aData)
      {
      if(aData.Keys().MdcaPoint(0).Compare(_L("actionResult")) == 0)
@@ -1086,6 +1063,8 @@
                  delete iRecvDoneDialog;
                  iRecvDoneDialog = NULL;
                  }break;
+             default:
+                 break;
              }
          }
      }
@@ -1095,7 +1074,94 @@
      (void) aCompletionCode;
      }
 
+ void CBIPController::LaunchFailureDialogL()
+     {
+     if(iFailureDialog)
+         {
+         iFailureDialog->Cancel();
+         delete iFailureDialog;
+         iFailureDialog = NULL;
+         }
+
+     iFailureDialog = CHbDeviceDialogSymbian::NewL();
+     
+     CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL();
+     CleanupStack::PushL(variantMap);
+     
+     TInt dialogIdx = TBluetoothDialogParams::EInformationDialog;
+     AddParamL(TBluetoothDialogParams::EDialogType, (TAny*) &dialogIdx,
+             CHbSymbianVariant::EInt, *variantMap);
+     
+     AddParamL(TBluetoothDeviceDialog::EDeviceName, (TAny*) &iRemoteDeviceName,
+             CHbSymbianVariant::EDes, *variantMap);
+     
+     TInt dialogTitleIdx = TBluetoothDialogParams::ERecvFailed;
+     AddParamL(TBluetoothDialogParams::EDialogTitle, (TAny*) &dialogTitleIdx,
+             CHbSymbianVariant::EInt, *variantMap);
+     
+     TUint32 deviceClass = iResultArray->At(0)->DeviceClass().DeviceClass();
+     AddParamL(TBluetoothDeviceDialog::EDeviceClass, (TAny*) &deviceClass,
+             CHbSymbianVariant::EInt, *variantMap);
+     
+     iFailureDialog->Show( KBTDevDialogId(), *variantMap );
+     CleanupStack::PopAndDestroy(variantMap);
+     
+     iReceivingFailed = EFalse;
+     }
  
-//////////////////////////// Global part ////////////////////////////
+ void CBIPController::LaunchMemoryFullDialogL(TInt aDrive)
+     {
+     if(iMemoryFullDailog)
+         {
+         iMemoryFullDailog->Cancel();
+         delete iMemoryFullDailog;
+         iMemoryFullDailog = NULL;
+         }
+
+     iMemoryFullDailog = CHbDeviceDialogSymbian::NewL();
+     
+     CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL();
+     CleanupStack::PushL(variantMap);
+     
+     TInt dialogIdx = TBluetoothDialogParams::EInformationDialog;
+     AddParamL(TBluetoothDialogParams::EDialogType, (TAny*) &dialogIdx,
+             CHbSymbianVariant::EInt, *variantMap);
+     
+     TInt dialogTitleIdx = TBluetoothDialogParams::EMemoryFull;
+     AddParamL(TBluetoothDialogParams::EDialogTitle, (TAny*) &dialogTitleIdx,
+             CHbSymbianVariant::EInt, *variantMap);
+     
+     TChar driveLetter;
+     iFs.DriveToChar(aDrive, driveLetter);
+     AddParamL(TBluetoothDeviceDialog::EDriveLetter, (TAny*) &driveLetter,
+             CHbSymbianVariant::EChar, *variantMap);
+     
+     TVolumeInfo volumeInfo;
+     iFs.Volume(volumeInfo, aDrive);
+     AddParamL(TBluetoothDeviceDialog::EDriveName, (TAny*) &(volumeInfo.iName),
+             CHbSymbianVariant::EDes, *variantMap);
+     
+     iMemoryFullDailog->Show( KBTDevDialogId(), *variantMap );
+     CleanupStack::PopAndDestroy(variantMap);
+     }
+
+ void CBIPController::AddParamL(const TInt aKey, const TAny* aValue, 
+         CHbSymbianVariant::TType aValueType,  CHbSymbianVariantMap& aVariantMap)
+     {
+     //Prepare the key
+     TBuf<KMinStringSize> key;
+     key.Num(aKey);
+     
+     //Prepare the value
+     CHbSymbianVariant* value = CHbSymbianVariant::NewL( aValue, aValueType );
+     CleanupStack::PushL(value);
+     
+     //add the key-value pair to the variant map
+     User::LeaveIfError(aVariantMap.Add(key, value));
+     
+     CleanupStack::Pop(value);
+     }
+ 
+ //////////////////////////// Global part ////////////////////////////
 
 //  End of File
--- a/btobexprofiles/obexreceiveservices/btmsgviewer/btmsgviewer.pro	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexreceiveservices/btmsgviewer/btmsgviewer.pro	Fri Sep 03 16:17:59 2010 +0300
@@ -38,12 +38,16 @@
 libFiles.sources = xqservice.dll
 SERVICE.OPTIONS = embeddable \
     hidden
-libFiles.path = "!:\sys\bin"
+libFiles.path = "!:/sys/bin"
 DEPLOYMENT += libFiles
 HEADERS += ./inc/btmsgviewer.h \
 		   ./inc/btmsgviewerutils.h 
 SOURCES += ./src/btmsgviewer.cpp \
     	   ./src/main.cpp \
     	   ./src/btmsgviewerutils.cpp
+INCLUDEPATH += $$MW_LAYER_SYSTEMINCLUDE \
+       ../inc \
+       /epoc32/include/platform/mw/btservices
+   
 BLD_INF_RULES.prj_exports += "$${LITERAL_HASH}include <platform_paths.hrh>" \
     "./rom/btmsgviewer.iby CORE_APP_LAYER_IBY_EXPORT_PATH(btmsgviewer.iby)"
--- a/btobexprofiles/obexreceiveservices/btmsgviewer/inc/btmsgviewer.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexreceiveservices/btmsgviewer/inc/btmsgviewer.h	Fri Sep 03 16:17:59 2010 +0300
@@ -25,6 +25,8 @@
 
 #include "btmsgviewerutils.h"
 
+class HbDeviceDialog;
+
 
 class BTMsgViewer : public XQServiceProvider
 {
@@ -36,14 +38,20 @@
     
 public slots:
     void displaymsg(int messageId);
+    
+private slots:
+    void handledialogClosed();
 
 private:
-    bool isError(int aError);
+    bool isError(int err);
     QString copyVCardToTemp(const QString& filepath);
     void deleteVCardFromTemp(const QString& filepath);
-    
+    void launchErrordDialog(int dialogTitle);
+        
 private:
     int mCurrentRequestIndex;
+    HbDeviceDialog* mDialog;
+    int mError;
 };
 
 #endif // BTMSGVIEWER_H
--- a/btobexprofiles/obexreceiveservices/btmsgviewer/inc/btmsgviewerutils.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexreceiveservices/btmsgviewer/inc/btmsgviewerutils.h	Fri Sep 03 16:17:59 2010 +0300
@@ -19,6 +19,8 @@
 #define BTMSGVIEWERUTILS_H_
 
 #include <msvapi.h>
+#include <bluetoothdevicedialogs.h>
+#include <hbdevicedialogsymbian.h>
 
 
 class CBtMsgViewerUtils: public CBase, public MMsvSessionObserver
@@ -26,7 +28,7 @@
 public:
     static CBtMsgViewerUtils* NewL();
     ~CBtMsgViewerUtils();
-    HBufC* GetMessagePath(TInt aMessageId, TInt aError);
+    HBufC* GetMessagePath(TInt aMessageId, TInt& aError);
     HBufC8* GetMimeType();
 
 private: // From MMsvSessionObserver
@@ -35,6 +37,7 @@
 private:
     void GetMessagePathL(TPtr aMsgPath, const TInt aMessageId);
     void StoreMessageMimeTypeL(TPtr aMsgPath);
+    void LaunchFailureDialogL(TInt aDialogTitle);
        
 private:
     CBtMsgViewerUtils();
--- a/btobexprofiles/obexreceiveservices/btmsgviewer/src/btmsgviewer.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexreceiveservices/btmsgviewer/src/btmsgviewer.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -25,20 +25,25 @@
 #include <QDir>
 #include <QFile>
 #include <hbapplication.h>
+#include <hbdevicedialog.h>
 
 const QString KMimeTypeVCard("text/X-vCard");
+const QString deviceDialogType = "com.nokia.hb.btdevicedialog/1.0";
 
 
 BTMsgViewer::BTMsgViewer(QObject* parent)
-: XQServiceProvider("com.nokia.services.btmsgdispservices.displaymsg", parent), mCurrentRequestIndex(0)
+: XQServiceProvider("com.nokia.services.btmsgdispservices.displaymsg", parent), 
+  mCurrentRequestIndex(0),
+  mDialog(0),
+  mError(0)
     {    
     publishAll();
-    connect(this, SIGNAL(returnValueDelivered()), qApp, SLOT(quit()));
+    connect(this, SIGNAL(clientDisconnected()), qApp, SLOT(quit()));
     }
 
-BTMsgViewer::~BTMsgViewer ()
+BTMsgViewer::~BTMsgViewer()
     {
-
+    delete mDialog;
     }
 
 void BTMsgViewer::displaymsg( int messageId )
@@ -46,28 +51,39 @@
     mCurrentRequestIndex = setCurrentRequestAsync(); 
     CBtMsgViewerUtils* btViewerUtils = 0;
     
-    TRAPD(error, btViewerUtils = CBtMsgViewerUtils::NewL());  
-    if(isError(error))
+    TRAP(mError, btViewerUtils = CBtMsgViewerUtils::NewL());  
+    if(isError(mError))
         {
         if(btViewerUtils)
             delete btViewerUtils;
         
-        QVariant retVal(error); 
+        QVariant retVal(mError); 
         completeRequest(mCurrentRequestIndex, retVal);
         return;
         }
         
     HBufC* fileName = 0;
-    fileName = btViewerUtils->GetMessagePath(messageId, error);
-    if(isError(error))
+    fileName = btViewerUtils->GetMessagePath(messageId, mError);
+    if( isError(mError))
         {
         if(fileName)
             delete fileName;
         
         delete btViewerUtils;
-        
-        QVariant retVal(error); 
-        completeRequest(mCurrentRequestIndex, retVal);
+
+        if(mError == KErrNotFound || mError == KErrPathNotFound)
+            {
+            launchErrordDialog(TBluetoothDialogParams::EFileMoved);
+            }
+        else if(mError == KErrNotReady)
+            {
+            launchErrordDialog(TBluetoothDialogParams::EDriveNotFound);
+            }
+        else
+            {
+            QVariant retVal(mError); 
+            completeRequest(mCurrentRequestIndex, retVal);
+            }
         return;
         }
     
@@ -78,7 +94,7 @@
     
     if(mimeType == KMimeTypeVCard)
         {
-        int error = KErrGeneral;
+        mError = KErrGeneral;
         
         /*todo: copyVCardToTemp() has to be removed when phonebook updates it's capabilites to
                 access messages from private folder*/
@@ -98,11 +114,11 @@
             bool res = request->send(retValue);
             if  (!res) 
                 {
-                error = request->lastError();
+                mError = request->lastError();
                 }
             else
                 {
-                error = retValue.toInt();
+                mError = retValue.toInt();
                 }
             
             delete request;
@@ -112,7 +128,7 @@
                 access messages from private folder*/        
         deleteVCardFromTemp(newfilepath);
         
-        QVariant retVal(error); 
+        QVariant retVal(mError); 
         completeRequest(mCurrentRequestIndex, retVal);
         return;
         }
@@ -157,7 +173,7 @@
     args << qVariantFromValue(sf);
     request->setArguments(args);
 
-    int err = KErrNone;
+    int err = 0;
     bool res = request->send();
     if  (!res) 
         {
@@ -173,9 +189,9 @@
     return;
     }
 
-bool BTMsgViewer::isError(int aError)
+bool BTMsgViewer::isError(int err)
     {
-    return ((aError < KErrNone)?true:false);
+    return ((err < 0)?true:false);
     }
 
 QString BTMsgViewer::copyVCardToTemp(const QString& filepath)
@@ -193,3 +209,28 @@
 {
     QFile::remove(filepath);
 }
+
+void BTMsgViewer::launchErrordDialog(int dialogTitle)
+{
+    if(!mDialog)
+        {
+        mDialog = new HbDeviceDialog();
+        }
+    
+    connect(mDialog, SIGNAL(deviceDialogClosed()), this, SLOT(handledialogClosed()));
+    QVariantMap parameters;
+    
+    parameters.insert(QString::number(TBluetoothDialogParams::EDialogType), 
+      QString::number(TBluetoothDialogParams::EInformationDialog));
+    
+    parameters.insert(QString::number(TBluetoothDialogParams::EDialogTitle),
+      QString::number(dialogTitle));
+    
+    mDialog->show(deviceDialogType, parameters);    
+}
+
+void BTMsgViewer::handledialogClosed()
+{
+    QVariant retVal(mError); 
+    completeRequest(mCurrentRequestIndex, retVal);
+}
--- a/btobexprofiles/obexreceiveservices/btmsgviewer/src/btmsgviewerutils.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexreceiveservices/btmsgviewer/src/btmsgviewerutils.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -17,9 +17,17 @@
 
 #include <mmsvattachmentmanager.h>
 #include <apgcli.h>
+#include <txtrich.h>
+#include <bioscmds.h>
+#include <biocmtm.h>
+#include <mtclreg.h>
+#include <hbsymbianvariant.h>
 #include "btmsgviewerutils.h"
 
 const TInt32 KUidMsgTypeBtTInt32 = 0x10009ED5;
+#define KBioUidValue  0x10001262
+const TUid KBioUidValueUid =
+{KBioUidValue};
 
     
 CBtMsgViewerUtils* CBtMsgViewerUtils::NewL()
@@ -47,10 +55,11 @@
         {
         delete iMsvSession;
         }
+    
     delete iMimeType;
     }
 
-HBufC* CBtMsgViewerUtils::GetMessagePath(TInt aMessageId, TInt aError)
+HBufC* CBtMsgViewerUtils::GetMessagePath(TInt aMessageId, TInt& aError)
     {
     HBufC* fileName = NULL;
     TRAP(aError, fileName = HBufC::NewL(KMaxPath));   
@@ -63,45 +72,104 @@
     return fileName;
     }
 
-void CBtMsgViewerUtils::GetMessagePathL(TPtr aMsgPath, const TInt aMessageId)
+void CBtMsgViewerUtils::GetMessagePathL(TPtr aMsgPath, const TInt aMessageId )
     {
     CMsvEntry* messageEntry = iMsvSession->GetEntryL(aMessageId);
-    CleanupStack::PushL(messageEntry); //1st push
+    CleanupStack::PushL(messageEntry);
     
     TMsvEntry entry = messageEntry->Entry();
     if(entry.MtmData1() == KUidMsgTypeBtTInt32)
         {
         CMsvStore* store = messageEntry->ReadStoreL();
-        CleanupStack::PushL(store); //2nd push
-
-        //get file handle for the attachment & the complete path of the file
+        CleanupStack::PushL(store);
+        
+        TInt attachmentCount = store->AttachmentManagerL().AttachmentCount();
         RFile attachmentFile;
-        attachmentFile = store->AttachmentManagerL().GetAttachmentFileL(0);
-        CleanupClosePushL(attachmentFile); //3rd push
-        User::LeaveIfError(attachmentFile.FullName(aMsgPath));
-        CleanupStack::PopAndDestroy(&attachmentFile);
-        StoreMessageMimeTypeL(aMsgPath);
-        
-        //mark attachment as Read
-        TMsvEntry attachEntry = messageEntry->Entry();
-        attachEntry.SetUnread(EFalse);
-        messageEntry->ChangeL(attachEntry);
-        
+        if(attachmentCount != 0)
+            {
+            //get file handle for the attachment & the complete path of the file
+            attachmentFile = store->AttachmentManagerL().GetAttachmentFileL(0);
+            CleanupClosePushL(attachmentFile);
+            User::LeaveIfError(attachmentFile.FullName(aMsgPath));
+            CleanupStack::PopAndDestroy(&attachmentFile);
+            StoreMessageMimeTypeL(aMsgPath);
+            
+            //mark attachment as Read
+            TMsvEntry attachEntry = messageEntry->Entry();
+            attachEntry.SetUnread(EFalse);
+            messageEntry->ChangeL(attachEntry);
+            }
+        else
+            {
+            CClientMtmRegistry* mtmReg = CClientMtmRegistry::NewL(*iMsvSession);
+            CleanupStack::PushL(mtmReg); //1st Push
+            
+            CBIOClientMtm* bioClientMtm = (CBIOClientMtm*) mtmReg->NewMtmL(KBioUidValueUid);
+            CleanupStack::PushL(bioClientMtm); //2nd Push
+            
+            bioClientMtm->SwitchCurrentEntryL(aMessageId);
+            
+            CMsvEntry* attachmentEntry = CMsvEntry::NewL(bioClientMtm->Session(),
+                                        aMessageId,
+                                        TMsvSelectionOrdering());
+            CleanupStack::PushL(attachmentEntry); //3rd Push
+            
+            bioClientMtm->LoadMessageL();
+    
+            CMsvEntrySelection* selection = new (ELeave) CMsvEntrySelection;
+            CleanupStack::PushL(selection); //4th Push
+    
+            selection->AppendL(aMessageId);
+    
+            TBuf8<1> aParameter;
+            CMsvOperationActiveSchedulerWait* wait = CMsvOperationActiveSchedulerWait::NewLC();
+            //5th Push
+    
+            CMsvOperation* operation = bioClientMtm->InvokeAsyncFunctionL(KBiosMtmParse, *selection,
+                aParameter, wait->iStatus);
+    
+            wait->Start();
+    
+            CMsvStore* store = attachmentEntry->ReadStoreL();
+            CleanupStack::PushL(store); //6th Push
+            MMsvAttachmentManager& attachMan = store->AttachmentManagerL();
+            
+            attachmentFile = attachMan.GetAttachmentFileL(0);
+            CleanupClosePushL(attachmentFile); //7th Push
+            User::LeaveIfError(attachmentFile.FullName(aMsgPath));
+            CleanupStack::PopAndDestroy(&attachmentFile);
+            StoreMessageMimeTypeL(aMsgPath);
+            
+            //mark attachment as Read
+            TMsvEntry attachEntry = attachmentEntry->Entry();
+            attachEntry.SetUnread(EFalse);
+            attachmentEntry->ChangeL(attachEntry);
+            
+            delete operation;
+            CleanupStack::PopAndDestroy(6);
+            }
         CleanupStack::PopAndDestroy(store);
-        CleanupStack::PopAndDestroy(messageEntry);
         }
     else
         {
         CMsvEntry* attachmentEntry = iMsvSession->GetEntryL((*messageEntry)[0].Id());
-        CleanupStack::PushL(attachmentEntry); //2nd push
+        CleanupStack::PushL(attachmentEntry); //1st push
             
         CMsvStore* store = attachmentEntry->ReadStoreL();
-        CleanupStack::PushL(store);  //3rd push
+        CleanupStack::PushL(store);  //2nd push
+        
+        TBuf<KMaxPath> attachmentName(store->AttachmentManagerL().GetAttachmentInfoL(0)->AttachmentName());
+        RFs fs;
+        User::LeaveIfError(fs.Connect());
+        CleanupClosePushL(fs);
+        TEntry entry;
+        User::LeaveIfError(fs.Entry(attachmentName, entry));
+        CleanupStack::PopAndDestroy(&fs);
         
         //get file handle for the attachment & the complete path of the file
         RFile attachmentFile;
         attachmentFile = store->AttachmentManagerL().GetAttachmentFileL(0);
-        CleanupClosePushL(attachmentFile);
+        CleanupClosePushL(attachmentFile); //3rd Push
         User::LeaveIfError(attachmentFile.FullName(aMsgPath));
         CleanupStack::PopAndDestroy(&attachmentFile);
         StoreMessageMimeTypeL(aMsgPath);
@@ -113,8 +181,8 @@
         
         CleanupStack::PopAndDestroy(store);
         CleanupStack::PopAndDestroy(attachmentEntry);
-        CleanupStack::PopAndDestroy(messageEntry);
         }
+    CleanupStack::PopAndDestroy(messageEntry);
     }
 
 void CBtMsgViewerUtils::HandleSessionEventL(TMsvSessionEvent aEvent, TAny* aArg1, 
--- a/btobexprofiles/obexreceiveservices/btmsgviewer/src/main.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexreceiveservices/btmsgviewer/src/main.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -25,7 +25,7 @@
 {
     HbApplication a( argc, argv );
     
-    BTMsgViewer* btmsgviewer = new BTMsgViewer();
+    QPointer<BTMsgViewer> btmsgviewer = new BTMsgViewer();
     
     int retVal = a.exec();
     delete btmsgviewer;
--- a/btobexprofiles/obexreceiveservices/mtmuibluetooth/group/btmtmui.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexreceiveservices/mtmuibluetooth/group/btmtmui.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -37,7 +37,8 @@
 
 SOURCEPATH      ../src
 USERINCLUDE     ../inc
-SYSTEMINCLUDE  ../../../inc ../../../../inc  
+SYSTEMINCLUDE	../../../obexserviceman/utils/inc
+
 SYSTEMINCLUDE /epoc32/include/mw/hb/hbwidgets
 SYSTEMINCLUDE  /epoc32/include/mw/hb/hbcore
 
--- a/btobexprofiles/obexreceiveservices/mtmuiinfrared/group/irmtmui.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexreceiveservices/mtmuiinfrared/group/irmtmui.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -37,7 +37,6 @@
 
 SOURCEPATH      ../src
 USERINCLUDE     ../inc
-SYSTEMINCLUDE  ../../../inc ../../../../inc  
 MW_LAYER_SYSTEMINCLUDE
 
 SOURCE          irmtmui.cpp 
--- a/btobexprofiles/obexreceiveservices/opp/group/obexserviceopp.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexreceiveservices/opp/group/obexserviceopp.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -36,7 +36,8 @@
 
 
 USERINCLUDE   ../inc
-SYSTEMINCLUDE  ../../../inc ../../../../inc  /epoc32/include/ecom
+SYSTEMINCLUDE	../../../obexserviceman/utils/inc
+SYSTEMINCLUDE  /epoc32/include/ecom
 MW_LAYER_SYSTEMINCLUDE
 SYSTEMINCLUDE  /epoc32/include/mw/hb/hbcore
 SYSTEMINCLUDE  /epoc32/include/mw/hb/hbwidgets
--- a/btobexprofiles/obexreceiveservices/opp/inc/oppcontroller.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexreceiveservices/opp/inc/oppcontroller.h	Fri Sep 03 16:17:59 2010 +0300
@@ -32,7 +32,6 @@
 
 #include <obexutilspropertynotifier.h>
 
-#include <obexutilsdialog.h>
 #include <hbdevicedialogsymbian.h>
 #include <hbsymbianvariant.h>
 
@@ -58,7 +57,6 @@
 */
 class COPPController : public CSrcsInterface, public MObexServerNotify, 
                        public MObexUtilsPropertyNotifyHandler,
-                       public MObexUtilsDialogObserver,
                        public MBTEngDevManObserver,
                        public MHbDeviceDialogObserver     
     {
@@ -93,9 +91,6 @@
 private: // from MBTEngDevManObserver
     void HandleGetDevicesComplete(TInt aErr, CBTDeviceArray* aDeviceArray);
     
-private: //from MObexUtilsDialogObserver
-    void DialogDismissed(TInt aButtonId);
-    
 private:
     COPPController();
     void ConstructL();
@@ -114,6 +109,11 @@
     TBool IsBackupRunning();
     TBool ProcessExists( const TSecureId& aSecureId );
     
+    void LaunchFailureDialogL();
+    void LaunchMemoryFullDialogL(TInt aDrive);
+    void AddParamL(const TInt aKey, const TAny* aValue, 
+            CHbSymbianVariant::TType aValueType, CHbSymbianVariantMap& aVariantMap);
+    
 private:
     void DataReceived(CHbSymbianVariantMap& aData);
     void DeviceDialogClosed(TInt aCompletionCode);
@@ -153,13 +153,14 @@
     CBTEngDevMan*               iDevMan;
     CBTDeviceArray*             iResultArray;
     TBTDeviceName               iRemoteDeviceName;
-    CObexUtilsDialog*           iDialog;
     CHbDeviceDialogSymbian*     iProgressDialog;
     TBool                       iDialogActive;
     TInt                        iFileCount;
+    CHbDeviceDialogSymbian*     iFailureDialog;
     TBool                       iReceivingFailed;
     CHbDeviceDialogSymbian*     iRecvDoneDialog;
     TBool                       iShowRecvCompleteDialog;
+    CHbDeviceDialogSymbian*     iMemoryFullDailog;
     };
 
 #endif      // OPPCONTROLLER_H
--- a/btobexprofiles/obexreceiveservices/opp/src/oppcontroller.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexreceiveservices/opp/src/oppcontroller.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -30,15 +30,14 @@
 #include    <es_sock.h>
 #include    <bt_sock.h>
 #include    <bluetoothdevicedialogs.h>
-#include <hbtextresolversymbian.h>
 
 // CONSTANTS
 
 const TInt    KBufferSize = 0x10000;  // 64 kB
 const TInt KFileManagerUID3 = 0x101F84EB; /// File Manager application UID3
 _LIT( KBTDevDialogId, "com.nokia.hb.btdevicedialog/1.0" );
-_LIT(KLocFileName, "btdialogs_");
-_LIT(KPath, "z:/resource/qt/translations/");  
+const TInt KMaxDisplayFileName = 20;
+const TInt KMinStringSize = 11;
 
 // ================= MEMBER FUNCTIONS =======================
 
@@ -69,12 +68,6 @@
     TObexUtilsMessageHandler::GetCenRepKeyStringValueL(KCRUidBluetoothEngine, 
                                                        KLCReceiveFolder,
                                                        iCenRepFolder);
-    iDialog = CObexUtilsDialog::NewL(this);
-    TBool ok = HbTextResolverSymbian::Init(KLocFileName, KPath);
-    if (!ok) 
-        {
-        User::Leave( KErrNotFound );
-        }
 	} 
 
 COPPController::~COPPController()
@@ -91,9 +84,11 @@
         delete iResultArray;
         }
     iFs.Close();
-    delete iDialog;
+
     delete iProgressDialog;
+    delete iFailureDialog;
     delete iRecvDoneDialog;
+    delete iMemoryFullDailog;
     }
 
 // ---------------------------------------------------------
@@ -122,25 +117,21 @@
     TRACE_ERROR((_L( "[oppreceiveservice] COPPController:HandleError" )));
     iReceivingFailed = ETrue;
     iShowRecvCompleteDialog = EFalse;
-    if( iObexTransferState == ETransferPut || iObexTransferState == ETransferPutDiskError )
+    if( iObexTransferState == ETransferPut || (!aAbort && iObexTransferState == ETransferPutDiskError) )
         {        
+        CancelTransfer();
+        if(iMediaType == ESrcsMediaBT)
+            {
+            TRAP_IGNORE(
+                    LaunchFailureDialogL();
+                    );
+            }
+        TRACE_ASSERT(iMediaType != ESrcsMediaIrDA, KErrNotSupported)
+
         if(iObexObject)
             {
             iObexObject->Reset();
             }
-        CancelTransfer();
-        if(!aAbort)
-        	{
-			if(iMediaType == ESrcsMediaBT)
-				{
-                TRAP_IGNORE(
-                        HBufC* note = HbTextResolverSymbian::LoadLC(_L("txt_bt_dpophead_receiving_failed"));
-                        iDialog->ShowErrorNoteL(note->Des());
-                        CleanupStack::PopAndDestroy(note);
-                        );
-				}
-			TRACE_ASSERT(iMediaType != ESrcsMediaIrDA, KErrNotSupported)
-        	}
         }
     delete iBuf;
     iBuf = NULL;
@@ -224,54 +215,50 @@
     TRACE_FUNC
     if(!iReceivingFailed && iShowRecvCompleteDialog)
         {
+        TFileName shortname;
+        if ( iReceivingFileName.Length() > KMaxDisplayFileName ) 
+            {
+            // Filename is too long, 
+            // We make it shorter. Hiding the chars in the middle part of filename. 
+            shortname = iReceivingFileName.Mid(0,KMaxDisplayFileName/2);
+            shortname.Append(_L("..."));
+            shortname.Append(iReceivingFileName.Mid(iReceivingFileName.Length() - KMaxDisplayFileName/2, KMaxDisplayFileName/2));
+            }
+        else
+            {
+            shortname.Copy(iReceivingFileName);
+            }
+
         //Launch recevice completed dialog.
         iRecvDoneDialog = CHbDeviceDialogSymbian::NewL();
         iRecvDoneDialog->SetObserver(this);
     
         CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL();
         CleanupStack::PushL(variantMap);
-        
+
         TInt dialogIdx = TBluetoothDialogParams::EReceiveDone;
-        CHbSymbianVariant* dialogType = CHbSymbianVariant::NewL( (TAny*) &(dialogIdx), 
-                                                            CHbSymbianVariant::EInt );
-        CleanupStack::PushL(dialogType);
-        TBuf16<6> dialogTypeKey;
-        dialogTypeKey.Num(TBluetoothDialogParams::EDialogType);
-        User::LeaveIfError(variantMap->Add(dialogTypeKey, dialogType));
-        CleanupStack::Pop(dialogType);
+        AddParamL(TBluetoothDialogParams::EDialogType, (TAny*) &dialogIdx,
+                CHbSymbianVariant::EInt, *variantMap);
         
-        CHbSymbianVariant* deviceName = CHbSymbianVariant::NewL( (TAny*) (&iRemoteDeviceName), 
-                                                            CHbSymbianVariant::EDes );
-        CleanupStack::PushL(deviceName);
-        TBuf16<6> deviceNameKey;
-        deviceNameKey.Num(TBluetoothDeviceDialog::EDeviceName);
-        User::LeaveIfError(variantMap->Add(deviceNameKey, deviceName));
-        CleanupStack::Pop(deviceName);
+        AddParamL(TBluetoothDeviceDialog::EDeviceName, (TAny*) &iRemoteDeviceName,
+                CHbSymbianVariant::EDes, *variantMap);
+        
+        AddParamL(TBluetoothDeviceDialog::EReceivingFileName, (TAny*) &shortname,
+                CHbSymbianVariant::EDes, *variantMap);
         
-        CHbSymbianVariant* fileName = CHbSymbianVariant::NewL( (TAny*) (&iReceivingFileName), 
-                                                            CHbSymbianVariant::EDes );
-        CleanupStack::PushL(fileName);
-        TBuf16<6> fileNameKey;
-        fileNameKey.Num(TBluetoothDeviceDialog::EReceivingFileName);
-        User::LeaveIfError(variantMap->Add(fileNameKey, fileName));
-        CleanupStack::Pop(fileName);
+        AddParamL(TBluetoothDeviceDialog::EReceivingFileSize, (TAny*) &iTotalSizeByte,
+                CHbSymbianVariant::EInt, *variantMap);
         
-        CHbSymbianVariant* fileSz = CHbSymbianVariant::NewL( (TAny*) &iTotalSizeByte, 
-                                                            CHbSymbianVariant::EInt );
-        CleanupStack::PushL(fileSz);
-        TBuf16<6> fileSzKey;
-        fileSzKey.Num(TBluetoothDeviceDialog::EReceivingFileSize);
-        User::LeaveIfError(variantMap->Add(fileSzKey, fileSz));
-        CleanupStack::Pop(fileSz);
-        
-        CHbSymbianVariant* fileCnt = CHbSymbianVariant::NewL( (TAny*) &iFileCount, 
-                                                            CHbSymbianVariant::EInt );
-        CleanupStack::PushL(fileCnt);
-        TBuf16<6> fileCntKey;
-        fileCntKey.Num(TBluetoothDeviceDialog::EReceivedFileCount);
-        User::LeaveIfError(variantMap->Add(fileCntKey, fileCnt));
-        CleanupStack::Pop(fileCnt);
-        
+        AddParamL(TBluetoothDeviceDialog::EReceivedFileCount, (TAny*) &iFileCount,
+                CHbSymbianVariant::EInt, *variantMap);
+
+        TBuf<KMinStringSize> key(_L("OpenCnvView"));
+        TBool option = ETrue;
+        CHbSymbianVariant* value = CHbSymbianVariant::NewL( (TAny*) &option, CHbSymbianVariant::EBool );
+        CleanupStack::PushL(value);
+        variantMap->Add(key, value);
+        CleanupStack::Pop(value);
+
         iRecvDoneDialog->Show( KBTDevDialogId(), *variantMap, this );
         CleanupStack::PopAndDestroy(variantMap);
         iShowRecvCompleteDialog = EFalse;
@@ -349,11 +336,8 @@
             }
         if(!capacity)
             {
-            //TRAP_IGNORE(TObexUtilsUiLayer::ShowGlobalConfirmationQueryL(R_OUT_OF_MEMORY));
-            //todo: Need to use Localized string.
-            _LIT(KText, "Not enough memory to execute operation. Delete some documents and try again.");
-            TRAP_IGNORE(iDialog->ShowErrorNoteL(KText));
-    
+            LaunchMemoryFullDialogL(iDrive);
+            
             return KErrDiskFull;
             }
         }
@@ -517,10 +501,7 @@
     //
     if (SysUtil::DiskSpaceBelowCriticalLevelL( &iFs, 0, iDrive ))
         {
-        //TRAP_IGNORE(TObexUtilsUiLayer::ShowGlobalConfirmationQueryL(R_OUT_OF_MEMORY));
-        //todo: Need to use Localized string.
-        _LIT(KText, "Not enough memory to execute operation. Delete some documents and try again.");
-        TRAP_IGNORE(iDialog->ShowErrorNoteL(KText));
+        LaunchMemoryFullDialogL(iDrive);
     
         User::Leave(KErrGeneral);
         }
@@ -786,53 +767,42 @@
         {
         if(iReceivingFileName.Length() > 0)
             {
+            TFileName shortname;
+            if ( iReceivingFileName.Length() > KMaxDisplayFileName ) 
+                {
+                // Filename is too long, 
+                // We make it shorter. Hiding the chars in the middle part of filename. 
+                shortname = iReceivingFileName.Mid(0,KMaxDisplayFileName/2);
+                shortname.Append(_L("..."));
+                shortname.Append(iReceivingFileName.Mid(iReceivingFileName.Length() - KMaxDisplayFileName/2, KMaxDisplayFileName/2));
+                }
+            else
+                {
+                shortname.Copy(iReceivingFileName);
+                }
+
             iProgressDialog = CHbDeviceDialogSymbian::NewL();
             iProgressDialog->SetObserver(this);
 
             CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL();
             CleanupStack::PushL(variantMap);
-            
+
             TInt dialogIdx = TBluetoothDialogParams::EReceiveProgress;
-            CHbSymbianVariant* dialogType = CHbSymbianVariant::NewL( (TAny*) &(dialogIdx), 
-                                                                CHbSymbianVariant::EInt );
-            CleanupStack::PushL(dialogType);
-            TBuf16<6> dialogTypeKey;
-            dialogTypeKey.Num(TBluetoothDialogParams::EDialogType);
-            User::LeaveIfError(variantMap->Add(dialogTypeKey, dialogType));
-            CleanupStack::Pop(dialogType);
+            AddParamL(TBluetoothDialogParams::EDialogType, (TAny*) &dialogIdx, 
+                    CHbSymbianVariant::EInt, *variantMap);
             
-            CHbSymbianVariant* deviceName = CHbSymbianVariant::NewL( (TAny*) (&iRemoteDeviceName), 
-                                                                CHbSymbianVariant::EDes );
-            CleanupStack::PushL(deviceName);
-            TBuf16<6> deviceNameKey;
-            deviceNameKey.Num(TBluetoothDeviceDialog::EDeviceName);
-            User::LeaveIfError(variantMap->Add(deviceNameKey, deviceName));
-            CleanupStack::Pop(deviceName);
+            AddParamL(TBluetoothDeviceDialog::EDeviceName, (TAny*) &iRemoteDeviceName,
+                    CHbSymbianVariant::EDes, *variantMap);
             
-            CHbSymbianVariant* fileName = CHbSymbianVariant::NewL( (TAny*) (&iReceivingFileName), 
-                                                                CHbSymbianVariant::EDes );
-            CleanupStack::PushL(fileName);
-            TBuf16<6> fileNameKey;
-            fileNameKey.Num(TBluetoothDeviceDialog::EReceivingFileName);
-            User::LeaveIfError(variantMap->Add(fileNameKey, fileName));
-            CleanupStack::Pop(fileName);
+            AddParamL(TBluetoothDeviceDialog::EReceivingFileName, (TAny*) &shortname,
+                    CHbSymbianVariant::EDes, *variantMap);
             
-            CHbSymbianVariant* fileSz = CHbSymbianVariant::NewL( (TAny*) &iTotalSizeByte, 
-                                                                CHbSymbianVariant::EInt );
-            CleanupStack::PushL(fileSz);
-            TBuf16<6> fileSzKey;
-            fileSzKey.Num(TBluetoothDeviceDialog::EReceivingFileSize);
-            User::LeaveIfError(variantMap->Add(fileSzKey, fileSz));
-            CleanupStack::Pop(fileSz);
+            AddParamL(TBluetoothDeviceDialog::EReceivingFileSize, (TAny*) &iTotalSizeByte,
+                    CHbSymbianVariant::EInt, *variantMap);
             
-            CHbSymbianVariant* fileCnt = CHbSymbianVariant::NewL( (TAny*) &iFileCount, 
-                                                                CHbSymbianVariant::EInt );
-            CleanupStack::PushL(fileCnt);
-            TBuf16<6> fileCntKey;
-            fileCntKey.Num(TBluetoothDeviceDialog::EReceivedFileCount);
-            User::LeaveIfError(variantMap->Add(fileCntKey, fileCnt));
-            CleanupStack::Pop(fileCnt);
-            
+            AddParamL(TBluetoothDeviceDialog::EReceivedFileCount, (TAny*) &iFileCount,
+                    CHbSymbianVariant::EInt, *variantMap);
+
             iDialogActive = ETrue;
             iProgressDialog->Show( KBTDevDialogId(), *variantMap, this );
             CleanupStack::PopAndDestroy(variantMap);
@@ -1019,11 +989,6 @@
      return EFalse;
      }
  
- void COPPController::DialogDismissed(TInt aButtonId)
-     {
-     (void) aButtonId;
-     }
-
  void COPPController::DataReceived(CHbSymbianVariantMap& aData)
      {
      if(aData.Keys().MdcaPoint(0).Compare(_L("actionResult")) == 0)
@@ -1051,6 +1016,8 @@
                  delete iRecvDoneDialog;
                  iRecvDoneDialog = NULL;
                  }break;
+             default:
+                 break;
              }
          }
      }
@@ -1059,7 +1026,95 @@
      {
      (void) aCompletionCode;
      }
+ 
+ void COPPController::LaunchFailureDialogL()
+     {
+     if(iFailureDialog)
+         {
+         iFailureDialog->Cancel();
+         delete iFailureDialog;
+         iFailureDialog = NULL;
+         }
 
-//////////////////////////// Global part ////////////////////////////
+     iFailureDialog = CHbDeviceDialogSymbian::NewL();
+     
+     CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL();
+     CleanupStack::PushL(variantMap);
+
+     TInt dialogIdx = TBluetoothDialogParams::EInformationDialog;
+     AddParamL(TBluetoothDialogParams::EDialogType, (TAny*) &dialogIdx,
+             CHbSymbianVariant::EInt, *variantMap);
+     
+     AddParamL(TBluetoothDeviceDialog::EDeviceName, (TAny*) &iRemoteDeviceName,
+             CHbSymbianVariant::EDes, *variantMap);
+     
+     TInt dialogTitleIdx = TBluetoothDialogParams::ERecvFailed;
+     AddParamL(TBluetoothDialogParams::EDialogTitle, (TAny*) &dialogTitleIdx,
+             CHbSymbianVariant::EInt, *variantMap);
+     
+     TUint32 deviceClass = iResultArray->At(0)->DeviceClass().DeviceClass();
+     AddParamL(TBluetoothDeviceDialog::EDeviceClass, (TAny*) &deviceClass,
+             CHbSymbianVariant::EInt, *variantMap);
+     
+     iFailureDialog->Show( KBTDevDialogId(), *variantMap );
+     CleanupStack::PopAndDestroy(variantMap);
+     
+     iReceivingFailed = EFalse;
+     }
+ 
+ void COPPController::LaunchMemoryFullDialogL(TInt aDrive)
+     {
+     if(iMemoryFullDailog)
+         {
+         iMemoryFullDailog->Cancel();
+         delete iMemoryFullDailog;
+         iMemoryFullDailog = NULL;
+         }
+
+     iMemoryFullDailog = CHbDeviceDialogSymbian::NewL();
+     
+     CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL();
+     CleanupStack::PushL(variantMap);
 
+     TInt dialogIdx = TBluetoothDialogParams::EInformationDialog;
+     AddParamL(TBluetoothDialogParams::EDialogType, (TAny*) &dialogIdx,
+             CHbSymbianVariant::EInt, *variantMap);
+     
+     TInt dialogTitleIdx = TBluetoothDialogParams::EMemoryFull;
+     AddParamL(TBluetoothDialogParams::EDialogTitle, (TAny*) &dialogTitleIdx,
+             CHbSymbianVariant::EInt, *variantMap);
+     
+     TChar driveLetter;
+     iFs.DriveToChar(aDrive, driveLetter);
+     AddParamL(TBluetoothDeviceDialog::EDriveLetter, (TAny*) &driveLetter,
+             CHbSymbianVariant::EChar, *variantMap);
+     
+     TVolumeInfo volumeInfo;
+     iFs.Volume(volumeInfo, aDrive);
+     AddParamL(TBluetoothDeviceDialog::EDriveName, (TAny*) &(volumeInfo.iName),
+             CHbSymbianVariant::EDes, *variantMap);
+     
+     iMemoryFullDailog->Show( KBTDevDialogId(), *variantMap );
+     CleanupStack::PopAndDestroy(variantMap);
+     }
+
+ void COPPController::AddParamL(const TInt aKey, const TAny* aValue, 
+         CHbSymbianVariant::TType aValueType,  CHbSymbianVariantMap& aVariantMap)
+     {
+     //Prepare the key
+     TBuf<KMinStringSize> key;
+     key.Num(aKey);
+     
+     //Prepare the value
+     CHbSymbianVariant* value = CHbSymbianVariant::NewL( aValue, aValueType );
+     CleanupStack::PushL(value);
+     
+     //add the key-value pair to the variant map
+     User::LeaveIfError(aVariantMap.Add(key, value));
+     
+     CleanupStack::Pop(value);
+     }
+
+ //////////////////////////// Global part ////////////////////////////
+ 
 //  End of File  
--- a/btobexprofiles/obexsendservices/group/bld.inf	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexsendservices/group/bld.inf	Fri Sep 03 16:17:59 2010 +0300
@@ -23,8 +23,7 @@
 
 
 PRJ_EXPORTS
-../obexservicesendutils/inc/BTServiceAPI.h           |../../inc/btserviceapi.h
-../obexservicesendutils/inc/BTServiceParameterList.h |../../inc/BTServiceParameterList.h
+
 ../rom/obexservicesendutils.iby                      CORE_MW_LAYER_IBY_EXPORT_PATH(obexservicesendutils.iby)
 
 PRJ_MMPFILES
--- a/btobexprofiles/obexsendservices/group/sendutils.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexsendservices/group/sendutils.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -49,7 +49,8 @@
 SOURCE          BTSController.cpp
 
 USERINCLUDE     ../obexservicesendutils/inc
-SYSTEMINCLUDE  ../../inc /epoc32/include/libc
+SYSTEMINCLUDE	../../obexserviceman/utils/inc
+SYSTEMINCLUDE  /epoc32/include/libc
 SYSTEMINCLUDE  /epoc32/include/mw/hb/hbcore
 SYSTEMINCLUDE  /epoc32/include/mw/hb/hbwidgets
 MW_LAYER_SYSTEMINCLUDE
--- a/btobexprofiles/obexsendservices/obexhighway/obexhighway.pro	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexsendservices/obexhighway/obexhighway.pro	Fri Sep 03 16:17:59 2010 +0300
@@ -32,7 +32,7 @@
     src/btsendserviceprovider.cpp
 
     
-INCLUDEPATH += . ../../inc
+INCLUDEPATH += . ../obexservicesendutils/inc
 
 SERVICE.FILE = xml/obexhighway_conf.xml
 SERVICE.OPTIONS = embeddable \
--- a/btobexprofiles/obexsendservices/obexhighway/src/btsendserviceprovider.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexsendservices/obexhighway/src/btsendserviceprovider.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -17,7 +17,7 @@
 
 
 #include "btsendserviceprovider.h"
-#include <btserviceapi.h>
+#include <BTServiceAPI.h>
 #include "btsssendlisthandler.h"
 #include <btfeaturescfg.h>  // For Enterprise security settings
 #include <btnotif.h>    // For Enterprise security notifier
--- a/btobexprofiles/obexsendservices/obexhighway/src/btsssendlisthandler.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexsendservices/obexhighway/src/btsssendlisthandler.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -19,7 +19,7 @@
 
 
 #include "btsssendlisthandler.h"
-#include "BTServiceParameterList.h"
+#include <BTServiceParameterList.h>
 
 #include <xqconversions.h>
 
--- a/btobexprofiles/obexsendservices/obexhighway/xml/obexhighway_conf.xml	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexsendservices/obexhighway/xml/obexhighway_conf.xml	Fri Sep 03 16:17:59 2010 +0300
@@ -1,14 +1,14 @@
-<?xml version="1.0" encoding="utf-8" ?>  
+<?xml version="1.0" encoding="utf-8"?>
 <service>
   <name>obexhighway</name>
   <filepath>No path</filepath>
   <description>BT Send Service</description>
   <interface>
-     <name>com.nokia.symbian.IFileShare</name>
-     <version>1.0</version>
-     <description>Send interface</description>
-     <customproperty key="txt_aiw_action_text">Via Bluetooth</customproperty>
-    <customproperty key="aiw_action_text_file">bluetooth</customproperty>
-    <customproperty key="aiw_action_text">txt_send_via_bluetooth</customproperty>
+    <name>com.nokia.symbian.IFileShare</name>
+    <version>1.0</version>
+    <description>Send interface</description>
+    <customproperty key="aiw_action_text_file">share</customproperty>
+    <customproperty key="aiw_action_text">txt_share_dblist_bluetooth</customproperty>
+    <customproperty key="aiw_action_icon">qtg_large_bluetooth</customproperty>
   </interface>
 </service>
\ No newline at end of file
--- a/btobexprofiles/obexsendservices/obexservicesendutils/inc/BTServiceStarter.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexsendservices/obexservicesendutils/inc/BTServiceStarter.h	Fri Sep 03 16:17:59 2010 +0300
@@ -115,7 +115,8 @@
                           public MObexUtilsDialogObserver,
                           public MObexUtilsProgressObserver,
                           public MBTEngSdpResultReceiver,
-                          public MBTEngSettingsObserver
+                          public MBTEngSettingsObserver,
+                          public MHbDeviceDialogObserver
     {
     public:  // Constructors and destructor
         
@@ -393,7 +394,7 @@
         * @param aReason Error value
         * @return None.
         */
-        void ShowErrorNote( TInt aReason ) const;
+        void ShowErrorNote( TInt aReason );
 
         /**
         * Cancel progress note
@@ -428,6 +429,30 @@
          */
         void TurnBTPowerOnL( const TBTPowerStateValue aState );
         
+        /**
+         * Shows appropriate result of the send request using the BTDeviceDialogPlugin
+         * The dialog shown will be of discreet notifcation type
+         * @param aDialogTitle The notification dialog title
+         */
+        void ShowSendCompleteNoteL( const TInt aDialogTitle );
+        
+        /**
+         * Shows appropriate result of the send request using the BTDeviceDialogPlugin
+         * The dialog shown will be of message box type
+         * @param aDialogTitle The notification dialog title
+         * */
+        void ShowErrorMessageL( const TInt aDialogTitle,
+                                        const TDesC& aConfirmText = KNullDesC);
+        
+        
+        void AddDataL(CHbSymbianVariantMap* aMap, const TInt aKey, 
+            const TAny* aData, CHbSymbianVariant::TType aDataType);
+        
+    private: // From MHbDeviceDialogObserver
+        void DataReceived(CHbSymbianVariantMap& aData);
+        
+        void DeviceDialogClosed(TInt aCompletionCode);
+
     private:    // Data definitions
 
         enum TBTServiceStarterState
@@ -474,7 +499,10 @@
         TBool                       iTriedBIP;
         TBool                       iTriedOPP;
         CBTServiceDelayedDestroyer* iDelayedDestroyer;
-        TBool                       iLocalisationInit;
+        CHbDeviceDialogSymbian*     iNotificationDialog;
+        RBuf                        iRemoteDeviceName;
+        TUint32                     iRemoteDeviceClass;
+        TBool                       iShowDialogNote;
     };
 
 #endif      // BT_SERVICE_CONTROLLER_H
--- a/btobexprofiles/obexsendservices/obexservicesendutils/src/BTSBIPController.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexsendservices/obexservicesendutils/src/BTSBIPController.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -49,6 +49,9 @@
 const TInt KBTSUMaxPathLenght=256;
 const TInt KBTSUMaxPrivatePathLenght=20;
 
+_LIT(KLocFileName, "btdialogs_");
+_LIT(KPath, "z:/resource/qt/translations/");  
+
 _LIT(KBTNotSendSomeText,"txt_bt_info_receiving_device_does_not_support_all");
 _LIT(KBTNotSendOneText,"txt_bt_info_receiving_device_does_not_support_this");
 
@@ -297,7 +300,7 @@
         RBuf filename;
         filename.CreateL(KMaxFileName);
         CleanupClosePushL(filename);
-        imageparam.iFile.Name(filename);
+        User::LeaveIfError(imageparam.iFile.Name(filename));
         
         iObserverPtr->UpdateProgressNoteL(imageparam.iFileSize,iFileIndex,filename);
         CleanupStack::PopAndDestroy(&filename);
@@ -632,6 +635,7 @@
 	delete remoteCapabilityList;
     CleanupStack::PopAndDestroy( xmlParser ); 
     
+    HbTextResolverSymbian::Init(KLocFileName, KPath);
     if(!allSupported  && iListPtr->ImageCount() > 1)
     	{      	
         HBufC* sendText = HbTextResolverSymbian::LoadLC(KBTNotSendSomeText);
--- a/btobexprofiles/obexsendservices/obexservicesendutils/src/BTServiceClient.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexsendservices/obexservicesendutils/src/BTServiceClient.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -25,9 +25,9 @@
 #include "BTConnectionTimer.h"
 #include "BTSUDebug.h"
 
-const TUint16 KMtuSizeReceiv    = 0xFFFF;	// 64kB - 1 (65535)
-const TUint16 KMtuSizeTrans     = 0x8000;	// 32kB
-const TInt    KBufferSize       = 0x8000;	// 32kB
+const TUint16 KMtuSizeReceiv    = 0xFFFF;   // 64kB - 1 (65535)
+const TUint16 KMtuSizeTrans     = 0x7200;   // 29kB 
+const TInt    KBufferSize       = 0x7200;   // 29kB
 
 const TInt KBTConnectionTimeout = 20 * 1000 * 1000;	// 20 seconds
 const TInt KBTAbortTimeout      = 2 * 1000 * 1000;	// 2 seconds
--- a/btobexprofiles/obexsendservices/obexservicesendutils/src/BTServiceStarter.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexsendservices/obexservicesendutils/src/BTServiceStarter.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -27,7 +27,7 @@
 #include <obexutilsmessagehandler.h>
 #include <featmgr.h>
 #include <hbdevicenotificationdialogsymbian.h>
-#include <hbtextresolversymbian.h>
+#include <btservices/bluetoothdevicedialogs.h>
 
 // CONSTANTS
 
@@ -41,18 +41,11 @@
 const TUid KUidMsgTypeBt                 = {0x10009ED5};
 //todo  need to find a suitable header to include. This is from obexutilslayer.h
 
-const TInt KMaxDesCLength  = 256;
+const TInt KMinStringSize = 10;
 
 
-//_LIT(KSendingDialog,"com.nokia.hb.btdevicedialog/1.0");
 
-_LIT(KLocFileName, "btdialogs_");
-_LIT(KPath, "z:/resource/qt/translations/");  
-
-_LIT(KFilesSentText, "txt_bt_dpophead_all_files_sent");//All files sent 
-_LIT(KDeviceText,"txt_bt_dpopinfo_sent_to_1");
-//_LIT(KNotConnectedText,"txt_bt_info_unable_to_connect_with_bluetooth");
-_LIT(KSendingFailedText,"txt_bt_dpophead_sending_failed");
+_LIT( KBTDevDialogId, "com.nokia.hb.btdevicedialog/1.0" );
 
 // ============================ MEMBER FUNCTIONS ===============================
 
@@ -73,7 +66,8 @@
       iUserCancel(EFalse), 
       iFeatureManagerInitialized(EFalse),
       iTriedBIP(EFalse),
-      iTriedOPP(EFalse)
+      iTriedOPP(EFalse),
+      iShowDialogNote(EFalse)
     {    
     CActiveScheduler::Add( this );
     }
@@ -91,7 +85,6 @@
     iDelayedDestroyer = CBTServiceDelayedDestroyer::NewL(CActive::EPriorityStandard);
     FeatureManager::InitializeLibL();
     iFeatureManagerInitialized = ETrue;
-    iLocalisationInit = HbTextResolverSymbian::Init(KLocFileName, KPath);
     FLOG(_L("[BTSU]\t CBTServiceStarter::ConstructL() completed"));
     }
 
@@ -127,6 +120,7 @@
     delete iBTEngDiscovery;
     delete iDialog;
     delete iDelayedDestroyer;
+    iRemoteDeviceName.Close();
     
     if(iWaiter && iWaiter->IsStarted() )
         {
@@ -139,6 +133,11 @@
         FeatureManager::UnInitializeLib();
         }
     
+    if (iNotificationDialog)
+        {
+        iNotificationDialog->Cancel();
+        delete iNotificationDialog;
+        }
     FLOG(_L("[BTSU]\t CBTServiceStarter::Destructor() completed"));
     }
 
@@ -448,6 +447,7 @@
         }
     else
         {
+        iShowDialogNote = ETrue;
     //todo need to do the localisation here
         _LIT(KConnectText, "Connecting...");
         iDialog->LaunchWaitDialogL(KConnectText);
@@ -490,20 +490,20 @@
         
         if ( !iProgressDialogActive )
         	{
+            iShowDialogNote = ETrue;  
             // todo need to change the last parameter because we are now using the textmap id which is a string
             // whether we replace it with that or remove the parameter is to be decided
         	iMessageServerIndex = TObexUtilsMessageHandler::CreateOutboxEntryL( 
             KUidMsgTypeBt, 0 );     
 
-            deviceName.CreateL(KMaxDesCLength);
             
             if ( iDevice->IsValidFriendlyName() )
                 {
-                deviceName.Copy( iDevice->FriendlyName() );
+                deviceName.CreateL( iDevice->FriendlyName() );
                 }
             else 
                 {
-                deviceName.Copy( BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName()));
+                deviceName.CreateL( BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName()));
                 }        	
         	iDialog->LaunchProgressDialogL( this, aFileCount, 
                                 deviceName, KBTProgressInterval );	
@@ -550,6 +550,20 @@
         { // this condition is hit for the progress dialog and connecting dialog cancel
         FLOG(_L("[BTSU]\t CBTServiceStarter::DialogDissmissed(), cancelled by user"));        
         iUserCancel=ETrue;
+        iShowDialogNote = EFalse;
+/*        if ( iDevice->IsValidFriendlyName() )
+            {
+            TRAP_IGNORE(iRemoteDeviceName.CreateL( iDevice->FriendlyName()) );
+            }
+        else 
+            {
+            TRAP_IGNORE( iRemoteDeviceName.CreateL( BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName())));
+            }
+        
+        iRemoteDeviceClass = iDevice->DeviceClass().DeviceClass();        
+        
+        TRAP_IGNORE( ShowSendCompleteNoteL(ESendCancelled) );*/
+        
         if ( iController )
             {
             iController->Abort();
@@ -563,6 +577,7 @@
         {
         // user abortion
         //
+        iShowDialogNote = EFalse;
         iUserCancel = ETrue;
         StopTransfer( KErrCancel );
         CancelWaitNote();
@@ -578,33 +593,35 @@
 // CBTServiceStarter::ShowErrorNote
 // -----------------------------------------------------------------------------
 //
-void CBTServiceStarter::ShowErrorNote( TInt aReason ) const
+void CBTServiceStarter::ShowErrorNote( TInt aReason ) 
     {
     FLOG(_L("[BTSU]\t CBTServiceStarter::ShowErrorNote()"));
      
-    TBuf<KMaxDesCLength> buf;
-    TPtrC sendTextMapId;
-    
     if ( iDevice->IsValidFriendlyName() )
         {
-        buf.Copy( iDevice->FriendlyName() );
+        iRemoteDeviceName.CreateL( iDevice->FriendlyName() );
         }
     else 
         {
-        TRAP_IGNORE( buf.Copy( BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName())));
+        TRAP_IGNORE( iRemoteDeviceName.CreateL( BTDeviceNameConverter::ToUnicodeL(iDevice->DeviceName())));
         }
     
+    iRemoteDeviceClass = iDevice->DeviceClass().DeviceClass();    
 
     switch ( aReason )
         {
         case EBTSNoError:
             {
-            sendTextMapId.Set(KFilesSentText());
+            TRAP_IGNORE( ShowSendCompleteNoteL(ESendCompleted) );
             break;
             }
         case EBTSConnectingFailed:
         case EBTSGettingFailed:
         case EBTSPuttingFailed:
+            {
+            TRAP_IGNORE( ShowErrorMessageL(TBluetoothDialogParams::ESendFailed) );
+            break;
+            }
         case EBTSNoSuitableProfiles:
       //todo below three enums are not valid and it is not being used at anywhere do we need to have it 
             
@@ -612,27 +629,8 @@
 //        case EBTSBIPOneNotSend:
 //        case EBTSBIPNoneSend:
         default:            
-            {
-            sendTextMapId.Set(KSendingFailedText());
             break;
-            }
         }        
-    
-    
-    if(iLocalisationInit)
-        {
-        TRAP_IGNORE(
-               HBufC* sendText = HbTextResolverSymbian::LoadLC(sendTextMapId);
-               HBufC* deviceName =  HbTextResolverSymbian::LoadLC(KDeviceText,buf);
-               CHbDeviceNotificationDialogSymbian::NotificationL(KNullDesC, deviceName->Des(), sendText->Des());
-               CleanupStack::PopAndDestroy( deviceName );
-               CleanupStack::PopAndDestroy( sendText );
-               );
-        }
-    else
-        {
-        TRAP_IGNORE(CHbDeviceNotificationDialogSymbian::NotificationL(KNullDesC, KDeviceText(), sendTextMapId));
-        }
     FLOG(_L("[BTSU]\t CBTServiceStarter::ShowErrorNote() completed"));
     }
 
@@ -644,7 +642,9 @@
 //
 void  CBTServiceStarter::LaunchConfirmationQuery(const TDesC& aConfirmText)
     {
-    TRAP_IGNORE(iDialog->LaunchQueryDialogL(aConfirmText ));
+    TInt dialogTitle = TBluetoothDialogParams::EUnsupportedImages;
+    iRemoteDeviceClass = iDevice->DeviceClass().DeviceClass();
+    ShowErrorMessageL(dialogTitle,aConfirmText);
     }
 
 // -----------------------------------------------------------------------------
@@ -695,7 +695,7 @@
     // Reset states
     //
     iServiceStarted = EFalse;
-    if ( iWaiter && iWaiter->IsStarted() )
+    if (( iWaiter && iWaiter->IsStarted() )&&(!iShowDialogNote))
         {                
         iWaiter->AsyncStop();                    
         }    
@@ -1053,6 +1053,109 @@
     return KErrNone;
     }
 
+void CBTServiceStarter::ShowSendCompleteNoteL(const TInt aDialogTitle)
+    {
+    iNotificationDialog = CHbDeviceDialogSymbian::NewL();
+    iNotificationDialog->SetObserver(this);
+    
+    CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL();
+    CleanupStack::PushL(variantMap);
+    
+    TInt dialogIdx = TBluetoothDialogParams::EGlobalNotif;
+    AddDataL(variantMap,TBluetoothDialogParams::EDialogType,&dialogIdx,CHbSymbianVariant::EInt);
+
+    
+    AddDataL(variantMap,TBluetoothDeviceDialog::EDeviceName,&iRemoteDeviceName,
+            CHbSymbianVariant::EDes);
+    
+    AddDataL(variantMap,TBluetoothDialogParams::EResource,&aDialogTitle,
+            CHbSymbianVariant::EInt);
+    
+    AddDataL(variantMap,TBluetoothDeviceDialog::EDeviceClass,&iRemoteDeviceClass,
+            CHbSymbianVariant::EInt);
+
+    iNotificationDialog->Show( KBTDevDialogId(), *variantMap, this );
+    CleanupStack::PopAndDestroy(variantMap);
+    }
+
+void CBTServiceStarter::ShowErrorMessageL(const TInt aDialogTitle,
+                                            const TDesC& aConfirmText)
+    {
+    iNotificationDialog = CHbDeviceDialogSymbian::NewL();
+    iNotificationDialog->SetObserver(this);
+    
+    CHbSymbianVariantMap* variantMap = CHbSymbianVariantMap::NewL();
+    CleanupStack::PushL(variantMap);
+    
+    TInt dialogIdx = TBluetoothDialogParams::EInformationDialog;
+    AddDataL(variantMap,TBluetoothDialogParams::EDialogType,&dialogIdx,CHbSymbianVariant::EInt);
+    
+    if(aDialogTitle == TBluetoothDialogParams::EUnsupportedImages )
+        {
+        AddDataL(variantMap,TBluetoothDeviceDialog::EAdditionalDesc,&aConfirmText,
+            CHbSymbianVariant::EDes);
+        }
+    else
+        {
+        AddDataL(variantMap,TBluetoothDeviceDialog::EDeviceName,&iRemoteDeviceName,
+            CHbSymbianVariant::EDes);
+        }
+    
+    AddDataL(variantMap,TBluetoothDialogParams::EDialogTitle,&aDialogTitle,
+            CHbSymbianVariant::EInt);
+    
+    AddDataL(variantMap,TBluetoothDeviceDialog::EDeviceClass,&iRemoteDeviceClass,
+            CHbSymbianVariant::EInt);
+
+    iNotificationDialog->Show( KBTDevDialogId(), *variantMap, this );
+    CleanupStack::PopAndDestroy(variantMap);
+    }
+
+void CBTServiceStarter::AddDataL(CHbSymbianVariantMap* aMap, const TInt aKey, 
+    const TAny* aData, CHbSymbianVariant::TType aDataType)
+    {
+    TBuf<KMinStringSize> key;
+    key.Num(aKey);
+
+    CHbSymbianVariant* value = CHbSymbianVariant::NewL(aData, aDataType);
+    CleanupStack::PushL( value );
+    User::LeaveIfError( aMap->Add( key, value ) ); // aMap takes the ownership of value
+    CleanupStack::Pop( value );
+    }
 
 
+void CBTServiceStarter::DataReceived(CHbSymbianVariantMap& aData)
+    {
+    if(aData.Keys().MdcaPoint(0).Compare(_L("actionResult"))==KErrNone)
+        {
+        TBool val = *(static_cast<TBool*>(aData.Get(_L("actionResult"))->Data()));
+        if(val)
+            {
+            DialogDismissed(EYesButton);
+            }
+        else
+            {
+            DialogDismissed(ENoButton);
+            }
+        if(iNotificationDialog)
+            {
+            delete iNotificationDialog;
+            iNotificationDialog = NULL;
+            }
+        }
+    }
 
+void CBTServiceStarter::DeviceDialogClosed(TInt aCompletionCode)
+    {
+    (void) aCompletionCode;
+    if(iNotificationDialog)
+        {
+        delete iNotificationDialog;
+        iNotificationDialog = NULL;
+        }
+    if ( iWaiter && iWaiter->IsStarted() )
+        {                
+        iWaiter->AsyncStop();                    
+        }
+    }
+
--- a/btobexprofiles/obexserviceman/group/obexserviceman.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexserviceman/group/obexserviceman.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -43,7 +43,7 @@
 
 
 USERINCLUDE   ../obexservicemanserver/inc
-SYSTEMINCLUDE  ../../inc ../../../inc  /epoc32/include/ecom
+SYSTEMINCLUDE  /epoc32/include/ecom
 MW_LAYER_SYSTEMINCLUDE
 
 
--- a/btobexprofiles/obexserviceman/group/obexservicemanclient.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexserviceman/group/obexservicemanclient.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -39,7 +39,7 @@
 SOURCE      ObexSMRequester.cpp
 
 USERINCLUDE     ../obexservicemanclient/inc
-SYSTEMINCLUDE  ../../inc ../../../inc /epoc32/include/ecom
+SYSTEMINCLUDE  /epoc32/include/ecom
 MW_LAYER_SYSTEMINCLUDE
 
 
--- a/btobexprofiles/obexserviceman/group/obexusbapi.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexserviceman/group/obexusbapi.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -35,7 +35,7 @@
 SOURCE      usbclientwrapper.cpp
 
 USERINCLUDE     ../obexservicemanclient/inc
-SYSTEMINCLUDE  ../../inc ../../../inc /epoc32/include/ecom
+SYSTEMINCLUDE  /epoc32/include/ecom
 MW_LAYER_SYSTEMINCLUDE
 
 
--- a/btobexprofiles/obexserviceman/obexservicemanclient/inc/obexsmclient.h	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexserviceman/obexservicemanclient/inc/obexsmclient.h	Fri Sep 03 16:17:59 2010 +0300
@@ -22,7 +22,7 @@
 //  INCLUDES
 #include <e32std.h>
 #include <locodbearer.h>
-#include "usbobex.h"
+#include <usbobex.h>
 
 /// server name
 _LIT(KSrcsName,"obexserviceman");
--- a/btobexprofiles/obexserviceman/obexservicemanclient/inc/usbobex.h	Fri Aug 06 16:43:21 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,84 +0,0 @@
-/*
-* Copyright (c) 2006-2007 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:  USB obexservicemanager client definition
-*
-*/
-
-
-#ifndef USBOBEX_H
-#define USBOBEX_H
-
-#include <e32base.h>
-
-
-class CUSBClientWrapper;
-
-
-/**
-*	Transportation string definition
-*/
-_LIT8(KSrcsTransportBT,"OBEX/BT");
-_LIT8(KSrcsTransportUSB,"OBEX/USB");
-_LIT8(KSrcsTransportIrDA,"OBEX/IrDA");
-
-
-/**
- *  obexservicemanager client for usb.
- *  @lib obexusbapi.lib
- *  @since S60 v3.2
- */
-class CObexUSB : public CBase
-    {
-public:
-
-   /**
-    * Two-phased constructor.    
-    */
-    IMPORT_C static CObexUSB* NewL();
-        
-   /**
-    * Destructor.
-    */
-    ~CObexUSB();
-    
-   /**
-    * Turn USB services on or off
-    *
-    * @since S60 v3.2
-    * @param aUSBStatus the requested USB service status
-    * @param aStatus the Request status
-    * @return None
-    */
-    IMPORT_C void  ManageUSBServices( TBool aUSBStatus, TRequestStatus &aStatus );     
-      
-   /**
-    * Cancel managment request and turn services off   
-    * @since S60 v3.2
-    *
-    */
-    IMPORT_C void  CancelManageUSBServices();     
-
-private: 
-
-    CObexUSB();
-    void ConstructL();
-
-private: //data
-
-   /**
-    * Obexserviceman client wrapper
-    */
-    CUSBClientWrapper* iUSBWrapper;        
-    };
-#endif // USBOBEX_H
--- a/btobexprofiles/obexserviceman/obexservicemanclient/src/usbobex.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexserviceman/obexservicemanclient/src/usbobex.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -16,7 +16,7 @@
 */
 
 
-#include "usbobex.h"
+#include <usbobex.h>
 #include "debug.h"
 #include "obexsmclient.h"
 #include "usbclientwrapper.h"
--- a/btobexprofiles/obexserviceman/plugins/group/obexservicemanbt.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexserviceman/plugins/group/obexservicemanbt.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -39,7 +39,7 @@
 END
 
 USERINCLUDE ../inc/bt ../../obexservicemanserver/inc ../../utils/inc
-SYSTEMINCLUDE  ../../../inc ../../../../inc  /epoc32/include/ecom
+SYSTEMINCLUDE  /epoc32/include/ecom
 MW_LAYER_SYSTEMINCLUDE
 
 LIBRARY euser.lib           // Base library
--- a/btobexprofiles/obexserviceman/plugins/group/obexservicemanir.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexserviceman/plugins/group/obexservicemanir.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -38,7 +38,7 @@
 END
 
 USERINCLUDE ../inc/ir ../../obexservicemanserver/inc  ../../utils/inc
-SYSTEMINCLUDE  ../../../inc ../../../../inc  /epoc32/include/ecom
+SYSTEMINCLUDE  /epoc32/include/ecom
 MW_LAYER_SYSTEMINCLUDE
 
 LIBRARY euser.lib           // Base library
--- a/btobexprofiles/obexserviceman/plugins/group/obexservicemanusb.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexserviceman/plugins/group/obexservicemanusb.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -39,7 +39,7 @@
 END
 
 USERINCLUDE ../inc/usb ../../obexservicemanserver/inc ../../utils/inc ../../inc
-SYSTEMINCLUDE  ../../../inc ../../../../inc  /epoc32/include/ecom
+SYSTEMINCLUDE  /epoc32/include/ecom
 MW_LAYER_SYSTEMINCLUDE
 
 
--- a/btobexprofiles/obexserviceman/rom/obex.iby	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexserviceman/rom/obex.iby	Fri Sep 03 16:17:59 2010 +0300
@@ -35,7 +35,7 @@
 //file=ABI_DIR\BUILD_DIR\msgth.dll                         System\libs\msgth.dll 
 
 
-#ifdef SYMBIAN_EXCLUDE_INFRARED
+#ifndef __IRDA
 REM Messaging infrared MTM is not included in this ROM, because it depends on excluded INFRARED
 #else
 //IR MTM Client
@@ -46,10 +46,10 @@
 
 //IR MTM Resources
 
-#endif // SYMBIAN_EXCLUDE_INFRARED
+#endif // __IRDA
 
 
-#ifdef SYMBIAN_EXCLUDE_BLUETOOTH
+#ifndef __BT
 REM Messaging Bluetooth MTM is not included in this ROM, because it depends on excluded BLUETOOTH
 #else
 //BT MTM Client
@@ -60,7 +60,7 @@
 
 //BT MTM Resources
 
-#endif // SYMBIAN_EXCLUDE_BLUETOOTH
+#endif // __BT
 
 
 //Test Harness Executable
--- a/btobexprofiles/obexserviceman/utils/group/bld.inf	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexserviceman/utils/group/bld.inf	Fri Sep 03 16:17:59 2010 +0300
@@ -31,6 +31,8 @@
 // once the localisation files are avaialble and in place in epoc32
 
 ../loc/btdialogs_en_GB.qm  /epoc32/data/z/resource/qt/translations/btdialogs_en_GB.qm
+../loc/btdialogs_en_GB.qm  /epoc32/release/winscw/urel/z/resource/qt/translations/btdialogs_en_GB.qm
+../loc/btdialogs_en_GB.qm  /epoc32/release/winscw/udeb/z/resource/qt/translations/btdialogs_en_GB.qm
 
 PRJ_MMPFILES
 obexutils.mmp
--- a/btobexprofiles/obexserviceman/utils/group/obexutils.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexserviceman/utils/group/obexutils.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -42,7 +42,6 @@
 SOURCE       vMessageHandler.cpp
 #endif
 
-SYSTEMINCLUDE  ../../../inc ../../../../inc  
 SYSTEMINCLUDE  /epoc32/include/mw/hb/hbwidgets
 SYSTEMINCLUDE  /epoc32/include/mw/hb/hbcore
 #ifdef NO101APPDEPFIXES
@@ -70,7 +69,7 @@
 LIBRARY			platformenv.lib 
 LIBRARY			mpxcollectionhelper.lib
 LIBRARY			mpxplaybackutility.lib
-LIBRARY			hbcore.lib
+LIBRARY			HbCore.lib
 LIBRARY			HbWidgets.lib
 
 #ifdef __BT_SAP
--- a/btobexprofiles/obexserviceman/utils/src/obexutilsdialog.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexserviceman/utils/src/obexutilsdialog.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -22,7 +22,6 @@
 #include "obexutilsdebug.h"
 #include <hbdevicenotificationdialogsymbian.h>
 #include <btservices/bluetoothdevicedialogs.h>
-#include <hbtextresolversymbian.h>
 
 _LIT(KSendingDialog, "com.nokia.hb.btdevicedialog/1.0");
 _LIT(KCurrentFileIndex,"currentFileIdx" );
@@ -33,15 +32,11 @@
 _LIT(KFileSize,"fileSz");
 _LIT(KProgressValue,"progressValue");
 
-_LIT(KSendingCancelledText, "txt_bt_dpophead_sending_cancelled");
-_LIT(KDeviceText,"txt_bt_dpopinfo_sent_to_1");
 
 const TInt KMaxDescriptionLength = 256;
 const TInt KMinStringSize = 10;
-const TInt KMinFileSize = 1024;
+const TInt KMaxDisplayFileName = 20; 
 
-_LIT(KLocFileName, "btdialogs_");     
-_LIT(KPath, "z:/resource/qt/translations/"); 
 
 // ============================ MEMBER FUNCTIONS ===============================
 
@@ -174,24 +169,54 @@
     AddDataL( map, *key, &iDeviceName, CHbSymbianVariant::EDes );
     
     key->Des().Copy(KFileName());
-    AddDataL( map, *key, &aFileName, CHbSymbianVariant::EDes );
+    TFileName shortname;
+    if ( aFileName.Length() > KMaxDisplayFileName ) 
+        {
+        // Filename is too long, 
+        // We make it shorter. Hiding the chars in the middle part of filename. 
+        shortname = aFileName.Mid(0,KMaxDisplayFileName/2);
+        shortname.Append(_L("..."));
+        shortname.Append(aFileName.Mid(aFileName.Length() - KMaxDisplayFileName/2, KMaxDisplayFileName/2));
+        }
+    else
+        {
+        shortname.Copy(aFileName);
+        }
+    
+    AddDataL( map, *key, &shortname, CHbSymbianVariant::EDes );
     
     // todo: localiation is needed for code below:
     HBufC* value = HBufC::NewL(KMaxDescriptionLength);
     CleanupStack::PushL(value);
     key->Des().Copy(KFileSizeTxt());
     value->Des().Zero();
-    if(aFileSize < KMinFileSize)
+
+    //Format the file size into a more readable format
+    if ( aFileSize >> 20 )    // size in MB
+        {       
+        TReal32 sizeInMB = 0;
+        sizeInMB = ((TReal32)aFileSize ) / (1024*1024);
+        value->Des().AppendNum(sizeInMB);
+        //TODO - check for localization
+        value->Des().Append(_L(" Mb"));
+        }
+    
+    else if( aFileSize >> 10 )        // size in KB
+        {
+        TInt64 sizeInKB = 0;
+        sizeInKB = aFileSize >> 10;
+        value->Des().AppendNum(sizeInKB);
+        //TODO - check for localization
+        value->Des().Append(_L(" Kb"));
+        }
+
+    else                              // size is unknown or less than 1K
         {
         value->Des().AppendNum(aFileSize);
         value->Des().Append(_L(" Bytes"));
         }
-    else
-        {
-        TInt filesize =  aFileSize/KMinFileSize;
-        value->Des().AppendNum(filesize);
-        value->Des().Append(_L(" KB"));
-        }
+
+    
     AddDataL( map, *key, value, CHbSymbianVariant::EDes );
     CleanupStack::PopAndDestroy( value );
     
@@ -415,32 +440,14 @@
     FLOG(_L("[BTSU]\t CObexUtilsDialog::DeviceDialogClosed()"));   
     (void) aCompletionCode;
 
+    if ( iDialogObserverPtr )
+        {
+        iDialogObserverPtr->DialogDismissed(ECancelButton);
+        }
     delete iObexDialogTimer;
     iObexDialogTimer = NULL;
     delete iProgressDialog;
     iProgressDialog = NULL;  
-    
-    TBool ok = HbTextResolverSymbian::Init(KLocFileName, KPath);
-    if(ok)
-        {
-        TRAP_IGNORE(
-                 HBufC* deviceName = HbTextResolverSymbian::LoadLC(KDeviceText,iDeviceName);
-                 HBufC* sendText = HbTextResolverSymbian::LoadLC(KSendingCancelledText);
-                 CHbDeviceNotificationDialogSymbian::NotificationL(
-                         KNullDesC, deviceName->Des(), sendText->Des());
-                 CleanupStack::PopAndDestroy( sendText );		 
-                 CleanupStack::PopAndDestroy( deviceName );
-                );
-        }
-    else
-        {
-        CHbDeviceNotificationDialogSymbian::NotificationL(
-                KNullDesC, KDeviceText(), KSendingCancelledText());
-        }
-    if ( iDialogObserverPtr )
-        {
-        iDialogObserverPtr->DialogDismissed(ECancelButton);
-        }
     }
 
 void CObexUtilsDialog::AddDataL(CHbSymbianVariantMap* aMap, const TDesC& aKey, 
@@ -464,6 +471,8 @@
     messageBox->SetTextL(aText);
     messageBox->SetObserver(aObserver);
     messageBox->SetTimeout(aTimeout);
+    messageBox->SetButtonTextL(CHbDeviceMessageBoxSymbian::EAcceptButton,_L("Continue"));
+    messageBox->SetButtonTextL(CHbDeviceMessageBoxSymbian::ERejectButton,_L("Cancel"));
     messageBox->ShowL();
     CleanupStack::Pop(messageBox);
     return messageBox;
--- a/btobexprofiles/obexserviceman/utils/src/obexutilsentryhandler.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexserviceman/utils/src/obexutilsentryhandler.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -17,11 +17,9 @@
 
 
 
-
+#include "obexutilsentryhandler.h"
 #include <msvstore.h>
 #include <mmsvattachmentmanager.h>
-
-#include "obexutilsentryhandler.h"
 #include "obexutilsdebug.h"
 
 
--- a/btobexprofiles/obexserviceman/utils/src/updatemusiccollection.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/btobexprofiles/obexserviceman/utils/src/updatemusiccollection.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -16,11 +16,9 @@
 */
 
 
-
+#include "updatemusiccollection.h"
 //#include <mpxcollectionhelper.h>
 #include <mpxcollectionhelperfactory.h>
-
-#include "updatemusiccollection.h"
 #include "obexutilsdebug.h"
 
 //#include <mpxplaybackutility.h>
--- a/btservices.pro	Fri Aug 06 16:43:21 2010 +0300
+++ b/btservices.pro	Fri Sep 03 16:17:59 2010 +0300
@@ -23,7 +23,8 @@
            bluetoothengine/btnotif/btdevicedialogplugin \
            bluetoothengine/btindicator \
            btobexprofiles/obexsendservices/obexhighway \
-		   btobexprofiles/obexreceiveservices/btmsgviewer \
+           btobexprofiles/obexreceiveservices/btmsgviewer \
+           bluetoothengine/btxqservice \
 
 CONFIG += ordered
 
--- a/cbsatplugin/atmisccmdplugin/group/atmisccmdplugin.mmp	Fri Aug 06 16:43:21 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/group/atmisccmdplugin.mmp	Fri Sep 03 16:17:59 2010 +0300
@@ -41,8 +41,8 @@
 SOURCE          cbsettinghandler.cpp
 SOURCE          cpwdcommandhandler.cpp
 SOURCE          cpincommandhandler.cpp
-SOURCE          cusdcommandhandler.cpp 
-SOURCE          cnumcommandhandler.cpp
+SOURCE          cusdcommandhandler.cpp
+SOURCE 		    cnumcommandhandler.cpp 
 SOURCE          cfuncommandhandler.cpp 
 SOURCE          cbccommandhandler.cpp
 SOURCE          ussdreadmessageimpl.cpp
@@ -54,11 +54,11 @@
 SOURCE          cgmrcommandhandler.cpp 
 SOURCE          cmgwcommandhandler.cpp 
 SOURCE          cgmicommandhandler.cpp
-SOURCE			cmgdcommandhandler.cpp
-SOURCE			telephonywrapper.cpp
-SOURCE			cgmmcommandhandler.cpp 
-SOURCE			scpbrcommandhandler.cpp
-SOURCE			scpbwcommandhandler.cpp
+SOURCE		    cmgdcommandhandler.cpp
+SOURCE		    telephonywrapper.cpp
+SOURCE		    cgmmcommandhandler.cpp 
+SOURCE		    scpbrcommandhandler.cpp
+SOURCE 		    scpbwcommandhandler.cpp
 #endif
 
 USERINCLUDE     ../inc
@@ -84,7 +84,7 @@
 LIBRARY         hash.lib
 
 LIBRARY         ProfileEng.lib
-LIBRARY         StarterClient.lib 
+LIBRARY         starterclient.lib 
 
 LIBRARY			etel3rdparty.lib
 LIBRARY			sysutil.lib 
@@ -96,3 +96,4 @@
 DEBUGLIBRARY	flogger.lib
 
 // End of File
+ 
--- a/cbsatplugin/atmisccmdplugin/src/atcommandparser.cpp	Fri Aug 06 16:43:21 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/src/atcommandparser.cpp	Fri Sep 03 16:17:59 2010 +0300
@@ -258,8 +258,8 @@
     if(!iCmd.Eos())
         {
         chr = iCmd.Peek();
-        while(!iCmd.Eos() && chr != ',' && !chr.IsSpace() && !chr.IsControl())
-            {// Stop at any of those chars: comma, space or control
+        while(!iCmd.Eos() && chr != ',' && !chr.IsControl())
+            {// Stop at any comma or control character
             iCmd.Inc();
             chr = iCmd.Peek();
             }
@@ -268,7 +268,23 @@
     // Extract the token at this point            
     TPtrC8 retVal = iCmd.MarkedToken();
     
-    // Skip the first delimiter and any further space and control chars
+	//ignore all space characters at the end
+    if(retVal.Length() > 1)
+    {
+        TInt pos = retVal.Length() - 1; 
+        for ( ; pos >= 0; pos-- )
+            {
+            const TChar ch( retVal[pos] );
+            if( !ch.IsSpace() )
+                {
+                break;
+                }
+            }
+        retVal.Set( retVal.Mid( 0, pos + 1 ) );
+    }
+    
+    
+    // Skip comma, space and control chars
     do
       {
       iCmd.Inc();
@@ -316,8 +332,21 @@
         }
     else
         {
-        TLex8 lex(param);
-        retVal = lex.Val(aValue);
+        //check if param contains only digits - TLex doesn't do that
+        for(TInt pos = param.Length() - 1; pos >= 0; pos--)
+            {
+            if(( param[pos] < '0' ) || ( param[pos] > '9' ))
+                {
+                retVal = KErrArgument;
+                break;
+                }
+            }
+        
+        if(retVal == KErrNone)
+            {
+            TLex8 lex(param);
+            retVal = lex.Val(aValue);
+            }
         }
     TRACE_FUNC_EXIT
     return retVal;
--- a/package_definition.xml	Fri Aug 06 16:43:21 2010 +0300
+++ b/package_definition.xml	Fri Sep 03 16:17:59 2010 +0300
@@ -1,56 +1,188 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<SystemDefinition schema="3.0.0">
-  <package id="btservices" name="Bluetooth Services" levels="framework server generic specific plugin">
-    <collection id="bluetoothengine" name="Bluetooth Engine" level="framework">
-      <component id="bteng" filter="s60" name="Bluetooth Engine">
-        <unit bldFile="bluetoothengine/bteng/group"/>
-      </component>
-      <component id="btserviceutil" filter="s60" name="Bluetooth Service Utility">
-        <unit bldFile="bluetoothengine/btserviceutil/group"/>
-      </component>
-      <component id="btnotif" filter="s60" name="Bluetooth Notifier">
-      	<!-- client is separated for breaking cyclic compiling dependencies -->
-        <unit bldFile="bluetoothengine/btnotif/btnotifclient/group"/>
-        <unit bldFile="bluetoothengine/btnotif/group"/>
-          <!-- is this test needed as unit? -->
-        <!-- <unit bldFile="bluetoothengine/btnotif/tsrc/btnotifapitest/group"/> -->
-      </component>
-      <component id="btaudioman" filter="s60" name="Bluetooth Audio Manager">
-        <unit bldFile="bluetoothengine/btaudioman/group"/>
-      </component>
-      <component id="btmac" filter="s60" name="Bluetooth Mono Audio Controller" class="plugin">
-        <unit bldFile="bluetoothengine/btmac/group"/>
-      </component>
-      <component id="btsac" filter="s60" name="Bluetooth Stereo Audio Controller" class="plugin">
-        <unit bldFile="bluetoothengine/btsac/group"/>
-      </component>
-      <component id="btaudiostreamer" filter="s60" name="Bluetooth Audio Streamer">
-        <unit bldFile="bluetoothengine/btaudiostreamer/group"/>
-        <!-- <unit bldFile="bluetoothengine/btaudiostreamer/tsrc/btaudiostreamerapitest/group"/> -->
-      </component>
-      <component id="btsap" filter="s60" name="Bluetooth SIM Access Profile" class="plugin">
-        <unit bldFile="bluetoothengine/btsap/group"/>
-      </component>
-      <component id="btui" filter="s60" name="Bluetooth UI">
-        <!-- <unit bldFile="bluetoothengine/btui/ecom/group"/> -->
-        <unit bldFile="bluetoothengine/btui/group"/>
-      </component>
-      <component id="btpbap" filter="s60" name="Bluetooth Phonebook Access Profile" class="plugin">
-        <unit bldFile="bluetoothengine/btpbap/group"/>
-      </component>
-      <component id="bthid" filter="s60" name="Bluetooth HID">
-        <unit bldFile="bluetoothengine/bthid/group"/>
-      </component>
-    </collection>
-    <collection id="bluetoothappprofiles" name="Bluetooth Application Profiles" level="plugin">
-      <component id="avrcp" name="Bluetooth AVRCP" introduced="9.1" purpose="optional">
-        <unit bldFile="bluetoothappprofiles/avrcp" mrp="bluetoothappprofiles/avrcp/bluetooth_avrcp.mrp"/>
-      </component>
-    </collection>
-    <collection id="btservices_info" name="BT Services Info" level="plugin">
-      <component id="btservices_metadata" name="BT Services Metadata" class="config" introduced="^3" purpose="development" target="desktop">
-        <unit mrp="btservices_info/btservices_metadata/btservices_metadata.mrp"/>
-      </component>
-    </collection>
-  </package>
+<SystemDefinition schema="3.0.0" xmlns:qt="http://www.nokia.com/qt">
+ <package id="btservices" name="Bluetooth Services" levels="framework server generic specific plugin">
+  <collection id="btservices_pub" name="BT Services Public Interfaces" level="plugin">
+   <component id="bluetooth_power_state_api" name="Bluetooth Power State API" class="api" filter="s60">
+    <meta rel="Api" href="btservices_pub/bluetooth_power_state_api/bluetooth_power_state_api.metaxml"/>
+    <unit bldFile="btservices_pub/bluetooth_power_state_api/group"/>
+   </component>
+   <component id="bluetooth_notifier_api" name="Bluetooth Notifier API" class="api" filter="s60">
+    <meta rel="Api" href="btservices_pub/bluetooth_notifier_api/bluetooth_notifier_api.metaxml"/>
+    <unit bldFile="btservices_pub/bluetooth_notifier_api/group"/>
+   </component>
+  </collection>
+  <collection id="btservices_plat" name="BT Services Platform Interfaces" level="plugin">
+   <!-- Turn the device setting pri file into a pro and rephrase this entry accordingly and get rid of btservices_plat.pro -->
+   <component id="bt_remote_device_setting_api" name="Bluetooth Remote Device Setting API" class="api" filter="s60" introduced="^4">
+    <meta rel="Api" href="btservices_plat/bt_remote_device_setting_api/bt_remote_device_setting_api.metaxml"/>
+    <unit bldFile="btservices_plat" qt:proFile="btservices_plat.pro"/>
+   </component>
+   <component id="bluetooth_dosserver_audio_api" name="Bluetooth DOS Server Audio API" class="api" filter="s60">
+    <meta rel="Api" href="btservices_plat/bluetooth_dosserver_audio_api/bluetooth_dosserver_audio_api.metaxml"/>
+    <unit bldFile="btservices_plat/bluetooth_dosserver_audio_api/group"/>
+   </component>
+   <component id="bluetooth_dut_mode_api" name="Bluetooth DUT Mode API" class="api" filter="s60">
+    <meta rel="Api" href="btservices_plat/bluetooth_dut_mode_api/bluetooth_dut_mode_api.metaxml"/>
+    <unit bldFile="btservices_plat/bluetooth_dut_mode_api/group"/>
+   </component>
+   <component id="bluetooth_engine_api" name="Bluetooth Engine API" class="api" filter="s60">
+    <meta rel="Api" href="btservices_plat/bluetooth_engine_api/bluetooth_engine_api.metaxml"/>
+    <unit bldFile="btservices_plat/bluetooth_engine_api/group"/>
+   </component>
+   <component id="bluetooth_engine_connection_management_api" name="Bluetooth Engine Connection Management API" class="api" filter="s60">
+    <meta rel="Api" href="btservices_plat/bluetooth_engine_connection_management_api/bluetooth_engine_connection_management_api.metaxml"/>
+    <unit bldFile="btservices_plat/bluetooth_engine_connection_management_api/group" filter="!test"/>
+    <unit bldFile="btservices_plat/bluetooth_engine_connection_management_api/tsrc/group"  filter="test,api_test"/>
+   </component>
+   <component id="bluetooth_engine_device_management_api" name="Bluetooth Engine Device Management API" class="api" filter="s60">
+    <meta rel="Api" href="btservices_plat/bluetooth_engine_device_management_api/bluetooth_engine_device_management_api.metaxml"/>
+    <unit bldFile="btservices_plat/bluetooth_engine_device_management_api/group" filter="!test"/>
+    <unit bldFile="btservices_plat/bluetooth_engine_device_management_api/tsrc/group"  filter="test,api_test"/>
+   </component>
+   <component id="bluetooth_engine_discovery_api" name="Bluetooth Engine Discovery API" class="api" filter="s60">
+    <meta rel="Api" href="btservices_plat/bluetooth_engine_discovery_api/bluetooth_engine_discovery_api.metaxml"/>
+    <unit bldFile="btservices_plat/bluetooth_engine_discovery_api/group" filter="!test"/>
+    <unit bldFile="btservices_plat/bluetooth_engine_discovery_api/tsrc/group"  filter="test,api_test"/>
+   </component>
+   <component id="bluetooth_engine_features_api" name="Bluetooth Engine Features API" class="api" filter="s60">
+    <meta rel="Api" href="btservices_plat/bluetooth_engine_features_api/bluetooth_engine_features_api.metaxml"/>
+    <unit bldFile="btservices_plat/bluetooth_engine_features_api/group"/>
+   </component>
+   <component id="bluetooth_engine_settings_api" name="Bluetooth Engine Settings API" class="api" filter="s60">
+    <meta rel="Api" href="btservices_plat/bluetooth_engine_settings_api/bluetooth_engine_settings_api.metaxml"/>
+    <unit bldFile="btservices_plat/bluetooth_engine_settings_api/group" filter="!test"/>
+    <unit bldFile="btservices_plat/bluetooth_engine_settings_api/tsrc/group"  filter="test,api_test"/>
+   </component>
+   <component id="bluetooth_engine_plugin_api" name="Bluetooth Engine Plugin API" class="api" filter="s60">
+    <meta rel="Api" href="btservices_plat/bluetooth_engine_plugin_api/bluetooth_engine_plugin_api.metaxml"/>
+    <unit bldFile="btservices_plat/bluetooth_engine_plugin_api/group"/>
+   </component>
+   <component id="bluetooth_local_variation_api" name="Bluetooth Local Variation API" class="api" filter="s60">
+    <meta rel="Api" href="btservices_plat/bluetooth_local_variation_api/bluetooth_local_variation_api.metaxml"/>
+    <unit bldFile="btservices_plat/bluetooth_local_variation_api/group"/>
+   </component>
+   <component id="bluetooth_notifier_internal_api" name="Bluetooth Notifier internal API" class="api" filter="s60">
+    <meta rel="Api" href="btservices_plat/bluetooth_notifier_internal_api/bluetooth_notifier_internal_api.metaxml"/>
+    <unit bldFile="btservices_plat/bluetooth_notifier_internal_api/group"/>
+   </component>
+   <component id="bluetooth_sap_connection_state_api" name="Bluetooth SAP Connection State API" class="api" filter="s60">
+    <meta rel="Api" href="btservices_plat/bluetooth_sap_connection_state_api/bluetooth_sap_connection_state_api.metaxml"/>
+    <unit bldFile="btservices_plat/bluetooth_sap_connection_state_api/group"/>
+   </component>
+   <component id="bluetooth_secondary_display_notification_api" name="Bluetooth Secondary Display Notification API" class="api" filter="s60">
+    <meta rel="Api" href="btservices_plat/bluetooth_secondary_display_notification_api/bluetooth_secondary_display_notification_api.metaxml"/>
+    <unit bldFile="btservices_plat/bluetooth_secondary_display_notification_api/group"/>
+   </component>
+   <component id="obex_secondary_display_notification_api" name="OBEX Secondary Display Notification API" class="api" filter="s60">
+    <meta rel="Api" href="btservices_plat/obex_secondary_display_notification_api/obex_secondary_display_notification_api.metaxml"/>
+    <unit bldFile="btservices_plat/obex_secondary_display_notification_api/group"/>
+   </component>
+   <component id="obex_service_plugin_api" name="OBEX Service Plugin API" class="api" filter="s60">
+    <meta rel="Api" href="btservices_plat/obex_service_plugin_api/obex_service_plugin_api.metaxml"/>
+    <unit bldFile="btservices_plat/obex_service_plugin_api/group"/>
+   </component>
+   <component id="obex_service_utils_api" name="OBEX Service Utils API" class="api" filter="s60">
+    <meta rel="Api" href="btservices_plat/obex_service_utils_api/obex_service_utils_api.metaxml"/>
+    <unit bldFile="btservices_plat/obex_service_utils_api/group"/>
+   </component>
+   <component id="usb_obexservicemanager_client_api" name="OBEX Service Manager Client API" class="api" filter="s60">
+    <unit bldFile="btservices_plat/usb_obexservicemanager_client_api/group"/>
+   </component>
+  </collection>
+  <collection id="bluetoothengine" name="Bluetooth Engine" level="framework">
+   <component id="btnotifclient" filter="s60" name="Bluetooth Notification Client" introduced="^4">
+	<!-- cannot put a component under another component. Move up a directory -->
+    <unit bldFile="bluetoothengine/btnotif/btnotifclient/group"/>
+   </component>
+   <component id="bteng" filter="s60" name="Bluetooth Engine">
+    <unit bldFile="bluetoothengine/bteng/group"/>
+   </component>
+   <component id="btserviceutil" filter="s60" name="Bluetooth Service Utils" introduced="^4">
+    <unit bldFile="bluetoothengine/btserviceutil/group" filter="!test"/>
+    <unit bldFile="bluetoothengine/btserviceutil/tsrc/btserviceutiltest/group"  filter="test,api_test"/>
+   </component>
+   <component id="btnotif" filter="s60" name="Bluetooth Notifier">
+    <unit bldFile="bluetoothengine/btnotif/group"/>
+   </component>
+   <!-- btdevicedialogplugin is a component, under another component (btnotif)- this is a coding standards violation -->
+   <component id="btdevicedialogplugin" filter="s60" name="Bluetooth Device Dialog Plugin" class="plugin" introduced="^4">
+    <unit bldFile="bluetoothengine/btnotif/btdevicedialogplugin" qt:proFile="btdevicedialogplugin.pro"/>
+   </component>
+   <component id="btaudioman" filter="s60" name="Bluetooth Audio Manager">
+    <unit bldFile="bluetoothengine/btaudioman/group" filter="!test"/>
+    <unit bldFile="bluetoothengine/btaudioman/tsrc/btAudioManApiTest/group"  filter="test,api_test"/>
+   </component>
+   <component id="btmac" filter="s60" name="Bluetooth Mono Audio Controller" class="plugin">
+    <unit bldFile="bluetoothengine/btmac/group"/>
+   </component>
+   <component id="btsac" filter="s60" name="Bluetooth Stereo Audio Controller" class="plugin">
+    <unit bldFile="bluetoothengine/btsac/group"/>
+   </component>
+   <component id="btaudiostreamer" filter="s60" name="Bluetooth Audio Streamer">
+    <unit bldFile="bluetoothengine/btaudiostreamer/group" filter="!test"/>
+    <unit bldFile="bluetoothengine/btaudiostreamer/tsrc/BtAudioStreamerApiTest/group" filter="test,api_test"/>
+   </component>
+   <component id="btsap" filter="s60" name="Bluetooth SIM Access Profile" class="plugin">
+    <unit bldFile="bluetoothengine/btsap/group"/>
+   </component>
+   <component id="btui" filter="s60" name="Bluetooth UI">
+	 <unit  bldFile="bluetoothengine/btui" qt:proFile="btui.pro" />
+   </component>
+   <component id="btpbap" filter="s60" name="Bluetooth Phonebook Access Profile" class="plugin">
+    <unit bldFile="bluetoothengine/btpbap/group"/>
+   </component>
+   <component id="bthid" filter="s60" name="Bluetooth HID">
+    <unit bldFile="bluetoothengine/bthid/group"/>
+   </component>
+   <component id="btindicator" filter="s60" name="Bluetooth Indicator" introduced="^4">
+    <unit bldFile="bluetoothengine/btindicator" qt:proFile="btindicator.pro"/>
+   </component>
+   <component id="btctrldcmoadapter" filter="s60" name="Bluetooth Control DCMO Adapter" class="plugin" introduced="^3">
+    <unit bldFile="bluetoothengine/btctrldcmoadapter/group"/>
+   </component>
+  </collection>
+  <collection id="bluetoothappprofiles" name="Bluetooth Application Profiles" level="plugin">
+   <component id="avrcp" name="Bluetooth AVRCP" introduced="9.1" purpose="optional">
+    <unit bldFile="bluetoothappprofiles/avrcp" mrp="bluetoothappprofiles/avrcp/bluetooth_avrcp.mrp"/>
+   </component>
+  </collection>
+  <collection id="atcommands" name="AT Commands" level="generic">
+   <component id="modematplugin" name="Modem AT Plugin" filter="s60" class="plugin" introduced="^4">
+    <unit bldFile="atcommands/modematplugin/group"/>
+   </component>
+   <component id="lccustomplugin" name="LC Custom Plugin" filter="s60" class="plugin" introduced="^4">
+    <unit bldFile="atcommands/lccustomplugin/group"/>
+   </component>
+  </collection>
+  <collection id="cbsatplugin" name="CBS AT Plugin" level="plugin">
+     <component id="atmisccmdplugin" name="AT Misc Commands Plugin"  filter="s60" class="plugin" introduced="^4">
+      <unit bldFile="cbsatplugin/atmisccmdplugin/group"/>
+     </component>
+  </collection>
+  <collection id="btobexprofiles" name="BT OBEX Profiles" level="generic">
+     <component id="obexreceiveservices" name="OBEX Receive Services"  filter="s60">
+      <unit bldFile="btobexprofiles/obexreceiveservices/group"/>
+     </component>
+     <!-- Move this up to btobexprofiles/btmsgviewer, because obexreceiveservices is already a cpt and you can't have components inside components -->
+     <component id="btmsgviewer" name="BT message viewer"  filter="s60" introduced="^4">
+      <unit bldFile="btobexprofiles/obexreceiveservices/btmsgviewer" qt:proFile="btmsgviewer.pro"/>
+     </component>
+     <component id="obexsendservices" name="OBEX Send Services"  filter="s60">
+      <unit bldFile="btobexprofiles/obexsendservices/group"/>
+     </component>
+     <component id="obexhighway" name="OBEX Highway"  filter="s60" introduced="^4">
+		<!-- should be moved out from under obexsendservices into own component dir -->
+        <unit bldFile="btobexprofiles/obexsendservices/obexhighway" qt:proFile="obexhighway.pro"/>
+     </component>
+     <component id="obexserviceman" name="OBEX Service Manager"  filter="s60">
+      <unit bldFile="btobexprofiles/obexserviceman/group"/>
+     </component>
+  </collection>
+  <collection id="btservices_info" name="BT Services Info" level="plugin">
+   <component id="btservices_metadata" name="BT Services Metadata" class="config" introduced="^3" purpose="development" target="desktop">
+    <unit mrp="btservices_info/btservices_metadata/btservices_metadata.mrp"/>
+   </component>
+  </collection>
+ </package>
 </SystemDefinition>
+