Revision: 201021 RCL_3
authorDremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Wed, 09 Jun 2010 09:52:54 +0300
branchRCL_3
changeset 35 95674584745d
parent 21 53b7818cd282
child 39 5a89845f78e2
Revision: 201021 Kit: 2010123
atcommands/lccustomplugin/src/lccustomplugin.cpp
atcommands/lccustomplugin/src/lclistallcmd.cpp
atcommands/modematplugin/src/modematplugin.cpp
bluetoothengine/bteng/src/btengsrvsession.cpp
bluetoothengine/bthid/bthidkbdsettings/data/BthidResource.rss
bluetoothengine/btnotif/inc/btninqui.h
bluetoothengine/btnotif/inc/btnotifuiutil.h
bluetoothengine/btnotif/src/BTNAuthNotifier.cpp
bluetoothengine/btnotif/src/BTNGenericInfoNotifier.cpp
bluetoothengine/btnotif/src/BTNGenericQueryNotifier.cpp
bluetoothengine/btnotif/src/BTNInqUI.cpp
bluetoothengine/btnotif/src/BTNInquiAO.cpp
bluetoothengine/btnotif/src/BTNObexPinNotifier.cpp
bluetoothengine/btnotif/src/BTNPBAPPinNotifier.cpp
bluetoothengine/btnotif/src/BTNPinNotifier.cpp
bluetoothengine/btnotif/src/BTNPwrNotifier.cpp
bluetoothengine/btnotif/src/btnpaireddevsettnotifier.cpp
bluetoothengine/btnotif/src/btnssppasskeyentrynotifier.cpp
bluetoothengine/btnotif/src/btnumcmpnotifier.cpp
bluetoothengine/btnotif/src/btuserconfnotifier.cpp
bluetoothengine/btui/Ecom/inc/BTUIPairedDevicesView.h
bluetoothengine/btui/Ecom/src/BTUIBlockedDevicesView.cpp
bluetoothengine/btui/Ecom/src/BTUIMainView.cpp
bluetoothengine/btui/Ecom/src/BTUIPairedDevicesView.cpp
bluetoothengine/btui/Ecom/src/BTUISap.cpp
bluetoothengine/btui/Ecom/src/BTUIViewsCommonUtils.cpp
cbsatplugin/atmisccmdplugin/data/2002C3BA.rss
cbsatplugin/atmisccmdplugin/group/atmisccmdplugin.mmp
cbsatplugin/atmisccmdplugin/inc/atcmdasyncbase.h
cbsatplugin/atmisccmdplugin/inc/atcmdbase.h
cbsatplugin/atmisccmdplugin/inc/atcmdsyncbase.h
cbsatplugin/atmisccmdplugin/inc/atcommandparser.h
cbsatplugin/atmisccmdplugin/inc/atmisccmdplugin.h
cbsatplugin/atmisccmdplugin/inc/atmisccmdpluginconsts.h
cbsatplugin/atmisccmdplugin/inc/cbccommandhandler.h
cbsatplugin/atmisccmdplugin/inc/cfuncommandhandler.h
cbsatplugin/atmisccmdplugin/inc/clckcommandhandler.h
cbsatplugin/atmisccmdplugin/inc/cnumcommandhandler.h
cbsatplugin/atmisccmdplugin/inc/cpincommandhandler.h
cbsatplugin/atmisccmdplugin/inc/cpwdcommandhandler.h
cbsatplugin/atmisccmdplugin/inc/cusdcommandhandler.h
cbsatplugin/atmisccmdplugin/inc/cusdreadwriteimp.h
cbsatplugin/atmisccmdplugin/inc/ussdreadmessageimpl.h
cbsatplugin/atmisccmdplugin/inc/ussdsendmessageimpl.h
cbsatplugin/atmisccmdplugin/src/atcmdasyncbase.cpp
cbsatplugin/atmisccmdplugin/src/atcmdsyncbase.cpp
cbsatplugin/atmisccmdplugin/src/atcommandparser.cpp
cbsatplugin/atmisccmdplugin/src/atmisccmdplugin.cpp
cbsatplugin/atmisccmdplugin/src/atmisccmdpluginbase.cpp
cbsatplugin/atmisccmdplugin/src/cbccommandhandler.cpp
cbsatplugin/atmisccmdplugin/src/cbsettinghandler.cpp
cbsatplugin/atmisccmdplugin/src/cfuncommandhandler.cpp
cbsatplugin/atmisccmdplugin/src/clckcommandhandler.cpp
cbsatplugin/atmisccmdplugin/src/cnumcommandhandler.cpp
cbsatplugin/atmisccmdplugin/src/cpincommandhandler.cpp
cbsatplugin/atmisccmdplugin/src/cpwdcommandhandler.cpp
cbsatplugin/atmisccmdplugin/src/cusdcommandhandler.cpp
cbsatplugin/atmisccmdplugin/src/cusdreadwriteimp.cpp
cbsatplugin/atmisccmdplugin/src/ussdreadmessageimpl.cpp
cbsatplugin/atmisccmdplugin/src/ussdsendmessageimpl.cpp
--- a/atcommands/lccustomplugin/src/lccustomplugin.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/atcommands/lccustomplugin/src/lccustomplugin.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -278,14 +278,7 @@
     switch ( aReplyType )
         {
         case EReplyTypeOther:
-            if ( iQuietMode )
-                {
-                iReplyBuffer.Create( KNullDesC8 );
-                }
-            else
-                {
-                iReplyBuffer.Create( aSrcBuffer );
-                }
+            iReplyBuffer.Create( aSrcBuffer );
             break;
         case EReplyTypeOk:
             CreateOkOrErrorReply( iReplyBuffer, ETrue );
--- a/atcommands/lccustomplugin/src/lclistallcmd.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/atcommands/lccustomplugin/src/lclistallcmd.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -142,13 +142,6 @@
         return;
         }
     RBuf8 reply;
-    if ( quietMode )
-        {
-        iCallback->CreateReplyAndComplete( EReplyTypeOther, reply );
-        reply.Close();
-        TRACE_FUNC_EXIT
-        return;
-        }
     TBool error = CreateSupportedList( reply );
     if ( error )
         {
--- a/atcommands/modematplugin/src/modematplugin.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/atcommands/modematplugin/src/modematplugin.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -283,14 +283,7 @@
     switch ( aReplyType )
         {
         case EReplyTypeOther:
-            if ( iQuietMode )  //  In quite mode there should be no response at all. 
-                {
-                iReplyBuffer.Create( KNullDesC8 );
-                }
-            else
-                {
-                iReplyBuffer.Create( aSrcBuffer ); 
-                }
+            iReplyBuffer.Create( aSrcBuffer );
             break;
         case EReplyTypeOk:
             CreateOkOrErrorReply( iReplyBuffer, ETrue );
--- a/bluetoothengine/bteng/src/btengsrvsession.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/bluetoothengine/bteng/src/btengsrvsession.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -190,6 +190,8 @@
         {
         case EBTEngSetPowerState:
             {
+            // Store auto off information
+            iAutoSwitchOff = (TBool) aMessage.Int1();
             Server()->SetPowerStateL( aMessage );
             }
             break;
--- a/bluetoothengine/bthid/bthidkbdsettings/data/BthidResource.rss	Tue May 25 12:53:11 2010 +0300
+++ b/bluetoothengine/bthid/bthidkbdsettings/data/BthidResource.rss	Wed Jun 09 09:52:54 2010 +0300
@@ -98,11 +98,13 @@
             command=EBTKeyCmdAppChange;
             txt = qtn_hid_change;
             },
+#ifdef __SERIES60_HELP
         MENU_ITEM 
             { 
-            command=EBTKeyCmdAppHelp;
-            txt = qtn_hid_help;
+            command = EBTKeyCmdAppHelp; 
+            txt = qtn_options_help; 
             },
+#endif
         MENU_ITEM 
             {
             command=EEikCmdExit; 
--- a/bluetoothengine/btnotif/inc/btninqui.h	Tue May 25 12:53:11 2010 +0300
+++ b/bluetoothengine/btnotif/inc/btninqui.h	Wed Jun 09 09:52:54 2010 +0300
@@ -111,9 +111,10 @@
          * Check if Eir device name available.
          * @param TNameEntry    Decode it to get device name
          * @param TBTDeviceName Device name returned
+         * @param TBool         Is the name returned complete
          * @return ETrue if Eir data contains name.
          */
-        static TBool CheckEirDeviceName( TNameEntry& aEntry, TBTDeviceName& aName );
+        static TBool CheckEirDeviceName( TNameEntry& aEntry, TBTDeviceName& aName, TBool& aIsComplete );
 
     private: // Functions from base classes
         
@@ -193,7 +194,7 @@
         * @param aSignalStrength The signal bar for RSSI
         * @return None.
         */
-        void UpdateDeviceListL(CBTDevice* aDevice, const TInt aSignalStrength = 0 );             
+        void AddToDeviceListBoxL(CBTDevice* aDevice, const TInt aSignalStrength = 0 );             
 		
 		/**
         * Creates and adds local bitmap to icon array.
@@ -282,7 +283,7 @@
          * Adds found Bluetooth device into popup list.
          * @param aInquiryResultRecord TNameEntry and flag, which indicates if Eir device.
          */
-        void DeviceAvailableL( const TNameRecord& aNameRecord, const TDesC& aDevName);
+        void DeviceAvailableL( const TNameRecord& aNameRecord, const TDesC& aDevName, TBool aIsNameComplete );
         
         /**
         * The inquiry has been completed.
@@ -296,18 +297,45 @@
          * which passes the search filter. Its name will be retrived later
          */
         void HandleInquiryDeviceL();
-        
-        void HandleFoundNameL();   
-        
+
+        /**
+         * Name lookup complete for the current device in the unnamed devices queue.
+         */
+        void HandleFoundNameL();  
+
+        /**
+         * Name lookup complete for device aLastSeenIndex in the last seen array
+         * (this is done for devices with partial names returned by EIR).
+         */
+        void HandleUpdatedNameL(TInt aLastSeenIndex);
+
         /**
          * Allow/Disallow dialer and app key presses.
          * @param aAllow ETrue to allow  key press; EFalse to disallow.
          */
         void AllowDialerAndAppKeyPress( TBool aAllow );
 
+        /**
+         * Update the inquiry list box with a new (complete) device name
+         * (this is done for devices with partial names returned by EIR).
+         */
+        void DeviceNameUpdatedL(const TNameRecord& aNameRecord, TInt aLastSeenIndex);
+        void DeviceUpdatedL(TInt aSignalStrength, TInt aLastSeenIndex);
+
+        /**
+         * React to page timeout on a device that's already in the inquiry list box
+         * (which can happen for devices with partial names returned by EIR).
+         */
+        void PageTimeoutOnDeviceWithPartialNameL(TInt aLastSeenIndex);
+
+        void FormatListBoxEntryL(CBTDevice& aDevice, const TInt aSignalStrength, TPtr aFormatString);
+
+        TBool HaveDevsWithPartialName(TInt& aFirstFoundIndex);
+
     private:  // Data
         CBTNotifUIUtil*         iUiUtil;
-        CBTDeviceArray*         iLastSeenDevicesArray;            // Last seen devices array from BTInqNotifier
+        CBTDeviceArray*         iLastSeenDevicesArray;           // Last seen devices array from BTInqNotifier
+        RArray<TBool>           iLastSeenDevicesNameComplete;    // Is the name in corresponding cell of iLastSeenDevicesArray complete ?
         CBTDeviceArray*         iLastUsedDevicesArray;           // Used devices from BT registry
         CBTDeviceArray*         iPairedDevicesArray;             // Paired devices from Bluetooth registry
         CBTDeviceArray*         iAdjustedUsedDeviceArray;         // 5 Lately used devices + All the Paired devices 
@@ -342,7 +370,7 @@
         TNameEntry          iEntry;             // Inquiry results record
         TBool               iPageForName;    // Flag for inquiry name
         RArray<TNameRecord> iDevsWithoutName;    // Devices without dev name 
-        TInt                iIndex;             // Current btdevice to inquiry its name 
+        TInt                iCurrentlyResolvingUnnamedDeviceIndex;             // Current btdevice to inquiry its name 
         MBTNDeviceSearchObserver* iDevSearchObserver;
 
 		TBool               iExcludePairedDevices;
--- a/bluetoothengine/btnotif/inc/btnotifuiutil.h	Tue May 25 12:53:11 2010 +0300
+++ b/bluetoothengine/btnotif/inc/btnotifuiutil.h	Wed Jun 09 09:52:54 2010 +0300
@@ -21,7 +21,7 @@
 #include <data_caging_path_literals.hrh> 
 #include <AknQueryDialog.h>
 #include <AknWaitDialog.h>
-#include <secondarydisplay/BTnotifSecondaryDisplayAPI.h>
+#include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h>
 
 // CONSTANTS
 // Literals for resource and bitmap files ( drive, directory, filename(s) )
--- a/bluetoothengine/btnotif/src/BTNAuthNotifier.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/bluetoothengine/btnotif/src/BTNAuthNotifier.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -22,7 +22,7 @@
 #include "btNotifDebug.h"    // Debugging macros
 #include <btextnotifiers.h>
 #include <AknMediatorFacade.h> // Cover UI
-#include <secondarydisplay/BTnotifSecondaryDisplayAPI.h>
+#include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h>
 #include <btengconstants.h>
 #include <btengsettings.h>
 #include <e32cmn.h>
--- a/bluetoothengine/btnotif/src/BTNGenericInfoNotifier.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/bluetoothengine/btnotif/src/BTNGenericInfoNotifier.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -22,7 +22,7 @@
 #include <BTNotif.rsg>          // Own resources
 #include "BTNGenericInfoNotifier.h"      // Own class definition
 #include "btNotifDebug.h"       // Debugging macros
-#include <secondarydisplay/BTnotifSecondaryDisplayAPI.h>
+#include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h>
 #include <e32cmn.h>
 #include <bluetoothuiutil.h>
 #include "btnotifnameutils.h"
--- a/bluetoothengine/btnotif/src/BTNGenericQueryNotifier.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/bluetoothengine/btnotif/src/BTNGenericQueryNotifier.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -19,7 +19,7 @@
 // INCLUDE FILES
 
 #include <StringLoader.h>       // Localisation stringloader
-#include <secondarydisplay/BTnotifSecondaryDisplayAPI.h>
+#include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h>
 #include <e32cmn.h>
 #include <BTNotif.rsg>          // Own resources
 #include <btengsettings.h>
--- a/bluetoothengine/btnotif/src/BTNInqUI.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/bluetoothengine/btnotif/src/BTNInqUI.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -42,6 +42,7 @@
 const TInt KBTNotifNonPairedUsedDevicesMaxNumber= 5;
 // RSSI value range: -127dB ~ +20dB
 const TInt KRssiRangeOffset = 127 + 1;  // Offset for getting a non-zero positive value
+const TInt KMinimumStrength = 1;
 const TInt KMediumStrength = 53;
 const TInt KHighStrength = 82;
 const TUint32 ExcludePairedDeviceMask = 0x800000;
@@ -67,7 +68,7 @@
         iDesiredDeviceClass (aDesiredDevClass),
         iSystemCancel (EFalse), 
         iPageForName ( EFalse ),
-        iIndex (0),
+        iCurrentlyResolvingUnnamedDeviceIndex (0),
         iDevSearchObserver (aObserver)
     {
 	iBTRegistryQueryState=ENoQuery;
@@ -230,8 +231,11 @@
         iLastSeenDevicesArray->ResetAndDestroy();
         delete iLastSeenDevicesArray; 
         }
+
+    iLastSeenDevicesNameComplete.Close();
+
     if( iAdjustedUsedDeviceArray )
-        {  
+        {
         iAdjustedUsedDeviceArray->ResetAndDestroy();
         delete iAdjustedUsedDeviceArray; 
         }
@@ -307,7 +311,7 @@
     // Add devices into device list.
     for( TInt index = 0; index < iAdjustedUsedDeviceArray->Count(); index++ )
     	{        
-   	    UpdateDeviceListL ( iAdjustedUsedDeviceArray->At(index) );  
+   	    AddToDeviceListBoxL ( iAdjustedUsedDeviceArray->At(index) );  
         }  
 
     // Add "more devices" command as first item of list
@@ -438,7 +442,7 @@
     // Inquiry completed, show final device list 
     FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceSearchUiL Displaying final devicelist"));          
     CreatePopupListL( R_AVKON_SOFTKEYS_SELECT_CANCEL__SELECT, R_BT_FOUND_DEVS_POPUP_TITLE );
-   
+
     //cancel iPeriodicTimer after the final list is shown
     iPeriodicTimer->Cancel();
     User::ResetInactivityTime();
@@ -540,7 +544,7 @@
 // Bluetooth device has been received.
 // ----------------------------------------------------------
 //
-void CBTInqUI::DeviceAvailableL( const TNameRecord& aNameRecord, const TDesC& aDevName )
+void CBTInqUI::DeviceAvailableL( const TNameRecord& aNameRecord, const TDesC& aDevName, TBool aIsNameComplete )
     {
     FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceAvailableL()"));
 
@@ -567,18 +571,168 @@
         rssi = sa.Rssi() + KRssiRangeOffset;
         }
 
-    BtNotifNameUtils::SetDeviceNameL(aDevName, *newDevice);
-
-    // Update device popup list with newDevice
-    UpdateDeviceListL( newDevice, rssi );
+    TBTDeviceName name(aDevName);
+    if (!aIsNameComplete)
+        {
+        // Append a little "..." to partial names.
+        _LIT(KToBeContd, "...");
+        if (name.MaxLength() - name.Length() >= KToBeContd().Length())
+            {
+            name.Append(KToBeContd);
+            }
+        }
+    BtNotifNameUtils::SetDeviceNameL(name, *newDevice);
 
     // Append newDevice in the bottom of the "last seen" device array.
     iLastSeenDevicesArray->AppendL(newDevice);
+    iLastSeenDevicesNameComplete.AppendL(aIsNameComplete);
     CleanupStack::Pop(); // new device is under iLastSeenDevicesArray control now
 
+    __ASSERT_DEBUG(iLastSeenDevicesArray->Count() == iLastSeenDevicesNameComplete.Count(),
+                   User::Panic(_L("BTNotifInqUI - device array and name resolution status array out of sync"), KErrCorrupt));
+
+    // Update device popup list with newDevice
+    AddToDeviceListBoxL( newDevice, rssi );
+
+    __ASSERT_DEBUG(iLastSeenDevicesArray->Count() == iDeviceListRows->Count(),
+                   User::Panic(_L("BTNotifInqUI - device array and UI list out of sync"), KErrCorrupt));
+
     FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceAvailableL() completed"));
     }
 
+void CBTInqUI::DeviceNameUpdatedL(const TNameRecord& aNameRecord, TInt aLastSeenIndex)
+    {
+    FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::DeviceUpdatedL() Name found: %S"), &(aNameRecord.iName) ));
+
+    TInquirySockAddr& sa = TInquirySockAddr::Cast( iEntry().iAddr );
+
+    TInt rssi = 0;
+    if( sa.ResultFlags() & TInquirySockAddr::ERssiValid )
+        {
+        rssi = sa.Rssi() + KRssiRangeOffset;
+        }
+
+    BtNotifNameUtils::SetDeviceNameL(aNameRecord.iName, *iLastSeenDevicesArray->At(aLastSeenIndex));
+    DeviceUpdatedL(rssi, aLastSeenIndex);
+
+    FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceUpdatedL() completed"));
+    }
+
+void CBTInqUI::PageTimeoutOnDeviceWithPartialNameL(TInt aLastSeenIndex)
+    {
+    FLOG(_L("[BTNOTIF]\t CBTInqUI::PageTimeoutOnDeviceWithPartialNameL()"));
+    DeviceUpdatedL(KMinimumStrength, aLastSeenIndex);
+    FLOG(_L("[BTNOTIF]\t CBTInqUI::PageTimeoutOnDeviceWithPartialNameL() completed"));
+    }
+
+
+void CBTInqUI::DeviceUpdatedL(TInt aSignalStrength, TInt aLastSeenIndex)
+    {
+    FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceUpdatedL()"));
+
+    HBufC* formatString = HBufC::NewLC( KBTAllPurposeBufferLength );
+    FormatListBoxEntryL(*iLastSeenDevicesArray->At(aLastSeenIndex), aSignalStrength, formatString->Des());
+
+    // The assumption here is that iLastSeenDevicesArray is always accurately reflected
+    // in iDeviceListRows so device indexes match.
+    __ASSERT_DEBUG(iLastSeenDevicesArray->Count() == iDeviceListRows->Count(),
+                   User::Panic(_L("BTNotifInqUI - device array and UI dev list out of sync not created"), KErrCorrupt));
+
+    iDeviceListRows->Delete(aLastSeenIndex);
+    iDeviceListRows->InsertL(aLastSeenIndex, *formatString);
+    CleanupStack::PopAndDestroy();  // formatString
+
+    __ASSERT_DEBUG(iDeviceListBox,
+                   User::Panic(_L("BTNotifInqUI - UI list non-existant on name update"), KErrCorrupt));
+    iDeviceListBox->HandleItemAdditionL();
+
+    FLOG(_L("[BTNOTIF]\t CBTInqUI::DeviceUpdatedL()"));
+    }
+
+void CBTInqUI::FormatListBoxEntryL(CBTDevice& aDevice, const TInt aSignalStrength, TPtr aFormatString)
+    {
+    FLOG(_L("[BTNOTIF]\t CBTInqUI::FormatListBoxEntryL()"));
+
+    TInt iconIndex (EDeviceIconDefault);
+    TInt defNameIndex (EBTDeviceNameIndexDefault);
+
+    // Check whether the device is already in registry.
+    TInt index = LookupFromDevicesArray(iPairedDevicesArray, &aDevice );
+    if( index >= 0 )
+        {
+        // Update device's link key and friendly name 
+        // with those found from registry.
+        aDevice.UpdateL( *( iPairedDevicesArray->At( index ) ) );
+        }
+
+    for (TInt i = 0; i < KDeviceRowLayoutTableSize; i++)
+        {
+        if ( ( aDevice.DeviceClass().MajorDeviceClass() == KDeviceRowLayoutTable[i].iMajorDevClass ) &&
+            ( (aDevice.DeviceClass().MinorDeviceClass() == KDeviceRowLayoutTable[i].iMinorDevClass ) ||
+                    KDeviceRowLayoutTable[i].iMinorDevClass == 0 ) )
+            {
+            iconIndex = KDeviceRowLayoutTable[i].iIconIndex;
+            defNameIndex = KDeviceRowLayoutTable[i].iDefaultNameIndex;
+            break;
+            }
+        }
+    
+    if ( !aDevice.IsValidFriendlyName() && !aDevice.IsValidDeviceName() )
+        {
+        BtNotifNameUtils::SetDeviceNameL(iDefaultDeviceNamesArray->MdcaPoint(defNameIndex), aDevice);
+        }
+
+    //Convert device name to Unocode for display
+    if ( aDevice.IsValidFriendlyName() )
+        {
+        aFormatString.Copy( aDevice.FriendlyName() );
+        }
+    else 
+        {
+        aFormatString.Copy( BTDeviceNameConverter::ToUnicodeL(aDevice.DeviceName()));
+        }
+
+    TPtrC iconFormat (KDeviceIconFormatTable[iconIndex].iFormat);
+    
+    aFormatString.Insert( 0, iconFormat );
+
+    if( aSignalStrength > 0)
+        {
+        if( aSignalStrength <= KMediumStrength )
+            {
+            aFormatString.Append( TPtrC(KDeviceIconFormatTable[EDeviceIconRssiLow].iFormat ) );
+            }
+        else if( aSignalStrength <= KHighStrength )
+            {
+            aFormatString.Append( TPtrC(KDeviceIconFormatTable[EDeviceIconRssiMed].iFormat ) );
+            }
+        else
+            {
+            aFormatString.Append( TPtrC(KDeviceIconFormatTable[EDeviceIconRssiGood].iFormat ) );
+            }
+        }
+    
+    // If the device is paired, add paired icon to format list
+    // Paired device using JustWork file transfering mode is not shown as paired here. 
+    if( index >= 0 && IsUserAwarePaired ( aDevice.AsNamelessDevice() ) )
+        {
+        aFormatString.Append( TPtrC(KDeviceIconFormatTable[EDeviceIconPaired].iFormat ) );
+        }
+    else
+        {
+        // if device is blocked, add blocked icon to format list
+        
+        TInt indexB = LookupFromDevicesArray(iLastUsedDevicesArray, &aDevice );
+        
+        if ( indexB>=0 && iLastUsedDevicesArray->At( indexB )->GlobalSecurity().Banned())
+            {
+            aFormatString.Append( TPtrC(KDeviceIconFormatTable[EDeviceIconBlocked].iFormat ) );
+            }
+        }
+    FLOG(_L("[BTNOTIF]\t CBTInqUI::FormatListBoxEntryL() completed"));
+    }
+
+
 // ----------------------------------------------------------
 // CBTInqUI::InquiryComplete
 // Inquiry has been completed.
@@ -757,96 +911,19 @@
 // CBTInqUI::UpdateDeviceListL
 // ----------------------------------------------------------
 //
-void CBTInqUI::UpdateDeviceListL( CBTDevice* aDevice, const TInt aSignalStrength )
+void CBTInqUI::AddToDeviceListBoxL( CBTDevice* aDevice, const TInt aSignalStrength )
     {
-    FLOG(_L("[BTNOTIF]\t CBTInqUI::UpdateDeviceListL()")); 
-    
-    TInt iconIndex (EDeviceIconDefault);
-    TInt defNameIndex (EBTDeviceNameIndexDefault);
+    FLOG(_L("[BTNOTIF]\t CBTInqUI::AddToDeviceListBoxL()")); 
     
     HBufC* formatString = HBufC::NewLC( KBTAllPurposeBufferLength );
-
-    // Check whether the device is already in registry.
-    TInt index = LookupFromDevicesArray(iPairedDevicesArray, aDevice );
-
-    if( index >= 0 )
-        {
-        // Update device's link key and friendly name 
-        // with those found from registry.
-        aDevice->UpdateL( *( iPairedDevicesArray->At( index ) ) );
-        }
-
-	for (TInt i = 0; i < KDeviceRowLayoutTableSize; i++)
-	    {
-	    if ( ( aDevice->DeviceClass().MajorDeviceClass() == KDeviceRowLayoutTable[i].iMajorDevClass ) &&
-	        ( (aDevice->DeviceClass().MinorDeviceClass() == KDeviceRowLayoutTable[i].iMinorDevClass ) ||
-	                KDeviceRowLayoutTable[i].iMinorDevClass == 0 ) )
-            {
-            iconIndex = KDeviceRowLayoutTable[i].iIconIndex;
-            defNameIndex = KDeviceRowLayoutTable[i].iDefaultNameIndex;
-            break;
-            }
-	    }
-    
-	if ( !aDevice->IsValidFriendlyName() && !aDevice->IsValidDeviceName() )
-		{
-        BtNotifNameUtils::SetDeviceNameL(iDefaultDeviceNamesArray->MdcaPoint(defNameIndex), *aDevice);
-		}
-
-	//Convert device name to Unocode for display
-	if ( aDevice->IsValidFriendlyName() )
-		{
-        formatString->Des().Copy( aDevice->FriendlyName() );
-		}
-	else 
-		{
-		formatString->Des().Copy( BTDeviceNameConverter::ToUnicodeL(aDevice->DeviceName()));
-		}
-
-	TPtrC iconFormat (KDeviceIconFormatTable[iconIndex].iFormat);
-	
-    formatString->Des().Insert( 0, iconFormat );
-
-    if( aSignalStrength > 0)
-        {
-        if( aSignalStrength <= KMediumStrength )
-            {
-            formatString->Des().Append( TPtrC(KDeviceIconFormatTable[EDeviceIconRssiLow].iFormat ) );
-            }
-        else if( aSignalStrength <= KHighStrength )
-            {
-            formatString->Des().Append( TPtrC(KDeviceIconFormatTable[EDeviceIconRssiMed].iFormat ) );
-            }
-        else
-            {
-            formatString->Des().Append( TPtrC(KDeviceIconFormatTable[EDeviceIconRssiGood].iFormat ) );
-            }
-        }
-    
-    // If the device is paired, add paired icon to format list
-    // Paired device using JustWork file transfering mode is not shown as paired here. 
-    if( index >= 0 && IsUserAwarePaired ( aDevice->AsNamelessDevice() ) )
-        {
-        formatString->Des().Append( TPtrC(KDeviceIconFormatTable[EDeviceIconPaired].iFormat ) );
-        }
-    else
-    	{
-    	// if device is blocked, add blocked icon to format list
-    	
-    	TInt indexB = LookupFromDevicesArray(iLastUsedDevicesArray, aDevice );
-    	
-    	if ( indexB>=0 && iLastUsedDevicesArray->At( indexB )->GlobalSecurity().Banned())
-    		{
-        	formatString->Des().Append( TPtrC(KDeviceIconFormatTable[EDeviceIconBlocked].iFormat ) );
-    		}
-    	}
+    FormatListBoxEntryL(*aDevice, aSignalStrength, formatString->Des());
 
     // Add device format string into device items
     //
     TInt deviceCount = iDeviceListRows->Count();
 	iDeviceListRows->InsertL( deviceCount, *formatString );      
     CleanupStack::PopAndDestroy();  // formatString
-	
+
     TInt currentItemIndex = 0;
 	if(deviceCount != 0 && iDeviceListBox)
 		{
@@ -860,7 +937,7 @@
         iDeviceListBox->HandleItemAdditionL();
         
 		if(deviceCount != 0 )	
-			{        
+			{
 			//set highligh back to user selected one.       
 			iDeviceListBox->SetCurrentItemIndex(currentItemIndex); 
 			}
@@ -875,10 +952,10 @@
 		if( (currentItemIndex != topIndex  && deviceCount > 5 ) && (currentItemIndex+1 < deviceCount ) )
 			{
 			iDeviceListBox->SetTopItemIndex( topIndex+1 ); //scroll up
-			}	     
+			}
         }
-		
-    FLOG(_L("[BTNOTIF]\t CBTInqUI::UpdateDeviceListL() completed"));
+
+    FLOG(_L("[BTNOTIF]\t CBTInqUI::AddToDeviceListBoxL() completed"));
     }
 
 // ----------------------------------------------------------
@@ -1022,13 +1099,13 @@
 			//append it to the end of the list.
 	        if (j == sSize) 
 	            {
-							if ( iExcludePairedDevices )
-								 {                
-			            // Add device to list if device is not paired and iExcludePairedDevices is not set. 
-			            if ( !IsUserAwarePaired( iPairedDevicesArray->At(i)->AsNamelessDevice() ) )
-			                {                                      
-			                aDeviceArray->AppendL(iPairedDevicesArray->At(i)->CopyL());
-			                }			           
+				if ( iExcludePairedDevices )
+				    {                
+                    // Add device to list if device is not paired and iExcludePairedDevices is not set. 
+                    if ( !IsUserAwarePaired( iPairedDevicesArray->At(i)->AsNamelessDevice() ) )
+                        {                                      
+                        aDeviceArray->AppendL(iPairedDevicesArray->At(i)->CopyL());
+                        }			           
 	               }
 	            else
 	            	{
@@ -1338,4 +1415,20 @@
     FTRACE( FPrint( _L( "CBTInqUI::AllowDialerAndAppKeyPress : %d" ), aAllow ) );
     }
 
+TBool CBTInqUI::HaveDevsWithPartialName(TInt& aFirstFoundIndex )
+    {
+    FLOG(_L("[BTNOTIF]\t CBTInqUI::HaveDevsWithPartialName()."));
+    for (TInt i = 0; i < iLastSeenDevicesNameComplete.Count(); i++)
+        {
+        if (!iLastSeenDevicesNameComplete[i])
+            {
+            FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::HaveDevsWithPartialName() index %d is partial."), i));
+
+            aFirstFoundIndex = i;
+            return ETrue;
+            }
+        }
+    return EFalse;
+    }
+
 // End of File
--- a/bluetoothengine/btnotif/src/BTNInquiAO.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/bluetoothengine/btnotif/src/BTNInquiAO.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -66,10 +66,22 @@
         }
     else
         {
-        if( iIndex < iDevsWithoutName.Count() )
+        TInt firstPartialNameDevIndex;
+        if (HaveDevsWithPartialName(firstPartialNameDevIndex))
             {
+            FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::IssueRequestL() looking up device index %d (have partial name already)"), firstPartialNameDevIndex));
+
             action = KHostResName + KHostResIgnoreCache;
-            TInquirySockAddr& sa = TInquirySockAddr::Cast( iDevsWithoutName[iIndex].iAddr );
+            TInquirySockAddr sa;
+            sa.SetBTAddr(iLastSeenDevicesArray->At(firstPartialNameDevIndex)->BDAddr());
+            iInquirySockAddr.SetBTAddr( sa.BTAddr() );            
+            }
+        else if( iCurrentlyResolvingUnnamedDeviceIndex < iDevsWithoutName.Count() )
+            {
+            FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::IssueRequestL() looking up device index %d (currently anonymous)"), iCurrentlyResolvingUnnamedDeviceIndex));
+
+            action = KHostResName + KHostResIgnoreCache;
+            TInquirySockAddr& sa = TInquirySockAddr::Cast( iDevsWithoutName[iCurrentlyResolvingUnnamedDeviceIndex].iAddr );
             iInquirySockAddr.SetBTAddr( sa.BTAddr() );            
             }
         }
@@ -84,7 +96,7 @@
         {
         FLOG(_L("[BTNOTIF]\t CBTInqUI::RunL() All name inquiries complete ."));
         iPageForName = EFalse;
-        iIndex = 0;
+        iCurrentlyResolvingUnnamedDeviceIndex = 0;
         InquiryComplete( KErrNone );
         }
     FLOG(_L("[BTNOTIF]\t CBTInqUI::IssueRequestL() completed"));
@@ -101,13 +113,28 @@
     FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::RequestCompletedL() status: %d >>"), aStatus ));
     ASSERT( aId == KBTNotifInquiryNotifierReq);
     (void) aActive;
-    
+
+    TInt firstPartialNameDevIndex = -1;
+    const TBool haveDevsWithPartialName = HaveDevsWithPartialName(firstPartialNameDevIndex);
+
     if( aStatus == KErrNone )
         {
         if( iPageForName )
             {
-            HandleFoundNameL();
-            iIndex++;
+            FLOG(_L("[BTNOTIF]\t CBTInqUI::RequestCompletedL() in name request state."));
+
+            if (haveDevsWithPartialName)
+                {
+                // We resolve names in chronological order so it must be the first device
+                // with an incomplete name we can find on the last seen list.
+                HandleUpdatedNameL(firstPartialNameDevIndex);
+                }
+            else
+                {
+                // Must be the current index in iDevsWithoutName.
+                HandleFoundNameL();
+                iCurrentlyResolvingUnnamedDeviceIndex++;
+                }
             IssueRequestL();
             }
         else
@@ -120,16 +147,26 @@
     else if( aStatus == (KHCIErrorBase - EPageTimedOut) && iPageForName )
         {
         FLOG(_L("[BTNOTIF]\t CBTInqUI::RequestCompletedL() HCI:EPageTimeOut, page next one."));
-        iIndex++;
+        if (haveDevsWithPartialName)
+            {
+            // A device with incomplete name has probably gone out of range. Just removing
+            // it from the UI may be a bit confusing, so let's just update its RSSI indicator
+            // to minimum.
+            PageTimeoutOnDeviceWithPartialNameL(firstPartialNameDevIndex);
+            }
+        else
+            {
+            iCurrentlyResolvingUnnamedDeviceIndex++;            
+            }
         IssueRequestL();
         }
     else
         {
-        if( !iPageForName && iDevsWithoutName.Count()>0 )
+        if( !iPageForName && (iDevsWithoutName.Count() > 0 || haveDevsWithPartialName) )
             {
-            FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::RequestCompletedL() nameless devices %d, paging for name."), 
-                    iDevsWithoutName.Count() ));
-            iIndex = 0;
+            FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::RequestCompletedL() have devs with incomplete name = %d, nameless devices %d, paging for name."), 
+                    haveDevsWithPartialName, iDevsWithoutName.Count() ));
+            iCurrentlyResolvingUnnamedDeviceIndex = 0;
             iPageForName = ETrue;
             IssueRequestL();
             }
@@ -188,15 +225,16 @@
     FTRACE(FPrint(_L("[BTNOTIF]\t BT Address: %S"), &devAddrString));
 #endif
         TBTDeviceName devName;
-        TBool nameGotten = CheckEirDeviceName( iEntry, devName );
-        FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::HandleInquiryDeviceL() EIR device name? %d, %S"), nameGotten, &devName ));
+        TBool isNameComplete(EFalse);
+        TBool nameGotten = CheckEirDeviceName( iEntry, devName, isNameComplete );
+        FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::HandleInquiryDeviceL() EIR device name? %d, %S, complete = %d"), nameGotten, &devName, isNameComplete ));
         if( nameGotten )
             {
-            DeviceAvailableL( iEntry(), devName );
+            DeviceAvailableL( iEntry(), devName, isNameComplete );
             }
         else
             {
-            iDevsWithoutName.Append( iEntry() );
+            iDevsWithoutName.AppendL( iEntry() );
             }
         }
     }
@@ -217,29 +255,45 @@
     if( iEntry().iName != KNullDesC )
         {
         FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::HandleFoundNameL() Name found: %S"), &(iEntry().iName) ));
+        DeviceAvailableL( iDevsWithoutName[iCurrentlyResolvingUnnamedDeviceIndex], iEntry().iName, ETrue );
+        }
 
-        DeviceAvailableL( iDevsWithoutName[iIndex], iEntry().iName );
-        }
-    
     FLOG(_L("[BTNOTIF]\t CBTInqUI::HandleFoundNameL() Complete"));
     }
 
+void CBTInqUI::HandleUpdatedNameL(TInt aLastSeenIndex)
+    {
+#ifdef _DEBUG
+    TBuf<12> devAddrString;
+    TInquirySockAddr& sa = TInquirySockAddr::Cast( iEntry().iAddr );
+    sa.BTAddr().GetReadable(devAddrString);
+    FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::HandleUpdatedNameL() BT Address: %S"), &devAddrString));
+#endif
+    iLastSeenDevicesNameComplete[aLastSeenIndex] = ETrue;
+    if( iEntry().iName != KNullDesC )
+        {
+        DeviceNameUpdatedL(iEntry(), aLastSeenIndex);
+        }
+
+    FTRACE(FPrint(_L("[BTNOTIF]\t CBTInqUI::HandleUpdatedNameL() Complete")));
+    }
+
+
 // ----------------------------------------------------------
 // CBTInqUI::CheckEirDeviceName
 // Check if the retrieved the device info contains device name.  
 // ----------------------------------------------------------
 //
-TBool CBTInqUI::CheckEirDeviceName( TNameEntry& aEntry, TBTDeviceName& aName )
+TBool CBTInqUI::CheckEirDeviceName( TNameEntry& aEntry, TBTDeviceName& aName, TBool& aIsComplete )
     {
     TBluetoothNameRecordWrapper eir( aEntry() );
     TInt length = eir.GetDeviceNameLength();
-    
-    TBool isComplete( EFalse );
+
     TInt err( KErrNone );
-        
+
     if( length > 0 )
         {            
-        err = eir.GetDeviceName( aName, isComplete);
+        err = eir.GetDeviceName( aName, aIsComplete);
         return (!err);
         }
     return EFalse;
--- a/bluetoothengine/btnotif/src/BTNObexPinNotifier.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/bluetoothengine/btnotif/src/BTNObexPinNotifier.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -23,7 +23,7 @@
 #include "btnobexpinnotifier.h" // Own class definition
 #include "btNotifDebug.h"       // Debugging macros
 
-#include <secondarydisplay/BTnotifSecondaryDisplayAPI.h>
+#include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h>
 
 // ================= MEMBER FUNCTIONS =======================
 
--- a/bluetoothengine/btnotif/src/BTNPBAPPinNotifier.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/bluetoothengine/btnotif/src/BTNPBAPPinNotifier.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -31,7 +31,7 @@
 #include "btnpbappinnotifier.h" // own class definition
 #include "btNotifDebug.h"       // debugging macros
 
-#include <secondarydisplay/BTnotifSecondaryDisplayAPI.h>
+#include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h>
 
 // ================= MEMBER FUNCTIONS =======================
 
--- a/bluetoothengine/btnotif/src/BTNPinNotifier.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/bluetoothengine/btnotif/src/BTNPinNotifier.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -37,7 +37,7 @@
 #include <btextnotifierspartner.h>
 #endif
 
-#include <secondarydisplay/BTnotifSecondaryDisplayAPI.h>
+#include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h>
 
 #ifdef __SERIES60_HELP
 #include <hlplch.h>
--- a/bluetoothengine/btnotif/src/BTNPwrNotifier.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/bluetoothengine/btnotif/src/BTNPwrNotifier.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -21,7 +21,7 @@
 #include "btnpwrnotifier.h"  // Own class definition
 #include "btNotifDebug.h"    // Debugging macros
 #include <bt_subscribe.h>
-#include <secondarydisplay/BTnotifSecondaryDisplayAPI.h>
+#include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h>
 
 
 // ================= MEMBER FUNCTIONS =======================
--- a/bluetoothengine/btnotif/src/btnpaireddevsettnotifier.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/bluetoothengine/btnotif/src/btnpaireddevsettnotifier.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -27,7 +27,7 @@
 #include <bluetooth/hci/hcierrors.h>
 #include "btnotifnameutils.h"
 
-#include <secondarydisplay/BTnotifSecondaryDisplayAPI.h>
+#include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h>
 
 #include <e32cmn.h>
 #include <AknMediatorFacade.h>  // CoverUI 
--- a/bluetoothengine/btnotif/src/btnssppasskeyentrynotifier.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/bluetoothengine/btnotif/src/btnssppasskeyentrynotifier.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -30,7 +30,7 @@
 #include <btextnotifierspartner.h>
 #endif
 #include <BTNotif.rsg>       // Own resources
-#include <secondarydisplay/BTnotifSecondaryDisplayAPI.h>
+#include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h>
 #include <bluetoothuiutil.h>
 #include "btnotif.hrh"       // Own resource header
 #include "btnssppasskeyentrynotifier.h"  // Own class definition
--- a/bluetoothengine/btnotif/src/btnumcmpnotifier.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/bluetoothengine/btnotif/src/btnumcmpnotifier.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -32,7 +32,7 @@
 #include "btNotifDebug.h"    // Debugging macros
 #include <btotgpairpub.inl>
 #include <btengconnman.h>
-#include <secondarydisplay/BTnotifSecondaryDisplayAPI.h>
+#include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h>
 #include <bluetoothuiutil.h>
 #include "btnotifnameutils.h"
 
--- a/bluetoothengine/btnotif/src/btuserconfnotifier.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/bluetoothengine/btnotif/src/btuserconfnotifier.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -32,7 +32,7 @@
 #include "btNotifDebug.h"    // Debugging macros
 #include <btotgpairpub.inl>
 #include <btengconnman.h>
-#include <secondarydisplay/BTnotifSecondaryDisplayAPI.h>
+#include <SecondaryDisplay/BTnotifSecondaryDisplayAPI.h>
 #include <bluetoothuiutil.h>
 #include "btnotifnameutils.h"
 
--- a/bluetoothengine/btui/Ecom/inc/BTUIPairedDevicesView.h	Tue May 25 12:53:11 2010 +0300
+++ b/bluetoothengine/btui/Ecom/inc/BTUIPairedDevicesView.h	Wed Jun 09 09:52:54 2010 +0300
@@ -29,7 +29,7 @@
 #include "BTUIListedDevicesView.h"
 #include "btuipluginman.h"
 #include "BTUIActive.h"
-#include <secondarydisplay/BtuiSecondaryDisplayAPI.h>
+#include <SecondaryDisplay/BtuiSecondaryDisplayAPI.h>
 #include <gstabbedview.h>
 
 class CAknNavigationControlContainer;
--- a/bluetoothengine/btui/Ecom/src/BTUIBlockedDevicesView.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/bluetoothengine/btui/Ecom/src/BTUIBlockedDevicesView.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -27,7 +27,7 @@
 #include <StringLoader.h>   // Series 60 localisation stringloader
 #include <aknnavi.h>
 #include <hlplch.h>         // Help launcher
-#include <secondarydisplay/BtuiSecondaryDisplayAPI.h>
+#include <SecondaryDisplay/BtuiSecondaryDisplayAPI.h>
 
 #include "BTUIBlockedDevicesView.h"
 #include "BTUIDeviceContainer.h"
--- a/bluetoothengine/btui/Ecom/src/BTUIMainView.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/bluetoothengine/btui/Ecom/src/BTUIMainView.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -43,7 +43,7 @@
 #include <AknUtils.h>					// For char filter
 #include <CoreApplicationUIsSDKCRKeys.h>
 #include <hlplch.h>         			// Help launcher
-#include <secondarydisplay/BtuiSecondaryDisplayAPI.h>
+#include <SecondaryDisplay/BtuiSecondaryDisplayAPI.h>
 #include <btengprivatecrkeys.h>
 #include <gstabhelper.h>
 #include <gsfwviewuids.h>
--- a/bluetoothengine/btui/Ecom/src/BTUIPairedDevicesView.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/bluetoothengine/btui/Ecom/src/BTUIPairedDevicesView.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -43,7 +43,7 @@
 #include "btui.h" 						// Global declarations
 #include "BTUIPairedDevicesView.h"
 #include "BTUIDeviceContainer.h"
-#include <secondarydisplay/BtuiSecondaryDisplayAPI.h>
+#include <SecondaryDisplay/BtuiSecondaryDisplayAPI.h>
 #include <csxhelp/bt.hlp.hrh>   // Help IDs
 
 #include <gstabhelper.h>
--- a/bluetoothengine/btui/Ecom/src/BTUISap.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/bluetoothengine/btui/Ecom/src/BTUISap.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -25,7 +25,7 @@
 #include <btengconnman.h>       // for disconnect type and connection observer
 #include <btengsettings.h>
 #include <btengdevman.h>
-#include <secondarydisplay/BtuiSecondaryDisplayAPI.h>
+#include <SecondaryDisplay/BtuiSecondaryDisplayAPI.h>
 #include <btfeaturescfg.h>					// For EnterpriseEnablementL()
 #include <btnotif.h>
 #include <utf.h>
--- a/bluetoothengine/btui/Ecom/src/BTUIViewsCommonUtils.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/bluetoothengine/btui/Ecom/src/BTUIViewsCommonUtils.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -25,7 +25,7 @@
 #include <btengsettings.h>
 #include <ctsydomainpskeys.h>
 #include <CoreApplicationUIsSDKCRKeys.h>
-#include <secondarydisplay/BtuiSecondaryDisplayAPI.h>
+#include <SecondaryDisplay/BtuiSecondaryDisplayAPI.h>
 
 #include "BTUIViewsCommonUtils.h"
 #include "debug.h"
--- a/cbsatplugin/atmisccmdplugin/data/2002C3BA.rss	Tue May 25 12:53:11 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/data/2002C3BA.rss	Wed Jun 09 09:52:54 2010 +0300
@@ -31,7 +31,7 @@
 	                implementation_uid = 0x2002DC6B;// KUidATMiscCmdEcomImpl;
 	                version_no = 1;
 	                display_name = "Miscellaneous AT commands Implementation";
-	                default_data = "MAT+CLCK|MAT+CPWD|MAT+CUSD|MAT+CPIN|MAT+CNUM|MAT+CFUN|MAT+CBC";
+	                default_data = "MAT+CLCK|MAT+CPWD|MAT+CUSD|MAT+CPIN|MAT+CNUM|MAT+CFUN|MAT+CBC|OAT+CMEE";
 	                opaque_data = "";
 	                }
 				};
--- a/cbsatplugin/atmisccmdplugin/group/atmisccmdplugin.mmp	Tue May 25 12:53:11 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/group/atmisccmdplugin.mmp	Wed Jun 09 09:52:54 2010 +0300
@@ -26,7 +26,8 @@
 SOURCEPATH      ../src
 SOURCE          main.cpp
 SOURCE          atmisccmdplugin.cpp 
-SOURCE          atmisccmdpluginbase.cpp 
+SOURCE          atcmdasyncbase.cpp
+SOURCE          atcmdsyncbase.cpp  
 SOURCE          atcommandparser.cpp
 SOURCE          clckcommandhandler.cpp 
 SOURCE          securitycodeverifier.cpp
@@ -38,7 +39,9 @@
 SOURCE          cnumcommandhandler.cpp
 SOURCE          cfuncommandhandler.cpp 
 SOURCE          cbccommandhandler.cpp
-SOURCE          cusdreadwriteimp.cpp
+SOURCE          ussdreadmessageimpl.cpp
+SOURCE          ussdsendmessageimpl.cpp
+
 
 USERINCLUDE     ../inc
 
@@ -59,6 +62,11 @@
 LIBRARY         ProfileEng.lib
 LIBRARY         StarterClient.lib 
 
-DEBUGLIBRARY    flogger.lib
+LIBRARY			etel3rdparty.lib
+LIBRARY			sysutil.lib 
 
+LIBRARY		    flogger.lib
+
+MACRO _DEBUG
+MACRO USE_FILE_LOGGING
 // End of File
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cbsatplugin/atmisccmdplugin/inc/atcmdasyncbase.h	Wed Jun 09 09:52:54 2010 +0300
@@ -0,0 +1,49 @@
+/*
+* 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:  Base class for async commands
+*
+*/
+
+#ifndef ATCMDASYNCBASE_H
+#define ATCMDASYNCBASE_H
+
+#include <e32base.h>
+#include <etelmm.h>
+#include "atcommandparser.h"
+#include "atcmdbase.h"
+#include "atmisccmdplugin.h"
+
+/**
+ *  Abstract base class for async AT command handler interface.
+ *  It can not be instantiated individually as it doesn't fully
+ *  implement MATCmdBase.
+ *  
+ */
+NONSHARABLE_CLASS( CATCmdAsyncBase ) : public CActive,
+                                      public MATCmdBase
+    {
+public:
+    virtual ~CATCmdAsyncBase() {};
+    CATCmdAsyncBase(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone);
+
+    // From MATCmdBase
+    virtual void HandleCommandCancel();
+      
+protected:
+    MATMiscCmdPlugin* iCallback;
+    TAtCommandParser& iATCmdParser;
+    RMobilePhone& iPhone;
+    };
+
+#endif // ATCMDASYNCBASE_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cbsatplugin/atmisccmdplugin/inc/atcmdbase.h	Wed Jun 09 09:52:54 2010 +0300
@@ -0,0 +1,40 @@
+/*
+* 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:  Interface class for AT Commands
+*
+*/
+
+#ifndef ATCMDBASE_H_
+#define ATCMDBASE_H_
+
+/**
+ *  Class for accessing AT command common functionality
+ */
+NONSHARABLE_CLASS( MATCmdBase )
+    {
+public:
+    /**
+     * @see CATExtPluginBase::HandleCommand
+     */
+    virtual void HandleCommand( const TDesC8& aCmd,
+                                RBuf8& aReply,
+                                TBool aReplyNeeded ) = 0;
+
+    /**
+     * @see CATExtPluginBase::HandleCommandCancel
+     */
+    virtual void HandleCommandCancel() = 0;
+    };
+
+#endif /* ATCMDBASE_H_ */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cbsatplugin/atmisccmdplugin/inc/atcmdsyncbase.h	Wed Jun 09 09:52:54 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:  Base class for sync commands. 
+*               
+*/
+
+#ifndef ATCMDSYNCBASE_H
+#define ATCMDSYNCBASE_H
+
+#include <e32base.h>
+#include <etelmm.h>
+#include "atcommandparser.h"
+#include "atcmdbase.h"
+#include "atmisccmdplugin.h"
+
+/**
+ *  Abstract base class for sync AT command handler interface.
+ *  It can not be instantiated individually as it doesn't fully
+ *  implement MATCmdBase.
+ */
+NONSHARABLE_CLASS( CATCmdSyncBase ) : public CBase,
+                                      public MATCmdBase
+    {
+public:
+    virtual ~CATCmdSyncBase() {};
+    CATCmdSyncBase(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone);
+
+    // From MATCmdBase
+    virtual void HandleCommandCancel();
+    
+protected:
+    MATMiscCmdPlugin* iCallback;
+    TAtCommandParser& iATCmdParser;
+    RMobilePhone& iPhone;
+    };
+
+#endif // ATCMDSYNCBASE_H
--- a/cbsatplugin/atmisccmdplugin/inc/atcommandparser.h	Tue May 25 12:53:11 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/inc/atcommandparser.h	Wed Jun 09 09:52:54 2010 +0300
@@ -52,7 +52,8 @@
         ECmdAtCpwd,
         ECmdAtCpin,
         ECmdAtCusd,
-        ECmdAtCnum
+        ECmdAtCnum,
+        ECmdAtCmee
         };
 public:
     TAtCommandParser();
@@ -96,10 +97,10 @@
      * This function validate the parameter is a valid string.
      * if the parameter is absent, it returns KErrNotFound.
      * if the parameter is an invalid string such as not in a pair of double quotes, it returns KErrArgument
-     * @param aError return the error code. 
-     * @return Next text parameter when aError is not KErrNone; 
+     * @param aParam the text string without quotes
+     * @return  Symbian system wide error codes
      */
-    TPtrC8 NextTextParam(TInt& aError);
+    TInt NextTextParam(TPtrC8& aParam);
 
     /**
      * Get ISA hash code for security code
--- a/cbsatplugin/atmisccmdplugin/inc/atmisccmdplugin.h	Tue May 25 12:53:11 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/inc/atmisccmdplugin.h	Wed Jun 09 09:52:54 2010 +0300
@@ -23,6 +23,10 @@
 
 #include "atcommandparser.h"
 
+class MATCmdBase;
+class CATCmdAsyncBase;
+class CATCmdSyncBase;
+
 /** Character types: carriage return, line feed or backspace */
 enum TCharacterTypes
     {
@@ -39,36 +43,6 @@
     };
 
 
-class MATMiscCmdPlugin;
-
-
-/**
- *  Class for common AT command handler interface
- */
-NONSHARABLE_CLASS( CATCmdAsyncBase ) : public CActive 
-    {
-public:
-    virtual ~CATCmdAsyncBase() {};
-    CATCmdAsyncBase(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone);
-
-    /**
-     * @see CATExtPluginBase::HandleCommand
-     */
-    virtual void HandleCommand( const TDesC8& aCmd,
-                                RBuf8& aReply,
-                                TBool aReplyNeeded ) = 0;
-
-    /**
-     * @see CATExtPluginBase::HandleCommandCancel
-     */
-    virtual void HandleCommandCancel() = 0;
-
-protected:
-    MATMiscCmdPlugin* iCallback;
-    TAtCommandParser& iATCmdParser;
-    RMobilePhone& iPhone;
-    };
-
 /**
  *  Class for accessing plugin information and common functionality
  */
@@ -173,6 +147,7 @@
     void ConstructL();
     
     TInt CreatePartOfReply( RBuf8& aBuffer );
+    void HandleCMEECommand();
     
     /*
      * Utility function that connect to Etel server and establish a subsession to RMobilePhone
@@ -191,12 +166,12 @@
      * Current AT command handler in.
      * Used when IsCommandSupported() detects a matching handler class.
      */
-    CATCmdAsyncBase* iCurrentHandler;
+    MATCmdBase* iCurrentHandler;
     
     CATCmdAsyncBase* iCLCKHandler;
     CATCmdAsyncBase* iCPWDHandler;
     CATCmdAsyncBase* iCPINHandler;
-    CATCmdAsyncBase* iCUSDHandler;
+    CATCmdSyncBase* iCUSDHandler;
     CATCmdAsyncBase* iCNUMHandler;
     CATCmdAsyncBase* iCFUNHandler;
     CATCmdAsyncBase* iCBCHandler;
@@ -217,6 +192,11 @@
      * Global reply buffer for the AT command replies
      */
     RBuf8 iReplyBuffer;
+    
+    /**
+     * +CME error level
+     */
+    TInt iErrorLevel;
     };
 
 #endif  // ATMISCCMDPLUGIN_H
--- a/cbsatplugin/atmisccmdplugin/inc/atmisccmdpluginconsts.h	Tue May 25 12:53:11 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/inc/atmisccmdpluginconsts.h	Wed Jun 09 09:52:54 2010 +0300
@@ -31,7 +31,6 @@
 _LIT8(KCBCSupportedCmdsList, "+CBC: (0,1,2,3),(1...100)\r\n\r\nOK\r\n");
 _LIT8(KCUSDSupportedCmdsList, "+CUSD: (0,1)\r\n\r\nOK\r\n");
 
-
 _LIT8(KATCLCKPS, "PS");
 _LIT8(KATCLCKSC, "SC");
 _LIT8(KATCLCKAO, "AO");
@@ -43,4 +42,7 @@
 _LIT8(KATCLCKAG, "AG");
 _LIT8(KATCLCKAC, "AC");
 
+// Max buffer length for an MD5 digest - originally defined in SCPServerInterface.h
+const TInt KSCPMaxHashLength( 32 );
+
 #endif // ATMISCCMDPLUGINCONSTS_H
--- a/cbsatplugin/atmisccmdplugin/inc/cbccommandhandler.h	Tue May 25 12:53:11 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/inc/cbccommandhandler.h	Wed Jun 09 09:52:54 2010 +0300
@@ -19,7 +19,7 @@
 #ifndef CBCCOMMANDHANDLER_H
 #define CBCCOMMANDHANDLER_H
 
-#include "atmisccmdplugin.h"
+#include "atcmdasyncbase.h"
 
 /**
  *  AT+CBC command handler implementation class
@@ -35,9 +35,8 @@
     virtual void DoCancel();
     // RunError not needed as RunL does not leave
 
-private: // methods from CATCmdAsyncBase    
+private: // method from CATCmdAsyncBase::MATCmdBase    
     virtual void HandleCommand( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded );
-    virtual void HandleCommandCancel();
     
 private:
     CCBCCommandHandler(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone);
--- a/cbsatplugin/atmisccmdplugin/inc/cfuncommandhandler.h	Tue May 25 12:53:11 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/inc/cfuncommandhandler.h	Wed Jun 09 09:52:54 2010 +0300
@@ -19,7 +19,9 @@
 #ifndef CFUNCOMMANDHANDLER_H
 #define CFUNCOMMANDHANDLER_H
 
-#include "atmisccmdplugin.h"
+#include <e32property.h> 
+
+#include "atcmdasyncbase.h"
 
 const TInt KGeneralProfileId = 0;
 const TInt KOfflineProfileId = 5;
@@ -39,16 +41,15 @@
     virtual void RunL();
     virtual void DoCancel();
     // RunError not needed as RunL does not leave
-
-private: // methods from CATCmdAsyncBase    
+    
+private: // method from CATCmdAsyncBase::MATCmdBase    
     virtual void HandleCommand( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded );
-    virtual void HandleCommandCancel();
     
 private:
     CCFUNCommandHandler(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone);
     void ConstructL();
     
-    TInt ActivateProfile(TInt aFunc, TInt aReset);
+    TInt ActivateProfile(TInt aFunc);
     TInt SetActiveProfile(TInt aProfileId);
     TInt RestartDevice();
     
@@ -56,6 +57,9 @@
     RBuf8 iReply;
     
     MProfileEngine* iProfileEngine;
+    RProperty iProperty;
+    TInt iExpectedState;
+    TInt iReset; // default 0 - do not reset the MT before setting it to <fun> power level
     };
 
 #endif /* CFUNCOMMANDHANDLER_H */
--- a/cbsatplugin/atmisccmdplugin/inc/clckcommandhandler.h	Tue May 25 12:53:11 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/inc/clckcommandhandler.h	Wed Jun 09 09:52:54 2010 +0300
@@ -18,7 +18,7 @@
 
 #include <mmretrieve.h>
 
-#include "atmisccmdplugin.h"
+#include "atcmdasyncbase.h"
 
 class CSecurityCodeVerifier;
 class CSecurityEventHandler;
@@ -84,10 +84,9 @@
     virtual void DoCancel();
     // RunError not needed as RunL does not leave
 
-private: // methods from CATCmdAsyncBase    
+private: // method from CATCmdAsyncBase::MATCmdBase    
     virtual void HandleCommand( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded );
-    virtual void HandleCommandCancel();
-    
+   
 private:
     CCLCKCommandHandler(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone);
     void ConstructL();
--- a/cbsatplugin/atmisccmdplugin/inc/cnumcommandhandler.h	Tue May 25 12:53:11 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/inc/cnumcommandhandler.h	Wed Jun 09 09:52:54 2010 +0300
@@ -16,7 +16,7 @@
 #ifndef CNUMCOMMANDHANDLER_H
 #define CNUMCOMMANDHANDLER_H
 
-#include "atmisccmdplugin.h"
+#include "atcmdasyncbase.h"
 
 /**
  *  This class implements an AO for AT+CPIN command using ATExt plugin framework.
@@ -37,15 +37,8 @@
     virtual void DoCancel();
     // RunError is not required because RunL doesn't leave.
 
-    // inherited from CATCmdAsyncBase
-    /**
-     *  @see CATCmdAsyncBase::HandleCommand
-     */
+    // method from CATCmdAsyncBase::MATCmdBase
     virtual void HandleCommand( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded );
-    /**
-     *  @see CATCmdAsyncBase::HandleCommandCancel
-     */
-    virtual void HandleCommandCancel();
 
     CCNUMCommandHandler(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser,
                        RMobilePhone& aPhone, RTelServer& aTelServer);
--- a/cbsatplugin/atmisccmdplugin/inc/cpincommandhandler.h	Tue May 25 12:53:11 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/inc/cpincommandhandler.h	Wed Jun 09 09:52:54 2010 +0300
@@ -16,7 +16,7 @@
 #ifndef CPINCOMMANDHANDLER_H
 #define CPINCOMMANDHANDLER_H
 
-#include "atmisccmdplugin.h"
+#include "atcmdasyncbase.h"
 
 /**
  *  This class implements an AO for AT+CPIN command using ATExt plugin framework.
@@ -36,14 +36,8 @@
     virtual void DoCancel();
     // RunError is not required because RunL doesn't leave.
 
-    /**
-     *  @see CATCmdAsyncBase::HandleCommand
-     */
+    // method from CATCmdAsyncBase::MATCmdBase
     virtual void HandleCommand( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded );
-    /**
-     *  @see CATCmdAsyncBase::HandleCommandCancel
-     */
-    virtual void HandleCommandCancel();
 
     CCPINCommandHandler(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone);
     void ConstructL();
--- a/cbsatplugin/atmisccmdplugin/inc/cpwdcommandhandler.h	Tue May 25 12:53:11 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/inc/cpwdcommandhandler.h	Wed Jun 09 09:52:54 2010 +0300
@@ -19,7 +19,7 @@
 #include <e32base.h>
 #include <etelmm.h>
 
-#include "atmisccmdplugin.h"
+#include "atcmdasyncbase.h"
 
 /**
  *  This class implements an AO for AT+CPWD command using ATExt plugin framework.
@@ -39,14 +39,8 @@
     virtual void DoCancel();
     // RunError is not required because RunL doesn't leave.
     
-    /**
-     * @see CATCmdAsyncBase::HandleCommand
-     */
+    // method from CATCmdAsyncBase::MATCmdBase
     virtual void HandleCommand( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded );
-    /**
-     * @see CATCmdAsyncBase::HandleCommandCancel
-     */
-    virtual void HandleCommandCancel();
     
     CCPWDCommandHandler(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone);
     void ConstructL();
--- a/cbsatplugin/atmisccmdplugin/inc/cusdcommandhandler.h	Tue May 25 12:53:11 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/inc/cusdcommandhandler.h	Wed Jun 09 09:52:54 2010 +0300
@@ -20,10 +20,10 @@
 #include <mmretrieve.h>
 #include <gsmuelem.h>
 
-#include "atmisccmdplugin.h"
+#include "atcmdsyncbase.h"
 
-class CCUSSDSendMessageImpl;
-class CCUSSDReadMessageImpl;
+class CUSSDSendMessageImpl;
+class CUSSDReadMessageImpl;
 /**
  *  Class for accessing plugin information and common functionality
  */
@@ -31,34 +31,31 @@
     {
 public:
     /**
-     * Creates an AT command reply based on the reply type and completes the
-     * request to ATEXT.
+     * Callback method for handling received USSD messages
+     * @param aError - the result code from the read operation
      */
-    virtual void HandleReadMessageComplete(TInt aResult) = 0;
+    virtual void HandleReadMessageComplete(TInt aError) = 0;
 
     /**
-      * Creates an AT command reply based on the reply type and completes the
-      * request to ATEXT.
+      * Callback method for handling sent USSD messages
+      * @param aError - the result code from the send operation
       */
-    virtual void HandleSendMessageComplete(TInt aResult) = 0;
+    virtual void HandleSendMessageComplete(TInt aError) = 0;
     };
 
-
-NONSHARABLE_CLASS( CCUSDCommandHandler ) : public CATCmdAsyncBase,
+/**
+ *  Class for handling USSD requests
+ */
+NONSHARABLE_CLASS( CCUSDCommandHandler ) : public CATCmdSyncBase,
                                            public MUSSDCallback
 {
 public:
     static CCUSDCommandHandler* NewL(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone);
     ~CCUSDCommandHandler();
-    
-private: // methods from CActive
-    virtual void RunL();
-    virtual void DoCancel();
-    // RunError not needed as RunL does not leave
- 
+     
 private: // methods from MUSSDCallback
-    virtual void HandleSendMessageComplete(TInt aResult);
-    virtual void HandleReadMessageComplete(TInt aResult);
+    virtual void HandleSendMessageComplete(TInt aError);
+    virtual void HandleReadMessageComplete(TInt aError);
     
 private: // methods from CATCmdAsyncBase    
     virtual void HandleCommand( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded );
@@ -68,7 +65,7 @@
     CCUSDCommandHandler(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone);
     void ConstructL();
     
-    TInt ParseCUSDCmd(const TDesC8& aCmd);
+    TInt ParseCUSDCmd();
     void CCUSDCommandHandler::FindFirstCarriageReturnL( 
          const TDesC& aBuffer ,
          TUint& aSkipChars , 
@@ -86,11 +83,11 @@
 
     RMobileUssdMessaging iUssdMessaging;
 
-    CCUSSDSendMessageImpl* iUSSDSender;
+    CUSSDSendMessageImpl* iUSSDSender;
     RMobileUssdMessaging::TMobileUssdAttributesV1 iSendAttributes;
     RBuf8 iUSSDCommand;
 
-    CCUSSDReadMessageImpl* iUSSDReader;
+    CUSSDReadMessageImpl* iUSSDReader;
     RMobileUssdMessaging::TGsmUssdMessageData iReceivedData;
     TInt iDisplayRetMessage;
     RMobileUssdMessaging::TMobileUssdAttributesV1 iReceiveAttributes;
--- a/cbsatplugin/atmisccmdplugin/inc/cusdreadwriteimp.h	Tue May 25 12:53:11 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,68 +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 CUSDREADWRITEIMP_H
-#define CUSDREADWRITEIMP_H
-
-#include <e32base.h>
-#include <etelmm.h>
-
-class MUSSDCallback;
-
-NONSHARABLE_CLASS( CCUSSDReadMessageImpl ) : public CActive
-{
-public:
-    static CCUSSDReadMessageImpl* NewL(MUSSDCallback* aCallback, RMobileUssdMessaging& aUssdSession);
-    ~CCUSSDReadMessageImpl();
-
-    TInt ReadUSSDMessage(TDes8& aReceivedData, 
-                               RMobileUssdMessaging::TMobileUssdAttributesV1& aUSDAttribute );
-
-private: // methods from CActive
-    virtual void RunL();
-    virtual void DoCancel();
-    // RunError not needed as RunL does not leave
-
-private:
-    CCUSSDReadMessageImpl(MUSSDCallback* aCallback, 
-                          RMobileUssdMessaging& aUSSDMessagingSession);
-private:
-    MUSSDCallback* iCallback;
-    RMobileUssdMessaging& iUssdSession;
-    };
-
-NONSHARABLE_CLASS( CCUSSDSendMessageImpl ) : public CActive
-{
-public:
-     static CCUSSDSendMessageImpl* NewL(MUSSDCallback* aCallback, RMobileUssdMessaging& aUssdSession);
-     ~CCUSSDSendMessageImpl();
-
-    TInt HandleSendUSSDCmd(const TDesC8& aCmd, 
-                           RMobileUssdMessaging::TMobileUssdAttributesV1& aUSDAttribute);
-
-private: // methods from CActive
-    virtual void RunL();
-    virtual void DoCancel();
-    // RunError not needed as RunL does not leave
-    
-private:
-    CCUSSDSendMessageImpl(MUSSDCallback* aCallback, 
-                          RMobileUssdMessaging& aUSSDMessagingSession);
-
-private:
-    MUSSDCallback* iCallback;        
-    RMobileUssdMessaging& iUssdSession;
-    };
-
-#endif // CUSDREADWRITEIMP_H
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cbsatplugin/atmisccmdplugin/inc/ussdreadmessageimpl.h	Wed Jun 09 09:52:54 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 USSDREADMESSAGEIMPL_H
+#define USSDREADMESSAGEIMPL_H
+
+#include <etelmm.h>
+
+class MUSSDCallback;
+
+/**
+ *  Class for receiving USSD data
+ */
+NONSHARABLE_CLASS( CUSSDReadMessageImpl ) : public CActive
+{
+public:
+    static CUSSDReadMessageImpl* NewL(MUSSDCallback* aCallback, RMobileUssdMessaging& aUssdSession);
+    ~CUSSDReadMessageImpl();
+
+    TInt ReadUSSDMessage(TDes8& aReceivedData, 
+                               RMobileUssdMessaging::TMobileUssdAttributesV1& aUSDAttribute );
+
+private: // methods from CActive
+    virtual void RunL();
+    virtual void DoCancel();
+    // RunError not needed as RunL does not leave
+
+private:
+    CUSSDReadMessageImpl(MUSSDCallback* aCallback, 
+                          RMobileUssdMessaging& aUSSDMessagingSession);
+private:
+    MUSSDCallback* iCallback;
+    RMobileUssdMessaging& iUssdSession;
+    };
+
+#endif /* USSDREADMESSAGEIMPL_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cbsatplugin/atmisccmdplugin/inc/ussdsendmessageimpl.h	Wed Jun 09 09:52:54 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 USSDSENDMESSAGEIMPL_H
+#define USSDSENDMESSAGEIMPL_H
+
+#include <etelmm.h>
+
+class MUSSDCallback;
+
+/**
+ *  Class for sending USSD data
+ */
+NONSHARABLE_CLASS( CUSSDSendMessageImpl ) : public CActive
+{
+public:
+     static CUSSDSendMessageImpl* NewL(MUSSDCallback* aCallback, RMobileUssdMessaging& aUssdSession);
+     ~CUSSDSendMessageImpl();
+
+    TInt SendUSSDCmd(const TDesC8& aCmd, 
+                     RMobileUssdMessaging::TMobileUssdAttributesV1& aUSDAttribute);
+
+private: // methods from CActive
+    virtual void RunL();
+    virtual void DoCancel();
+    // RunError not needed as RunL does not leave
+    
+private:
+    CUSSDSendMessageImpl(MUSSDCallback* aCallback, 
+                          RMobileUssdMessaging& aUSSDMessagingSession);
+
+private:
+    MUSSDCallback* iCallback;        
+    RMobileUssdMessaging& iUssdSession;
+    };
+
+#endif /* USSDSENDMESSAGEIMPL_H */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cbsatplugin/atmisccmdplugin/src/atcmdasyncbase.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -0,0 +1,39 @@
+/*
+* 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:  Main handler for incoming requests
+*
+*/
+
+#include "atcmdasyncbase.h"
+
+#include "debug.h"
+
+
+CATCmdAsyncBase::CATCmdAsyncBase(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) :
+    CActive(CActive::EPriorityStandard),
+    iATCmdParser(aATCmdParser),
+    iPhone(aPhone)
+    {
+    TRACE_FUNC_ENTRY
+    iCallback = aCallback;
+    CActiveScheduler::Add(this);
+    TRACE_FUNC_EXIT
+    }
+
+void CATCmdAsyncBase::HandleCommandCancel()
+    {
+    TRACE_FUNC_ENTRY
+    Cancel();
+    TRACE_FUNC_EXIT
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cbsatplugin/atmisccmdplugin/src/atcmdsyncbase.cpp	Wed Jun 09 09:52:54 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:  Main handler for incoming requests that don't require async operation.
+*
+*/
+
+#include "atcmdsyncbase.h"
+
+#include "debug.h"
+
+
+CATCmdSyncBase::CATCmdSyncBase(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) :
+    iATCmdParser(aATCmdParser),
+    iPhone(aPhone)
+    {
+    TRACE_FUNC_ENTRY
+    iCallback = aCallback;
+    TRACE_FUNC_EXIT
+    }
+
+void CATCmdSyncBase::HandleCommandCancel()
+    {
+    TRACE_FUNC_ENTRY
+    TRACE_FUNC_EXIT
+    }
--- a/cbsatplugin/atmisccmdplugin/src/atcommandparser.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/src/atcommandparser.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -19,24 +19,23 @@
 #include <hash.h>
 
 #include "debug.h"
-
-
-// Max buffer length for an MD5 digest
-const TInt KSCPMaxHashLength( 32 );
-
+#include "atmisccmdpluginconsts.h"
 
 TAtCommandParser::TAtCommandParser()
     : iCmdType(EUnknown), iCmdHandlerType(ECmdHandlerTypeUndefined)  
     {
+    TRACE_FUNC_ENTRY
+    TRACE_FUNC_EXIT
     }
 
 TAtCommandParser::TAtCommandParser(const TDesC8& aCmd)
     : iCmdType(EUnknown), iCmdHandlerType(ECmdHandlerTypeUndefined)  
     {
+    TRACE_FUNC_ENTRY
     ParseAtCommand(aCmd);
+    TRACE_FUNC_EXIT
     }
 
-
 void TAtCommandParser::ParseAtCommand(const TDesC8& aCmd)
     {
     TRACE_FUNC_ENTRY
@@ -59,37 +58,42 @@
     _LIT8(KAtCpin, "AT+CPIN");
     _LIT8(KAtCusd, "AT+CUSD");
     _LIT8(KAtCnum, "AT+CNUM");
+    _LIT8(KAtCmee, "AT+CMEE");
     
     Trace(KDebugPrintS, "token: ", &token);
     // Determine the AT command type
-    if(!token.Compare(KAtCfun))
+    if(!token.CompareF(KAtCfun))
         {
         iCmdType = ECmdAtCfun;
         }
-    else if(!token.Compare(KAtCbc))
+    else if(!token.CompareF(KAtCbc))
         {
         iCmdType = ECmdAtCbc;
         }
-    else if(!token.Compare(KAtClck))
+    else if(!token.CompareF(KAtClck))
         {
         iCmdType = ECmdAtClck;
         }
-    else if(!token.Compare(KAtCpwd))
+    else if(!token.CompareF(KAtCpwd))
         {
         iCmdType = ECmdAtCpwd;
         }
-    else if(!token.Compare(KAtCpin))
+    else if(!token.CompareF(KAtCpin))
         {
         iCmdType = ECmdAtCpin;
         }
-    else if(!token.Compare(KAtCusd))
+    else if(!token.CompareF(KAtCusd))
         {
         iCmdType = ECmdAtCusd;
         }
-    else if(!token.Compare(KAtCnum))
+    else if(!token.CompareF(KAtCnum))
         {
         iCmdType = ECmdAtCnum;
         }
+    else if(!token.Compare(KAtCmee))
+        {
+        iCmdType = ECmdAtCmee;
+        }
     else
         {
         iCmdType = EUnknown;
@@ -128,11 +132,15 @@
 
 TAtCommandParser::TCommandType TAtCommandParser::Command() const
     {
+    TRACE_FUNC_ENTRY
+    TRACE_FUNC_EXIT
     return iCmdType;
     }
 
 TAtCommandParser::TCommandHandlerType TAtCommandParser::CommandHandlerType() const
     {
+    TRACE_FUNC_ENTRY
+    TRACE_FUNC_EXIT
     return iCmdHandlerType;
     }
 
@@ -166,25 +174,29 @@
     return retVal;
     }
 
-TPtrC8 TAtCommandParser::NextTextParam(TInt& aError)
+TInt TAtCommandParser::NextTextParam(TPtrC8& aParam)
     {
+    TRACE_FUNC_ENTRY
+    TInt ret = KErrNone;
     TPtrC8 param = NextParam();
     
-    if (param.Compare(KNullDesC8) == 0)
+    if (param.Length() == 0)
         {
-        aError = KErrNotFound;
-        return param; 
+        aParam.Set(NULL,0);
+        ret = KErrNotFound;
         }
-    
-    if(param.Length()<2 
-            || param[0] != '"'
+    else if(param.Length() < 2 || param[0] != '"'
             || param[param.Length()-1] != '"')
         {
-        aError = KErrArgument;
-        return param.Left(0);
+        aParam.Set(NULL,0);
+        ret = KErrArgument;
         }
-    aError = KErrNone;
-    return param.Mid(1, param.Length() - 2);
+    else
+        {
+        aParam.Set(param.Mid(1, param.Length() - 2));
+        }
+    TRACE_FUNC_EXIT
+    return ret;
     }
 
 TInt TAtCommandParser::NextIntParam(TInt& aValue)
@@ -192,7 +204,7 @@
     TRACE_FUNC_ENTRY
     TInt retVal =KErrNone;
     TPtrC8 param = NextParam();
-    if (param.Compare(KNullDesC8) == 0)
+    if (param.Length() == 0)
         {
         retVal = KErrNotFound;
         }
--- a/cbsatplugin/atmisccmdplugin/src/atmisccmdplugin.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/src/atmisccmdplugin.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -28,15 +28,14 @@
 #include "atmisccmdpluginconsts.h"
 #include "debug.h"
 
-#include <exterror.h>           // Additional RMobilePhone error code
-
+#include <EXTERROR.H>           // Additional RMobilePhone error code
 
 // +CME error code
-_LIT8(KCMEIncorrectPassword, "+CME: 16\r\n"); // Incorrect password.\r\n
-_LIT8(KCMEPUKRequired, "+CME: 12\r\n"); // PUK required.\r\n
-_LIT8(KCMENotAllowed, "+CME: 3\r\n"); // Operation not allowed.\r\n
-_LIT8(KCMEPhoneError, "+CME: 0\r\n"); // Phone failure.\r\n
-_LIT8(KCMEPhoneUnknown, "+CME: 100\r\n"); // unknown error
+_LIT8(KCMEIncorrectPassword, "+CME ERROR: 16\r\n"); // Incorrect password.\r\n
+_LIT8(KCMEPUKRequired, "+CME ERROR: 12\r\n"); // PUK required.\r\n
+_LIT8(KCMENotAllowed, "+CME ERROR: 3\r\n"); // Operation not allowed.\r\n
+_LIT8(KCMEPhoneError, "+CME ERROR: 0\r\n"); // Phone failure.\r\n
+_LIT8(KCMEPhoneUnknown, "+CME ERROR: 100\r\n"); // unknown error
 
 const TInt KErrorReplyLength = 9;  // CR+LF+"ERROR"+CR+LF
 
@@ -149,6 +148,11 @@
             iCurrentHandler = iCBCHandler;
             break;
             }
+        case (TAtCommandParser::ECmdAtCmee):
+            {
+            iCurrentHandler = NULL;
+            break;
+            }
         case (TAtCommandParser::EUnknown):
         default:
             {
@@ -170,10 +174,17 @@
 	{
 	TRACE_FUNC_ENTRY
 	
-	if (iCurrentHandler != NULL)
+	if(iCommandParser.Command() == TAtCommandParser::ECmdAtCmee)
+	    {
+        HandleCMEECommand();
+        HandleCommandCompleted( KErrNone, EReplyTypeOk);
+	    }
+	else if (iCurrentHandler != NULL)
 	    {
 	    iHcCmd = &aCmd;
 	    iHcReply = &aReply;
+	    // No need to parse the command again as assumed that
+	    // it is always called from CATMiscCmdPlugin::IsCommandSupported()
 	    iCurrentHandler->HandleCommand( aCmd, aReply, aReplyNeeded );
 	    }
 	TRACE_FUNC_EXIT
@@ -456,59 +467,94 @@
     {
     TRACE_FUNC_ENTRY
     
-    // TODO should return CME error according to CME state (and quiet mode?)
-    RBuf8 response;
-    response.Create(KDefaultCmdBufLength);
+    // currently only support +CME error level 0 and 1
+    ASSERT(iErrorLevel == 0 || iErrorLevel == 1 );
     
-    // log error code
-    response.AppendNum(aError);
-    Trace(KDebugPrintD, "complete with error ", &response);
+    // Log error code
+    Trace(KDebugPrintD, "complete with error ", aError);
     
-    // return error code to AT client
-    response.Zero(); // reuse RBuf
-    response.Append(KCRLF);
-    switch(aError)
+    if(iErrorLevel == 1 && !iQuietMode)
         {
-        case KErrGsm0707IncorrectPassword:
-        case KErrAccessDenied:
-            {    
-            // code was entered erroneously
-            response.Append(KCMEIncorrectPassword);
-            break;
-            }    
-        case KErrGsmSSPasswordAttemptsViolation:
-        case KErrLocked:
-            {
-            // Pin blocked 
-            response.Append(KCMEPUKRequired);
-            break;
-            }
-        case KErrGsm0707OperationNotAllowed:
+        // return error code to AT client
+        RBuf8 response;
+        response.Create(KDefaultCmdBufLength);
+        response.Append(KCRLF);
+        switch(aError)
             {
-            // not allowed with this sim
-            response.Append(KCMENotAllowed);
-            break;
+            case KErrGsm0707IncorrectPassword:
+            case KErrAccessDenied:
+                {    
+                // code was entered erroneously
+                response.Append(KCMEIncorrectPassword);
+                break;
+                }
+            case KErrGsmSSPasswordAttemptsViolation:
+            case KErrLocked:
+                {
+                // Pin blocked 
+                response.Append(KCMEPUKRequired);
+                break;
+                }
+            case KErrGsm0707OperationNotAllowed:
+                {
+                // not allowed with this sim
+                response.Append(KCMENotAllowed);
+                break;
+                }
+            case KErrUnknown:
+                {
+                // unknown error
+                response.Append(KCMEPhoneUnknown);
+                break;
+                }
+            default:
+                {
+                response.Append(KCMEPhoneError);
+                break;
+                }
             }
-        case KErrUnknown:
-            {
-            // unknown error
-            response.Append(KCMEPhoneUnknown);
-            break;
-            }
-        default:
-            response.Append(KCMEPhoneError);
+        CreateReplyAndComplete( EReplyTypeError, response );
+        response.Close();
         }
-    CreateReplyAndComplete( EReplyTypeError, response );
-    response.Close();
+    else
+        {
+        CreateReplyAndComplete( EReplyTypeError);
+        }
+
     TRACE_FUNC_EXIT
     }
 
-
 TInt CATMiscCmdPlugin::HandleUnsolicitedRequest(const TDesC8& aAT )
     {
+    TRACE_FUNC_ENTRY
+    TRACE_FUNC_EXIT
     return SendUnsolicitedResult(aAT);
     }
 
+void CATMiscCmdPlugin::HandleCMEECommand()
+    {
+    TRACE_FUNC_ENTRY
+    TAtCommandParser::TCommandHandlerType cmdHandlerType = iCommandParser.CommandHandlerType();
+    
+    if (cmdHandlerType == TAtCommandParser::ECmdHandlerTypeSet)
+        {
+        // +CMEE=n
+        TInt errLevel;
+        TInt ret = iCommandParser.NextIntParam(errLevel);
+        TPtrC8 param = iCommandParser.NextParam();
+        _LIT8(KCMEDbg, "CME : NextIntParam returned %d, NextParam Length is %d, errLevel %d\r\n");
+        Trace(KCMEDbg, ret, param.Length(), errLevel);
+        if (ret == KErrNone && param.Length() == 0 &&
+           (errLevel == 0 || errLevel == 1))
+            {
+            iErrorLevel = errLevel;
+            _LIT8(KCMEErrorLevel, "CME error level: %d\r\n");
+            Trace(KCMEErrorLevel, iErrorLevel);
+            }
+        }
+    TRACE_FUNC_EXIT
+    }
+
 void CATMiscCmdPlugin::ConnectToEtelL(RTelServer& aTelServer, RMobilePhone& aPhone)
     {
     TRACE_FUNC_ENTRY
@@ -521,9 +567,10 @@
     User::LeaveIfError(aTelServer.EnumeratePhones(phoneCount));  
     if (phoneCount < 1)
         {
-        User::Leave(KErrNotFound); // TODO: appropriate error code
+        User::Leave(KErrNotFound);
         }
     User::LeaveIfError(aTelServer.GetPhoneInfo(0, info));
     User::LeaveIfError(aPhone.Open(aTelServer, info.iName));
     TRACE_FUNC_EXIT
     }
+
--- a/cbsatplugin/atmisccmdplugin/src/atmisccmdpluginbase.cpp	Tue May 25 12:53:11 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,33 +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:  Main handler for incoming requests
-*
-*/
-
-#include "atmisccmdplugin.h"
-
-#include "debug.h"
-
-
-CATCmdAsyncBase::CATCmdAsyncBase(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) :
-    CActive(CActive::EPriorityStandard),
-    iATCmdParser(aATCmdParser),
-    iPhone(aPhone)
-    {
-    TRACE_FUNC_ENTRY
-    iCallback = aCallback;
-    CActiveScheduler::Add(this);
-    TRACE_FUNC_EXIT
-    }
-
--- a/cbsatplugin/atmisccmdplugin/src/cbccommandhandler.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/src/cbccommandhandler.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -53,6 +53,7 @@
 
 void CCBCCommandHandler::HandleCommand(const TDesC8& /*aCmd*/, RBuf8& /*aReply*/, TBool /*aReplyNeeded*/)
     {
+    TRACE_FUNC_ENTRY
     iReply.Zero();
  
     TAtCommandParser::TCommandHandlerType cmdHandlerType = iATCmdParser.CommandHandlerType();
@@ -79,14 +80,6 @@
     TRACE_FUNC_EXIT
     }
 
-void CCBCCommandHandler::HandleCommandCancel()
-    {
-    TRACE_FUNC_ENTRY
-    Cancel();
-    TRACE_FUNC_EXIT
-    }
-
-
 void CCBCCommandHandler::RunL()
     {
     TRACE_FUNC_ENTRY
--- a/cbsatplugin/atmisccmdplugin/src/cbsettinghandler.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/src/cbsettinghandler.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -61,7 +61,6 @@
         {
         iClassArray.Append(RMobilePhone::ETelephony);
         }
-   // TODO: confirm ECircuitDataService is not needed 
     if ((aInfoClass & EInfoClassData) == EInfoClassData)
         {
         iClassArray.Append(RMobilePhone::EAllBearer);
@@ -150,9 +149,11 @@
 
 void CCBSettingHandler::Complete(TInt aError)
     {
+    TRACE_FUNC_ENTRY
     if (iQueuedStatus != NULL)
         {
         User::RequestComplete(iQueuedStatus, aError);
         iQueuedStatus = NULL;
         }
+    TRACE_FUNC_EXIT
     }
--- a/cbsatplugin/atmisccmdplugin/src/cfuncommandhandler.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/src/cfuncommandhandler.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -17,6 +17,7 @@
 
 #include <MProfileEngine.h>
 #include <starterclient.h>
+#include <ssm/startupdomainpskeys.h>
 
 #include <Profile.hrh>
 
@@ -53,6 +54,7 @@
     {
     TRACE_FUNC_ENTRY
     Cancel();
+    iProperty.Close();
     if (iProfileEngine != NULL)
         {
         iProfileEngine->Release();
@@ -62,6 +64,15 @@
 
 void CCFUNCommandHandler::HandleCommand(const TDesC8& /*aCmd*/, RBuf8& /*aReply*/, TBool /*aReplyNeeded*/)
     {
+    TRACE_FUNC_ENTRY
+    
+    if (IsActive())
+        {
+        iCallback->CreateReplyAndComplete(EReplyTypeError);
+        TRACE_FUNC_EXIT
+        return;
+        }
+    
     TInt ret = KErrNone;
     iReply.Zero();
     TAtCommandParser::TCommandHandlerType cmdHandlerType = iATCmdParser.CommandHandlerType();
@@ -94,8 +105,7 @@
         case (TAtCommandParser::ECmdHandlerTypeSet):
             {
             TInt func = 0;
-            TInt reset = 0; // default 0 - do not reset the MT before setting it to <fun> power level
-            
+
             ret = iATCmdParser.NextIntParam(func);
             if (ret != KErrNone && ret != KErrNotFound)
                 {
@@ -103,73 +113,136 @@
                 TRACE_FUNC_EXIT
                 return;
                 }
-            ret = iATCmdParser.NextIntParam(reset);
+			iReset = 0; // default 0 - do not reset the MT before setting it to <fun> power level
+            ret = iATCmdParser.NextIntParam(iReset);
             
             // second parameter is optional, but only 0 and 1 are valid if it is specified
-            if (ret != KErrNone && ret != KErrNotFound && (reset != 0 || reset != 1))
+            if (!(ret == KErrNone || ret == KErrNotFound) || !(iReset == 0 || iReset == 1))
                 {
                 iCallback->CreateReplyAndComplete(EReplyTypeError);
                 TRACE_FUNC_EXIT
                 return;
                 }
-            ret = ActivateProfile(func, reset);
-           
+            
+            ret = ActivateProfile(func);       
             break;
             }
         default:
             {
             iCallback->CreateReplyAndComplete(EReplyTypeError);
+            break;
             }
         }
     
-    if (ret != KErrNone)
+    if (!IsActive())
         {
-        iCallback->CreateReplyAndComplete(EReplyTypeError);
-        }
-    else
-        {
-        iCallback->CreateReplyAndComplete( EReplyTypeOther, iReply );
+        if (ret != KErrNone)
+            {
+            iCallback->CreateReplyAndComplete(EReplyTypeError);
+            }
+        else
+            {
+            iCallback->CreateReplyAndComplete( EReplyTypeOther, iReply );
+            }
         }
     TRACE_FUNC_EXIT
     }
 
-void CCFUNCommandHandler::HandleCommandCancel()
-    {
-    TRACE_FUNC_ENTRY
-    // no asyc requests are made in when using AT+CFUN
-    TRACE_FUNC_EXIT
-    }
-
-
 void CCFUNCommandHandler::RunL()
     {
     TRACE_FUNC_ENTRY
-    // no asyc requests are made in when using AT+CFUN
+    TInt systemState;
+    
+    TInt ret = iProperty.Get(systemState);
+    if (ret != KErrNone)
+        {
+        if (systemState != iExpectedState)
+            {
+            iProperty.Subscribe(iStatus);
+            SetActive();
+            }
+        else if (iReset == 1)
+            {
+            ret = RestartDevice();
+            }
+        }
+    if (!IsActive())
+        {
+        if (ret != KErrNone)
+            {
+            iCallback->CreateReplyAndComplete(EReplyTypeError);
+            }
+        else
+            {
+            iCallback->CreateReplyAndComplete( EReplyTypeOther, iReply );
+            }
+        }
     TRACE_FUNC_EXIT
     }
 
 void CCFUNCommandHandler::DoCancel()
     {
     TRACE_FUNC_ENTRY
-    // no asyc requests are made in when using AT+CFUN
+    iProperty.Cancel();
     TRACE_FUNC_EXIT
     }
 
-TInt CCFUNCommandHandler::ActivateProfile(TInt aFunc, TInt aReset)
+TInt CCFUNCommandHandler::ActivateProfile(TInt aFunc)
     {
-    TInt err = KErrNone;
+    TRACE_FUNC_ENTRY
+    TInt systemState;
+    
+    //Listen to the property KPSGlobalSystemState for profile change.
+    TInt err = iProperty.Attach(KPSUidStartup, KPSGlobalSystemState);
+    if (err != KErrNone)
+        {
+        TRACE_FUNC_EXIT
+        return err;
+        }
+
+    err = iProperty.Get(systemState);
+    if (err != KErrNone)
+        {
+        TRACE_FUNC_EXIT
+        return err;
+        }
     
     switch (aFunc)
         {
         case (0):
         case (4):
             {
-            err = SetActiveProfile(KOfflineProfileId);
+            // check of KPSGlobalSystemState is not already set to ESwStateNormalRfOff,
+            // issue the profile change request and start monitoring the property
+            if (systemState != ESwStateNormalRfOff)
+                {
+                err = SetActiveProfile(KOfflineProfileId);
+                
+                
+                if (err == KErrNone)
+                    {
+                    iExpectedState = ESwStateNormalRfOff;
+                    iProperty.Subscribe(iStatus);
+                    SetActive();
+                    }           
+                }
             break;
             }
         case (1):
             {
-            err = SetActiveProfile(KGeneralProfileId);
+            // check of KPSGlobalSystemState is not already set to ESwStateNormalRfOn,
+            // issue the profile change request and start monitoring the property
+            if (systemState != ESwStateNormalRfOn)
+                {
+                err = SetActiveProfile(KGeneralProfileId);
+                
+                if (err == KErrNone)
+                    {
+                    iExpectedState = ESwStateNormalRfOn;
+                    iProperty.Subscribe(iStatus);
+                    SetActive();
+                    }
+                }
             break;
             }
         default:
@@ -178,29 +251,26 @@
             break;
             }
         }
-    
-    if (err == KErrNone && aReset == 1)
-        {
-        err = RestartDevice();
-        }
-    
+    TRACE_FUNC_EXIT
     return err;
     }
 
 TInt CCFUNCommandHandler::SetActiveProfile(TInt aProfileId)
     {
+    TRACE_FUNC_ENTRY
     TInt err = KErrNone;
 
     if(iProfileEngine)
         {
         TRAP(err, iProfileEngine->SetActiveProfileL( aProfileId ));
         }
-
+    TRACE_FUNC_EXIT
     return err;
     }
 
 TInt CCFUNCommandHandler::RestartDevice()
     {
+    TRACE_FUNC_ENTRY
     RStarterSession session;
     TInt err = session.Connect();
 
@@ -209,6 +279,6 @@
         session.Reset(RStarterSession::EUnknownReset);
         session.Close();
         }
-
+    TRACE_FUNC_EXIT
     return err;
     }
--- a/cbsatplugin/atmisccmdplugin/src/clckcommandhandler.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/src/clckcommandhandler.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -25,8 +25,6 @@
 #include "atmisccmdpluginconsts.h"
 #include "debug.h"
 
-const TInt KSCPMaxHashLength( 32 );
-
 CCLCKCommandHandler* CCLCKCommandHandler::NewL(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone)
     {
     TRACE_FUNC_ENTRY
@@ -304,13 +302,6 @@
     return KErrNone;
     }
 
-void CCLCKCommandHandler::HandleCommandCancel()
-    {
-    TRACE_FUNC_ENTRY
-    Cancel();
-    TRACE_FUNC_EXIT
-    }
-
 void CCLCKCommandHandler::IssueCLCKCommand()
     {
     TRACE_FUNC_ENTRY
@@ -327,7 +318,7 @@
             }
         case (CCLCKCommandHandler::ECLCKLockSet):
             {
-            if (iPassword.Compare(KNullDesC8) == 0)
+            if (iPassword.Length() == 0)
                 {
                 iCallback->CreateReplyAndComplete( EReplyTypeError);
                 }
@@ -336,15 +327,14 @@
                 // Set the property to ignore security events in other clients
                 // it allows to avoid GUI promt for security code
                 TInt  ret = KErrNone;
-                // TODO: reenable when KIgnoreSecurityEvent propety definition is submitted to codeline
-//                if (iLockType == RMobilePhone::ELockICC)
-//                    {
-//                    ret = RProperty::Set(KPSUidStartup, KIgnoreSecurityEvent, EPSIgnoreSecurityEventEPin1Required);
-//                    }
-//                else
-//                    {
-//                    ret = RProperty::Set(KPSUidStartup, KIgnoreSecurityEvent, EPSIgnoreSecurityEventEPhonePasswordRequired);
-//                    }
+                if (iLockType == RMobilePhone::ELockICC)
+                    {
+                    ret = RProperty::Set(KPSUidStartup, KIgnoreSecurityEvent, EPSIgnoreSecurityEventEPin1Required);
+                    }
+                else
+                    {
+                    ret = RProperty::Set(KPSUidStartup, KIgnoreSecurityEvent, EPSIgnoreSecurityEventEPhonePasswordRequired);
+                    }
                 Trace(KDebugPrintD, "RProperty::Set: ", ret);
                 if (ret == KErrNone)
                     {
@@ -373,7 +363,7 @@
             }
         case (CCLCKCommandHandler::ECLCKBarringSet):
             {
-            if (iPassword.Compare(KNullDesC8) == 0)
+            if (iPassword.Length() == 0)
                 {
                 iCallback->CreateReplyAndComplete(EReplyTypeError);
                 }
@@ -546,98 +536,97 @@
 TInt CCLCKCommandHandler::ParseCCLCKCommand()
     {
     TRACE_FUNC_ENTRY
-    TCmdFacilityType facilityType = ECmdFacilityTypeUnknown;
-    TInt mode = 0;
-    TInt ret = KErrNone;
-
-    TPtrC8 command = iATCmdParser.NextTextParam(ret);
-    if (!command.Compare(KNullDesC8) || ret != KErrNone)
+    TPtrC8 command;
+    TInt ret = iATCmdParser.NextTextParam(command);
+    if (ret != KErrNone)
         {
         TRACE_FUNC_EXIT
         return KErrArgument;
         }
     
+    TInt mode = 0;
     ret = iATCmdParser.NextIntParam(mode);
-    if (!command.Compare(KNullDesC8) || ret != KErrNone)
+    if (ret != KErrNone)
         {
         TRACE_FUNC_EXIT
         return KErrArgument;
         }
     
-    iPassword.Create(iATCmdParser.NextTextParam(ret));
-    Trace(KDebugPrintD, "NextTextParam returned: ", ret);
+    TPtrC8 tmpPwd;
+    ret = iATCmdParser.NextTextParam(tmpPwd);
     if (ret != KErrNone && ret != KErrNotFound)
         {
         TRACE_FUNC_EXIT
         return KErrArgument;
         }
     
-    if (iPassword.Compare(KNullDesC8) != 0)
+    iPassword.Create(tmpPwd);
+    if (iPassword.Length() != 0)
         {
-        ret = iATCmdParser.NextIntParam(iInfoClass);
-        Trace(KDebugPrintD, "NextIntParam(iInfoClass): ", ret);
+        ret = iATCmdParser.NextIntParam(iInfoClass);;
         if (ret == KErrNotFound)
             {
-            iInfoClass = 7;
+            iInfoClass = 7; // Default value, see ETSI TS 127 007 V6.9.0 (2007-06)
             }
-        if ((ret != KErrNone && ret != KErrNotFound ) || 
-            iATCmdParser.NextParam().Compare(KNullDesC8) != 0)
+        else if (ret != KErrNone || iATCmdParser.NextParam().Length() != 0)
             {
             TRACE_FUNC_EXIT
             return KErrArgument;
             }
         }
     
-    if (command.Compare(KATCLCKPS) == 0)
+    TCmdFacilityType facilityType = ECmdFacilityTypeUnknown;
+    
+    if (command.CompareF(KATCLCKPS) == 0)
         {
         // Lock phone to SIM on/off
         iSecurityCode = RMobilePhone::ESecurityCodePhonePassword;
         iLockType = RMobilePhone::ELockPhoneToICC;
         facilityType = ECmdFacilityTypeLock;
         }
-    else if (command.Compare(KATCLCKSC) == 0)
+    else if (command.CompareF(KATCLCKSC) == 0)
         {
         // PIN on/off
         iSecurityCode = RMobilePhone::ESecurityCodePin1;
         iLockType = RMobilePhone::ELockICC;
         facilityType = ECmdFacilityTypeLock;
         }
-    else if (command.Compare(KATCLCKAO) == 0)
+    else if (command.CompareF(KATCLCKAO) == 0)
         {
         iCondition = RMobilePhone::EBarAllOutgoing;
         facilityType = ECmdFacilityTypeBarring;
         }
-    else if (command.Compare(KATCLCKOI) == 0)
+    else if (command.CompareF(KATCLCKOI) == 0)
         {
         iCondition = RMobilePhone::EBarOutgoingInternational;
         facilityType = ECmdFacilityTypeBarring;
         }
-    else if (command.Compare(KATCLCKOX) == 0)
+    else if (command.CompareF(KATCLCKOX) == 0)
         {
         iCondition = RMobilePhone::EBarOutgoingInternationalExHC;
         facilityType = ECmdFacilityTypeBarring;
         }
-    else if (command.Compare(KATCLCKAI) == 0)
+    else if (command.CompareF(KATCLCKAI) == 0)
         {
         iCondition = RMobilePhone::EBarAllIncoming;
         facilityType = ECmdFacilityTypeBarring;
         }
-    else if (command.Compare(KATCLCKIR) == 0)
+    else if (command.CompareF(KATCLCKIR) == 0)
         {
         iCondition = RMobilePhone::EBarIncomingRoaming;
         facilityType = ECmdFacilityTypeBarring;
         }
-    else if (command.Compare(KATCLCKAB) == 0)
+    else if (command.CompareF(KATCLCKAB) == 0)
         {
         iCondition = RMobilePhone::EBarAllCases;
         facilityType = ECmdFacilityTypeAllBarring;
         }
-    else if (command.Compare(KATCLCKAG) == 0)
+    else if (command.CompareF(KATCLCKAG) == 0)
         {
         iCondition = RMobilePhone::EBarAllOutgoingServices;
         facilityType = ECmdFacilityTypeAllBarring;
         }
-    else if (command.Compare(KATCLCKAC) == 0)
+    else if (command.CompareF(KATCLCKAC) == 0)
         {
         iCondition = RMobilePhone::EBarAllIncomingServices;
         facilityType = ECmdFacilityTypeAllBarring;
@@ -682,10 +671,6 @@
         case (ECmdFacilityTypeBarring):
             {
             iCBInfo.iPassword.Copy(iPassword);
-            if (iInfoClass == 0)
-                {
-                iInfoClass = 7; // Default value, see ETSI TS 127 007 V6.9.0 (2007-06)
-                }
             switch (mode)
                 {
                 case 0: // AT+CLCK="AO",0
--- a/cbsatplugin/atmisccmdplugin/src/cnumcommandhandler.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/src/cnumcommandhandler.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -126,13 +126,6 @@
     TRACE_FUNC_EXIT
     }
 
-void CCNUMCommandHandler::HandleCommandCancel()
-    {
-    TRACE_FUNC_ENTRY
-    Cancel();
-    TRACE_FUNC_EXIT
-    }
-
 void CCNUMCommandHandler::RunL()
     {
     TRACE_FUNC_ENTRY
@@ -162,7 +155,7 @@
         {
         ASSERT(iPendingEvent == EMobilePhoneStoreRead);
         // step 5 append a phone number entry to the reply buffer
-        if(iOwnNumberEntry.iNumber.iTelNumber.Compare(KNullDesC) != 0)
+        if(iOwnNumberEntry.iNumber.iTelNumber.Length() != 0)
             {
             // 129 is the type of address octet in interger format
             _LIT8(KATNumReply, "\r\n+CNUM: ,\"%S\",129");
--- a/cbsatplugin/atmisccmdplugin/src/cpincommandhandler.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/src/cpincommandhandler.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -18,7 +18,7 @@
 #include "cpincommandhandler.h"
 
 #include <mmretrieve.h>         // define AO wrapper
-#include <exterror.h>           // Additional RMobilePhone error code
+#include <EXTERROR.H>           // Additional RMobilePhone error code
 
 #include "debug.h"
 
@@ -82,48 +82,39 @@
     TRACE_FUNC_EXIT
     }
 
-void CCPINCommandHandler::HandleCommandCancel()
-    {
-    TRACE_FUNC_ENTRY
-    Cancel();
-    TRACE_FUNC_EXIT
-    }
-
 void CCPINCommandHandler::ChangePassword()
     {
     TRACE_FUNC_ENTRY
-    TRequestStatus status;
-
+    TPtrC8 pukCode8;
+    TPtrC8 pinCode8;
+    
     // Get parameters from AT command
-    TInt ret1;
-    TInt ret2; 
-    TPtrC8 pukCode8 = iATCmdParser.NextTextParam(ret1);
-    TPtrC8 pinCode8 = iATCmdParser.NextTextParam(ret2);
+    TInt ret1 = iATCmdParser.NextTextParam(pukCode8);
+    TInt ret2 = iATCmdParser.NextTextParam(pinCode8);
+    
     if(ret1 != KErrNone || ret2 != KErrNone
-            || iATCmdParser.NextParam().Compare(KNullDesC8) != 0)
+            || iATCmdParser.NextParam().Length() != 0)
         {
         iCallback->CreateReplyAndComplete( EReplyTypeError);
-        TRACE_FUNC_EXIT
-        return;
+        }
+    else
+        {
+        RMobilePhone::TMobilePassword pukCode;
+        RMobilePhone::TMobilePassword pinCode;
+        pukCode.Copy(pukCode8);
+        pinCode.Copy(pinCode8);
+        iPhone.VerifySecurityCode(iStatus, RMobilePhone::ESecurityCodePuk1, pinCode, pukCode);
+        // re-use the AO for VerifySecurityCode 
+        iPendingEvent = EMobilePhoneVerifySecurityCode; 
+        SetActive();
         }
     
-    RMobilePhone::TMobilePassword pukCode;
-    RMobilePhone::TMobilePassword pinCode;
-    pukCode.Copy(pukCode8);
-    pinCode.Copy(pinCode8);
-    iPhone.VerifySecurityCode(iStatus, RMobilePhone::ESecurityCodePuk1, pinCode, pukCode);
-    // re-use the AO for VerifySecurityCode 
-    iPendingEvent = EMobilePhoneVerifySecurityCode; 
-    SetActive();
-    
     TRACE_FUNC_EXIT
-    return;
     }
 
 void CCPINCommandHandler::RunL()
     {
     TRACE_FUNC_ENTRY
-
     if( iPendingEvent == EMobilePhoneGetLockInfo)
         { // after calling GetLockInfo
         HandleGetLockInfo();
--- a/cbsatplugin/atmisccmdplugin/src/cpwdcommandhandler.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/src/cpwdcommandhandler.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -15,32 +15,25 @@
 // 
 //
 
-
-#include <mmretrieve.h>         // AO
-
 #include "cpwdcommandhandler.h"
 
+#include <mmretrieve.h> 
+
+#include "atmisccmdpluginconsts.h"
 #include "debug.h"
 
-
 // password types
 _LIT8(KATCPWDPS, "PS"); // Phone lock
 _LIT8(KATCPWDP2, "P2"); // PIN2
 _LIT8(KATCPWDSC, "SC"); // PIN
 _LIT8(KATCPWDAB, "AB"); // All Barring code
 
-
-
 // strings for debugging trace
 _LIT8(KDbgStr, "+CPWD: %s \r\n");
 _LIT8(KDbgTDes, "+CPWD: %s%S\r\n");
 
 // constant for Set All barring code service - originally defined in mw/PSetConstants.h
 const TInt KPsetAllSSServices = 0;
-// Max buffer length for an MD5 digest - originally defined in SCPServerInterface.h
-const TInt KSCPMaxHashLength( 32 );
-
-
 
 CCPWDCommandHandler* CCPWDCommandHandler::NewL(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone)
     {
@@ -94,28 +87,20 @@
     TRACE_FUNC_EXIT
     }
 
-void CCPWDCommandHandler::HandleCommandCancel()
-    {
-    TRACE_FUNC_ENTRY
-    Cancel();
-    TRACE_FUNC_EXIT
-    }
-
-
 void CCPWDCommandHandler::ChangePassword()
     {
     TRACE_FUNC_ENTRY
 
     // Get parameters from AT command
-    TInt ret1;
-    TInt ret2; 
-    TInt ret3;
-    TPtrC8 passwordType = iATCmdParser.NextTextParam(ret1);
-    TPtrC8 oldPassword = iATCmdParser.NextTextParam(ret2);
-    TPtrC8 newPassword = iATCmdParser.NextTextParam(ret3);
+    TPtrC8 passwordType;
+    TPtrC8 oldPassword;
+    TPtrC8 newPassword;
+    TInt ret1 = iATCmdParser.NextTextParam(passwordType);
+    TInt ret2 = iATCmdParser.NextTextParam(oldPassword);
+    TInt ret3 = iATCmdParser.NextTextParam(newPassword);
     
     if(ret1 != KErrNone || ret2 != KErrNone || ret3 != KErrNone
-            || iATCmdParser.NextParam().Compare(KNullDesC8) != 0)
+            || iATCmdParser.NextParam().Length() != 0)
         {
         Trace(KDbgStr, "invalid arguments");
         iCallback->CreateReplyAndComplete( EReplyTypeError);
@@ -123,11 +108,11 @@
         return;
         }
     
-    if(passwordType.Compare(KATCPWDPS) == 0) // Phone lock
+    if(passwordType.CompareF(KATCPWDPS) == 0) // Phone lock
         {
-    // "PS" PH-SIM (lock PHone to SIM/UICC card) (MT asks password when other than current SIM/UICC card
-    // inserted; MT may remember certain amount of previously used cards thus not requiring password when they
-    // are inserted)
+        // "PS" PH-SIM (lock PHone to SIM/UICC card) (MT asks password when other than current SIM/UICC card
+        // inserted; MT may remember certain amount of previously used cards thus not requiring password when they
+        // are inserted)
         RMobilePhone::TMobilePhonePasswordChangeV1 passwordChange;
         
         // Phone lock password is hashed in RSPClient and NokiaTSY. See CSCPServer::HashISACode() for details.
@@ -138,7 +123,7 @@
 
         ChangeSecurityCode(RMobilePhone::ESecurityCodePhonePassword, hashOldPwd, hashNewPwd);
         }
-    else if(passwordType.Compare(KATCPWDSC) == 0) // SIM pin
+    else if(passwordType.CompareF(KATCPWDSC) == 0) // SIM pin
         {
         // "SC" SIM (lock SIM/UICC card) (SIM/UICC asks password in MT power-up and when this lock command
         // issued)
@@ -147,11 +132,11 @@
         // should check SIM Lock is on here and return an error if it is off.
         ChangeSecurityCode(RMobilePhone::ESecurityCodePin1, oldPassword, newPassword);
         }
-    else if(passwordType.Compare(KATCPWDP2) == 0) // SIM pin2
+    else if(passwordType.CompareF(KATCPWDP2) == 0) // SIM pin2
         {
         ChangeSecurityCode(RMobilePhone::ESecurityCodePin2, oldPassword, newPassword);
         }
-    else if(passwordType.Compare(KATCPWDAB) == 0) // All Barring services
+    else if(passwordType.CompareF(KATCPWDAB) == 0) // All Barring services
         {
         // "AB" All Barring services (refer 3GPP TS 22.030 [19]) (applicable only for <mode>=0)
         RMobilePhone::TMobilePhonePasswordChangeV2 passwordChange;
@@ -171,9 +156,7 @@
         Trace(KDbgTDes, "unknown password type:", &passwordType);
         iCallback->CreateCMEReplyAndComplete(KErrUnknown);
         }
-    
     TRACE_FUNC_EXIT
-    return;
     }
 
 void CCPWDCommandHandler::RunL()
@@ -203,10 +186,12 @@
 
 void CCPWDCommandHandler::ChangeSecurityCode(RMobilePhone::TMobilePhoneSecurityCode aType, TDesC8& aOldPassword, TDesC8& aNewPassword)
     {
+    TRACE_FUNC_ENTRY
     RMobilePhone::TMobilePhonePasswordChangeV1 passwordChange;
     passwordChange.iOldPassword.Copy(aOldPassword);
     passwordChange.iNewPassword.Copy(aNewPassword);
     iPhone.ChangeSecurityCode(iStatus, aType, passwordChange);
     iPendingEvent = EMobilePhoneChangeSecurityCode;
     SetActive();
+    TRACE_FUNC_EXIT
     }
--- a/cbsatplugin/atmisccmdplugin/src/cusdcommandhandler.cpp	Tue May 25 12:53:11 2010 +0300
+++ b/cbsatplugin/atmisccmdplugin/src/cusdcommandhandler.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -15,8 +15,10 @@
 
 #include <exterror.h> 
 
+#include "ussdreadmessageimpl.h"
+#include "ussdsendmessageimpl.h"
+
 #include "atmisccmdpluginconsts.h"
-#include "cusdreadwriteimp.h"
 #include "debug.h"
 
 const TUint8 KPhCltUssdCarriageReturn = 0x0d;
@@ -42,7 +44,7 @@
     }
 
 CCUSDCommandHandler::CCUSDCommandHandler(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) :
-    CATCmdAsyncBase(aCallback, aATCmdParser, aPhone)
+    CATCmdSyncBase(aCallback, aATCmdParser, aPhone)
     {
     TRACE_FUNC_ENTRY
     iSendAttributes.iDcs = KPhCltUssdDcsNotSet;  
@@ -54,10 +56,12 @@
 void CCUSDCommandHandler::ConstructL()
     {    
     TRACE_FUNC_ENTRY
+    iReply.CreateL(KDefaultCmdBufLength);
+
     User::LeaveIfError(iUssdMessaging.Open(iPhone));
     
-    iUSSDSender = CCUSSDSendMessageImpl::NewL(this, iUssdMessaging);
-    iUSSDReader = CCUSSDReadMessageImpl::NewL(this, iUssdMessaging);
+    iUSSDSender = CUSSDSendMessageImpl::NewL(this, iUssdMessaging);
+    iUSSDReader = CUSSDReadMessageImpl::NewL(this, iUssdMessaging);
     
     //start a read session for network based ussd requests
     User::LeaveIfError(iUSSDReader->ReadUSSDMessage(iReceivedData, iReceiveAttributes));
@@ -75,25 +79,18 @@
     TRACE_FUNC_EXIT
     }
 
-void CCUSDCommandHandler::DoCancel()
-    {
-    TRACE_FUNC_ENTRY
-    // This would never get called as the AO is never activated 
-    TRACE_FUNC_EXIT
-    }
-
-void CCUSDCommandHandler::HandleCommand( const TDesC8& aCmd,
+void CCUSDCommandHandler::HandleCommand( const TDesC8& /*aCmd*/,
                                          RBuf8& /*aReply*/,
                                          TBool /*aReplyNeeded*/ )
     {
     TRACE_FUNC_ENTRY
     TAtCommandParser::TCommandHandlerType cmdHandlerType = iATCmdParser.CommandHandlerType();
-    
+    iReply.Zero();
+
     switch (cmdHandlerType)
         {
         case (TAtCommandParser::ECmdHandlerTypeTest):
             {
-            iReply.Create(KDefaultCmdBufLength);
             iReply.Append(KCRLF);
             iReply.Append(KCUSDSupportedCmdsList);
             iCallback->CreateReplyAndComplete( EReplyTypeOther, iReply );
@@ -101,7 +98,6 @@
             }
         case (TAtCommandParser::ECmdHandlerTypeRead):
             {
-            iReply.Create(KDefaultCmdBufLength);
             iReply.Append(KCRLF);
             iReply.Append(KAtCUSD);
             iReply.AppendNum(iDisplayRetMessage);
@@ -112,28 +108,23 @@
             }
         case (TAtCommandParser::ECmdHandlerTypeSet):
             {         
-            if(ParseCUSDCmd(aCmd) == KErrNone)
+            if(ParseCUSDCmd() == KErrNone)
                {
                if(iUSSDCommand.Length() == 0)
                    {
                    Trace(KDebugPrintD, "No USSD command: ", iUSSDCommand.Length());
-
+                   
                    // the USSD command is not set then this is a set                   
-                   iReply.Create(KDefaultCmdBufLength);
-                   iReply.Append(KCRLF);
-                   iReply.Append(KAtCUSD);
-                   iReply.AppendNum(iDisplayRetMessage);
-                   iReply.Append(KCRLF);
-
-                   iCallback->CreateReplyAndComplete( EReplyTypeOther, iReply );                                     
+                   iReply.Append( KOKCRLF );
+                   iCallback->CreateReplyAndComplete( EReplyTypeOther, iReply);
                    }
                 else
                     {
-                    if(iUSSDSender->HandleSendUSSDCmd(iUSSDCommand, iSendAttributes) == KErrNone)
+                    if(iUSSDSender->SendUSSDCmd(iUSSDCommand, iSendAttributes) == KErrNone)
                         {
                         iSendCommandSent = ETrue;
                         }
-                        else
+                    else
                         {
                         iCallback->CreateReplyAndComplete(EReplyTypeError);
                         }                 
@@ -155,121 +146,131 @@
     TRACE_FUNC_EXIT
     }
 
-void CCUSDCommandHandler::RunL()
-    {
-    TRACE_FUNC_ENTRY
-    // This would never get called as the AO is never activated 
-    TRACE_FUNC_EXIT
-    }
-
-
 void CCUSDCommandHandler::HandleCommandCancel()
     {
     TRACE_FUNC_ENTRY   
     iUSSDSender->Cancel();
+    iSendCommandSent = EFalse;
     TRACE_FUNC_EXIT
     }
 
-TInt CCUSDCommandHandler::ParseCUSDCmd(const TDesC8& aCmd)
+TInt CCUSDCommandHandler::ParseCUSDCmd()
     {
     TRACE_FUNC_ENTRY
     
-    iReply.Create(KDefaultCmdBufLength);
-    TBool tempRetMessage = EFalse;
-    TInt ret = iATCmdParser.NextIntParam(tempRetMessage);
-
-    if(ret == KErrNone)
+    TInt tempDispValue;
+    TInt ret = iATCmdParser.NextIntParam(tempDispValue);
+    
+    
+    if (ret == KErrNone && tempDispValue >= 0 && tempDispValue < 3)
         {
-        if(tempRetMessage < 0 || tempRetMessage > 2)
-            {
-            Trace(KDebugPrintD, "Display mode invalid: ", tempRetMessage);
-            TRACE_FUNC_EXIT
-            return KErrGeneral;       
-            }
-        else
-            {
-            iDisplayRetMessage = tempRetMessage;
-            }
+        Trace(KDebugPrintD, "tempDispValue: ", tempDispValue);
+        iDisplayRetMessage = tempDispValue;
+        }    
+    else if (ret != KErrNotFound)
+        {
+        Trace(KDebugPrintD, "First NextIntParam failed: ", ret);
+        TRACE_FUNC_EXIT
+        return KErrGeneral;       
         }
     
     // now parse the USSD command
-    TPtrC8 command = iATCmdParser.NextTextParam(ret);
-
-    if (ret == KErrNone)
+    TPtrC8 command;
+    ret = iATCmdParser.NextTextParam(command);
+    if (ret == KErrNone )
         {
         if(iUSSDCommand.Create(command.Length()) != KErrNone)
-           {
-            TRACE_FUNC_EXIT
-            return KErrGeneral;
-           }
-        
-        if(Pack(command, iUSSDCommand) < 0)
-           {
-           Trace(KDebugPrintS, "Pack() returned error, command: ", &command);
-           TRACE_FUNC_EXIT
-           return KErrGeneral;
-           }             
-        }
-   
-    TInt tempDcs = -1;    
-    ret = iATCmdParser.NextIntParam(tempDcs); 
-
-    if(ret == KErrNone)
-        {
-        if(!IsDcsValid(tempDcs))
             {
-            Trace(KDebugPrintD, "Invalid coding standard: ", tempDcs);
+            Trace(KDebugPrintD, "iUSSDCommand.Create() failed ", ret);
             TRACE_FUNC_EXIT
             return KErrGeneral;
             }
-        else
+    
+        Trace(KDebugPrintS, "command: ", &command);
+        if(Pack(command, iUSSDCommand) < 0)
             {
-            iSendAttributes.iDcs = tempDcs;
-            }
-        } 
+            Trace(KDebugPrintS, "Pack() returned error, command: ", &command);
+            TRACE_FUNC_EXIT
+            return KErrGeneral;
+            }    
+        }
+    else if (ret != KErrNotFound)
+        {
+        TRACE_FUNC_EXIT
+        return KErrGeneral;       
+        }
+    TInt dcs = 0; // 3GPP TS 23.038 [25] Cell Broadcast Data Coding Scheme in integer format (default 0)
+    ret = iATCmdParser.NextIntParam(dcs); 
+
+    Trace(KDebugPrintD, "ret: ", ret);
+    Trace(KDebugPrintD, "IsDcsValid(dcs): ", IsDcsValid(dcs));
+    Trace(KDebugPrintD, "iATCmdParser.NextParam().Length(): ", iATCmdParser.NextParam().Length());
+    if(ret != KErrNone && ret != KErrNotFound || !IsDcsValid(dcs) || 
+            iATCmdParser.NextParam().Length() != 0)
+        {
+        Trace(KDebugPrintD, "Second NextIntParam failed: ", ret);
+        TRACE_FUNC_EXIT
+        return KErrGeneral;       
+        }
+    else
+        {
+        // dcs will have the default value if no parameter is given in the command line
+        Trace(KDebugPrintD, "dcs ", dcs);   
+        iSendAttributes.iDcs = dcs;
+        }
+
     TRACE_FUNC_EXIT
     return KErrNone;
     }
 
-void CCUSDCommandHandler::HandleSendMessageComplete(TInt aResult)
+void CCUSDCommandHandler::HandleSendMessageComplete(TInt aError)
+    {
+    TRACE_FUNC_ENTRY
+    if (aError != KErrNone)
+        {
+        // Only respond from a Send USSD request if there has been an error
+        iCallback->CreateReplyAndComplete(EReplyTypeError);
+        }
+    else if (iDisplayRetMessage == 0)
+        {
+        // if display mode is 0 then no response apart from OK should be displayed
+        iCallback->CreateReplyAndComplete( EReplyTypeOther, KOKCRLF );
+        }
+   
+    iUSSDCommand.Close();
+    TRACE_FUNC_EXIT
+    }
+
+void CCUSDCommandHandler::HandleReadMessageComplete(TInt aError)
     {
     TRACE_FUNC_ENTRY
-    if(aResult == KErrNone)
+    if(aError == KErrNone)
         {
-        iReply.Create(KDefaultCmdBufLength);
-        iReply.Append(KCRLF);
-        iReply.Append(KAtCUSD);
-        iReply.Append(KCRLF);
-        iCallback->CreateReplyAndComplete( EReplyTypeOther, iReply );          
+        if(iDisplayRetMessage)
+            {
+            FormatUSSDReceivedData();
+            
+            if(iSendCommandSent)
+                {
+                iCallback->CreateReplyAndComplete( EReplyTypeOther, iReply );
+                }
+             else
+                {       
+                iCallback->HandleUnsolicitedRequest(iReply);
+                }
+            }
+        
+        // as we have received the data initiated by the send USSD request we set
+        // this parameter to EFalse
+        iSendCommandSent = EFalse;
+    
+        // re-issue the read request
+        iUSSDReader->ReadUSSDMessage(iReceivedData, iReceiveAttributes);
         }
     else
         {
         iCallback->CreateReplyAndComplete(EReplyTypeError);
         }
-    
-    iSendCommandSent = EFalse;
-    iUSSDCommand.Close();
-    TRACE_FUNC_EXIT
-    }
-
-void CCUSDCommandHandler::HandleReadMessageComplete(TInt aResult)
-    {
-    TRACE_FUNC_ENTRY
-    if(iDisplayRetMessage)
-        {
-        FormatUSSDReceivedData();
-        
-        if(iSendCommandSent)
-            {
-            iCallback->CreateReplyAndComplete( EReplyTypeOther, iReply );
-            }
-         else
-            {       
-            iCallback->HandleUnsolicitedRequest(iReply);
-            }
-        }   
-    // re-issue the read request
-    iUSSDReader->ReadUSSDMessage(iReceivedData, iReceiveAttributes);
     TRACE_FUNC_EXIT
     }
 
@@ -280,7 +281,7 @@
     
     // Ensure we've got the right length
     TInt packedOctetsRequired = PackedOctetsRequired( aIn.Length() );
-    if ( packedOctetsRequired > ( aOut.MaxLength() - aOut.Length() ) )
+    if (packedOctetsRequired > ( aOut.MaxLength() - aOut.Length() ) )
         {
         Trace(KDebugPrintD, "packedOctetsRequired: ", packedOctetsRequired);
         TRACE_FUNC_EXIT
@@ -289,72 +290,84 @@
 
     // Do the conversion
     TInt elementSizeInBits = ElementSizeInBits(TSmsDataCodingScheme::ESmsAlphabet7Bit);
-    if ( elementSizeInBits == 8 ) // 8 bit data
+    
+    Trace(KDebugPrintD, "elementSizeInBits = : ", elementSizeInBits);
+    if (elementSizeInBits == 8) // 8 bit data
         {
         // Straight copy here
         aOut.Append( aIn );
         }
-        else if ( elementSizeInBits == 7 ) // Need packing to 7-bit
-            {
-            // Get raw pointers and do packing
-            TUint8* outPtr = ( TUint8* )aOut.Ptr() + aOut.Length();
-            const TUint8* inPtr = aIn.Ptr();
+    else if (elementSizeInBits == 7) // Need packing to 7-bit
+        {
+        Trace(KDebugPrintS, "aOut: ", &aOut);
+        Trace(KDebugPrintS, "aIn: ", &aIn);
+
+        // Get raw pointers and do packing
+        TUint8* outPtr = ( TUint8* )aOut.Ptr() + aOut.Length();
+        const TUint8* inPtr = aIn.Ptr();
     
-            outPtr[0] = 0;
-            for ( TInt i = 0; i < aIn.Length() ; ++i )
-                {
-                TUint8 to = inPtr[i];
-                *outPtr |= ( to << startBit );
-                if ( startBit )
+        TInt inLength = aIn.Length();
+        outPtr[0] = 0;
+        
+        Trace(KDebugPrintD, "inLength = : ", inLength);
+        for (TInt i = 0; i < inLength; ++i)
+           {
+           TUint8 to = inPtr[i];
+           *outPtr |= ( to << startBit );
+            
+           if (startBit)
+               {
+               ++outPtr;
+               *outPtr = ( TUint8 ) ( to >> ( 8 - startBit ) );
+               }
+
+           startBit = (startBit + 7) % 8; // roll 0,1,2,3,4,5,6,7,0,1,2,...
+           }
+       
+        Trace(KDebugPrintD, "startBit = : ", startBit);
+        
+        if ((inPtr[inLength - 1] == KPhCltUssdCarriageReturn && startBit == 0) || startBit == 1 )
+            {
+            //We have to add one CR more
+            *outPtr |= ( KPhCltUssdCarriageReturn << startBit );
+
+            if (startBit)
                 {
                 ++outPtr;
-                *outPtr = ( TUint8 ) ( to >> ( 8 - startBit ) );
+                *outPtr = (TUint8) (KPhCltUssdCarriageReturn >> (8 - startBit));
+                }
+            else
+                {
+                ++packedOctetsRequired;
                 }
-                startBit = ( startBit + 7 )%8; // roll 0,1,2,3,4,5,6,7,0,1,2,...
-             
-                if ( i == aIn.Length() - 1 ) // if this is the last time
-                    {
-                    if ( ( to == KPhCltUssdCarriageReturn && startBit == 0 ) || 
-                        startBit == 1 )
-                        {
-                    //We have to add one CR more
-                    *outPtr |= ( KPhCltUssdCarriageReturn << startBit );
-                    if ( startBit )
-                        {
-                        ++outPtr;
-                        *outPtr = ( TUint8 ) ( KPhCltUssdCarriageReturn >> ( 8 - startBit ) );
-                        }
-                    else
-                        {
-                        ++packedOctetsRequired;
-                        }
-                        startBit = ( startBit + 7 )%8;
-                        }
-                    }
-                }
-            // Increment the length for the packed data
-            aOut.SetLength( aOut.Length() + packedOctetsRequired );
+            startBit = (startBit + 7)%8;
             }
+        
+        // Increment the length for the packed data
+        aOut.SetLength(aOut.Length() + packedOctetsRequired);
+        
+        Trace(KDebugPrintD, "aOut.Length() = : ", aOut.Length());
+        }
 
     // Return number of bytes used
     TRACE_FUNC_EXIT
     return packedOctetsRequired;
     }
 
- TInt CCUSDCommandHandler::PackedOctetsRequired( TInt aNumUDUnits ) const
+ TInt CCUSDCommandHandler::PackedOctetsRequired(TInt aNumUDUnits) const
     {
     TRACE_FUNC_ENTRY
     TInt startBit = 0; 
 
     TInt octetsRequired = 0;
     TInt elementSizeInBits = ElementSizeInBits(TSmsDataCodingScheme::ESmsAlphabet7Bit);
-    if ( elementSizeInBits == 8 )
+    if (elementSizeInBits == 8)
          {
         octetsRequired=aNumUDUnits;
          }
     else
         {
-        octetsRequired =  ( startBit + aNumUDUnits*elementSizeInBits + 7 )/8;    // Rounds up
+        octetsRequired =  (startBit + aNumUDUnits*elementSizeInBits + 7 )/8;    // Rounds up
         }
     TRACE_FUNC_EXIT
     return octetsRequired;
@@ -363,13 +376,13 @@
  TBool CCUSDCommandHandler::IsDcsValid( const TUint8 aDcs ) const
      {
      TRACE_FUNC_ENTRY
-     TBool isDcsValid( EFalse );
+     TBool isDcsValid(EFalse);
                                                                 //      76543210
      TUint8 codingGroup  = ( aDcs & 0xF0 ) >> KHighNibbleShift; // bits XXXX____
      TUint8 characterSet = ( aDcs & 0x0C ) >> KQuarterShift;    // bits ____XX__
      TUint8 lowQuartet   = ( aDcs & 0x0F );                     // bits ____XXXX
   
-     switch ( codingGroup )
+     switch (codingGroup)
          {
          case 0x00:
          case 0x02:
@@ -404,6 +417,10 @@
                  }
              break;
              }
+         default:
+             {
+             break;
+             }
          }
      TRACE_FUNC_EXIT
      return isDcsValid;
@@ -413,7 +430,7 @@
     {
     TRACE_FUNC_ENTRY
     TInt ret;
-    switch ( aAlphabet )
+    switch (aAlphabet)
        {
        case TSmsDataCodingScheme::ESmsAlphabet7Bit:
            {
@@ -438,8 +455,8 @@
 void CCUSDCommandHandler::FormatUSSDReceivedData()
     {
     TRACE_FUNC_ENTRY
-    iReply.Create(KDefaultCmdBufLength);
-
+    iReply.Zero();
+    
     iReply.Append(KCRLF);
     iReply.Append(KAtCUSD);
     iReply.AppendNum(iDisplayRetMessage);
--- a/cbsatplugin/atmisccmdplugin/src/cusdreadwriteimp.cpp	Tue May 25 12:53:11 2010 +0300
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,155 +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 :
- *
- */
-
-#include "cusdreadwriteimp.h"
-
-#include "cusdcommandhandler.h"
-#include "debug.h"
-
-CCUSSDReadMessageImpl* CCUSSDReadMessageImpl::NewL(MUSSDCallback* aCallback, RMobileUssdMessaging& aUssdSession)
-    {
-    TRACE_FUNC_ENTRY
-    CCUSSDReadMessageImpl* self = new(ELeave) CCUSSDReadMessageImpl(aCallback, aUssdSession);
-    TRACE_FUNC_EXIT
-    return self;
-    }
-
-CCUSSDReadMessageImpl::CCUSSDReadMessageImpl(MUSSDCallback* aCallback, 
-                                             RMobileUssdMessaging& aUssdSession):
-    CActive(CActive::EPriorityStandard),
-    iCallback(aCallback),
-    iUssdSession(aUssdSession)
-    {
-    TRACE_FUNC_ENTRY
-    CActiveScheduler::Add(this);
-    TRACE_FUNC_EXIT
-    }
-
-CCUSSDReadMessageImpl::~CCUSSDReadMessageImpl()
-    {    
-    TRACE_FUNC_ENTRY
-    Cancel();
-    TRACE_FUNC_EXIT
-    }
-
-void CCUSSDReadMessageImpl::RunL()
-    {
-    TRACE_FUNC_ENTRY
-    iCallback->HandleReadMessageComplete(iStatus.Int());
-    TRACE_FUNC_EXIT
-    }
-
-void CCUSSDReadMessageImpl::DoCancel()
-    {
-    TRACE_FUNC_ENTRY
-    iUssdSession.CancelAsyncRequest(EMobileUssdMessagingReceiveMessage);
-    TRACE_FUNC_EXIT
-    }
-
-TInt CCUSSDReadMessageImpl::ReadUSSDMessage(TDes8& aReceivedData,
-                                            RMobileUssdMessaging::TMobileUssdAttributesV1& aUssdReadAttribute)
-    {
-    TRACE_FUNC_ENTRY
-    
-    TInt retCode = KErrNone;
-    if(!IsActive())
-        {
-        TPckg<RMobileUssdMessaging::TMobileUssdAttributesV1> msgAttributes(aUssdReadAttribute);
-        iUssdSession.ReceiveMessage(iStatus, aReceivedData, msgAttributes);
-        SetActive();
-        }
-    else
-        {
-        retCode = KErrInUse;
-        }
-        
-    TRACE_FUNC_EXIT
-    return retCode;
-    }
-
-CCUSSDSendMessageImpl* CCUSSDSendMessageImpl::NewL(MUSSDCallback* aCallback, 
-                                                   RMobileUssdMessaging& aUssdSession)
-    {
-    TRACE_FUNC_ENTRY
-    CCUSSDSendMessageImpl* self = new(ELeave) CCUSSDSendMessageImpl(aCallback, aUssdSession);
-    TRACE_FUNC_EXIT
-    return self;
-    }
-
-CCUSSDSendMessageImpl::CCUSSDSendMessageImpl(MUSSDCallback* aCallback, 
-                                             RMobileUssdMessaging& aUssdSession):
-    CActive(CActive::EPriorityStandard),
-    iCallback(aCallback),
-    iUssdSession(aUssdSession)
-    {
-    TRACE_FUNC_ENTRY
-    CActiveScheduler::Add(this);
-    TRACE_FUNC_EXIT
-    }
-
-void CCUSSDSendMessageImpl::RunL()
-    {
-    TRACE_FUNC_ENTRY
-    iCallback->HandleSendMessageComplete(iStatus.Int());
-    TRACE_FUNC_EXIT
-    }
-
-void CCUSSDSendMessageImpl::DoCancel()
-    {
-    TRACE_FUNC_ENTRY
-    iUssdSession.CancelAsyncRequest(EMobileUssdMessagingSendMessage);   
-    TRACE_FUNC_EXIT
-    }
-
-TInt CCUSSDSendMessageImpl::HandleSendUSSDCmd(const TDesC8& aCmd, 
-                                              RMobileUssdMessaging::TMobileUssdAttributesV1& aUSSDAttribute)
-    {    
-    TRACE_FUNC_ENTRY
-    TInt retCode = KErrNone;
-    if(!IsActive())
-        {
-        // Get USSD messaging caps
-        RMobileUssdMessaging::TMobileUssdCapsV1 ussdCaps;
-        RMobileUssdMessaging::TMobileUssdCapsV1Pckg ussdCapsPckg(ussdCaps);
-   
-        iUssdSession.GetCaps(ussdCapsPckg);   
-        ussdCaps=ussdCapsPckg();
-        
-        if(ussdCaps.iUssdFormat != RMobileUssdMessaging::KCapsPackedString)
-            {
-            retCode =  KErrArgument;
-            }
-        else
-            {
-            // we only support packed strings?
-            aUSSDAttribute.iFormat = RMobileUssdMessaging::EFormatPackedString;
-            TPckg<RMobileUssdMessaging::TMobileUssdAttributesV1> msgAttributes(aUSSDAttribute);
-            iUssdSession.SendMessage(iStatus, aCmd, msgAttributes);
-            SetActive();
-            }   
-        }
-    else
-        {
-        retCode = KErrInUse;
-        }
-    TRACE_FUNC_EXIT
-    return retCode;
-    }
-
-CCUSSDSendMessageImpl::~CCUSSDSendMessageImpl()
-    {    
-    TRACE_FUNC_ENTRY
-    Cancel();
-    TRACE_FUNC_EXIT
-    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cbsatplugin/atmisccmdplugin/src/ussdreadmessageimpl.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -0,0 +1,79 @@
+/* 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 "ussdreadmessageimpl.h"
+
+#include "cusdcommandhandler.h"
+#include "debug.h"
+
+CUSSDReadMessageImpl* CUSSDReadMessageImpl::NewL(MUSSDCallback* aCallback, RMobileUssdMessaging& aUssdSession)
+    {
+    TRACE_FUNC_ENTRY
+    CUSSDReadMessageImpl* self = new(ELeave) CUSSDReadMessageImpl(aCallback, aUssdSession);
+    TRACE_FUNC_EXIT
+    return self;
+    }
+
+CUSSDReadMessageImpl::CUSSDReadMessageImpl(MUSSDCallback* aCallback, 
+                                             RMobileUssdMessaging& aUssdSession):
+    CActive(CActive::EPriorityStandard),
+    iCallback(aCallback),
+    iUssdSession(aUssdSession)
+    {
+    TRACE_FUNC_ENTRY
+    CActiveScheduler::Add(this);
+    TRACE_FUNC_EXIT
+    }
+
+CUSSDReadMessageImpl::~CUSSDReadMessageImpl()
+    {    
+    TRACE_FUNC_ENTRY
+    Cancel();
+    TRACE_FUNC_EXIT
+    }
+
+void CUSSDReadMessageImpl::RunL()
+    {
+    TRACE_FUNC_ENTRY
+    iCallback->HandleReadMessageComplete(iStatus.Int());
+    TRACE_FUNC_EXIT
+    }
+
+void CUSSDReadMessageImpl::DoCancel()
+    {
+    TRACE_FUNC_ENTRY
+    iUssdSession.CancelAsyncRequest(EMobileUssdMessagingReceiveMessage);
+    TRACE_FUNC_EXIT
+    }
+
+TInt CUSSDReadMessageImpl::ReadUSSDMessage(TDes8& aReceivedData,
+                                            RMobileUssdMessaging::TMobileUssdAttributesV1& aUssdReadAttribute)
+    {
+    TRACE_FUNC_ENTRY
+    
+    TInt retCode = KErrNone;
+    if(!IsActive())
+        {
+        TPckg<RMobileUssdMessaging::TMobileUssdAttributesV1> msgAttributes(aUssdReadAttribute);
+        iUssdSession.ReceiveMessage(iStatus, aReceivedData, msgAttributes);
+        SetActive();
+        }
+    else
+        {
+        retCode = KErrInUse;
+        }
+        
+    TRACE_FUNC_EXIT
+    return retCode;
+    }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/cbsatplugin/atmisccmdplugin/src/ussdsendmessageimpl.cpp	Wed Jun 09 09:52:54 2010 +0300
@@ -0,0 +1,94 @@
+/* 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 "ussdsendmessageimpl.h"
+
+#include "cusdcommandhandler.h"
+#include "debug.h"
+
+CUSSDSendMessageImpl* CUSSDSendMessageImpl::NewL(MUSSDCallback* aCallback, 
+                                                   RMobileUssdMessaging& aUssdSession)
+    {
+    TRACE_FUNC_ENTRY
+    CUSSDSendMessageImpl* self = new(ELeave) CUSSDSendMessageImpl(aCallback, aUssdSession);
+    TRACE_FUNC_EXIT
+    return self;
+    }
+
+CUSSDSendMessageImpl::CUSSDSendMessageImpl(MUSSDCallback* aCallback, 
+                                             RMobileUssdMessaging& aUssdSession):
+    CActive(CActive::EPriorityStandard),
+    iCallback(aCallback),
+    iUssdSession(aUssdSession)
+    {
+    TRACE_FUNC_ENTRY
+    CActiveScheduler::Add(this);
+    TRACE_FUNC_EXIT
+    }
+
+void CUSSDSendMessageImpl::RunL()
+    {
+    TRACE_FUNC_ENTRY
+    iCallback->HandleSendMessageComplete(iStatus.Int());
+    TRACE_FUNC_EXIT
+    }
+
+void CUSSDSendMessageImpl::DoCancel()
+    {
+    TRACE_FUNC_ENTRY
+    iUssdSession.CancelAsyncRequest(EMobileUssdMessagingSendMessage);   
+    TRACE_FUNC_EXIT
+    }
+
+TInt CUSSDSendMessageImpl::SendUSSDCmd(const TDesC8& aCmd, 
+                                        RMobileUssdMessaging::TMobileUssdAttributesV1& aUSSDAttribute)
+    {    
+    TRACE_FUNC_ENTRY
+    TInt retCode = KErrNone;
+    if(!IsActive())
+        {
+        // Get USSD messaging caps
+        RMobileUssdMessaging::TMobileUssdCapsV1 ussdCaps;
+        RMobileUssdMessaging::TMobileUssdCapsV1Pckg ussdCapsPckg(ussdCaps);
+   
+        iUssdSession.GetCaps(ussdCapsPckg);   
+        ussdCaps=ussdCapsPckg();
+        
+        if(ussdCaps.iUssdFormat != RMobileUssdMessaging::KCapsPackedString)
+            {
+            retCode =  KErrArgument;
+            }
+        else
+            {
+            // we only support packed strings?
+            aUSSDAttribute.iFormat = RMobileUssdMessaging::EFormatPackedString;
+            TPckg<RMobileUssdMessaging::TMobileUssdAttributesV1> msgAttributes(aUSSDAttribute);
+            iUssdSession.SendMessage(iStatus, aCmd, msgAttributes);
+            SetActive();
+            }   
+        }
+    else
+        {
+        retCode = KErrInUse;
+        }
+    TRACE_FUNC_EXIT
+    return retCode;
+    }
+
+CUSSDSendMessageImpl::~CUSSDSendMessageImpl()
+    {    
+    TRACE_FUNC_ENTRY
+    Cancel();
+    TRACE_FUNC_EXIT
+    }