# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1272376184 -10800 # Node ID b23265fb36da85618bf08d15ad7b03479614c85c # Parent f7fbeaeb166a8caac8136b3ed4165f16abc26a80 Revision: 201015 Kit: 201017 diff -r f7fbeaeb166a -r b23265fb36da bluetoothengine/bteng/inc/btengserver.h --- a/bluetoothengine/bteng/inc/btengserver.h Wed Apr 14 16:09:00 2010 +0300 +++ b/bluetoothengine/bteng/inc/btengserver.h Tue Apr 27 16:49:44 2010 +0300 @@ -203,8 +203,8 @@ * @since S60 v3.2 * @param ?arg1 ?description */ - void DisconnectAllL(); - + void DisconnectAllForPowerOffL(); + /** * ?description * diff -r f7fbeaeb166a -r b23265fb36da bluetoothengine/bteng/inc/btengsrvbbconnectionmgr.h --- a/bluetoothengine/bteng/inc/btengsrvbbconnectionmgr.h Wed Apr 14 16:09:00 2010 +0300 +++ b/bluetoothengine/bteng/inc/btengsrvbbconnectionmgr.h Tue Apr 27 16:49:44 2010 +0300 @@ -26,7 +26,7 @@ #include "btengactive.h" -class CBTEngActive; +class CBTEngServer; /** ?description */ //const ?type ?constant_var = ?constant; @@ -50,7 +50,7 @@ /** * Two-phase constructor */ - static CBTEngSrvBBConnMgr* NewL(RSocketServ& aSockServ); + static CBTEngSrvBBConnMgr* NewL(CBTEngServer* aServer, RSocketServ& aSockServ); /** * Destructor @@ -99,6 +99,9 @@ */ void DisconnectAllLinksL( TCallBack& aCallBack ); + void DisconnectAllLinksForPowerOffL( TCallBack& aCallBack ); + + /** * Indicate to turn off BT when idle. * @@ -169,7 +172,7 @@ /** * C++ default constructor */ - CBTEngSrvBBConnMgr(RSocketServ& aSockServ); + CBTEngSrvBBConnMgr(CBTEngServer* aServer, RSocketServ& aSockServ); /** * Symbian 2nd-phase constructor @@ -234,7 +237,13 @@ * Not own. */ TCallBack iCallBack; - + + /** + * Pointer to our parent. + * Not own. + */ + CBTEngServer* iServer; + }; diff -r f7fbeaeb166a -r b23265fb36da bluetoothengine/bteng/inc/btengsrvkeywatcher.h --- a/bluetoothengine/bteng/inc/btengsrvkeywatcher.h Wed Apr 14 16:09:00 2010 +0300 +++ b/bluetoothengine/bteng/inc/btengsrvkeywatcher.h Tue Apr 27 16:49:44 2010 +0300 @@ -112,12 +112,6 @@ RProperty iSystemStateKey; /** - * Property containing count of physical BT connections. - * When physical connections exists, specific BT UI indicator is shown. - */ - RProperty iPHYCountKey; - - /** * Property containing the BT connecting status. * When connecting, specific BT UI indicator is shown. */ @@ -178,12 +172,6 @@ CBTEngActive* iSystemStateWatcher; /** - * Active object for subscribing to PHYCount property changes. - * Own. - */ - CBTEngActive* iPHYCountWatcher; - - /** * Active object for subscribing to BT connection property changes. * Own. */ diff -r f7fbeaeb166a -r b23265fb36da bluetoothengine/bteng/src/btengserver.cpp --- a/bluetoothengine/bteng/src/btengserver.cpp Wed Apr 14 16:09:00 2010 +0300 +++ b/bluetoothengine/bteng/src/btengserver.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -165,7 +165,7 @@ iWatcher = CBTEngSrvKeyWatcher::NewL( this ); iSettingsMgr = CBTEngSrvSettingsMgr::NewL( this ); iPluginMgr = CBTEngSrvPluginMgr::NewL( this ); - iBBConnMgr = CBTEngSrvBBConnMgr::NewL( iSocketServ ); + iBBConnMgr = CBTEngSrvBBConnMgr::NewL( this, iSocketServ ); User::LeaveIfError( iBTRegServ.Connect() ); iPairMan = CBTEngPairMan::NewL( *this ); @@ -256,12 +256,11 @@ // ?implementation_description // --------------------------------------------------------------------------- // -void CBTEngServer::DisconnectAllL() +void CBTEngServer::DisconnectAllForPowerOffL() { TRACE_FUNC_ENTRY - iPluginMgr->DisconnectAllPlugins(); TCallBack cb( DisconnectAllCallBack, this ); - iBBConnMgr->DisconnectAllLinksL( cb ); + iBBConnMgr->DisconnectAllLinksForPowerOffL( cb ); } diff -r f7fbeaeb166a -r b23265fb36da bluetoothengine/bteng/src/btengsrvbbconnectionmgr.cpp --- a/bluetoothengine/bteng/src/btengsrvbbconnectionmgr.cpp Wed Apr 14 16:09:00 2010 +0300 +++ b/bluetoothengine/bteng/src/btengsrvbbconnectionmgr.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -22,6 +22,8 @@ #include #include "btengsrvbbconnectionmgr.h" +#include "btengserver.h" +#include "btengsrvsettingsmgr.h" #include "debug.h" /** ?description */ @@ -38,8 +40,8 @@ // C++ default constructor // --------------------------------------------------------------------------- // -CBTEngSrvBBConnMgr::CBTEngSrvBBConnMgr(RSocketServ& aSockServ) - : iSockServ(aSockServ) +CBTEngSrvBBConnMgr::CBTEngSrvBBConnMgr(CBTEngServer* aServer, RSocketServ& aSockServ) + : iSockServ(aSockServ), iServer(aServer) { } @@ -73,9 +75,10 @@ // NewL // --------------------------------------------------------------------------- // -CBTEngSrvBBConnMgr* CBTEngSrvBBConnMgr::NewL(RSocketServ& aSockServ) +CBTEngSrvBBConnMgr* CBTEngSrvBBConnMgr::NewL(CBTEngServer* aServer, + RSocketServ& aSockServ) { - CBTEngSrvBBConnMgr* self = new( ELeave ) CBTEngSrvBBConnMgr(aSockServ); + CBTEngSrvBBConnMgr* self = new( ELeave ) CBTEngSrvBBConnMgr(aServer, aSockServ); CleanupStack::PushL( self ); self->ConstructL(); CleanupStack::Pop( self ); @@ -266,6 +269,37 @@ TRACE_FUNC_EXIT } +// --------------------------------------------------------------------------- +// Request to disconnect all Bluetooth baseband connections with Power off reason code. +// --------------------------------------------------------------------------- +// +void CBTEngSrvBBConnMgr::DisconnectAllLinksForPowerOffL( TCallBack& aCallBack ) + { + TRACE_FUNC_ENTRY + iCallBack = aCallBack; + RBTDevAddrArray addrArray; + GetConnectedAddressesL( addrArray ); + TInt err = KErrNone; + if( addrArray.Count() > 0 ) + { + err = iPhyLinks->DisconnectAll(); + // @todo Once fix is in stack, call this API instead + // err = iPhyLinks->DisconnectAllForPowerOff(); + } + else + { + err = KErrNotFound; + } + addrArray.Close(); + if( err && err != KErrInUse ) + { + // No connections, or something went wrong; just clean up + // and inform our client. + HandleDisconnectAllCompleteL( err ); + } + TRACE_FUNC_EXIT + } + // --------------------------------------------------------------------------- // Request to disconnect all Bluetooth baseband connections. @@ -345,6 +379,11 @@ } (void) ManageTopology( EFalse ); // Ignore result; nothing to do // about it here. + if( aId == KBTEngSrvBBConnId ) + { + TRACE_INFO( ( _L( "[BTENG] PHY count key changed, update UI connection status" ) ) ) + iServer->SettingsManager()->SetUiIndicatorsL(); + } TRACE_FUNC_EXIT } diff -r f7fbeaeb166a -r b23265fb36da bluetoothengine/bteng/src/btengsrvkeywatcher.cpp --- a/bluetoothengine/bteng/src/btengsrvkeywatcher.cpp Wed Apr 14 16:09:00 2010 +0300 +++ b/bluetoothengine/bteng/src/btengsrvkeywatcher.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -39,8 +39,6 @@ /** Identification for active object */ const TInt KBTEngSysWatcher = 17; /** Identification for active object */ -const TInt KBTEngPHYCountWatcher = 18; -/** Identification for active object */ const TInt KBTEngBtConnectionWatcher = 19; /** Identification for active object */ const TInt KBTEngScanningWatcher = 20; @@ -103,16 +101,7 @@ CActive::EPriorityStandard ); iSystemStateKey.Subscribe( iSystemStateWatcher->RequestStatus() ); iSystemStateWatcher->GoActive(); - } - - err = iPHYCountKey.Attach( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothPHYCount ); - if( !err ) - { - iPHYCountWatcher = CBTEngActive::NewL( *this, KBTEngPHYCountWatcher, - CActive::EPriorityStandard ); - iPHYCountKey.Subscribe( iPHYCountWatcher->RequestStatus() ); - iPHYCountWatcher->GoActive(); - } + } err = iBtConnectionKey.Attach( KPropertyUidBluetoothCategory, KPropertyKeyBluetoothConnecting ); if( !err ) @@ -224,14 +213,7 @@ iSystemStateKey.Cancel(); } delete iSystemStateWatcher; - iSystemStateKey.Close(); - - if( iPHYCountKey.Handle() ) - { - iPHYCountKey.Cancel(); - } - delete iPHYCountWatcher; - iPHYCountKey.Close(); + iSystemStateKey.Close(); if( iBtConnectionKey.Handle() ) { @@ -332,17 +314,9 @@ val == ESwStateShuttingDown ) { iServer->SettingsManager()->SetVisibilityModeL( EBTVisibilityModeNoScans , 0 ); - iServer->DisconnectAllL(); + iServer->DisconnectAllForPowerOffL(); } } - break; - case KBTEngPHYCountWatcher: - { - TRACE_INFO( ( _L( "PHY count key changed" ) ) ) - iPHYCountKey.Subscribe( aActive->RequestStatus() ); - aActive->GoActive(); - iServer->SettingsManager()->SetUiIndicatorsL(); - } break; case KBTEngBtConnectionWatcher: { diff -r f7fbeaeb166a -r b23265fb36da bluetoothengine/bteng/src/btengsrvpluginmgr.cpp --- a/bluetoothengine/bteng/src/btengsrvpluginmgr.cpp Wed Apr 14 16:09:00 2010 +0300 +++ b/bluetoothengine/bteng/src/btengsrvpluginmgr.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -485,9 +485,17 @@ TInt err = KErrNotFound; for( TInt i = 0; i < iPluginArray.Count(); i++ ) { - // Should be ignored if the plug-in does not have - // a connection to the address. - err = iPluginArray[ i ]->Disconnect( aAddr, aDiscType ); + // Should be ignored if the plug-in does not have + // a connection to the address. + TBTEngConnectionStatus status = iPluginArray[ i ]->IsConnected( aAddr ); + if( status == EBTEngConnecting || status == EBTEngConnected ) + { + err = iPluginArray[ i ]->Disconnect( aAddr, aDiscType ); + if( err ) + { + TRACE_INFO( ( _L( "[BTENG] ERR! Disconnect failed, plugin index %d with err %d" ), i, err ) ) + } + } } TRACE_FUNC_RES( ( _L( "result: %d" ), err ) ) return err; diff -r f7fbeaeb166a -r b23265fb36da bluetoothengine/bteng/src/btengsrvsettingsmgr.cpp --- a/bluetoothengine/bteng/src/btengsrvsettingsmgr.cpp Wed Apr 14 16:09:00 2010 +0300 +++ b/bluetoothengine/bteng/src/btengsrvsettingsmgr.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -148,6 +148,13 @@ iPowerState = EBTOff; #endif //__WINS__ } + +#ifdef __WINS__ + TRequestStatus* status = &(iActive->RequestStatus()); + iActive->GoActive(); + User::RequestComplete(status,KErrNone); +#endif //__WINS__ + TRACE_FUNC_RES( ( _L( "result: %d" ), err ) ) return err; } diff -r f7fbeaeb166a -r b23265fb36da bluetoothengine/bthid/common/inc/bthidPsKey.h --- a/bluetoothengine/bthid/common/inc/bthidPsKey.h Wed Apr 14 16:09:00 2010 +0300 +++ b/bluetoothengine/bthid/common/inc/bthidPsKey.h Tue Apr 27 16:49:44 2010 +0300 @@ -28,7 +28,9 @@ { ECursorNotInitialized = 0, ECursorShow = 1, - ECursorHide = 2 + ECursorHide = 2, + ECursorRedraw = 3, + ECursorReset = 4 }; #endif /* BTHIDPSKEY_H_ */ diff -r f7fbeaeb166a -r b23265fb36da bluetoothengine/bthid/common/src/bthidpskeywatcher.cpp --- a/bluetoothengine/bthid/common/src/bthidpskeywatcher.cpp Wed Apr 14 16:09:00 2010 +0300 +++ b/bluetoothengine/bthid/common/src/bthidpskeywatcher.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -30,7 +30,7 @@ // CBTMouseCursorStatusObserver::CBTMouseCursorStatusObserver() //---------------------------------------------------------- // -CBTMouseCursorStatusObserver::CBTMouseCursorStatusObserver(): CActive(CActive::EPriorityStandard) +CBTMouseCursorStatusObserver::CBTMouseCursorStatusObserver(): CActive(CActive::EPriorityStandard) { CActiveScheduler::Add( this ); } diff -r f7fbeaeb166a -r b23265fb36da bluetoothengine/bthid/keyboard/inc/keyboard.h --- a/bluetoothengine/bthid/keyboard/inc/keyboard.h Wed Apr 14 16:09:00 2010 +0300 +++ b/bluetoothengine/bthid/keyboard/inc/keyboard.h Tue Apr 27 16:49:44 2010 +0300 @@ -310,6 +310,9 @@ TBool IsSpecialHandleKey(TInt aUniCode); void LaunchApplicationL(const TDesC& aName); + + //Redraw cursor + void CursorRedraw(); private: TKeyboardDriverState iDriverState; diff -r f7fbeaeb166a -r b23265fb36da bluetoothengine/bthid/keyboard/src/keyboard.cpp --- a/bluetoothengine/bthid/keyboard/src/keyboard.cpp Wed Apr 14 16:09:00 2010 +0300 +++ b/bluetoothengine/bthid/keyboard/src/keyboard.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -140,7 +140,7 @@ if (iComboDevice) { - RProperty::Set( KPSUidBthidSrv, KBTMouseCursorState, ECursorHide ); + RProperty::Set( KPSUidBthidSrv, KBTMouseCursorState, ECursorNotInitialized ); } if (iSettings) @@ -288,7 +288,7 @@ CancelAllKeys(); if (iComboDevice) { - RProperty::Set( KPSUidBthidSrv, KBTMouseCursorState, ECursorHide ); + RProperty::Set( KPSUidBthidSrv, KBTMouseCursorState, ECursorNotInitialized ); } } @@ -343,10 +343,16 @@ { TInt mouseStatus; TInt err = RProperty::Get( KPSUidBthidSrv, KBTMouseCursorState, mouseStatus ); - if ( !err && (static_cast(mouseStatus) == ECursorHide) ) + if ( !err && + ((static_cast(mouseStatus) == ECursorRedraw)|| + (static_cast(mouseStatus) == ECursorReset)) ) { err = RProperty::Set( KPSUidBthidSrv, KBTMouseCursorState, ECursorShow ); + DBG(RDebug::Print( + _L("[BTHID]\tCHidKeyboardDriver::DataIn() ECursorRedraw ||ECursorReset ")) ); } + + CursorRedraw(); } InterruptData(aPayload); } @@ -462,6 +468,7 @@ iButton2Down = ETrue; TRawEvent rawEvent; rawEvent.Set(TRawEvent::EKeyDown, EStdKeyApplication0); + CursorRedraw(); UserSvr::AddEvent(rawEvent); } } @@ -472,6 +479,7 @@ iButton2Down = EFalse; TRawEvent rawEvent; rawEvent.Set(TRawEvent::EKeyUp, EStdKeyApplication0); + CursorRedraw(); UserSvr::AddEvent(rawEvent); } } @@ -1929,4 +1937,18 @@ CancelAllKeys(); } +void CHidKeyboardDriver::CursorRedraw() + { + TInt mouseStatus; + + TInt err = RProperty::Get( KPSUidBthidSrv, KBTMouseCursorState, mouseStatus ); + if ( !err ) + { + err = RProperty::Set( KPSUidBthidSrv, KBTMouseCursorState, ECursorRedraw ); + DBG(RDebug::Print( + _L("[BTHID]\tCHidKeyboardDriver::CursorRedraw() X->ECursorRedraw") ) ); + } + } + +// ---------------------------------------------------------------------- // End of file diff -r f7fbeaeb166a -r b23265fb36da bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursorappview.h --- a/bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursorappview.h Wed Apr 14 16:09:00 2010 +0300 +++ b/bluetoothengine/bthid/mouse/PaintCursor/inc/paintcursorappview.h Tue Apr 27 16:49:44 2010 +0300 @@ -60,7 +60,13 @@ void HideCursor(); void ShowCursor(); - + + //Repaint the cursor at last used point + void RedrawCursor(); + + //Repaint the cursor at TPoint(0,0) during orientation change + void ResetCursor(); + public: // from CCoeControl diff -r f7fbeaeb166a -r b23265fb36da bluetoothengine/bthid/mouse/PaintCursor/src/paintcursorappui.cpp --- a/bluetoothengine/bthid/mouse/PaintCursor/src/paintcursorappui.cpp Wed Apr 14 16:09:00 2010 +0300 +++ b/bluetoothengine/bthid/mouse/PaintCursor/src/paintcursorappui.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -31,7 +31,7 @@ void CPaintCursorAppUi::ConstructL() { - TRACE_INFO(_L("[PaintCursor]\t CPaintCursorAppUi::ConstructL()")); + TRACE_INFO(_L("[BTHID]\t CPaintCursorAppUi::ConstructL()")); BaseConstructL(); iAppView = CPaintCursorAppView::NewL(ClientRect()); @@ -83,7 +83,7 @@ void CPaintCursorAppUi::HandleCommandL(TInt aCommand) { - TRACE_INFO((_L("[PaintCursor]\t CPaintCursorAppUi::HandleCommandL(%d)"),aCommand)); + TRACE_INFO((_L("[BTHID]\tCPaintCursorAppUi::HandleCommandL(%d)"),aCommand)); switch ( aCommand ) { case EEikCmdExit : @@ -121,7 +121,7 @@ void CPaintCursorAppUi::MouseCursorStatusChangedL(TInt aStatus) { - + TRACE_INFO((_L("[BTHID]\tCPaintCursorAppUi::MouseCursorStatusChangedL(%d)"),aStatus)); switch (aStatus) { case ECursorShow: @@ -132,12 +132,23 @@ case ECursorHide: { iAppView->HideCursor(); - EndTask(); break; } case ECursorNotInitialized: { + iAppView->HideCursor(); EndTask(); + break; + } + case ECursorRedraw: + { + iAppView->RedrawCursor(); + break; + } + case ECursorReset: + { + iAppView->ResetCursor(); + break; } default: { diff -r f7fbeaeb166a -r b23265fb36da bluetoothengine/bthid/mouse/PaintCursor/src/paintcursorappview.cpp --- a/bluetoothengine/bthid/mouse/PaintCursor/src/paintcursorappview.cpp Wed Apr 14 16:09:00 2010 +0300 +++ b/bluetoothengine/bthid/mouse/PaintCursor/src/paintcursorappview.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -155,19 +155,33 @@ iMouseInitialized = ETrue; } +void CPaintCursorAppView::RedrawCursor() + { + TRect mainPaneRect; + AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); + SetRect( mainPaneRect ); + DrawNow(); + iClientCommander.ImageCommand( KRedrawBTCursorAnim ); + iMouseInitialized = ETrue; + } + + +void CPaintCursorAppView::ResetCursor() + { + TRect mainPaneRect; + AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); + SetRect( mainPaneRect ); + DrawNow(); + iClientCommander.ImageCommand( KResetBTCursorAnim ); + iMouseInitialized = ETrue; + } + void CPaintCursorAppView::HandleResourceChange( TInt aType ) { CCoeControl::HandleResourceChange( aType ); if ( aType == KEikDynamicLayoutVariantSwitch ) { - TRect mainPaneRect; - AknLayoutUtils::LayoutMetricsRect( AknLayoutUtils::EMainPane, mainPaneRect ); - SetRect( mainPaneRect ); - DrawNow(); - if (iMouseInitialized) - { - iClientCommander.ImageCommand( KRedrawBTCursorAnim ); - } + ResetCursor(); } } diff -r f7fbeaeb166a -r b23265fb36da bluetoothengine/bthid/mouse/Sesame_client/inc/pointmsgqueue.h --- a/bluetoothengine/bthid/mouse/Sesame_client/inc/pointmsgqueue.h Wed Apr 14 16:09:00 2010 +0300 +++ b/bluetoothengine/bthid/mouse/Sesame_client/inc/pointmsgqueue.h Tue Apr 27 16:49:44 2010 +0300 @@ -40,7 +40,8 @@ KStopBTCursorAnim = 2, KChangeCursor = 3, KSendRawEvent = 4, - KRedrawBTCursorAnim = 5 + KRedrawBTCursorAnim = 5, + KResetBTCursorAnim = 6 }; class TPointBuffer diff -r f7fbeaeb166a -r b23265fb36da bluetoothengine/bthid/mouse/Sesame_client/src/clientimagecommander.cpp --- a/bluetoothengine/bthid/mouse/Sesame_client/src/clientimagecommander.cpp Wed Apr 14 16:09:00 2010 +0300 +++ b/bluetoothengine/bthid/mouse/Sesame_client/src/clientimagecommander.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -175,7 +175,7 @@ { // Could optionally decode the commands here DBG(RDebug::Print(_L("RImageCommander::ImageCommand %d"), aCommand)); - if ( aCommand == KRedrawBTCursorAnim ) + if ( aCommand == KResetBTCursorAnim ) { //reset the current location to avoid sudden jumping iCurrentPoint.SetXY(0,0); diff -r f7fbeaeb166a -r b23265fb36da bluetoothengine/bthid/mouse/Sesame_server/inc/mousecursorimage.h --- a/bluetoothengine/bthid/mouse/Sesame_server/inc/mousecursorimage.h Wed Apr 14 16:09:00 2010 +0300 +++ b/bluetoothengine/bthid/mouse/Sesame_server/inc/mousecursorimage.h Tue Apr 27 16:49:44 2010 +0300 @@ -124,6 +124,7 @@ CFbsBitGc* iSpriteGc; CFbsBitmap* iCursorBitmap; CFbsBitmap* iCursorBitmapMask; + TPoint iLastUsedPoint; }; #endif // __MOUSECURSORIMAGE_H__ diff -r f7fbeaeb166a -r b23265fb36da bluetoothengine/bthid/mouse/Sesame_server/src/mousecursorimage.cpp --- a/bluetoothengine/bthid/mouse/Sesame_server/src/mousecursorimage.cpp Wed Apr 14 16:09:00 2010 +0300 +++ b/bluetoothengine/bthid/mouse/Sesame_server/src/mousecursorimage.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -84,7 +84,7 @@ iSpriteGc->Reset(); iSpriteFunctions->SetPosition(TPoint()); iSpriteFunctions->SizeChangedL(); - + iLastUsedPoint = TPoint(0,0); // Set the screen visible // We are using a timer, not the built in synchronising, so turn it off iFunctions->SetSync( MAnimGeneralFunctions::ESyncNone ); @@ -155,13 +155,13 @@ DBG(RDebug::Print(_L(" CImage::DrawCursor iBitmapMaskDevice"))); // Draw mask iSpriteGc->Activate(iBitmapMaskDevice); - iSpriteGc->BitBlt(TPoint(0,0), iCursorBitmapMask); + iSpriteGc->BitBlt(iLastUsedPoint, iCursorBitmapMask); DBG(RDebug::Print(_L(" CImage::DrawCursor iBitmapMaskDevice"))); // Draw bitmap iSpriteGc->Activate(iBitmapDevice); - iSpriteGc->BitBlt(TPoint(0,0), iCursorBitmap); + iSpriteGc->BitBlt(iLastUsedPoint, iCursorBitmap); } DBG(RDebug::Print(_L(" CImage::DrawCursor END"))); } @@ -180,7 +180,6 @@ case KStartBTCursorAnim: { iSpriteFunctions->Activate(ETrue); - DrawCursor(); } break; @@ -194,23 +193,42 @@ { iSpriteFunctions->Activate(EFalse); iSpriteGc->Reset(); - iSpriteFunctions->SetPosition(TPoint()); + DBG(RDebug::Print( + _L("[BTHID]\tCImage::Command iLastUsedPoint (%d, %d)"), iLastUsedPoint.iX, iLastUsedPoint.iY)); + iSpriteFunctions->SetPosition(iLastUsedPoint); iSpriteFunctions->SizeChangedL(); iSpriteFunctions->Activate(ETrue); - DrawCursor(); + } + break; + + case KResetBTCursorAnim: + { + iSpriteFunctions->Activate(EFalse); + iSpriteGc->Reset(); + DBG(RDebug::Print(_L("[BTHID]\tCImage::Command KResetBTCursorAnim") )); + iLastUsedPoint.iX = 0; + iLastUsedPoint.iY = 0; + iSpriteFunctions->SetPosition(iLastUsedPoint); + iSpriteFunctions->SizeChangedL(); + iSpriteFunctions->Activate(ETrue); } break; case KChangeCursor: { - TPoint pos = *(TPoint *)aArgs; - iSpriteFunctions->SetPosition(pos); + iLastUsedPoint = *(TPoint *)aArgs; + DBG(RDebug::Print( + _L("[BTHID]\tCImage::Command KChangeCursor *(TPoint *)aArgs (%d, %d)"), iLastUsedPoint.iX, iLastUsedPoint.iY)); + iSpriteFunctions->SetPosition(iLastUsedPoint); } break; case KSendRawEvent: { TRawEvent rawEvent = *(TRawEvent *)aArgs; - iSpriteFunctions->SetPosition(rawEvent.Pos()); + iLastUsedPoint = rawEvent.Pos(); + DBG(RDebug::Print( + _L("[BTHID]\tCImage::Command KSendRawEvent rawEvent.Pos() (%d, %d)"), iLastUsedPoint.iX, iLastUsedPoint.iY)); + iSpriteFunctions->SetPosition(iLastUsedPoint); iFunctions->PostRawEvent( rawEvent ); } break; diff -r f7fbeaeb166a -r b23265fb36da bluetoothengine/bthid/mouse/hidmousedriver/inc/mouse.h --- a/bluetoothengine/bthid/mouse/hidmousedriver/inc/mouse.h Wed Apr 14 16:09:00 2010 +0300 +++ b/bluetoothengine/bthid/mouse/hidmousedriver/inc/mouse.h Tue Apr 27 16:49:44 2010 +0300 @@ -136,6 +136,9 @@ */ virtual void SetInputHandlingReg(CHidInputDataHandlingReg* aHandlingReg); + //redraw cursor + void CursorRedraw(); + private: // Constructor taking a pointer to the HID layer requesting the driver // instance diff -r f7fbeaeb166a -r b23265fb36da bluetoothengine/bthid/mouse/hidmousedriver/src/mouse.cpp --- a/bluetoothengine/bthid/mouse/hidmousedriver/src/mouse.cpp Wed Apr 14 16:09:00 2010 +0300 +++ b/bluetoothengine/bthid/mouse/hidmousedriver/src/mouse.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -96,9 +96,6 @@ User::LeaveIfError(iWsSession.Connect()); } - - - CHidMouseDriver::~CHidMouseDriver() { DBG(RDebug::Print(_L("[HID]\t~CHidMouseDriver() 0x%08x"), this)); @@ -107,7 +104,7 @@ if (iDriverState == EInitialised || iDriverState == EDisabled ) { - RProperty::Set( KPSUidBthidSrv, KBTMouseCursorState, ECursorHide ); + RProperty::Set( KPSUidBthidSrv, KBTMouseCursorState, ECursorNotInitialized ); } iWsSession.Close(); @@ -176,7 +173,7 @@ void CHidMouseDriver::Stop() { iDriverState = EDisabled; - RProperty::Set( KPSUidBthidSrv, KBTMouseCursorState, ECursorHide ); + RProperty::Set( KPSUidBthidSrv, KBTMouseCursorState, ECursorNotInitialized ); } //---------------------------------------------------------------------------- @@ -225,10 +222,18 @@ { TInt mouseStatus; TInt err = RProperty::Get( KPSUidBthidSrv, KBTMouseCursorState, mouseStatus ); - if ( !err && (static_cast(mouseStatus) == ECursorHide) ) + if ( !err && + ((static_cast(mouseStatus) == ECursorRedraw)|| + (static_cast(mouseStatus) == ECursorReset)) ) { err = RProperty::Set( KPSUidBthidSrv, KBTMouseCursorState, ECursorShow ); + DBG(RDebug::Print( + _L("[BTHID]\tCHidMouseDriver::DataIn() ECursorRedraw ||ECursorReset ")) ); } + + + CursorRedraw(); + InterruptData(aPayload); } break; @@ -381,6 +386,7 @@ iButton2Down = ETrue; TRawEvent rawEvent; rawEvent.Set(TRawEvent::EKeyDown, EStdKeyApplication0); + CursorRedraw(); UserSvr::AddEvent(rawEvent); } } @@ -391,6 +397,7 @@ iButton2Down = EFalse; TRawEvent rawEvent; rawEvent.Set(TRawEvent::EKeyUp, EStdKeyApplication0); + CursorRedraw(); UserSvr::AddEvent(rawEvent); } } @@ -476,4 +483,17 @@ { iInputHandlingReg = aHandlingReg; } + +void CHidMouseDriver::CursorRedraw() + { + TInt mouseStatus; + + TInt err = RProperty::Get( KPSUidBthidSrv, KBTMouseCursorState, mouseStatus ); + if ( !err ) + { + err = RProperty::Set( KPSUidBthidSrv, KBTMouseCursorState, ECursorRedraw ); + DBG(RDebug::Print( + _L("[BTHID]\tCHidMouseDriver::ForegroundEventL() X->ECursorRedraw") ) ); + } + } // ---------------------------------------------------------------------- diff -r f7fbeaeb166a -r b23265fb36da bluetoothengine/btsac/inc/btsacStreamerController.h --- a/bluetoothengine/btsac/inc/btsacStreamerController.h Wed Apr 14 16:09:00 2010 +0300 +++ b/bluetoothengine/btsac/inc/btsacStreamerController.h Tue Apr 27 16:49:44 2010 +0300 @@ -249,6 +249,7 @@ TInt iPacketDropDeviation; RArray iBitpoolData; TBitpoolData* iCurrentBitpoolData; + TBool iRemoteSupportsOnlyOneValue; }; diff -r f7fbeaeb166a -r b23265fb36da bluetoothengine/btsac/src/btsacStreamerController.cpp --- a/bluetoothengine/btsac/src/btsacStreamerController.cpp Wed Apr 14 16:09:00 2010 +0300 +++ b/bluetoothengine/btsac/src/btsacStreamerController.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -940,10 +940,23 @@ { // Define max bitpool TInt MaxBP = 0; + TInt minBitpool = aCap.MinBitpoolValue(); + TInt maxBitpool = aCap.MaxBitpoolValue(); TBool ProperMaxBitpoolFound = EFalse; + + if( minBitpool == maxBitpool ) + { + // Remote supports only one bitpool value + iRemoteSupportsOnlyOneValue = ETrue; + TRACE_INFO((_L("CBTSACStreamerController::SetBitpoolValues(), remote supports only one bitpool value"))) + TRACE_INFO((_L("CBTSACStreamerController::SetBitpoolValues(), Max Bitpool: %d"), maxBitpool)) + TRACE_INFO((_L("CBTSACStreamerController::SetBitpoolValues(), Min Bitpool: %d"), minBitpool)) + return; + } + for(TInt i = 0 ; i < KNumOfBitpoolValues ; i++) { - if(aCap.MaxBitpoolValue() >= KMaxBitpoolValues[i]) + if(maxBitpool >= KMaxBitpoolValues[i]) { MaxBP = KMaxBitpoolValues[i]; ProperMaxBitpoolFound = ETrue; @@ -954,11 +967,11 @@ { // None of our proposed max bitpool values weren't suitable for accessory. // Let's use the one which was proposed by the accessory. - MaxBP = aCap.MaxBitpoolValue(); + MaxBP = maxBitpool; } // Define min bitpool. This bitpool value is negotiated with sink. - TInt MinBP = (iLocalCap.MinBitpoolValue() < aCap.MinBitpoolValue()) ? aCap.MinBitpoolValue() : iLocalCap.MinBitpoolValue(); + TInt MinBP = (iLocalCap.MinBitpoolValue() < minBitpool) ? minBitpool : iLocalCap.MinBitpoolValue(); // Define bitpool which is used for medium quality streaming (when streaming is interfered for some reason). // This is real lowest bitpool value which is used for streaming. @@ -975,8 +988,8 @@ iBitpoolData[iBitpoolData.Count()-1].iMaxBitpoolValue = MinBP; } - TRACE_INFO((_L("CBTSACStreamerController::SetBitpoolValues(), Remote Max Bitpool: %d"), aCap.MaxBitpoolValue())) - TRACE_INFO((_L("CBTSACStreamerController::SetBitpoolValues(), Remote Min Bitpool: %d"), aCap.MinBitpoolValue())) + TRACE_INFO((_L("CBTSACStreamerController::SetBitpoolValues(), Remote Max Bitpool: %d"), maxBitpool)) + TRACE_INFO((_L("CBTSACStreamerController::SetBitpoolValues(), Remote Min Bitpool: %d"), minBitpool)) aCap.SetMaxBitpoolValue(MaxBP); TRACE_INFO((_L("CBTSACStreamerController::SetBitpoolValues(), Max Bitpool: %d"), MaxBP)) @@ -1263,6 +1276,7 @@ void CBTSACStreamerController::InitializeBitpoolDataL() { TRACE_FUNC + iRemoteSupportsOnlyOneValue = EFalse; TBitpoolData data; iBitpoolData.Reset(); for(TInt i = 0 ; i < KNumOfBitpoolValues ; i++) @@ -1294,38 +1308,70 @@ // ----------------------------------------------------------------------------- // void CBTSACStreamerController::ReorganizeBitpoolTable(TInt aNegotiatedMaxBitpool) - { - TRACE_INFO((_L("CBTSACStreamerController::ReorganizeBitpoolTable(), Negotiated Max Bitpool %d"), aNegotiatedMaxBitpool)) - // Start checking from the lowest possible bitpool value - for(TInt i = (KNumOfBitpoolValues - 1) ; i > 0 ; i--) - { - if(aNegotiatedMaxBitpool <= KMaxBitpoolValues[i]) - { - TInt ii; - for(ii = 0 ; ii < i ; ii++) - { - iBitpoolData.Remove(0); - } - TRACE_INFO((_L("CBTSACStreamerController::ReorganizeBitpoolTable(), Tables removed: %d"), ii)) - for(TInt j = 0 ; j < iBitpoolData.Count() ; j++) - { - if(j == 0) - { - iBitpoolData[j].iMaxBitpoolValue = aNegotiatedMaxBitpool; - } - iBitpoolData[j].iIndex = j; - iBitpoolData[j].iUpBitpoolIndex = (j == 0) ? j : j - 1; - iBitpoolData[j].iDownBitpoolIndex = (j == iBitpoolData.Count() - 1) ? j : j + 1; - } - break; - } - } - TRACE_INFO((_L("CBTSACStreamerController::ReorganizeBitpoolTable(), Tables left: %d"), iBitpoolData.Count())) - for(TInt k = 0 ; k < iBitpoolData.Count() ; k++) - { - TRACE_INFO((_L("CBTSACStreamerController::ReorganizeBitpoolTable(), Table[%d] MaxBP: %d"), k, iBitpoolData[k].iMaxBitpoolValue)) - } - } + { + TRACE_INFO((_L("CBTSACStreamerController::ReorganizeBitpoolTable(), Negotiated Max Bitpool %d"), aNegotiatedMaxBitpool)) + + TInt tablesToBeRemoved; + if( iRemoteSupportsOnlyOneValue ) + { + // Remote supports only one bitpool value, so we need only one table, remove rest. + tablesToBeRemoved = KNumOfBitpoolValues - 1; + } + else + { + // Find proper bitpool value, start checking from the lowest possible bitpool value + for(tablesToBeRemoved = (KNumOfBitpoolValues - 1) ; tablesToBeRemoved > 0 ; tablesToBeRemoved--) + { + if(aNegotiatedMaxBitpool <= KMaxBitpoolValues[tablesToBeRemoved]) + { + break; + } + } + } + if( tablesToBeRemoved >= iBitpoolData.Count() ) + { + // This should never happen. + TRACE_INFO((_L("CBTSACStreamerController::ReorganizeBitpoolTable(), Index error!"))) + tablesToBeRemoved = 0; + TRAPD(err, InitializeBitpoolDataL()) + if(err) + { + return; + } + } + + // Remove tables we don't need + TInt idx; + for( idx = 0 ; idx < tablesToBeRemoved ; idx++) + { + iBitpoolData.Remove(0); + } + TRACE_INFO((_L("CBTSACStreamerController::ReorganizeBitpoolTable(), Tables removed: %d"), tablesToBeRemoved)) + + if( tablesToBeRemoved ) + { + for( idx = 0 ; idx < iBitpoolData.Count() ; idx++) + { + if( idx == 0 ) + { + // Index zero has the highest matching/negotiated bitpool value, update it. + // Rest values remains to be according to default table. + iBitpoolData[idx].iMaxBitpoolValue = aNegotiatedMaxBitpool; + } + // Update indexing. + iBitpoolData[idx].iIndex = idx; + iBitpoolData[idx].iUpBitpoolIndex = (idx == 0) ? idx : idx - 1; + iBitpoolData[idx].iDownBitpoolIndex = (idx == iBitpoolData.Count() - 1) ? idx : idx + 1; + iBitpoolData[idx].iMinimumMaxBitpool = (idx == iBitpoolData.Count() - 1) ? ETrue : EFalse; + } + } + + TRACE_INFO((_L("CBTSACStreamerController::ReorganizeBitpoolTable(), Tables left: %d"), iBitpoolData.Count())) + for( idx = 0 ; idx < iBitpoolData.Count() ; idx++) + { + TRACE_INFO((_L("CBTSACStreamerController::ReorganizeBitpoolTable(), Table[%d] MaxBP: %d"), idx, iBitpoolData[idx].iMaxBitpoolValue)) + } + } // ----------------------------------------------------------------------------- // CBTSACStreamerController::DoSelfComplete diff -r f7fbeaeb166a -r b23265fb36da bluetoothengine/btui/Ecom/src/BTUIPairedDevicesView.cpp --- a/bluetoothengine/btui/Ecom/src/BTUIPairedDevicesView.cpp Wed Apr 14 16:09:00 2010 +0300 +++ b/bluetoothengine/btui/Ecom/src/BTUIPairedDevicesView.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -1725,7 +1725,7 @@ TRACE_INFO(_L("Device status changed, update menupane")); iMenuDevice = device; iActiveMenuPane->Close(); - TRAP_IGNORE( this->ProcessCommandL(EAknSoftkeyOptions) ); + TRAP_IGNORE( this->ProcessCommandL(EAknSoftkeyContextOptions) ); } } } diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/data/2002C3BA.rss --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/data/2002C3BA.rss Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,42 @@ +// 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: +// + +#include "../inc/atmisccmdpluginuids.hrh" +#include +#include + +RESOURCE REGISTRY_INFO theInfo + { + // UID for the DLL + dll_uid = 0x2002C3BA;//KUidATCFunEcomDll; + // Declare array of interface info + interfaces = + { + INTERFACE_INFO + { + // UID of interface that is implemented + interface_uid = 0x2001CBEE; // ATEXT_INTERFACE_DUN_UID; + implementations = + { + IMPLEMENTATION_INFO + { + 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"; + opaque_data = ""; + } + }; + } + }; + } + +// End of file diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/group/atmisccmdplugin.mmp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/group/atmisccmdplugin.mmp Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,64 @@ +/* + * 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 +#include +#include "../inc/atmisccmdpluginuids.hrh" + +CAPABILITY CAP_ECOM_PLUGIN +VENDORID VID_DEFAULT +TARGET atmisccmdplugin.dll +TARGETTYPE PLUGIN +UID 0x10009D8D 0x2002C3BA + +SOURCEPATH ../src +SOURCE main.cpp +SOURCE atmisccmdplugin.cpp +SOURCE atmisccmdpluginbase.cpp +SOURCE atcommandparser.cpp +SOURCE clckcommandhandler.cpp +SOURCE securitycodeverifier.cpp +SOURCE securityeventhandler.cpp +SOURCE cbsettinghandler.cpp +SOURCE cpwdcommandhandler.cpp +SOURCE cpincommandhandler.cpp +SOURCE cusdcommandhandler.cpp +SOURCE cnumcommandhandler.cpp +SOURCE cfuncommandhandler.cpp +SOURCE cbccommandhandler.cpp +SOURCE cusdreadwriteimp.cpp + +USERINCLUDE ../inc + +MW_LAYER_SYSTEMINCLUDE + +START RESOURCE ../data/2002C3BA.rss +TARGET atmisccmdplugin.rsc +END + +LIBRARY ecom.lib +LIBRARY euser.lib +LIBRARY atextpluginbase.lib +LIBRARY bafl.lib +LIBRARY etelmm.lib +LIBRARY etel.lib +LIBRARY hash.lib + +LIBRARY ProfileEng.lib +LIBRARY StarterClient.lib + +DEBUGLIBRARY flogger.lib + +// End of File diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/group/bld.inf Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,34 @@ + +/* + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * Description :This file provides the information required for building the + * atcmdpluginecom.dll + * + */ + + +#include + +PRJ_PLATFORMS + +PRJ_EXPORTS +../rom/atmisccmdplugin.iby CORE_MW_LAYER_IBY_EXPORT_PATH(atmisccmdplugin.iby) + +PRJ_TESTEXPORTS + +PRJ_MMPFILES +atmisccmdplugin.mmp + +PRJ_TESTMMPFILES + +// End of File + diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/inc/atcommandparser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/inc/atcommandparser.h Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,120 @@ +// 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: +// This file contains the implementation of the AT command parser and common utilities +// +// + +#ifndef ATCOMMANDPARSER_H +#define ATCOMMANDPARSER_H + +#include + + +/** + * This class parses a given AT command into command type, command handler type and parameters. + * + */ +NONSHARABLE_CLASS(TAtCommandParser) + { +public: + /** + * AT command handler type which determines how the command is interpreted. + */ + enum TCommandHandlerType + { + ECmdHandlerTypeUndefined = KErrNotFound, + ECmdHandlerTypeBase = 0x01, // For command "AT+COMMAND" + ECmdHandlerTypeSet = 0x02, // For command "AT+COMMAND=" + ECmdHandlerTypeRead = 0x04, // For command "AT+COMMAND?" + ECmdHandlerTypeTest = 0x08, // For command "AT+COMMAND=?" + }; + + /** + * Extended AT commands supported by this parser. + */ + enum TCommandType + { + EUnknown = KErrNotFound, + ECmdAtCfun = 0, + ECmdAtCbc, + ECmdAtClck, + ECmdAtCpwd, + ECmdAtCpin, + ECmdAtCusd, + ECmdAtCnum + }; +public: + TAtCommandParser(); + + /** + * @param aCmd AT command to be parsed + */ + TAtCommandParser(const TDesC8& aCmd); + + /** + * Parse a new AT command. Previously parsed AT command is lost. + * @param aCmd AT command to be parsed + */ + void ParseAtCommand(const TDesC8& aCmd); + + /** + * @return AT command type @see CAtCommandParser::TCommandType + */ + TCommandType Command() const; + + /** + * @return AT Command handler type @see CAtCommandParser::TCommandHandlerType + */ + TCommandHandlerType CommandHandlerType() const; + + /** + * @return Next available parameter. KNullDesC8 if no more parameters. + */ + TPtrC8 NextParam(); + + /** + * Gets the integer value of the next parameter. + * + * @param aValue the integer value of the parameter + * @return Symbian system wide error codes + */ + TInt NextIntParam(TInt& aValue); + + /** + * Get the next text string without quote. + * 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; + */ + TPtrC8 NextTextParam(TInt& aError); + + /** + * Get ISA hash code for security code + * Phone lock code is encoded by using ISA hash. This hash algorithm is implemented in remotemgmt component + * This function is copied and modified from CSCPServer::HashISACode() + * @param aPasscode passcode to be encoded + * @param aHashCode encoded output + * @return Symbian system wide error codes + */ + TInt HashSecurityCode(const TDesC8& aPasscode, TDes8& aHashCode); + +private: + TLex8 iCmd; + TCommandType iCmdType; + TCommandHandlerType iCmdHandlerType; + }; + +#endif // ATCOMMANDPARSER_H diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/inc/atmisccmdplugin.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/inc/atmisccmdplugin.h Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,223 @@ +/* +* 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 +* +*/ + +#ifndef ATMISCCMDPLUGIN_H +#define ATMISCCMDPLUGIN_H + +#include +#include + +#include "atcommandparser.h" + +/** Character types: carriage return, line feed or backspace */ +enum TCharacterTypes + { + ECharTypeCR, // Carriage return + ECharTypeLF, // Line feed + ECharTypeBS // Backspace + }; + +/** Type of modes (quiet, verbose) */ +enum TModeTypes + { + EModeTypeQuiet, // Quiet mode + EModeTypeVerbose // Verbose mode + }; + + +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 + */ +NONSHARABLE_CLASS( MATMiscCmdPlugin ) + { +public: + /** + * Creates an AT command reply based on the reply type and completes the + * request to ATEXT. + * + * @param aReplyType Type of reply + * @param aSrcBuffer Source buffer; used only if aReplyType is EReplyTypeOther + * @param aError Completion code. If not KErrNone then other arguments are + * ignored and the request is completed to ATEXT with + * EReplyTypeUndefined. + * @return Symbian error code on error, KErrNone otherwise + */ + virtual TInt CreateReplyAndComplete( TATExtensionReplyType aReplyType, + const TDesC8& aSrcBuffer=KNullDesC8, + TInt aError=KErrNone ) = 0; + + /** + * Creates a buffer for "OK" or "ERROR" reply based on the line settings + * + * @param aReplyBuffer Destination buffer for the created reply + * @param aOkReply ETrue if "OK" reply needed, + * EFalse if "ERROR" reply needed + * @return Symbian error code on error, KErrNone otherwise + */ + virtual TInt CreateOkOrErrorReply( RBuf8& aReplyBuffer, + TBool aOkReply ) = 0; + + /* + * Complete the AT command request with AT CME error code according to given Symbian error code + * @param aError Symbian error code + */ + virtual void CreateCMEReplyAndComplete(TInt aError) = 0; + + /** + * Returns plugin's character value settings (from CATExtPluginBase) + * + * @param aCharType Character's type + * @param aChar Character's value matching aCharType + * @return Symbian error code on error, KErrNone otherwise + */ + virtual TInt GetCharacterValue( TCharacterTypes aCharType, TChar& aChar ) = 0; + + /** + * Returns plugin's mode value settings (from CATExtPluginBase) + * + * @param aModeType Mode type + * @param aMode Mode value matching aModeType + * @return Symbian error code on error, KErrNone otherwise + */ + virtual TInt GetModeValue( TModeTypes aModeType, TBool& aMode ) = 0; + + /** + * Returns plugin's response to an unsolicited request + * + * @param aAT the response to display to the user from unsolicited event + * @return Symbian error code on error, KErrNone otherwise + */ + virtual TInt HandleUnsolicitedRequest(const TDesC8& aAT ) = 0; + }; + +/** + * Class for selecting handlers for different AT commands + */ +NONSHARABLE_CLASS( CATMiscCmdPlugin ) : public CATExtPluginBase, + public MATMiscCmdPlugin + { +public: + static CATMiscCmdPlugin* NewL(); + virtual ~CATMiscCmdPlugin(); + +private: // methods from base class CATExtPluginBase + void ReportConnectionName( const TDesC8& aName ); + TBool IsCommandSupported( const TDesC8& aCmd ); + void HandleCommand( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded ); + void HandleCommandCancel(); + TInt NextReplyPartLength(); + TInt GetNextPartOfReply( RBuf8& aNextReply ); + void ReceiveUnsolicitedResult(); + void ReceiveUnsolicitedResultCancel(); + void ReportNvramStatusChange( const TDesC8& aNvram ); + void ReportExternalHandleCommandError(); + +private: // methods from base class MATMiscCmdPlugin + virtual TInt CreateReplyAndComplete( TATExtensionReplyType aReplyType, + const TDesC8& aSrcBuffer=KNullDesC8, + TInt aError=KErrNone ); + + virtual TInt CreateOkOrErrorReply( RBuf8& aReplyBuffer, + TBool aOkReply ); + virtual void CreateCMEReplyAndComplete(TInt aError); + virtual TInt GetCharacterValue( TCharacterTypes aCharType, TChar& aChar ); + virtual TInt GetModeValue( TModeTypes aModeType, TBool& aMode ); + virtual TInt HandleUnsolicitedRequest(const TDesC8& aAT ); + +private: + CATMiscCmdPlugin(); + void ConstructL(); + + TInt CreatePartOfReply( RBuf8& aBuffer ); + + /* + * Utility function that connect to Etel server and establish a subsession to RMobilePhone + * Caller must close session and subsession after use. + * @param aTelServer returns session to ETel + * @param aPhone returns RMobilePhone subsession + */ + void ConnectToEtelL(RTelServer& aTelServer, RMobilePhone& aPhone); + + +private: + TAtCommandParser iCommandParser; + RTelServer iTelServer; + RMobilePhone iPhone; + /** + * Current AT command handler in. + * Used when IsCommandSupported() detects a matching handler class. + */ + CATCmdAsyncBase* iCurrentHandler; + + CATCmdAsyncBase* iCLCKHandler; + CATCmdAsyncBase* iCPWDHandler; + CATCmdAsyncBase* iCPINHandler; + CATCmdAsyncBase* iCUSDHandler; + CATCmdAsyncBase* iCNUMHandler; + CATCmdAsyncBase* iCFUNHandler; + CATCmdAsyncBase* iCBCHandler; + + /** + * Buffer for handle command's command + * Not own. + */ + const TDesC8* iHcCmd; + + /** + * Buffer for handle command reply + * Not own. + */ + RBuf8* iHcReply; + + /** + * Global reply buffer for the AT command replies + */ + RBuf8 iReplyBuffer; + }; + +#endif // ATMISCCMDPLUGIN_H + diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/inc/atmisccmdpluginconsts.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/inc/atmisccmdpluginconsts.h Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,46 @@ +/* + * 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 ATMISCCMDPLUGINCONSTS_H +#define ATMISCCMDPLUGINCONSTS_H + +#include + +_LIT8(KCRLF, "\r\n"); +_LIT8(KOKCRLF, "\r\n\r\nOK\r\n"); + +_LIT8(KAtCLCK, "+CLCK: "); +_LIT8(KAtCFUN, "+CFUN: "); +_LIT8(KAtCBC, "+CBC: "); +_LIT8(KAtCUSD, "+CUSD: "); + +_LIT8(KCLCKSupportedCmdsList, "+CLCK: (\"PS\",\"SC\",\"AO\",\"OI\",\"OX\",\"AI\",\"IR\",\"AB\",\"AG\",\"AC\")\r\n\r\nOK\r\n"); +_LIT8(KCFUNSupportedCmdsList, "+CFUN: (0,1,4),(0,1)\r\n\r\nOK\r\n"); +_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"); +_LIT8(KATCLCKOI, "OI"); +_LIT8(KATCLCKOX, "OX"); +_LIT8(KATCLCKAI, "AI"); +_LIT8(KATCLCKIR, "IR"); +_LIT8(KATCLCKAB, "AB"); +_LIT8(KATCLCKAG, "AG"); +_LIT8(KATCLCKAC, "AC"); + +#endif // ATMISCCMDPLUGINCONSTS_H diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/inc/atmisccmdpluginuids.hrh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/inc/atmisccmdpluginuids.hrh Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,22 @@ +/* + * 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: Collection of uid's + * + */ + +#ifndef ATMISCCMDPLUGINUIDS_HRH +#define ATMISCCMDPLUGINUIDS_HRH + +#define KUidATMiscCmdEcomDll 0x2002C3BA +#define KUidATMiscCmdEcomImpl 0x2002DC6B + +#endif // ATMISCCMDPLUGINUIDS_HRH diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/inc/cbccommandhandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/inc/cbccommandhandler.h Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description : + * + * CCBCCommandHandler class declaration for AT+CBC command + * + */ + +#ifndef CBCCOMMANDHANDLER_H +#define CBCCOMMANDHANDLER_H + +#include "atmisccmdplugin.h" + +/** + * AT+CBC command handler implementation class + */ +NONSHARABLE_CLASS( CCBCCommandHandler ) : public CATCmdAsyncBase + { +public: + static CCBCCommandHandler* NewL(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone); + ~CCBCCommandHandler(); + +private: // methods from CActive + virtual void RunL(); + virtual void DoCancel(); + // RunError not needed as RunL does not leave + +private: // methods from CATCmdAsyncBase + virtual void HandleCommand( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded ); + virtual void HandleCommandCancel(); + +private: + CCBCCommandHandler(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone); + void ConstructL(); + +private: + RBuf8 iReply; + + RMobilePhone::TMobilePhoneBatteryInfoV1 iBatteryInfo; + }; + +#endif /* CBCCOMMANDHANDLER_H */ diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/inc/cbsettinghandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/inc/cbsettinghandler.h Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,54 @@ +/* + * 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 CBSETTTINGHANDLER_H +#define CBSETTTINGHANDLER_H + +#include + +class CCLCKCommandHandler; + +/** + * AO class handling Call Barring setting + */ +NONSHARABLE_CLASS(CCBSettingHandler) : public CActive + { +public: + static CCBSettingHandler* NewL(RMobilePhone& aPhone); + ~CCBSettingHandler(); + void Start(TRequestStatus& aReqStatus, TInt aInfoClass, RMobilePhone::TMobilePhoneCBCondition aCondition, + RMobilePhone::TMobilePhoneCBChangeV1* aCBInfo); + void SetCBForServiceGroup(); + +private: // methods from CActive + virtual void RunL(); + virtual void DoCancel(); + // RunError not needed as RunL does not leave + +private: + CCBSettingHandler(RMobilePhone& aPhone); + void ConstructL(); + void Complete(TInt aError); + +private: + RMobilePhone& iPhone; + RArray iClassArray; + RMobilePhone::TMobilePhoneCBCondition iCondition; + RMobilePhone::TMobilePhoneCBChangeV1* iCBInfo; + + TRequestStatus* iQueuedStatus; + }; + +#endif // CBSETTTINGHANDLER_H diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/inc/cfuncommandhandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/inc/cfuncommandhandler.h Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2010 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * + * Description : + * + * CCFUNCommandHandler class declaration for AT+CFUN command + * + */ + +#ifndef CFUNCOMMANDHANDLER_H +#define CFUNCOMMANDHANDLER_H + +#include "atmisccmdplugin.h" + +const TInt KGeneralProfileId = 0; +const TInt KOfflineProfileId = 5; + +class MProfileEngine; + +/** + * AT+CFUN command handler implementation class + */ +NONSHARABLE_CLASS( CCFUNCommandHandler ) : public CATCmdAsyncBase + { +public: + static CCFUNCommandHandler* NewL(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone); + ~CCFUNCommandHandler(); + +private: // methods from CActive + virtual void RunL(); + virtual void DoCancel(); + // RunError not needed as RunL does not leave + +private: // methods from CATCmdAsyncBase + 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 SetActiveProfile(TInt aProfileId); + TInt RestartDevice(); + +private: + RBuf8 iReply; + + MProfileEngine* iProfileEngine; + }; + +#endif /* CFUNCOMMANDHANDLER_H */ diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/inc/clckcommandhandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/inc/clckcommandhandler.h Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,123 @@ +/* + * 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 : + * CCLCKCommandHandler class declaration for AT+CLCK command + */ + +#ifndef CLCKCOMMANDHANDLER_H +#define CLCKCOMMANDHANDLER_H + +#include + +#include "atmisccmdplugin.h" + +class CSecurityCodeVerifier; +class CSecurityEventHandler; +class CCBSettingHandler; + +enum TInfoClassMask + { + EInfoClassVoice = 1, // voice (telephony) + EInfoClassData = 2, // data (refers to all bearer services; with =2 + // this may refer only to some bearer service if TA does + // not support values 16, 32, 64 and 128) + EInfoClassFax = 4, // fax (facsimile services) + EInfoClassSMS = 8, // short message service + EInfoClassSyncData = 16, // data circuit sync + EInfoClassASyncData = 32, // data circuit async + EInfoClassPacketData = 64, // dedicated packet access + EInfoClassPadAccess = 128 // dedicated PAD access + }; + +/** + * AT+CLCK command handler implementation class + */ +NONSHARABLE_CLASS( CCLCKCommandHandler ) : public CATCmdAsyncBase + { +public: + static CCLCKCommandHandler* NewL(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone); + ~CCLCKCommandHandler(); + + // Callback methods for helper objects + void HandlePasswordVerification(TInt aError); + void HandleSecurityEvent(TInt aError, RMobilePhone::TMobilePhoneSecurityEvent aSecurityEvent); + +private: + /** + * States for lock setting + */ + enum TLockSettingState + { + ELockSettingIdle = 0x01, + ELockSettingRequested = 0x02, + ELockSettingPasswordRequested = 0x03 + }; + + enum TCLCKCommand + { + ECLCKUndefined = KErrNotFound, + ECLCKLockSet = 0x01, + ECLCKLockGet = 0x02, + ECLCKBarringSet = 0x03, + ECLCKBarringGet = 0x04 + }; + + enum TCmdFacilityType + { + ECmdFacilityTypeUnknown = 0, + ECmdFacilityTypeLock, + ECmdFacilityTypeBarring, + ECmdFacilityTypeAllBarring + }; + +private: // methods from CActive + virtual void RunL(); + virtual void DoCancel(); + // RunError not needed as RunL does not leave + +private: // methods from CATCmdAsyncBase + virtual void HandleCommand( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded ); + virtual void HandleCommandCancel(); + +private: + CCLCKCommandHandler(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone); + void ConstructL(); + + TInt ParseCCLCKCommand(); + void IssueCLCKCommand(); + TInt ReceiveCBList(); + +private: + CCBSettingHandler* iCBSettingHandler; + CSecurityEventHandler* iSecurityEventHandler; + CSecurityCodeVerifier* iSecurityCodeVerifier; + CRetrieveMobilePhoneCBList* iCBRetrieve; + + RBuf8 iReply; + + TCLCKCommand iCLCKCommandType; + RBuf8 iPassword; + TInt iInfoClass; + + TLockSettingState iLockSettingState; + RMobilePhone::TMobilePhoneLock iLockType; + RMobilePhone::TMobilePhoneLockSetting iLockChange; + RMobilePhone::TMobilePhoneSecurityCode iSecurityCode; + + RMobilePhone::TMobilePhoneLockInfoV1 iLockInfo; + RMobilePhone::TMobilePhoneLockInfoV1Pckg iLockInfoPckg; + + RMobilePhone::TMobilePhoneCBCondition iCondition; + RMobilePhone::TMobilePhoneCBChangeV1 iCBInfo; + }; + +#endif // CLCKCOMMANDHANDLER_H diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/inc/cmeerror.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/inc/cmeerror.h Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,66 @@ +/* + * 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 : define all +CME Error code. + * Reference: + * 3GPP TS 27.007 version 6.9.0 Release 6 118 ETSI TS 127 007 V6.9.0 (2007-06) + * + */ + +#ifndef CMEERROR_H_ +#define CMEERROR_H_ + +enum TATCMEError + { + EATCmeNoError = -1, // No errors, only for internal use + EATCmePhoneFailure =0, // 0 phone failure + EATCmeNoConnection, // 1 no connection to phone + EATCmeAdaptorLinkReserved, // 2 phone-adaptor link reserved + EATCmeNotAllowed, // 3 operation not allowed + EATCmeNotSupported, // 4 operation not supported + EATCmePhSimPinRequired, // 5 PH-SIM PIN required + EATCmePhFsimPinRequired, // 6 PH-FSIM PIN required + EATCmePhFsimPukRequired, // 7 PH-FSIM PUK required + EATCmeSimNotInserted, // 10 SIM not inserted + EATCmeSimPinRequired, // 11 SIM PIN required + EATCmeSimPukRequired, // 12 SIM PUK required + EATCmeSimFailure, // 13 SIM failure + EATCmeSimBusy, // 14 SIM busy + EATCmeSimWrong, // 15 SIM wrong + EATCmeIncorrectPassword, // 16 incorrect password + EATCmeSimPin2Required, // 17 SIM PIN2 required + EATCmeSimPuk2Required, // 18 SIM PUK2 required + EATCmeMemoryFull, // 20 memory full + EATCmeInvalidIndex, // 21 invalid index + EATCmeNotFound, // 22 not found + EATCmeMemoryFailure, // 23 memory failure + EATCmeTextTooLong, // 24 text string too long + EATCmeInvalidChar, // 25 invalid characters in text string + EATCmeDialStringTooLong, // 26 dial string too long + EATCmeInvalidDialString, // 27 invalid characters in dial string + EATCmeNoNetworkService, // 30 no network service + EATCmeNetworkTimeout, // 31 network timeout + EATCmeNetworkNotAllowed, // 32 network not allowed - emergency calls only + EATCmeNetPerPinRequired, // 40 network personalization PIN required + EATCmeNetPerPukRequired, // 41 network personalization PUK required + EATCmeNetSubPerPinRequired, // 42 network subset personalization PIN required + EATCmeNetSubPerPukRequired, // 43 network subset personalization PUK required + EATCmeSPPerPinRequired, // 44 service provider personalization PIN required + EATCmeSPPerPukRequired, // 45 service provider personalization PUK required + EATCmeCorpPerPinRequired, // 46 corporate personalization PIN required + EATCmeCorpPerPukRequired, // 47 corporate personalization PUK required + EATCmeHiddenKeyRequired, // 48 hidden key required (NOTE: This key is required when accessing hidden phonebook entries.) + EATCmeEAPNotSupported, // 49 EAP method not supported + EATCmeIncorrectParams, // 50 Incorrect parameters + EATCmeUnknown = 100 // 100 unknown + }; + +#endif /* CMEERROR_H_ */ diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/inc/cnumcommandhandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/inc/cnumcommandhandler.h Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,72 @@ +/* + * 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 : CCNUMCommandHandler class declaration for AT+CNUM command + * + */ + +#ifndef CNUMCOMMANDHANDLER_H +#define CNUMCOMMANDHANDLER_H + +#include "atmisccmdplugin.h" + +/** + * This class implements an AO for AT+CPIN command using ATExt plugin framework. + */ +NONSHARABLE_CLASS( CCNUMCommandHandler ) : public CATCmdAsyncBase +{ +public: + /** + * @param aCallback is used to notfiy ATExt server to complete the AT command request. + */ + static CCNUMCommandHandler* NewL(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, + RMobilePhone& aPhone, RTelServer& aTelServer); + ~CCNUMCommandHandler(); + +private: + // methods inherited from CActive + virtual void RunL(); + virtual void DoCancel(); + // RunError is not required because RunL doesn't leave. + + // inherited from CATCmdAsyncBase + /** + * @see CATCmdAsyncBase::HandleCommand + */ + 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); + void ConstructL(); + +private: + enum TATNumState + { + EATNumGetStoreInfo, + EATNumReadNumber + }; + + RTelServer& iTelServer; + TInt iPendingEvent; + + RMobileONStore iOwnNumberStore; + RMobileONStore::TMobileONStoreInfoV1 iOwnStoreInfo; + RMobileONStore::TMobileONStoreInfoV1Pckg iOwnStoreInfoPckg; + RMobileONStore::TMobileONEntryV1 iOwnNumberEntry; + RMobileONStore::TMobileONEntryV1Pckg iOwnNumberEntryPckg; + RBuf8 iReplyBuffer; +}; + +#endif /* CNUMCOMMANDHANDLER_H */ diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/inc/cpincommandhandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/inc/cpincommandhandler.h Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,73 @@ +/* + * 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 : CCPIMCommandHandler class declaration for AT+CPIN command + * + */ + +#ifndef CPINCOMMANDHANDLER_H +#define CPINCOMMANDHANDLER_H + +#include "atmisccmdplugin.h" + +/** + * This class implements an AO for AT+CPIN command using ATExt plugin framework. + */ +NONSHARABLE_CLASS( CCPINCommandHandler ) : public CATCmdAsyncBase +{ +public: + /** + * @param aCallback is used to notfiy ATExt server to complete the AT command request. + */ + static CCPINCommandHandler* NewL(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone); + ~CCPINCommandHandler(); + +private: + // Methods inherited from CActive + virtual void RunL(); + virtual void DoCancel(); + // RunError is not required because RunL doesn't leave. + + /** + * @see CATCmdAsyncBase::HandleCommand + */ + 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(); + + /** + * Handle status change event for RMobilePhone::GetLockInfo method + */ + void HandleGetLockInfo(); + /** + * Handle status change event for RMobilePhone::HandleVerifySecurityCode method + */ + void HandleVerifySecurityCode(); + /** + * Change SIM PIN with PUK code + */ + void ChangePassword(); + +private: + + RMobilePhone::TMobilePhoneLockInfoV1 iLockInfo; + RMobilePhone::TMobilePhoneLockInfoV1Pckg iLockInfoPckg; + + TInt iPendingEvent; +}; + + +#endif /* CPINCOMMANDHANDLER_H */ diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/inc/cpwdcommandhandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/inc/cpwdcommandhandler.h Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,71 @@ +/* + * 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 : CPwdCommandHandler class declaration for AT+CPWD command + * + */ + + +#ifndef CPWDCOMMANDHANDLER_H +#define CPWDCOMMANDHANDLER_H +#include +#include + +#include "atmisccmdplugin.h" + +/** + * This class implements an AO for AT+CPWD command using ATExt plugin framework. + */ +NONSHARABLE_CLASS( CCPWDCommandHandler ) : public CATCmdAsyncBase +{ +public: + /** + * @param aCallback is used to notfiy ATExt server to complete the AT command request. + */ + static CCPWDCommandHandler* NewL(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone); + ~CCPWDCommandHandler(); + +private: + // methods inherited from CActive + virtual void RunL(); + virtual void DoCancel(); + // RunError is not required because RunL doesn't leave. + + /** + * @see CATCmdAsyncBase::HandleCommand + */ + 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(); + + /** + * Change password according to AT command arguments + */ + void ChangePassword(); + + /** + * request Etel server to change password and active the AO + * @param aType type of password to be changed + * @param aOldPassword old password + * @param aNewPassword new password + */ + void ChangeSecurityCode(RMobilePhone::TMobilePhoneSecurityCode aType, TDesC8& aOldPassword, TDesC8& aNewPassword); + +private: + TInt iPendingEvent; +}; + +#endif /* CPWDCOMMANDHANDLER_H */ diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/inc/cusdcommandhandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/inc/cusdcommandhandler.h Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,99 @@ +/* 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 CUSDCOMMANDHANDLER_H +#define CUSDCOMMANDHANDLER_H + +#include +#include +#include +#include + +#include "atmisccmdplugin.h" + +class CCUSSDSendMessageImpl; +class CCUSSDReadMessageImpl; +/** + * Class for accessing plugin information and common functionality + */ +NONSHARABLE_CLASS( MUSSDCallback ) + { +public: + /** + * Creates an AT command reply based on the reply type and completes the + * request to ATEXT. + */ + virtual void HandleReadMessageComplete(TInt aResult) = 0; + + /** + * Creates an AT command reply based on the reply type and completes the + * request to ATEXT. + */ + virtual void HandleSendMessageComplete(TInt aResult) = 0; + }; + + +NONSHARABLE_CLASS( CCUSDCommandHandler ) : public CATCmdAsyncBase, + 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); + +private: // methods from CATCmdAsyncBase + virtual void HandleCommand( const TDesC8& aCmd, RBuf8& aReply, TBool aReplyNeeded ); + virtual void HandleCommandCancel(); + +private: + CCUSDCommandHandler(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone); + void ConstructL(); + + TInt ParseCUSDCmd(const TDesC8& aCmd); + void CCUSDCommandHandler::FindFirstCarriageReturnL( + const TDesC& aBuffer , + TUint& aSkipChars , + TUint& aStartBit ); + + TInt Pack(const TDesC8& aIn, TDes8& aOut); + TInt ElementSizeInBits(TSmsDataCodingScheme::TSmsAlphabet aAlphabet) const; + TInt PackedOctetsRequired( TInt aNumUDUnits ) const; + TBool IsDcsValid( const TUint8 aDcs ) const; + void FormatUSSDReceivedData(); + +private: + TBool iSendCommandSent; + RBuf8 iReply; + + RMobileUssdMessaging iUssdMessaging; + + CCUSSDSendMessageImpl* iUSSDSender; + RMobileUssdMessaging::TMobileUssdAttributesV1 iSendAttributes; + RBuf8 iUSSDCommand; + + CCUSSDReadMessageImpl* iUSSDReader; + RMobileUssdMessaging::TGsmUssdMessageData iReceivedData; + TInt iDisplayRetMessage; + RMobileUssdMessaging::TMobileUssdAttributesV1 iReceiveAttributes; + }; + +#endif // CUSDCOMMANDHANDLER_H diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/inc/cusdreadwriteimp.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/inc/cusdreadwriteimp.h Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,68 @@ +/* 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 +#include + +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 diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/inc/debug.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/inc/debug.h Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,236 @@ +/* + * 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 :tracing and debuging definitions. + * + */ + + +#ifndef DEBUG_H +#define DEBUG_H + +#include +#include + +_LIT8(KDebugPrintS, "ATCmd: %s%S\r\n"); +_LIT8(KDebugPrintD, "ATCmd: %s%d\r\n"); + +#ifdef _DEBUG + +#include + +_LIT(KLogFile,"atmiscmdplugin.txt"); +_LIT(KLogDir,"atmiscmdplugin"); +_LIT(KATDebugFile, "log.txt" ); +_LIT(KATDebugDir, "atmiscmdplugin" ); + +_LIT(KTracePrefix16, "[atmiscmdplugin] "); +_LIT8(KTracePrefix8, "[atmiscmdplugin] "); +_LIT8(KFuncFormat8, ">< %S"); +_LIT8(KFuncThisFormat8, ">< %S, [0x%08X]"); +_LIT8(KFuncEntryFormat8, "-> %S"); +_LIT8(KFuncEntryThisFormat8, "-> %S, [0x%08X]"); +_LIT8(KFuncEntryArgFormat8, "-> %S, (%S)"); +_LIT8(KFuncExitFormat8, "<- %S"); +_LIT(KPanicCategory, "atmiscmdplugin"); +_LIT8(KPanicPrefix8, "PANIC code "); +_LIT8(KLeavePrefix8, "LEAVE code "); + +const TInt KMaxLogLineLength = 256; + +// Trace options +#define KPRINTERROR 0x00000001 // Print error +#define KPRINTINFO 0x00000002 // Print function trace +#define KPRINTSTATE 0x00000004 // Print state machine infos +#define KPRINTWARNING 0x00000008 // Print warnings + +#define USE_FILE_LOGGING + +const TInt KTraceMask = KPRINTERROR | KPRINTINFO | KPRINTSTATE | KPRINTWARNING; + +NONSHARABLE_CLASS(TOverflowTruncate16) : public TDes16Overflow + { +public: + void Overflow(TDes16& /*aDes*/) {} + }; + +NONSHARABLE_CLASS(TOverflowTruncate8) : public TDes8Overflow + { +public: + void Overflow(TDes8& /*aDes*/) {} + }; + +inline void Trace(TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list,aFmt); + RBuf16 buf; + buf.Create(KMaxLogLineLength); + buf.Zero(); + buf.Append(KTracePrefix16); + TOverflowTruncate16 overflow; + buf.AppendFormatList(aFmt,list,&overflow); + RDebug::Print(buf); +#ifdef USE_FILE_LOGGING + RFileLogger::Write(KLogDir, KLogFile, EFileLoggingModeAppend, buf); +#endif + buf.Close(); + } + +inline void Trace(TRefByValue aFmt, ...) + { + VA_LIST list; + VA_START(list, aFmt); + TOverflowTruncate8 overflow; + RBuf8 buf8; + buf8.Create(KMaxLogLineLength); + buf8.Zero(); + buf8.Append(KTracePrefix8); + buf8.AppendFormatList(aFmt, list, &overflow); + RDebug::RawPrint(buf8); +#ifdef USE_FILE_LOGGING + RFileLogger::Write(KLogDir, KLogFile, EFileLoggingModeAppend, buf8); +#endif + buf8.Close(); + } + +inline void TracePanic( + char* aFile, + TInt aLine, + TInt aPanicCode, + const TDesC& aPanicCategory) + { + TPtrC8 fullFileName((const TUint8*)aFile); + TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1); + RBuf8 buf; + buf.Create(KMaxLogLineLength); + buf.Zero(); + buf.Append(KPanicPrefix8); + buf.AppendFormat(_L8("%d at line %d in file %S"), aPanicCode, aLine, &fileName); + Trace(buf); + buf.Close(); + User::Panic(aPanicCategory, aPanicCode); + } + +inline void TraceLeave(char* aFile, TInt aLine, TInt aReason) + { + TPtrC8 fullFileName((const TUint8*)aFile); + TPtrC8 fileName(fullFileName.Ptr()+fullFileName.LocateReverse('\\')+1); + RBuf8 buf; + buf.Create(KMaxLogLineLength); + buf.Zero(); + buf.Append(KLeavePrefix8); + buf.AppendFormat(_L8("%d at line %d in file %S"), aReason, aLine, &fileName); + Trace(buf); + buf.Close(); + User::LeaveIfError(aReason); + } + +inline TBuf8<64> ArgFormat(TRefByValue aFmt, ...) + { + TOverflowTruncate8 overflow; + TBuf8<64> buf8; + buf8.Format(aFmt, &overflow); + return buf8; + } + +#define TRACE_INFO(p) {if(KTraceMask & KPRINTINFO) Trace p;} + +#define TRACE_ERROR(p) {if(KTraceMask & KPRINTERROR) Trace p;} + +#define TRACE_STATE(p) {if(KTraceMask & KPRINTSTATE) Trace p;} + +#define TRACE_WARNING(p) {if(KTraceMask & KPRINTWARNING) Trace p;} + +#define TRACE_INFO_SEG(p) {if(KTraceMask & KPRINTINFO) p;} + +#define TRACE_ASSERT(GUARD, CODE) {if (!(GUARD)) \ + TracePanic(__FILE__, __LINE__, CODE, KPanicCategory);} + +#define PANIC(CODE) TracePanic(__FILE__, __LINE__, CODE, KPanicCategory) + +#define LEAVE_IF_ERROR(REASON) {if (REASON) \ + TraceLeave(__FILE__, __LINE__, REASON);} + +#define LEAVE(REASON) TraceLeave(__FILE__, __LINE__, REASON) + +#define TRACE_FUNC_ENTRY {if(KTraceMask & KPRINTINFO) { \ + TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); \ + Trace(KFuncEntryFormat8, &ptr8);}} + +#define TRACE_FUNC_ENTRY_THIS {if(KTraceMask & KPRINTINFO) {\ + TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); \ + Trace(KFuncEntryThisFormat8, &ptr8, this);}} + +#define TRACE_FUNC_EXIT {if(KTraceMask & KPRINTINFO) {\ + TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); \ + Trace(KFuncExitFormat8, &ptr8);}} + +#define TRACE_FUNC {if(KTraceMask & KPRINTINFO) { \ + TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); \ + Trace(KFuncFormat8, &ptr8);}} + +#define TRACE_FUNC_THIS {if(KTraceMask & KPRINTINFO) {\ + TPtrC8 ptr8((TUint8*)__PRETTY_FUNCTION__); \ + Trace(KFuncThisFormat8, &ptr8, this);}} + +#define TRACE_FUNC_ARG(a) { if(KTraceMask & KPRINTINFO) { \ + TPtrC8 func( (TUint8*) __PRETTY_FUNCTION__ ); \ + TPtrC8 arg( ArgFormat a ); \ + Trace( KFuncEntryArgFormat8, &func, &arg ); } } + +#define RETURN_IF_ERR(ERR) {if(ERR) {Trace(_L8(" RETURN %d at file %S line %d"), ERR, &(TPtrC8((const TUint8*)__FILE__)), __LINE__); return ERR;}} + +#else // ! _DEBUG + +#define TRACE_INFO(p) + +#define TRACE_ERROR(p) + +#define TRACE_STATE(p) + +#define TRACE_WARNING(p) + +#define TRACE_INFO_SEG(p) + +#define TRACE_ASSERT(GUARD, CODE) + +#define PANIC(CODE) {User::Panic(KPanicCategory, CODE);} + +#define LEAVE_IF_ERROR(REASON) {static_cast(User::LeaveIfError(REASON));} + +#define LEAVE(REASON) {static_cast(User::Leave(REASON));} + +#define TRACE_FUNC_ENTRY + +#define TRACE_FUNC_ENTRY_THIS + +#define TRACE_FUNC_EXIT + +#define TRACE_FUNC + +#define TRACE_FUNC_THIS + +#define TRACE_FUNC_ARG(a) + +#define RETURN_IF_ERR(ERR) {if(ERR) return ERR;} + +inline void Trace(TRefByValue aFmt, ...) + { + } + +inline void Trace(TRefByValue aFmt, ...) + { + } +#endif // _DEBUG + +#endif // DEBUG_H + diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/inc/securitycodeverifier.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/inc/securitycodeverifier.h Tue Apr 27 16:49:44 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 SECURITYCODEVERIFIER_H +#define SECURITYCODEVERIFIER_H + +#include + +class CCLCKCommandHandler; + +/** + * AO class handling Secirity Code verification requests + */ +NONSHARABLE_CLASS(CSecurityCodeVerifier) : public CActive + { +public: + static CSecurityCodeVerifier* NewL(CCLCKCommandHandler* aCLCKHandler, RMobilePhone& aPhone); + ~CSecurityCodeVerifier(); + void Start(TDesC8& aPassword, RMobilePhone::TMobilePhoneSecurityCode& aSecurityCode); + +private: // methods from CActive + virtual void RunL(); + virtual void DoCancel(); + // RunError not needed as RunL does not leave + +private: + CSecurityCodeVerifier(CCLCKCommandHandler* aCLCKHandler, RMobilePhone& aPhone); + void ConstructL(); + +private: + CCLCKCommandHandler* iCLCKHandler; + RMobilePhone& iPhone; + RMobilePhone::TMobilePhoneSecurityEvent iSecurityEvent; + }; + +#endif /* SECURITYCODEVERIFIER_H */ diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/inc/securityeventhandler.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/inc/securityeventhandler.h Tue Apr 27 16:49:44 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 : + * + */ + + +#ifndef SECURITYEVENTHANDLER_H +#define SECURITYEVENTHANDLER_H + +#include + +class CCLCKCommandHandler; + +/** + * AO class handling Security Events notifications + */ +NONSHARABLE_CLASS(CSecurityEventHandler) : public CActive + { +public: + static CSecurityEventHandler* NewL(CCLCKCommandHandler* aCLCKHandler, RMobilePhone& aPhone); + ~CSecurityEventHandler(); + void Start(); + +private: // methods from CActive + virtual void RunL(); + virtual void DoCancel(); + // RunError not needed as RunL does not leave + +private: + CSecurityEventHandler(CCLCKCommandHandler* aCLCKHandler, RMobilePhone& aPhone); + void ConstructL(); + +private: + CCLCKCommandHandler* iCLCKHandler; + RMobilePhone& iPhone; + RMobilePhone::TMobilePhoneSecurityEvent iSecurityEvent; + }; + +#endif /* SECURITYEVENTHANDLER_H */ diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/readme.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/readme.txt Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,4 @@ +- AT misc commands plugin implements AT commands for AT+CFUN +- This plugin will not be part of SF and will be moved to ext folder later +- To test this plugin we need to manually build +- Optionally, after building we can generate a sisx file and use it for testing. Look at atmisccmdplugin\sis folder for information \ No newline at end of file diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/rom/atmisccmdplugin.iby --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/rom/atmisccmdplugin.iby Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * Description :Contains information about binary files and binary file locations + * + */ + +#ifndef ATMISCCMDPLUGIN_IBY +#define ATMISCCMDPLUGIN_IBY + +ECOM_PLUGIN(atmisccmdplugin.dll, atmisccmdplugin.rsc) +S60_APP_RESOURCE(atmisccmdpluginresource) + +#endif // ATMISCCMDPLUGIN_IBY + +// End of File diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/src/atcommandparser.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/src/atcommandparser.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,261 @@ +// 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: +// This file contains the implementation of the AT command parser and common utilities +// +// + +#include "atcommandparser.h" +#include + +#include "debug.h" + + +// Max buffer length for an MD5 digest +const TInt KSCPMaxHashLength( 32 ); + + +TAtCommandParser::TAtCommandParser() + : iCmdType(EUnknown), iCmdHandlerType(ECmdHandlerTypeUndefined) + { + } + +TAtCommandParser::TAtCommandParser(const TDesC8& aCmd) + : iCmdType(EUnknown), iCmdHandlerType(ECmdHandlerTypeUndefined) + { + ParseAtCommand(aCmd); + } + + +void TAtCommandParser::ParseAtCommand(const TDesC8& aCmd) + { + TRACE_FUNC_ENTRY + iCmd.Assign(aCmd); + iCmd.Mark(); + TChar c = 0; + // First extract the AT command "AT+COMMAND" + while(!iCmd.Eos() && !(c=='=' || c=='?')) + { + iCmd.Inc(); + c = iCmd.Peek(); + } + + TPtrC8 token = iCmd.MarkedToken(); + + _LIT8(KAtCfun, "AT+CFUN"); + _LIT8(KAtCbc, "AT+CBC"); + _LIT8(KAtClck, "AT+CLCK"); + _LIT8(KAtCpwd, "AT+CPWD"); + _LIT8(KAtCpin, "AT+CPIN"); + _LIT8(KAtCusd, "AT+CUSD"); + _LIT8(KAtCnum, "AT+CNUM"); + + Trace(KDebugPrintS, "token: ", &token); + // Determine the AT command type + if(!token.Compare(KAtCfun)) + { + iCmdType = ECmdAtCfun; + } + else if(!token.Compare(KAtCbc)) + { + iCmdType = ECmdAtCbc; + } + else if(!token.Compare(KAtClck)) + { + iCmdType = ECmdAtClck; + } + else if(!token.Compare(KAtCpwd)) + { + iCmdType = ECmdAtCpwd; + } + else if(!token.Compare(KAtCpin)) + { + iCmdType = ECmdAtCpin; + } + else if(!token.Compare(KAtCusd)) + { + iCmdType = ECmdAtCusd; + } + else if(!token.Compare(KAtCnum)) + { + iCmdType = ECmdAtCnum; + } + else + { + iCmdType = EUnknown; + TRACE_FUNC_EXIT + return; + } + + // Now find out the AT command handler type + if(iCmd.Eos()) + { + iCmdHandlerType = ECmdHandlerTypeBase; + } + else if(iCmd.Peek() == '?') + { + iCmdHandlerType = ECmdHandlerTypeRead; + } + else if(iCmd.Peek() == '=') + { + iCmd.Inc(); + if(iCmd.Peek() == '?') + { + iCmd.Inc(); + iCmdHandlerType = ECmdHandlerTypeTest; + } + else + { + iCmdHandlerType = ECmdHandlerTypeSet; + } + } + else + { + iCmdHandlerType = ECmdHandlerTypeUndefined; + } + TRACE_FUNC_EXIT + } + +TAtCommandParser::TCommandType TAtCommandParser::Command() const + { + return iCmdType; + } + +TAtCommandParser::TCommandHandlerType TAtCommandParser::CommandHandlerType() const + { + return iCmdHandlerType; + } + +TPtrC8 TAtCommandParser::NextParam() + { + TRACE_FUNC_ENTRY + iCmd.SkipSpace(); // Skip front spaces + iCmd.Mark(); + TChar chr = 0; + + if(!iCmd.Eos()) + { + chr = iCmd.Peek(); + while(!iCmd.Eos() && chr != ',' && !chr.IsSpace() && !chr.IsControl()) + {// Stop at any of those chars: comma, space or control + iCmd.Inc(); + chr = iCmd.Peek(); + } + } + + // Extract the token at this point + TPtrC8 retVal = iCmd.MarkedToken(); + + // Skip comma, space and control chars + while(!iCmd.Eos() && (chr == ',' || chr.IsSpace() || chr.IsControl())) + { + iCmd.Inc(); + chr = iCmd.Peek(); + } + TRACE_FUNC_EXIT + return retVal; + } + +TPtrC8 TAtCommandParser::NextTextParam(TInt& aError) + { + TPtrC8 param = NextParam(); + + if (param.Compare(KNullDesC8) == 0) + { + aError = KErrNotFound; + return param; + } + + if(param.Length()<2 + || param[0] != '"' + || param[param.Length()-1] != '"') + { + aError = KErrArgument; + return param.Left(0); + } + aError = KErrNone; + return param.Mid(1, param.Length() - 2); + } + +TInt TAtCommandParser::NextIntParam(TInt& aValue) + { + TRACE_FUNC_ENTRY + TInt retVal =KErrNone; + TPtrC8 param = NextParam(); + if (param.Compare(KNullDesC8) == 0) + { + retVal = KErrNotFound; + } + else + { + TLex8 lex(param); + retVal = lex.Val(aValue); + } + TRACE_FUNC_EXIT + return retVal; + } + +TInt TAtCommandParser::HashSecurityCode(const TDesC8& aPasscode, TDes8& aHashCode) + { + TRACE_FUNC_ENTRY + TInt ret = KErrNone; + + // Get MD5 Hash + // see remotemgmt component CSCPServer::HashISACode() for encoding algorithm + CMD5* hashObject = NULL; + TRAP( ret, hashObject = CMD5::NewL() ); + + if(ret != KErrNone) + { + TRACE_FUNC_EXIT + return ret; + } + + RBuf pwdBuffer; + ret = pwdBuffer.Create(KSCPMaxHashLength); + if(ret != KErrNone) + { + delete hashObject; + TRACE_FUNC_EXIT + return ret; + } + pwdBuffer.Copy(aPasscode); // convert to TDes16 + + // add TDes16 to a binary buffer + TUint16* inputPtr = const_cast( pwdBuffer.Ptr() ); + TPtrC8 inputData( reinterpret_cast(inputPtr), pwdBuffer.Length()*2 ); + + TPtrC8 hash = hashObject->Final( inputData ); + delete hashObject; + + pwdBuffer.Zero(); + pwdBuffer.Copy(hash); + + // Compute the hash sum as four 32-bit integers. + TInt64 hashSum = *(reinterpret_cast(&pwdBuffer[0])) + + *(reinterpret_cast(&pwdBuffer[4])) + + *(reinterpret_cast(&pwdBuffer[8])) + + *(reinterpret_cast(&pwdBuffer[12])); + pwdBuffer.Close(); + + // Create a five-digit security code from this number + TInt isaCode = ( hashSum % 90000 ) + 10000; + + // save encoded security code to TDes + aHashCode.Zero(); + aHashCode.AppendNum(isaCode); + + TRACE_FUNC_EXIT + return KErrNone; + } + diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/src/atmisccmdplugin.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/src/atmisccmdplugin.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,529 @@ +/* +* 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 "clckcommandhandler.h" +#include "cpwdcommandhandler.h" +#include "cpincommandhandler.h" +#include "cusdcommandhandler.h" +#include "cnumcommandhandler.h" +#include "cfuncommandhandler.h" +#include "cbccommandhandler.h" + +#include "atmisccmdpluginconsts.h" +#include "debug.h" + +#include // 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 + +const TInt KErrorReplyLength = 9; // CR+LF+"ERROR"+CR+LF + +CATMiscCmdPlugin* CATMiscCmdPlugin::NewL() + { + CATMiscCmdPlugin* self = new (ELeave) CATMiscCmdPlugin(); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + return self; + } + +CATMiscCmdPlugin::~CATMiscCmdPlugin() + { + iReplyBuffer.Close(); + + delete iCLCKHandler; + delete iCPWDHandler; + delete iCPINHandler; + delete iCUSDHandler; + delete iCNUMHandler; + delete iCFUNHandler; + delete iCBCHandler; + + iPhone.Close(); + iTelServer.Close(); + } + +CATMiscCmdPlugin::CATMiscCmdPlugin() : + CATExtPluginBase() + { + } + +void CATMiscCmdPlugin::ConstructL() + { + TRACE_FUNC_ENTRY + ConnectToEtelL(iTelServer, iPhone); + + iCLCKHandler = CCLCKCommandHandler::NewL(this, iCommandParser, iPhone); + iCPWDHandler = CCPWDCommandHandler::NewL(this, iCommandParser, iPhone); + iCUSDHandler = CCUSDCommandHandler::NewL(this, iCommandParser, iPhone); + iCPINHandler = CCPINCommandHandler::NewL(this, iCommandParser, iPhone); + iCNUMHandler = CCNUMCommandHandler::NewL(this, iCommandParser, iPhone, iTelServer); + iCFUNHandler = CCFUNCommandHandler::NewL(this, iCommandParser, iPhone); + iCBCHandler = CCBCCommandHandler::NewL(this, iCommandParser, iPhone); + TRACE_FUNC_EXIT + } + +/** + * @see CATExtPluginBase::ReportConnectionName + */ +void CATMiscCmdPlugin::ReportConnectionName( const TDesC8& /*aName*/ ) + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +/** + * @see CATExtPluginBase::IsCommandSupported + */ +TBool CATMiscCmdPlugin::IsCommandSupported( const TDesC8& aCmd ) + { + TRACE_FUNC_ENTRY + iHcCmd = NULL; + iHcReply = NULL; + iCurrentHandler = NULL; + TBool supported = ETrue; + + Trace(KDebugPrintS, "aCmd: ", &aCmd); + + iCommandParser.ParseAtCommand(aCmd); + + Trace(KDebugPrintD, "Command: ", iCommandParser.Command()); + // TODO: check if the type is supported? + // iCommandParser.CommandHandlerType() != TAtCommandParser::ECmdHandlerTypeUndefined + switch (iCommandParser.Command()) + { + case (TAtCommandParser::ECmdAtClck): + { + iCurrentHandler = iCLCKHandler; + break; + } + case (TAtCommandParser::ECmdAtCpwd): + { + iCurrentHandler = iCPWDHandler; + break; + } + case (TAtCommandParser::ECmdAtCpin): + { + iCurrentHandler = iCPINHandler; + break; + } + case (TAtCommandParser::ECmdAtCusd): + { + iCurrentHandler = iCUSDHandler; + break; + } + case (TAtCommandParser::ECmdAtCnum): + { + iCurrentHandler = iCNUMHandler; + break; + } + case (TAtCommandParser::ECmdAtCfun): + { + iCurrentHandler = iCFUNHandler; + break; + } + case (TAtCommandParser::ECmdAtCbc): + { + iCurrentHandler = iCBCHandler; + break; + } + case (TAtCommandParser::EUnknown): + default: + { + supported = EFalse; + break; + } + } + Trace(KDebugPrintD, "supported: ", supported); + TRACE_FUNC_EXIT + return supported; + } + +/** + * @see CATExtPluginBase::HandleCommand + */ +void CATMiscCmdPlugin::HandleCommand( const TDesC8& aCmd, + RBuf8& aReply, + TBool aReplyNeeded ) + { + TRACE_FUNC_ENTRY + + if (iCurrentHandler != NULL) + { + iHcCmd = &aCmd; + iHcReply = &aReply; + iCurrentHandler->HandleCommand( aCmd, aReply, aReplyNeeded ); + } + TRACE_FUNC_EXIT + } + +/** + * @see CATExtPluginBase::HandleCommandCancel + */ +void CATMiscCmdPlugin::HandleCommandCancel() + { + TRACE_FUNC_ENTRY + if (iCurrentHandler != NULL) + { + iCurrentHandler->HandleCommandCancel(); + } + TRACE_FUNC_EXIT + } + +/** + * @see CATExtPluginBase::NextReplyPartLength + */ +TInt CATMiscCmdPlugin::NextReplyPartLength() + { + TRACE_FUNC_ENTRY + TInt length = iReplyBuffer.Length(); + if ( length >= KDefaultCmdBufLength ) + { + length = KDefaultCmdBufLength; + } + TRACE_FUNC_EXIT + return length; + } + +/** + * @see CATExtPluginBase::GetNextPartOfReply + */ +TInt CATMiscCmdPlugin::GetNextPartOfReply( RBuf8& aNextReply ) + { + TRACE_FUNC_ENTRY + TInt retVal = CreatePartOfReply( aNextReply ); + TRACE_FUNC_EXIT + return retVal; + } + +/** + * @see CATExtPluginBase::ReceiveUnsolicitedResult + */ +void CATMiscCmdPlugin::ReceiveUnsolicitedResult() + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +/** + * @see CATExtPluginBase::ReceiveUnsolicitedResultCancel + */ +void CATMiscCmdPlugin::ReceiveUnsolicitedResultCancel() + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +/** + * @see CATExtPluginBase::ReportNvramStatusChange + */ +void CATMiscCmdPlugin::ReportNvramStatusChange( const TDesC8& /*aNvram*/ ) + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +/** + * @see CATExtPluginBase::ReportExternalHandleCommandError + */ +void CATMiscCmdPlugin::ReportExternalHandleCommandError() + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +/** + * Creates part of reply from the global reply buffer to the destination + * buffer. Used with APIs which need the next part of reply in multipart + * reply requests. + * + * @param aBuffer Destination buffer; the next part of reply is stored to + * this buffer. + * @return None + */ +TInt CATMiscCmdPlugin::CreatePartOfReply( RBuf8& aBuffer ) + { + TRACE_FUNC_ENTRY + TInt ret = KErrNone; + TInt partLength; + if ( iReplyBuffer.Length() <= 0 ) + { + ret = KErrGeneral; + } + else + { + partLength = NextReplyPartLength(); + if ( iReplyBuffer.Length() < partLength ) + { + ret = KErrNotFound; + } + } + Trace(KDebugPrintD, "ret: ", ret); + if (ret == KErrNone) + { + aBuffer.Create( iReplyBuffer, partLength ); + iReplyBuffer.Delete( 0, partLength ); + if ( iReplyBuffer.Length() == 0 ) + { + iReplyBuffer.Close(); + } + } + + TRACE_FUNC_EXIT + return ret; + } + +/** + * @see MATMiscCmdPlugin::CreateReplyAndComplete + */ +TInt CATMiscCmdPlugin::CreateReplyAndComplete( TATExtensionReplyType aReplyType, + const TDesC8& aSrcBuffer, + TInt aError ) + { + TRACE_FUNC_ENTRY + iReplyBuffer.Close(); + Trace(KDebugPrintD, "aError: ", aError); + if ( aError != KErrNone ) + { + HandleCommandCompleted( aError, EReplyTypeUndefined ); + iHcCmd = NULL; + iHcReply = NULL; + iCurrentHandler = NULL; + TRACE_FUNC_EXIT + return KErrNone; + } + + Trace(KDebugPrintS, "iHcReply: ", &iHcReply); + if (iHcReply == NULL) + { + TRACE_FUNC_EXIT + return KErrGeneral; + } + + Trace(KDebugPrintD, "iQuietMode: ", iQuietMode); + if ( iQuietMode ) + { + iReplyBuffer.Create( KNullDesC8 ); + } + else + { + iReplyBuffer.Create( aSrcBuffer ); + } + + Trace(KDebugPrintD, "aReplyType: ", aReplyType); + switch ( aReplyType ) + { + case EReplyTypeOther: + break; + case EReplyTypeOk: + CreateOkOrErrorReply( iReplyBuffer, ETrue ); + break; + case EReplyTypeError: + CreateOkOrErrorReply( iReplyBuffer, EFalse ); + break; + default: + TRACE_FUNC_EXIT + return KErrGeneral; + } + CreatePartOfReply( *iHcReply ); + HandleCommandCompleted( KErrNone, aReplyType ); + iHcCmd = NULL; + iHcReply = NULL; + iCurrentHandler = NULL; + TRACE_FUNC_EXIT + return KErrNone; + } + +/** + * @see MATMiscCmdPlugin::CreateOkOrErrorReply + */ +TInt CATMiscCmdPlugin::CreateOkOrErrorReply( RBuf8& aReplyBuffer, + TBool aOkReply ) + { + TRACE_FUNC_ENTRY + _LIT8( KErrorReplyVerbose, "ERROR" ); + _LIT8( KOkReplyVerbose, "OK" ); + _LIT8( KErrorReplyNumeric, "4" ); + _LIT8( KOkReplyNumeric, "0" ); + TBuf8 replyBuffer; + if ( iVerboseMode ) + { + replyBuffer.Append( iCarriageReturn ); + replyBuffer.Append( iLineFeed ); + if ( aOkReply ) + { + replyBuffer.Append( KOkReplyVerbose ); + } + else + { + replyBuffer.Append( KErrorReplyVerbose ); + } + replyBuffer.Append( iCarriageReturn ); + replyBuffer.Append( iLineFeed ); + } + else + { + if ( aOkReply ) + { + replyBuffer.Append( KOkReplyNumeric ); + } + else + { + replyBuffer.Append( KErrorReplyNumeric ); + } + replyBuffer.Append( iCarriageReturn ); + } + + aReplyBuffer.ReAlloc(aReplyBuffer.Length() + replyBuffer.Length()); + aReplyBuffer.Append( replyBuffer ); + TRACE_FUNC_EXIT + return KErrNone; + } + +/** + * @see MATMiscCmdPlugin::GetCharacterValue + */ +TInt CATMiscCmdPlugin::GetCharacterValue( TCharacterTypes aCharType, + TChar& aChar ) + { + TRACE_FUNC_ENTRY + TInt retVal = KErrNone; + switch ( aCharType ) + { + case ECharTypeCR: + aChar = iCarriageReturn; + break; + case ECharTypeLF: + aChar = iLineFeed; + break; + case ECharTypeBS: + aChar = iBackspace; + break; + default: + retVal = KErrNotFound; + break; + } + TRACE_FUNC_EXIT + return retVal; + } + +/** + * @see MATMiscCmdPlugin::GetModeValue + */ +TInt CATMiscCmdPlugin::GetModeValue( TModeTypes aModeType, TBool& aMode ) + { + TRACE_FUNC_ENTRY + TInt retVal = KErrNone; + switch ( aModeType ) + { + case EModeTypeQuiet: + aMode = iQuietMode; + break; + case EModeTypeVerbose: + aMode = iVerboseMode; + break; + default: + retVal = KErrNotFound; + break; + } + TRACE_FUNC_EXIT + return retVal; + } + +void CATMiscCmdPlugin::CreateCMEReplyAndComplete(TInt aError) + { + TRACE_FUNC_ENTRY + + // TODO should return CME error according to CME state (and quiet mode?) + RBuf8 response; + response.Create(KDefaultCmdBufLength); + + // log error code + response.AppendNum(aError); + Trace(KDebugPrintD, "complete with error ", &response); + + // return error code to AT client + response.Zero(); // reuse RBuf + response.Append(KCRLF); + switch(aError) + { + 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); + } + CreateReplyAndComplete( EReplyTypeError, response ); + response.Close(); + TRACE_FUNC_EXIT + } + + +TInt CATMiscCmdPlugin::HandleUnsolicitedRequest(const TDesC8& aAT ) + { + return SendUnsolicitedResult(aAT); + } + +void CATMiscCmdPlugin::ConnectToEtelL(RTelServer& aTelServer, RMobilePhone& aPhone) + { + TRACE_FUNC_ENTRY + User::LeaveIfError(aTelServer.Connect()); + + // get the name of the first available phone + TInt phoneCount; + RTelServer::TPhoneInfo info; + + User::LeaveIfError(aTelServer.EnumeratePhones(phoneCount)); + if (phoneCount < 1) + { + User::Leave(KErrNotFound); // TODO: appropriate error code + } + User::LeaveIfError(aTelServer.GetPhoneInfo(0, info)); + User::LeaveIfError(aPhone.Open(aTelServer, info.iName)); + TRACE_FUNC_EXIT + } diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/src/atmisccmdpluginbase.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/src/atmisccmdpluginbase.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,33 @@ +/* +* 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 + } + diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/src/cbccommandhandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/src/cbccommandhandler.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,145 @@ +/* + * 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 "cbccommandhandler.h" + +#include "atmisccmdpluginconsts.h" +#include "debug.h" + +CCBCCommandHandler* CCBCCommandHandler::NewL(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) + { + TRACE_FUNC_ENTRY + CCBCCommandHandler* self = new (ELeave) CCBCCommandHandler(aCallback, aATCmdParser, aPhone); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + TRACE_FUNC_EXIT + return self; + } + +CCBCCommandHandler::CCBCCommandHandler(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) : + CATCmdAsyncBase(aCallback, aATCmdParser, aPhone) + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +void CCBCCommandHandler::ConstructL() + { + TRACE_FUNC_ENTRY + iReply.CreateL(KDefaultCmdBufLength); + TRACE_FUNC_EXIT + } + +CCBCCommandHandler::~CCBCCommandHandler() + { + TRACE_FUNC_ENTRY + Cancel(); + iReply.Close(); + TRACE_FUNC_EXIT + } + +void CCBCCommandHandler::HandleCommand(const TDesC8& /*aCmd*/, RBuf8& /*aReply*/, TBool /*aReplyNeeded*/) + { + iReply.Zero(); + + TAtCommandParser::TCommandHandlerType cmdHandlerType = iATCmdParser.CommandHandlerType(); + + switch (cmdHandlerType) + { + case (TAtCommandParser::ECmdHandlerTypeTest): + { + iCallback->CreateReplyAndComplete( EReplyTypeOther, KCBCSupportedCmdsList); + break; + } + case (TAtCommandParser::ECmdHandlerTypeBase): + { + iPhone.GetBatteryInfo(iStatus, iBatteryInfo); + SetActive(); + break; + } + default: + { + iCallback->CreateReplyAndComplete(EReplyTypeError); + break; + } + } + TRACE_FUNC_EXIT + } + +void CCBCCommandHandler::HandleCommandCancel() + { + TRACE_FUNC_ENTRY + Cancel(); + TRACE_FUNC_EXIT + } + + +void CCBCCommandHandler::RunL() + { + TRACE_FUNC_ENTRY + if (iStatus.Int() == KErrNone) + { + iReply.Append(KAtCBC); + // status is mapped according to AT command spec: + // : + // 0 MT is powered by the battery + // 1 MT has a battery connected, but is not powered by it + // 2 MT does not have a battery connected + // 3 Recognized power fault, calls inhibited + switch(iBatteryInfo.iStatus) + { + case (RMobilePhone::EPoweredByBattery): + { + iReply.AppendNum(0); + break; + } + case (RMobilePhone::EBatteryConnectedButExternallyPowered): + { + iReply.AppendNum(1); + break; + } + case (RMobilePhone::ENoBatteryConnected): + { + iReply.AppendNum(2); + break; + } + case (RMobilePhone::EPowerFault): + default: + { + iReply.AppendNum(3); + break; + } + } + + iReply.Append(','); + iReply.AppendNum(iBatteryInfo.iChargeLevel); + iReply.Append(KOKCRLF); + + iCallback->CreateReplyAndComplete(EReplyTypeOther, iReply); + } + else + { + iCallback->CreateCMEReplyAndComplete(iStatus.Int()); + } + TRACE_FUNC_EXIT + } + +void CCBCCommandHandler::DoCancel() + { + TRACE_FUNC_ENTRY + iPhone.CancelAsyncRequest(EMobilePhoneGetBatteryInfo); + TRACE_FUNC_EXIT + } diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/src/cbsettinghandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/src/cbsettinghandler.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,158 @@ +/* + * 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 "cbsettinghandler.h" + +#include "clckcommandhandler.h" +#include "debug.h" + +/** + * AO class for setting call barring(s) + */ +CCBSettingHandler* CCBSettingHandler::NewL(RMobilePhone& aPhone) + { + TRACE_FUNC_ENTRY + CCBSettingHandler* self = new(ELeave) CCBSettingHandler(aPhone); + TRACE_FUNC_EXIT + return self; + } + +CCBSettingHandler::CCBSettingHandler(RMobilePhone& aPhone) : + CActive(EPriorityNormal), + iPhone(aPhone) + { + TRACE_FUNC_ENTRY + CActiveScheduler::Add(this); + TRACE_FUNC_EXIT + } + +CCBSettingHandler::~CCBSettingHandler() + { + TRACE_FUNC_ENTRY + Cancel(); + iClassArray.Close(); + TRACE_FUNC_EXIT + } + +void CCBSettingHandler::Start(TRequestStatus& aReqStatus, TInt aInfoClass, + RMobilePhone::TMobilePhoneCBCondition aCondition, + RMobilePhone::TMobilePhoneCBChangeV1* aCBInfo) + { + TRACE_FUNC_ENTRY + + iCBInfo = aCBInfo; + iCondition = aCondition; + aReqStatus = KRequestPending; + iQueuedStatus = &aReqStatus; + + if ((aInfoClass & EInfoClassVoice) == EInfoClassVoice) + { + iClassArray.Append(RMobilePhone::ETelephony); + } + // TODO: confirm ECircuitDataService is not needed + if ((aInfoClass & EInfoClassData) == EInfoClassData) + { + iClassArray.Append(RMobilePhone::EAllBearer); + } + + if ((aInfoClass & EInfoClassFax) == EInfoClassFax) + { + iClassArray.Append(RMobilePhone::EFaxService); + } + + if ((aInfoClass & EInfoClassSMS) == EInfoClassSMS) + { + iClassArray.Append(RMobilePhone::EShortMessageService); + } + + if ((aInfoClass & EInfoClassSyncData) == EInfoClassSyncData) + { + iClassArray.Append(RMobilePhone::ESyncData); + } + + if ((aInfoClass & EInfoClassASyncData) == EInfoClassASyncData) + { + iClassArray.Append(RMobilePhone::EAsyncData); + } + + if ((aInfoClass & EInfoClassPacketData) == EInfoClassPacketData) + { + iClassArray.Append(RMobilePhone::EPacketData); + } + + if ((aInfoClass & EInfoClassPadAccess) == EInfoClassPadAccess) + { + iClassArray.Append(RMobilePhone::EPadAccess); + } + + SetCBForServiceGroup(); + + TRACE_FUNC_EXIT + } + +void CCBSettingHandler::SetCBForServiceGroup() + { + TRACE_FUNC_ENTRY + + Trace(KDebugPrintD, "iClassArray.Count(): ", iClassArray.Count()); + if (iClassArray.Count() != 0) + { + iCBInfo->iServiceGroup = iClassArray[0]; + iPhone.SetCallBarringStatus(iStatus, iCondition, *iCBInfo); + iClassArray.Remove(0); + SetActive(); + } + else + { + Complete(KErrNone); + } + TRACE_FUNC_EXIT + } + +void CCBSettingHandler::RunL() + { + TRACE_FUNC_ENTRY + + Trace(KDebugPrintD, "iStatus.Int(): ", iStatus.Int()); + + if (iStatus.Int() != KErrNone ) + { + Complete(iStatus.Int()); + } + else + { + SetCBForServiceGroup(); + } + TRACE_FUNC_EXIT + } + +void CCBSettingHandler::DoCancel() + { + TRACE_FUNC_ENTRY + iPhone.CancelAsyncRequest(EMobilePhoneSetCallBarringStatus); + + Complete(KErrCancel); + + TRACE_FUNC_EXIT + } + +void CCBSettingHandler::Complete(TInt aError) + { + if (iQueuedStatus != NULL) + { + User::RequestComplete(iQueuedStatus, aError); + iQueuedStatus = NULL; + } + } diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/src/cfuncommandhandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/src/cfuncommandhandler.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,214 @@ +/* + * 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 "cfuncommandhandler.h" + +#include +#include + +#include + +#include "atmisccmdpluginconsts.h" +#include "debug.h" + +CCFUNCommandHandler* CCFUNCommandHandler::NewL(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) + { + TRACE_FUNC_ENTRY + CCFUNCommandHandler* self = new (ELeave) CCFUNCommandHandler(aCallback, aATCmdParser, aPhone); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + TRACE_FUNC_EXIT + return self; + } + +CCFUNCommandHandler::CCFUNCommandHandler(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) : + CATCmdAsyncBase(aCallback, aATCmdParser, aPhone) + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +void CCFUNCommandHandler::ConstructL() + { + TRACE_FUNC_ENTRY + iReply.CreateL(KDefaultCmdBufLength); + iProfileEngine = CreateProfileEngineL(); + TRACE_FUNC_EXIT + } + +CCFUNCommandHandler::~CCFUNCommandHandler() + { + TRACE_FUNC_ENTRY + Cancel(); + if (iProfileEngine != NULL) + { + iProfileEngine->Release(); + } + TRACE_FUNC_EXIT + } + +void CCFUNCommandHandler::HandleCommand(const TDesC8& /*aCmd*/, RBuf8& /*aReply*/, TBool /*aReplyNeeded*/) + { + TInt ret = KErrNone; + iReply.Zero(); + TAtCommandParser::TCommandHandlerType cmdHandlerType = iATCmdParser.CommandHandlerType(); + + switch (cmdHandlerType) + { + case (TAtCommandParser::ECmdHandlerTypeTest): + { + iCallback->CreateReplyAndComplete( EReplyTypeOther, KCFUNSupportedCmdsList); + break; + } + case (TAtCommandParser::ECmdHandlerTypeRead): + { + TInt profileId = iProfileEngine->ActiveProfileId(); + + iReply.Append( KAtCFUN ); + + if( profileId == EProfileOffLineId ) + { + iReply.Append( '0' ); + } + else + { + iReply.Append( '1' ); + } + iReply.Append( KOKCRLF ); + iCallback->CreateReplyAndComplete( EReplyTypeOther, iReply); + break; + } + case (TAtCommandParser::ECmdHandlerTypeSet): + { + TInt func = 0; + TInt reset = 0; // default 0 - do not reset the MT before setting it to power level + + ret = iATCmdParser.NextIntParam(func); + if (ret != KErrNone && ret != KErrNotFound) + { + iCallback->CreateReplyAndComplete(EReplyTypeError); + TRACE_FUNC_EXIT + return; + } + ret = iATCmdParser.NextIntParam(reset); + + // second parameter is optional, but only 0 and 1 are valid if it is specified + if (ret != KErrNone && ret != KErrNotFound && (reset != 0 || reset != 1)) + { + iCallback->CreateReplyAndComplete(EReplyTypeError); + TRACE_FUNC_EXIT + return; + } + ret = ActivateProfile(func, reset); + + break; + } + default: + { + iCallback->CreateReplyAndComplete(EReplyTypeError); + } + } + + 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 + TRACE_FUNC_EXIT + } + +void CCFUNCommandHandler::DoCancel() + { + TRACE_FUNC_ENTRY + // no asyc requests are made in when using AT+CFUN + TRACE_FUNC_EXIT + } + +TInt CCFUNCommandHandler::ActivateProfile(TInt aFunc, TInt aReset) + { + TInt err = KErrNone; + + switch (aFunc) + { + case (0): + case (4): + { + err = SetActiveProfile(KOfflineProfileId); + break; + } + case (1): + { + err = SetActiveProfile(KGeneralProfileId); + break; + } + default: + { + err = KErrArgument; + break; + } + } + + if (err == KErrNone && aReset == 1) + { + err = RestartDevice(); + } + + return err; + } + +TInt CCFUNCommandHandler::SetActiveProfile(TInt aProfileId) + { + TInt err = KErrNone; + + if(iProfileEngine) + { + TRAP(err, iProfileEngine->SetActiveProfileL( aProfileId )); + } + + return err; + } + +TInt CCFUNCommandHandler::RestartDevice() + { + RStarterSession session; + TInt err = session.Connect(); + + if( err == KErrNone ) + { + session.Reset(RStarterSession::EUnknownReset); + session.Close(); + } + + return err; + } diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/src/clckcommandhandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/src/clckcommandhandler.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,764 @@ +/* + * 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 "clckcommandhandler.h" + +#include +#include + +#include "securitycodeverifier.h" +#include "securityeventhandler.h" +#include "cbsettinghandler.h" + +#include "atmisccmdpluginconsts.h" +#include "debug.h" + +const TInt KSCPMaxHashLength( 32 ); + +CCLCKCommandHandler* CCLCKCommandHandler::NewL(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) + { + TRACE_FUNC_ENTRY + CCLCKCommandHandler* self = new (ELeave) CCLCKCommandHandler(aCallback, aATCmdParser, aPhone); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + TRACE_FUNC_EXIT + return self; + } + +CCLCKCommandHandler::CCLCKCommandHandler(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) : + CATCmdAsyncBase(aCallback, aATCmdParser, aPhone), + iLockInfoPckg(iLockInfo) + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +void CCLCKCommandHandler::ConstructL() + { + TRACE_FUNC_ENTRY + iReply.CreateL(KDefaultCmdBufLength); + + // initialise AOs + iCBRetrieve = CRetrieveMobilePhoneCBList::NewL(iPhone); + iCBSettingHandler = CCBSettingHandler::NewL(iPhone); + iSecurityEventHandler = CSecurityEventHandler::NewL(this, iPhone); + iSecurityCodeVerifier = CSecurityCodeVerifier::NewL(this, iPhone); + + TRACE_FUNC_EXIT + } + +CCLCKCommandHandler::~CCLCKCommandHandler() + { + TRACE_FUNC_ENTRY + Cancel(); + + delete iCBRetrieve; + delete iCBSettingHandler; + delete iSecurityEventHandler; + delete iSecurityCodeVerifier; + + iPassword.Close(); + iReply.Close(); + TRACE_FUNC_EXIT + } + +void CCLCKCommandHandler::DoCancel() + { + TRACE_FUNC_ENTRY + switch (iCLCKCommandType) + { + case (CCLCKCommandHandler::ECLCKLockGet): + { + iPhone.CancelAsyncRequest(EMobilePhoneGetLockInfo); + break; + } + case (CCLCKCommandHandler::ECLCKLockSet): + { + iPhone.CancelAsyncRequest(EMobilePhoneSetLockSetting); + iSecurityCodeVerifier->Cancel(); + iSecurityEventHandler->Cancel(); + break; + } + case (CCLCKCommandHandler::ECLCKBarringGet): + { + iCBRetrieve->Cancel(); + break; + } + case (CCLCKCommandHandler::ECLCKBarringSet): + { + iCBSettingHandler->Cancel(); + break; + } + } + TRACE_FUNC_EXIT + } + +void CCLCKCommandHandler::HandleCommand( const TDesC8& /*aCmd*/, RBuf8& /*aReply*/, TBool /*aReplyNeeded*/) + { + TRACE_FUNC_ENTRY + TAtCommandParser::TCommandHandlerType cmdHandlerType = iATCmdParser.CommandHandlerType(); + Trace(KDebugPrintD, "cmdHandlerType: ", cmdHandlerType); + + switch (cmdHandlerType) + { + case (TAtCommandParser::ECmdHandlerTypeTest): + { + iCallback->CreateReplyAndComplete(EReplyTypeOther, KCLCKSupportedCmdsList); + break; + } + case (TAtCommandParser::ECmdHandlerTypeSet): + { + if (ParseCCLCKCommand() == KErrNone) + { + IssueCLCKCommand(); + } + else + { + iCallback->CreateReplyAndComplete(EReplyTypeError); + } + break; + } + default: + { + iCallback->CreateReplyAndComplete(EReplyTypeError); + break; + } + } + TRACE_FUNC_EXIT + } + +void CCLCKCommandHandler::RunL() + { + TRACE_FUNC_ENTRY + Trace(KDebugPrintD, "iStatus.Int(): ", iStatus.Int()); + TInt err = iStatus.Int(); + if (err == KErrNone) + { + switch ( iCLCKCommandType ) + { + case (CCLCKCommandHandler::ECLCKLockGet): + { + iReply.Append(KAtCLCK); + if (iLockInfo.iStatus == RMobilePhone::EStatusUnlocked) + { + iReply.AppendNum(0); + iReply.Append(KCRLF); + } + else if (iLockInfo.iStatus == RMobilePhone::EStatusLocked) + { + iReply.AppendNum(1); + iReply.Append(KCRLF); + } + else + { + err = KErrArgument; + } + break; + } + case(CCLCKCommandHandler::ECLCKBarringGet): + { + err = ReceiveCBList(); + break; + } + case (CCLCKCommandHandler::ECLCKLockSet): + { + iLockSettingState = ELockSettingIdle; + iSecurityCodeVerifier->Cancel(); + iSecurityEventHandler->Cancel(); + break; + } + case(CCLCKCommandHandler::ECLCKBarringSet): + default: + { + // no action required + break; + } + } + } + + if (err != KErrNone) + { + if (iCLCKCommandType == CCLCKCommandHandler::ECLCKLockSet) + { + iLockSettingState =ELockSettingIdle; + iSecurityCodeVerifier->Cancel(); + iSecurityEventHandler->Cancel(); + } + iCallback->CreateCMEReplyAndComplete(err); + } + else + { + iCallback->CreateReplyAndComplete( EReplyTypeOther, iReply ); + } + + TRACE_FUNC_EXIT + } + +TInt CCLCKCommandHandler::ReceiveCBList() + { + TRACE_FUNC_ENTRY + iInfoClass = 0; + CMobilePhoneCBList* callBarringList=NULL; + TRAPD(leaveCode, callBarringList=iCBRetrieve->RetrieveListL();); + if (leaveCode != KErrNone) + { + TRACE_FUNC_EXIT + return leaveCode; + } + + TInt count = callBarringList->Enumerate(); + while (count-- > 0) + { + RMobilePhone::TMobilePhoneCBInfoEntryV1 entry; + TRAP(leaveCode, entry = callBarringList->GetEntryL(count);); + if (leaveCode != KErrNone) + { + TRACE_FUNC_EXIT + return leaveCode; + } + if (entry.iCondition == iCondition && + entry.iStatus == RMobilePhone::ECallBarringStatusActive) + { + switch (entry.iServiceGroup) + { + case(RMobilePhone::ETelephony): + { + iInfoClass |= EInfoClassVoice; + break; + } + case(RMobilePhone::EAllBearer): + { + iInfoClass |= EInfoClassData; + break; + } + case(RMobilePhone::EFaxService): + { + iInfoClass |= EInfoClassFax; + break; + } + case(RMobilePhone::EShortMessageService): + { + iInfoClass |= EInfoClassSMS; + break; + } + case(RMobilePhone::ESyncData): + { + iInfoClass |= EInfoClassSyncData; + break; + } + case(RMobilePhone::EAsyncData): + { + iInfoClass |= EInfoClassASyncData; + break; + } + case(RMobilePhone::EPacketData): + { + iInfoClass |= EInfoClassPacketData; + break; + } + case(RMobilePhone::EPadAccess): + { + iInfoClass |= EInfoClassPadAccess; + break; + } + } + } + } + + // There are no services with barring active - therefore report + // - status = 0 (inactive) + // - class = 7 (default value; voice, fax and data) + TInt status; + if (iInfoClass == 0) + { + status = 0; + iInfoClass = 7; // Default value, see ETSI TS 127 007 V6.9.0 (2007-06) + } + else + { + // There is at least one service with barring active - report status 1 (active) + status = 1; + } + + iReply.Append(KAtCLCK); + iReply.AppendNum(status); + iReply.Append(','); + iReply.AppendNum(iInfoClass); + iReply.Append(KCRLF); + + delete callBarringList; + TRACE_FUNC_EXIT + return KErrNone; + } + +void CCLCKCommandHandler::HandleCommandCancel() + { + TRACE_FUNC_ENTRY + Cancel(); + TRACE_FUNC_EXIT + } + +void CCLCKCommandHandler::IssueCLCKCommand() + { + TRACE_FUNC_ENTRY + Trace(KDebugPrintD, "iCLCKCommandType: ", iCLCKCommandType); + iReply.Zero(); + + switch (iCLCKCommandType) + { + case (CCLCKCommandHandler::ECLCKLockGet): + { + iPhone.GetLockInfo(iStatus, iLockType, iLockInfoPckg); + SetActive(); + break; + } + case (CCLCKCommandHandler::ECLCKLockSet): + { + if (iPassword.Compare(KNullDesC8) == 0) + { + iCallback->CreateReplyAndComplete( EReplyTypeError); + } + else + { + // 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); +// } + Trace(KDebugPrintD, "RProperty::Set: ", ret); + if (ret == KErrNone) + { + // Start security event handler - this will notify whether a + // password is required to complete the set lock request. + iSecurityEventHandler->Start(); + + Trace(KDebugPrintD, "SetLockSetting iLockType: ", iLockType); + Trace(KDebugPrintD, "SetLockSetting iLockChange: ", iLockChange); + iPhone.SetLockSetting(iStatus, iLockType, iLockChange); + iLockSettingState = ELockSettingRequested; + SetActive(); + } + else + { + iCallback->CreateReplyAndComplete( EReplyTypeError); + } + } + break; + } + case (CCLCKCommandHandler::ECLCKBarringGet): + { + iCBRetrieve->Start(iStatus, iCondition, RMobilePhone::RMobilePhone::EInfoLocationNetwork); + SetActive(); + break; + } + case (CCLCKCommandHandler::ECLCKBarringSet): + { + if (iPassword.Compare(KNullDesC8) == 0) + { + iCallback->CreateReplyAndComplete(EReplyTypeError); + } + else + { + iCBSettingHandler->Start(iStatus, iInfoClass, iCondition, &iCBInfo); + SetActive(); + } + break; + } + default: + { + iCallback->CreateReplyAndComplete(EReplyTypeError); + break; + } + } + TRACE_FUNC_EXIT + } + +void CCLCKCommandHandler::HandlePasswordVerification(TInt aError) + { + TRACE_FUNC_ENTRY + + if (aError != KErrNone) + { + iCallback->CreateCMEReplyAndComplete(aError); + Cancel(); + TRACE_FUNC_EXIT + return; + } + + switch (iLockSettingState) + { + case (ELockSettingIdle): + { + // Security code setting request has already been completed + iSecurityEventHandler->Cancel(); + break; + } + case (ELockSettingPasswordRequested): + { + // after password has been verified go back to the previous state + iLockSettingState = ELockSettingRequested; + break; + } + case (ELockSettingRequested): + default: + { + // should never be in this state + __ASSERT_DEBUG(EFalse, User::Invariant()); + break; + } + } + + TRACE_FUNC_EXIT + } + +void CCLCKCommandHandler::HandleSecurityEvent(TInt aError, RMobilePhone::TMobilePhoneSecurityEvent aSecurityEvent) + { + TRACE_FUNC_ENTRY + if (aError != KErrNone) + { + iCallback->CreateCMEReplyAndComplete(aError); + Cancel(); + TRACE_FUNC_EXIT + return; + } + + Trace(KDebugPrintD, "iLockSettingState: ", iLockSettingState); + Trace(KDebugPrintD, "aSecurityEvent: ", aSecurityEvent); + switch (iLockSettingState) + { + case (ELockSettingIdle): + { + // Set Lock request has already been completed + iSecurityCodeVerifier->Cancel(); + break; + } + case (ELockSettingRequested): + { + switch (aSecurityEvent) + { + case(RMobilePhone::EPin1Required): + case(RMobilePhone::EPhonePasswordRequired): + { + iSecurityEventHandler->Start(); + if( iSecurityCode == RMobilePhone::ESecurityCodePin1 && + aSecurityEvent == RMobilePhone::EPin1Required || + iSecurityCode == RMobilePhone::ESecurityCodePhonePassword && + aSecurityEvent == RMobilePhone::EPhonePasswordRequired) + { + // security code request has been triggered, reissue the security notification + // request and provide the code if this is expected + iSecurityCodeVerifier->Start(iPassword, iSecurityCode); + iLockSettingState =ELockSettingPasswordRequested; + } + break; + } + case(RMobilePhone::ENoICCFound): + case(RMobilePhone::EICCTerminated): + { + // No SIM present or it is unusable + iCallback->CreateCMEReplyAndComplete(aError); + Cancel(); + break; + } + default: + { + // other processes may trigger various security events, ignore them + // if not related and reissue the notification request + iSecurityEventHandler->Start(); + break; + } + } + break; + } + case (ELockSettingPasswordRequested): + { + switch (aSecurityEvent) + { + case(RMobilePhone::EPin1Verified): + { + // PIN1 has been verified, ignore if not applicable + // otherwise security event handler and security code verifier + // no longer needed + // (note that another client could have provided the PIN1) + if (iSecurityCode == RMobilePhone::ESecurityCodePin1) + { + iLockSettingState =ELockSettingRequested; + } + break; + } + case(RMobilePhone::EPhonePasswordVerified): + { + if (iSecurityCode == RMobilePhone::ESecurityCodePhonePassword) + { + iLockSettingState =ELockSettingRequested; + } + break; + } + case(RMobilePhone::ENoICCFound): + case(RMobilePhone::EICCTerminated): + { + // No SIM present or it is unusable, terminate the operation + Cancel(); + iCallback->CreateCMEReplyAndComplete(aError); + break; + } + default: + { + // other processes may trigger various security events, ignore them if not related + // and reissue the notification request + iSecurityEventHandler->Start(); + break; + } + } + break; + } + default: + { + // lock setting state value is out of boundies, complete with error + iCallback->CreateCMEReplyAndComplete(aError); + Cancel(); + break; + } + } + TRACE_FUNC_EXIT + } + +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) + { + TRACE_FUNC_EXIT + return KErrArgument; + } + + ret = iATCmdParser.NextIntParam(mode); + if (!command.Compare(KNullDesC8) || ret != KErrNone) + { + TRACE_FUNC_EXIT + return KErrArgument; + } + + iPassword.Create(iATCmdParser.NextTextParam(ret)); + Trace(KDebugPrintD, "NextTextParam returned: ", ret); + if (ret != KErrNone && ret != KErrNotFound) + { + TRACE_FUNC_EXIT + return KErrArgument; + } + + if (iPassword.Compare(KNullDesC8) != 0) + { + ret = iATCmdParser.NextIntParam(iInfoClass); + Trace(KDebugPrintD, "NextIntParam(iInfoClass): ", ret); + if (ret == KErrNotFound) + { + iInfoClass = 7; + } + if ((ret != KErrNone && ret != KErrNotFound ) || + iATCmdParser.NextParam().Compare(KNullDesC8) != 0) + { + TRACE_FUNC_EXIT + return KErrArgument; + } + } + + if (command.Compare(KATCLCKPS) == 0) + { + // Lock phone to SIM on/off + iSecurityCode = RMobilePhone::ESecurityCodePhonePassword; + iLockType = RMobilePhone::ELockPhoneToICC; + facilityType = ECmdFacilityTypeLock; + } + else if (command.Compare(KATCLCKSC) == 0) + { + // PIN on/off + iSecurityCode = RMobilePhone::ESecurityCodePin1; + iLockType = RMobilePhone::ELockICC; + facilityType = ECmdFacilityTypeLock; + } + else if (command.Compare(KATCLCKAO) == 0) + { + iCondition = RMobilePhone::EBarAllOutgoing; + facilityType = ECmdFacilityTypeBarring; + } + else if (command.Compare(KATCLCKOI) == 0) + { + iCondition = RMobilePhone::EBarOutgoingInternational; + facilityType = ECmdFacilityTypeBarring; + } + else if (command.Compare(KATCLCKOX) == 0) + { + iCondition = RMobilePhone::EBarOutgoingInternationalExHC; + facilityType = ECmdFacilityTypeBarring; + } + else if (command.Compare(KATCLCKAI) == 0) + { + iCondition = RMobilePhone::EBarAllIncoming; + facilityType = ECmdFacilityTypeBarring; + } + else if (command.Compare(KATCLCKIR) == 0) + { + iCondition = RMobilePhone::EBarIncomingRoaming; + facilityType = ECmdFacilityTypeBarring; + } + else if (command.Compare(KATCLCKAB) == 0) + { + iCondition = RMobilePhone::EBarAllCases; + facilityType = ECmdFacilityTypeAllBarring; + } + else if (command.Compare(KATCLCKAG) == 0) + { + iCondition = RMobilePhone::EBarAllOutgoingServices; + facilityType = ECmdFacilityTypeAllBarring; + } + else if (command.Compare(KATCLCKAC) == 0) + { + iCondition = RMobilePhone::EBarAllIncomingServices; + facilityType = ECmdFacilityTypeAllBarring; + } + else + { + TRACE_FUNC_EXIT + return KErrArgument; + } + + switch (facilityType) + { + case (ECmdFacilityTypeLock): + { + switch (mode) + { + case 0: // e.g. AT+CLCK="SC",0,"0000" + { + iCLCKCommandType = ECLCKLockSet; + iLockChange = RMobilePhone::ELockSetDisabled; + break; + } + case 1: // e.g. AT+CLCK="SC",1 + { + iCLCKCommandType = ECLCKLockSet; + iLockChange = RMobilePhone::ELockSetEnabled; + break; + } + case 2: // e.g. AT+CLCK="SC",2 + { + iCLCKCommandType = ECLCKLockGet; + break; + } + default: + { + TRACE_FUNC_EXIT + return KErrArgument; + } + } + break; + } + 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 + { + iCLCKCommandType = ECLCKBarringSet; + iCBInfo.iAction = RMobilePhone::EServiceActionDeactivate; + break; + } + case 1: // AT+CLCK="AO",1,"1919",1 + { + iCLCKCommandType = ECLCKBarringSet; + iCBInfo.iAction = RMobilePhone::EServiceActionActivate; + break; + } + case 2: // AT+CLCK="AO",2 + { + iCLCKCommandType = ECLCKBarringGet; + break; + } + default: + { + TRACE_FUNC_EXIT + return KErrArgument; + } + } + break; + } + case (ECmdFacilityTypeAllBarring): + { + iCBInfo.iPassword.Copy(iPassword); + if (iInfoClass == 0) + { + iInfoClass = 7; // Default value, see ETSI TS 127 007 V6.9.0 (2007-06) + } + + if ( mode == 0) + { + iCLCKCommandType = ECLCKBarringSet; + iCBInfo.iAction = RMobilePhone::EServiceActionDeactivate; + } + else + // only deactivation is supported + { + TRACE_FUNC_EXIT + return KErrArgument; + } + break; + } + default: + { + TRACE_FUNC_EXIT + return KErrArgument; + } + } + + // if phone password is required it needs to be hashed before verification + if (iSecurityCode == RMobilePhone::ESecurityCodePhonePassword + && iCLCKCommandType == ECLCKLockSet) + { + TBuf8 hashedPwd; + iATCmdParser.HashSecurityCode(iPassword, hashedPwd); + if (hashedPwd.Length() > iPassword.MaxLength()) + { + TInt ret = iPassword.ReAlloc(hashedPwd.Length()); + if (ret != KErrNone) + { + TRACE_FUNC_EXIT + return ret; + } + } + iPassword = hashedPwd; + } + + TRACE_FUNC_EXIT + return KErrNone; + } diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/src/cnumcommandhandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/src/cnumcommandhandler.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,197 @@ +// 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: +// This file contains the implementation of the AT+CNUM command +// +// + +#include "cnumcommandhandler.h" + +#include + +#include "atmisccmdpluginconsts.h" +#include "debug.h" + +CCNUMCommandHandler* CCNUMCommandHandler::NewL(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, + RMobilePhone& aPhone, RTelServer& aTelServer) + { + TRACE_FUNC_ENTRY + CCNUMCommandHandler* self = new (ELeave) CCNUMCommandHandler(aCallback, aATCmdParser, aPhone, aTelServer ); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + TRACE_FUNC_EXIT + return self; + } + +CCNUMCommandHandler::CCNUMCommandHandler(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, + RMobilePhone& aPhone, RTelServer& aTelServer) : + CATCmdAsyncBase(aCallback, aATCmdParser, aPhone), + iTelServer(aTelServer), + iOwnStoreInfoPckg(iOwnStoreInfo), + iOwnNumberEntryPckg(iOwnNumberEntry) + { + } + +void CCNUMCommandHandler::ConstructL() + { + iReplyBuffer.CreateL(KDefaultCmdBufLength); + } + +CCNUMCommandHandler::~CCNUMCommandHandler() + { + TRACE_FUNC_ENTRY + Cancel(); + iReplyBuffer.Close(); + iOwnNumberStore.Close(); + TRACE_FUNC_EXIT + } + +void CCNUMCommandHandler::HandleCommand( const TDesC8& /*aCmd*/, + RBuf8& /*aReply*/, + TBool /*aReplyNeeded */) + { + TRACE_FUNC_ENTRY + TAtCommandParser::TCommandHandlerType cmdHandlerType = iATCmdParser.CommandHandlerType(); + + switch (cmdHandlerType) + { + case (TAtCommandParser::ECmdHandlerTypeBase): + { + // Handle AT+CNUM + // step 1 check if the phone support Own Number Store + // and open the store if supported + + iReplyBuffer.Zero(); + // only open a subsession to OwnNumberStore when necessary + if(iOwnNumberStore.SubSessionHandle() == 0) + { + TName tsyName; + TInt ret = iTelServer.GetTsyName(0, tsyName); + if(ret != KErrNone) + { + Trace(KDebugPrintD, "GetTsyName returned error ", ret); + iCallback->CreateReplyAndComplete(EReplyTypeError); + break; + } + + TBool isSupported = EFalse; + // TODO: isSupported should be checked + ret = iTelServer.IsSupportedByModule(tsyName, KETelFuncMobileOwnNumberStore, isSupported); + if(ret != KErrNone) + { + Trace(KDebugPrintD, "IsSupportedByModule returned error ", ret); + iCallback->CreateReplyAndComplete(EReplyTypeError); + break; + } + + Trace(KDebugPrintD, "before open OwnNumberstore", 0); + ret = iOwnNumberStore.Open(iPhone); + if(ret != KErrNone) + { + Trace(KDebugPrintD, "Open OwnNumberStore returned error ", ret); + iCallback->CreateReplyAndComplete(EReplyTypeError); + break; + } + } + // step 2 Get number of own number entries stored. + iOwnNumberStore.GetInfo(iStatus, iOwnStoreInfoPckg); + iPendingEvent = EMobilePhoneStoreGetInfo; + SetActive(); + + break; + } + case (TAtCommandParser::ECmdHandlerTypeTest): + { + // Handle AT+CNUM=? + iCallback->CreateReplyAndComplete( EReplyTypeOk ); + break; + } + default: + { + iCallback->CreateReplyAndComplete(EReplyTypeError); + break; + } + } + TRACE_FUNC_EXIT + } + +void CCNUMCommandHandler::HandleCommandCancel() + { + TRACE_FUNC_ENTRY + Cancel(); + TRACE_FUNC_EXIT + } + +void CCNUMCommandHandler::RunL() + { + TRACE_FUNC_ENTRY + if(iStatus.Int() != KErrNone) + { + Trace(KDebugPrintD, "Pending event id: ", iPendingEvent); + iCallback->CreateCMEReplyAndComplete(iStatus.Int()); + } + else if(iPendingEvent == EMobilePhoneStoreGetInfo) + { // step 3 check the number of entries + Trace(KDebugPrintD, "Number of Owner's numbers: ", iOwnStoreInfo.iUsedEntries); + if(iOwnStoreInfo.iUsedEntries < 1) + { + // complete with OK if no owner's number + iCallback->CreateReplyAndComplete(EReplyTypeOk); + } + else + { + // step 4 Read the first owner's number entry + iOwnNumberEntry.iIndex = 0; + iOwnNumberStore.Read(iStatus,iOwnNumberEntryPckg); + iPendingEvent = EMobilePhoneStoreRead; + SetActive(); + } + } + else + { + ASSERT(iPendingEvent == EMobilePhoneStoreRead); + // step 5 append a phone number entry to the reply buffer + if(iOwnNumberEntry.iNumber.iTelNumber.Compare(KNullDesC) != 0) + { + // 129 is the type of address octet in interger format + _LIT8(KATNumReply, "\r\n+CNUM: ,\"%S\",129"); + TBuf8 telNumber8; + telNumber8.Copy(iOwnNumberEntry.iNumber.iTelNumber); + iReplyBuffer.AppendFormat(KATNumReply, &telNumber8); + } + // check if there is any more owner's number + if(iOwnNumberEntry.iIndex < iOwnStoreInfo.iUsedEntries) + { // step 6 read next entry + ++iOwnNumberEntry.iIndex; + Trace(KDebugPrintD, "Next number id", iOwnNumberEntry.iIndex); + iOwnNumberStore.Read(iStatus,iOwnNumberEntryPckg); + iPendingEvent = EMobilePhoneStoreRead; + SetActive(); + } + else + { // final step: all entries are retrieved. send them back to the AT server + iReplyBuffer.Append(KOKCRLF); + iCallback->CreateReplyAndComplete(EReplyTypeOther, iReplyBuffer); + } + } + + TRACE_FUNC_EXIT + } + +void CCNUMCommandHandler::DoCancel() + { + TRACE_FUNC_ENTRY + iCallback->CreateReplyAndComplete(EReplyTypeError); + TRACE_FUNC_EXIT + } diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/src/cpincommandhandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/src/cpincommandhandler.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,216 @@ +// 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: +// This file contains the implementation of the AT+CPIN command +// +// + +#include "cpincommandhandler.h" + +#include // define AO wrapper +#include // Additional RMobilePhone error code + +#include "debug.h" + +CCPINCommandHandler* CCPINCommandHandler::NewL(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) + { + TRACE_FUNC_ENTRY + CCPINCommandHandler* self = new (ELeave) CCPINCommandHandler(aCallback, aATCmdParser, aPhone); + TRACE_FUNC_EXIT + return self; + } + +CCPINCommandHandler::CCPINCommandHandler(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) : + CATCmdAsyncBase(aCallback, aATCmdParser, aPhone), + iLockInfoPckg(iLockInfo) + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +CCPINCommandHandler::~CCPINCommandHandler() + { + TRACE_FUNC_ENTRY + Cancel(); + TRACE_FUNC_EXIT + } + +void CCPINCommandHandler::HandleCommand(const TDesC8& /*aCmd*/, + RBuf8& /*aReply*/, + TBool /*aReplyNeeded*/) + { + TRACE_FUNC_ENTRY + + switch (iATCmdParser.CommandHandlerType()) + { + case (TAtCommandParser::ECmdHandlerTypeTest): + // AT+CPIN=? - simply return OK. + { + iCallback->CreateReplyAndComplete( EReplyTypeOk); + break; + } + + case(TAtCommandParser::ECmdHandlerTypeRead): + // AT+CPIN? - Get PIN require status. return +CPIN: READY/SIM PUK + case (TAtCommandParser::ECmdHandlerTypeSet): + // AT+CPIN="puk","pin" - Change password when PUK is required. + { + // call GetLockInfo to check if PUK is required + iPhone.GetLockInfo(iStatus, RMobilePhone::ELockICC, iLockInfoPckg); + iPendingEvent = EMobilePhoneGetLockInfo; + SetActive(); + break; + } + default: + { + // unsupported command + iCallback->CreateReplyAndComplete(EReplyTypeError); + break; + } + } + + TRACE_FUNC_EXIT + } + +void CCPINCommandHandler::HandleCommandCancel() + { + TRACE_FUNC_ENTRY + Cancel(); + TRACE_FUNC_EXIT + } + +void CCPINCommandHandler::ChangePassword() + { + TRACE_FUNC_ENTRY + TRequestStatus status; + + // Get parameters from AT command + TInt ret1; + TInt ret2; + TPtrC8 pukCode8 = iATCmdParser.NextTextParam(ret1); + TPtrC8 pinCode8 = iATCmdParser.NextTextParam(ret2); + if(ret1 != KErrNone || ret2 != KErrNone + || iATCmdParser.NextParam().Compare(KNullDesC8) != 0) + { + iCallback->CreateReplyAndComplete( EReplyTypeError); + TRACE_FUNC_EXIT + return; + } + + 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(); + } + else + { // after calling VerifySecurityCode + ASSERT(iPendingEvent == EMobilePhoneVerifySecurityCode); + HandleVerifySecurityCode(); + } + TRACE_FUNC_EXIT + } + +void CCPINCommandHandler::HandleGetLockInfo() + { + TRACE_FUNC_ENTRY + TAtCommandParser::TCommandHandlerType handleType = iATCmdParser.CommandHandlerType(); + + switch(iStatus.Int()) + { + case KErrNone: + { + // log lock info + _LIT8(KDbgPhoneLockInfo, "GetLockInfo: Status %d, Lock %d, Setting %d"); + Trace(KDbgPhoneLockInfo, iStatus.Int(), iLockInfo.iStatus, iLockInfo.iSetting); + + if(handleType == TAtCommandParser::ECmdHandlerTypeRead ) + { + // complete without error + _LIT8(KCPINReady, "\r\n+CPIN: READY\r\n\r\nOK\r\n"); + iCallback->CreateReplyAndComplete( EReplyTypeOther, KCPINReady); + } + else + { + ASSERT( handleType== TAtCommandParser::ECmdHandlerTypeSet ); + // PUK/PIN is not required + iCallback->CreateCMEReplyAndComplete(KErrGsm0707OperationNotAllowed); + } + break; + } + case KErrAccessDenied: + { + if(handleType == TAtCommandParser::ECmdHandlerTypeRead ) + { + // reply PUK is required + _LIT8(KCPINSimPuk, "\r\n+CPIN: SIM PUK\r\n\r\nOK\r\n"); + iCallback->CreateReplyAndComplete( EReplyTypeOther, KCPINSimPuk); + } + else + + { + // change PIN with a PUK code + ChangePassword(); + } + break; + } + default: + { + // any other errors, such as KErrGeneral when SIM card is not available + Trace(KDebugPrintD, "Complete CPIN with error ", iStatus.Int()); + iCallback->CreateReplyAndComplete( EReplyTypeError ); + break; + } + } + TRACE_FUNC_EXIT + } + +void CCPINCommandHandler::HandleVerifySecurityCode() + { + TRACE_FUNC_ENTRY + + // check error after change PUK + if (iStatus.Int() == KErrNone) + { // complete without error + iCallback->CreateReplyAndComplete( EReplyTypeOk ); + } + else + { // if there is an error + iCallback->CreateCMEReplyAndComplete(iStatus.Int()); + } + + TRACE_FUNC_EXIT + } + +void CCPINCommandHandler::DoCancel() + { + TRACE_FUNC_ENTRY + iPhone.CancelAsyncRequest(iPendingEvent); + TRACE_FUNC_EXIT + } + diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/src/cpwdcommandhandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/src/cpwdcommandhandler.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,212 @@ +// 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: +// This file contains the implementation of the AT+CPWD command +// +// + + +#include // AO + +#include "cpwdcommandhandler.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) + { + TRACE_FUNC_ENTRY + CCPWDCommandHandler* self = new (ELeave) CCPWDCommandHandler(aCallback, aATCmdParser, aPhone); + TRACE_FUNC_EXIT + return self; + } + +CCPWDCommandHandler::CCPWDCommandHandler(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) : + CATCmdAsyncBase(aCallback, aATCmdParser, aPhone) + { + TRACE_FUNC_ENTRY + TRACE_FUNC_EXIT + } + +CCPWDCommandHandler::~CCPWDCommandHandler() + { + TRACE_FUNC_ENTRY + Cancel(); + TRACE_FUNC_EXIT + } + +void CCPWDCommandHandler::HandleCommand( const TDesC8& /*aCmd*/, + RBuf8& /*aReply*/, + TBool /*aReplyNeeded*/ ) + { + TRACE_FUNC_ENTRY + TAtCommandParser::TCommandHandlerType cmdHandlerType = iATCmdParser.CommandHandlerType(); + switch (cmdHandlerType) + { + case (TAtCommandParser::ECmdHandlerTypeTest): + { + // Get supported passwords with max. length of them. AT+CPWD=? + // return hardcoded supported password with max. length + _LIT8(KCPWDTestValue, "\r\n+CPWD: (\"PS\",10),(\"SC\",8),(\"AB\",4),(\"P2\",8)\r\n\r\nOK\r\n"); + iCallback->CreateReplyAndComplete( EReplyTypeOther, KCPWDTestValue ); + break; + } + case (TAtCommandParser::ECmdHandlerTypeSet): + { + // Change password. AT+CPWD="nn","xxxx","yyyy" + ChangePassword(); + break; + } + default: + { + iCallback->CreateReplyAndComplete(EReplyTypeError); + } + } + 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); + + if(ret1 != KErrNone || ret2 != KErrNone || ret3 != KErrNone + || iATCmdParser.NextParam().Compare(KNullDesC8) != 0) + { + Trace(KDbgStr, "invalid arguments"); + iCallback->CreateReplyAndComplete( EReplyTypeError); + TRACE_FUNC_EXIT + return; + } + + if(passwordType.Compare(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) + RMobilePhone::TMobilePhonePasswordChangeV1 passwordChange; + + // Phone lock password is hashed in RSPClient and NokiaTSY. See CSCPServer::HashISACode() for details. + TBuf8 hashOldPwd; + TBuf8 hashNewPwd; + iATCmdParser.HashSecurityCode(oldPassword, hashOldPwd); + iATCmdParser.HashSecurityCode(newPassword, hashNewPwd); + + ChangeSecurityCode(RMobilePhone::ESecurityCodePhonePassword, hashOldPwd, hashNewPwd); + } + else if(passwordType.Compare(KATCPWDSC) == 0) // SIM pin + { + // "SC" SIM (lock SIM/UICC card) (SIM/UICC asks password in MT power-up and when this lock command + // issued) + + // todo: if it is required to return +CME code according to SIM Lock status, + // 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 + { + ChangeSecurityCode(RMobilePhone::ESecurityCodePin2, oldPassword, newPassword); + } + else if(passwordType.Compare(KATCPWDAB) == 0) // All Barring services + { + // "AB" All Barring services (refer 3GPP TS 22.030 [19]) (applicable only for =0) + RMobilePhone::TMobilePhonePasswordChangeV2 passwordChange; + passwordChange.iOldPassword.Copy(oldPassword); + passwordChange.iNewPassword.Copy(newPassword); + passwordChange.iVerifiedPassword.Copy(newPassword); + RMobilePhone::TMobilePhonePasswordChangeV2Pckg pwdPckg ( passwordChange ); + // The current S60 use SetSSPassword for All Barring services code. + // see CPsetCallBarring::ChangePasswordL for details. + iPhone.SetSSPassword(iStatus, pwdPckg, KPsetAllSSServices); + iPendingEvent = EMobilePhoneSetSSPassword; + SetActive(); + + } + else // other unsupported arguments + { + Trace(KDbgTDes, "unknown password type:", &passwordType); + iCallback->CreateCMEReplyAndComplete(KErrUnknown); + } + + TRACE_FUNC_EXIT + return; + } + +void CCPWDCommandHandler::RunL() + { + TRACE_FUNC_ENTRY + + if (iStatus.Int() == KErrNone) + { // complete without error + Trace(KDbgStr, "complete OK." ); + iCallback->CreateReplyAndComplete( EReplyTypeOk ); + } + else + { // if there is an error + iCallback->CreateCMEReplyAndComplete(iStatus.Int()); + } + TRACE_FUNC_EXIT + } + +void CCPWDCommandHandler::DoCancel() + { + TRACE_FUNC_ENTRY + Trace(KDbgStr, "Request cancelled." ); + iPhone.CancelAsyncRequest(iPendingEvent); + TRACE_FUNC_EXIT + } + + +void CCPWDCommandHandler::ChangeSecurityCode(RMobilePhone::TMobilePhoneSecurityCode aType, TDesC8& aOldPassword, TDesC8& aNewPassword) + { + RMobilePhone::TMobilePhonePasswordChangeV1 passwordChange; + passwordChange.iOldPassword.Copy(aOldPassword); + passwordChange.iNewPassword.Copy(aNewPassword); + iPhone.ChangeSecurityCode(iStatus, aType, passwordChange); + iPendingEvent = EMobilePhoneChangeSecurityCode; + SetActive(); + } diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/src/cusdcommandhandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/src/cusdcommandhandler.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,460 @@ +/* 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 "cusdcommandhandler.h" + +#include + +#include "atmisccmdpluginconsts.h" +#include "cusdreadwriteimp.h" +#include "debug.h" + +const TUint8 KPhCltUssdCarriageReturn = 0x0d; +const TUint8 KPhCltUssdDcsNotSet = 0x00; // not set + +const TUint8 KQuarterShift( 2 ); +const TUint8 KHighNibbleShift( 4 ); +const TUint8 KDcsCharacterSet7Bit( 0x00 ); +const TUint8 KDcsCharacterSet8Bit( 0x01 ); +const TUint8 KDcsCharacterSet16Bit( 0x02 ); +const TUint8 KDcsCharacterSet7Bit2( 0x00 ); +const TUint8 KDcsCharacterSet16Bit2( 0x01 ); + +CCUSDCommandHandler* CCUSDCommandHandler::NewL(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) + { + TRACE_FUNC_ENTRY + CCUSDCommandHandler* self = new (ELeave) CCUSDCommandHandler(aCallback, aATCmdParser, aPhone); + CleanupStack::PushL(self); + self->ConstructL(); + CleanupStack::Pop(self); + TRACE_FUNC_EXIT + return self; + } + +CCUSDCommandHandler::CCUSDCommandHandler(MATMiscCmdPlugin* aCallback, TAtCommandParser& aATCmdParser, RMobilePhone& aPhone) : + CATCmdAsyncBase(aCallback, aATCmdParser, aPhone) + { + TRACE_FUNC_ENTRY + iSendAttributes.iDcs = KPhCltUssdDcsNotSet; + iSendAttributes.iType = RMobileUssdMessaging::EUssdMORequest; + iSendAttributes.iFlags = RMobileUssdMessaging::KUssdMessageType | RMobileUssdMessaging::KUssdMessageDcs | RMobileUssdMessaging::KUssdDataFormat; + TRACE_FUNC_EXIT + } + +void CCUSDCommandHandler::ConstructL() + { + TRACE_FUNC_ENTRY + User::LeaveIfError(iUssdMessaging.Open(iPhone)); + + iUSSDSender = CCUSSDSendMessageImpl::NewL(this, iUssdMessaging); + iUSSDReader = CCUSSDReadMessageImpl::NewL(this, iUssdMessaging); + + //start a read session for network based ussd requests + User::LeaveIfError(iUSSDReader->ReadUSSDMessage(iReceivedData, iReceiveAttributes)); + TRACE_FUNC_EXIT + } + +CCUSDCommandHandler::~CCUSDCommandHandler() + { + TRACE_FUNC_ENTRY + delete iUSSDSender; + delete iUSSDReader; + + iReply.Close(); + iUssdMessaging.Close(); + 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, + RBuf8& /*aReply*/, + TBool /*aReplyNeeded*/ ) + { + TRACE_FUNC_ENTRY + TAtCommandParser::TCommandHandlerType cmdHandlerType = iATCmdParser.CommandHandlerType(); + + switch (cmdHandlerType) + { + case (TAtCommandParser::ECmdHandlerTypeTest): + { + iReply.Create(KDefaultCmdBufLength); + iReply.Append(KCRLF); + iReply.Append(KCUSDSupportedCmdsList); + iCallback->CreateReplyAndComplete( EReplyTypeOther, iReply ); + break; + } + case (TAtCommandParser::ECmdHandlerTypeRead): + { + iReply.Create(KDefaultCmdBufLength); + iReply.Append(KCRLF); + iReply.Append(KAtCUSD); + iReply.AppendNum(iDisplayRetMessage); + iReply.Append(KCRLF); + + iCallback->CreateReplyAndComplete( EReplyTypeOther, iReply ); + break; + } + case (TAtCommandParser::ECmdHandlerTypeSet): + { + if(ParseCUSDCmd(aCmd) == 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 ); + } + else + { + if(iUSSDSender->HandleSendUSSDCmd(iUSSDCommand, iSendAttributes) == KErrNone) + { + iSendCommandSent = ETrue; + } + else + { + iCallback->CreateReplyAndComplete(EReplyTypeError); + } + } + } + else + { + iCallback->CreateReplyAndComplete(EReplyTypeError); + } + + break; + } + default: + { + iCallback->CreateReplyAndComplete(EReplyTypeError); + break; + } + } + 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(); + TRACE_FUNC_EXIT + } + +TInt CCUSDCommandHandler::ParseCUSDCmd(const TDesC8& aCmd) + { + TRACE_FUNC_ENTRY + + iReply.Create(KDefaultCmdBufLength); + TBool tempRetMessage = EFalse; + TInt ret = iATCmdParser.NextIntParam(tempRetMessage); + + if(ret == KErrNone) + { + if(tempRetMessage < 0 || tempRetMessage > 2) + { + Trace(KDebugPrintD, "Display mode invalid: ", tempRetMessage); + TRACE_FUNC_EXIT + return KErrGeneral; + } + else + { + iDisplayRetMessage = tempRetMessage; + } + } + + // now parse the USSD command + TPtrC8 command = iATCmdParser.NextTextParam(ret); + + 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_FUNC_EXIT + return KErrGeneral; + } + else + { + iSendAttributes.iDcs = tempDcs; + } + } + TRACE_FUNC_EXIT + return KErrNone; + } + +void CCUSDCommandHandler::HandleSendMessageComplete(TInt aResult) + { + TRACE_FUNC_ENTRY + if(aResult == KErrNone) + { + iReply.Create(KDefaultCmdBufLength); + iReply.Append(KCRLF); + iReply.Append(KAtCUSD); + iReply.Append(KCRLF); + iCallback->CreateReplyAndComplete( EReplyTypeOther, iReply ); + } + 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 + } + +TInt CCUSDCommandHandler::Pack(const TDesC8& aIn, TDes8& aOut) + { + TRACE_FUNC_ENTRY + TInt startBit = 0; + + // Ensure we've got the right length + TInt packedOctetsRequired = PackedOctetsRequired( aIn.Length() ); + if ( packedOctetsRequired > ( aOut.MaxLength() - aOut.Length() ) ) + { + Trace(KDebugPrintD, "packedOctetsRequired: ", packedOctetsRequired); + TRACE_FUNC_EXIT + return KErrOverflow; + } + + // Do the conversion + TInt elementSizeInBits = ElementSizeInBits(TSmsDataCodingScheme::ESmsAlphabet7Bit); + 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(); + + outPtr[0] = 0; + for ( TInt i = 0; i < aIn.Length() ; ++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,... + + 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 ); + } + + // Return number of bytes used + TRACE_FUNC_EXIT + return packedOctetsRequired; + } + + TInt CCUSDCommandHandler::PackedOctetsRequired( TInt aNumUDUnits ) const + { + TRACE_FUNC_ENTRY + TInt startBit = 0; + + TInt octetsRequired = 0; + TInt elementSizeInBits = ElementSizeInBits(TSmsDataCodingScheme::ESmsAlphabet7Bit); + if ( elementSizeInBits == 8 ) + { + octetsRequired=aNumUDUnits; + } + else + { + octetsRequired = ( startBit + aNumUDUnits*elementSizeInBits + 7 )/8; // Rounds up + } + TRACE_FUNC_EXIT + return octetsRequired; + } + + TBool CCUSDCommandHandler::IsDcsValid( const TUint8 aDcs ) const + { + TRACE_FUNC_ENTRY + 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 ) + { + case 0x00: + case 0x02: + case 0x03: + case 0x0F: + { + isDcsValid = ETrue; + break; + } + + case 0x01: + { + if ( ( KDcsCharacterSet7Bit2 == lowQuartet ) || + ( KDcsCharacterSet16Bit2 == lowQuartet ) ) + { + isDcsValid = ETrue; + } + break; + } + + case 0x04: + case 0x05: + case 0x06: + case 0x07: + case 0x09: + { + if ( ( KDcsCharacterSet7Bit == characterSet ) || + ( KDcsCharacterSet8Bit == characterSet ) || + ( KDcsCharacterSet16Bit == characterSet ) ) + { + isDcsValid = ETrue; + } + break; + } + } + TRACE_FUNC_EXIT + return isDcsValid; + } + +TInt CCUSDCommandHandler::ElementSizeInBits(TSmsDataCodingScheme::TSmsAlphabet aAlphabet) const + { + TRACE_FUNC_ENTRY + TInt ret; + switch ( aAlphabet ) + { + case TSmsDataCodingScheme::ESmsAlphabet7Bit: + { + ret = 7; + break; + } + case TSmsDataCodingScheme::ESmsAlphabet8Bit: + case TSmsDataCodingScheme::ESmsAlphabetUCS2: + { + ret = 8; + break; + } + default: + { + ret = KErrGsmSMSDataCodingSchemeNotSupported; + } + } + TRACE_FUNC_EXIT + return ret; + } + +void CCUSDCommandHandler::FormatUSSDReceivedData() + { + TRACE_FUNC_ENTRY + iReply.Create(KDefaultCmdBufLength); + + iReply.Append(KCRLF); + iReply.Append(KAtCUSD); + iReply.AppendNum(iDisplayRetMessage); + iReply.Append(','); + iReply.Append('"'); + + TInt length = iReceivedData.Length(); + for(TInt i = 0; i < length; ++i) + { + iReply.AppendNum(iReceivedData[i], EHex); + } + iReply.Append('"'); + iReply.Append(','); + + iReply.AppendNum(iReceiveAttributes.iDcs); + iReply.Append(KCRLF); + TRACE_FUNC_EXIT + } diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/src/cusdreadwriteimp.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/src/cusdreadwriteimp.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,155 @@ +/* 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 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 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 + } diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/src/main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/src/main.cpp Tue Apr 27 16:49:44 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 : + * + */ + +#include +#include + +#include "atmisccmdpluginuids.hrh" +#include "atmisccmdplugin.h" + +/* + * Ecom plug-in implementation table + */ +const TImplementationProxy ImplementationTable[] = + { + IMPLEMENTATION_PROXY_ENTRY(KUidATMiscCmdEcomImpl, CATMiscCmdPlugin::NewL) + }; + +/* + * Instance of implementation proxy + * (exported) + */ +EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) + { + aTableCount = sizeof( ImplementationTable ) / sizeof( TImplementationProxy ); + + return ImplementationTable; + } diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/src/securitycodeverifier.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/src/securitycodeverifier.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,71 @@ +/* + * 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 "securitycodeverifier.h" + +#include "clckcommandhandler.h" +#include "debug.h" + +/** + * AO class for verifing security codes + */ +CSecurityCodeVerifier* CSecurityCodeVerifier::NewL(CCLCKCommandHandler* aCLCKHandler, RMobilePhone& aPhone) + { + TRACE_FUNC_ENTRY + CSecurityCodeVerifier* self = new(ELeave) CSecurityCodeVerifier(aCLCKHandler, aPhone); + TRACE_FUNC_EXIT + return self; + } + +CSecurityCodeVerifier::CSecurityCodeVerifier(CCLCKCommandHandler* aCLCKHandler, RMobilePhone& aPhone) : + CActive(EPriorityNormal), + iCLCKHandler(aCLCKHandler), + iPhone(aPhone) + { + TRACE_FUNC_ENTRY + CActiveScheduler::Add(this); + TRACE_FUNC_EXIT + } + +CSecurityCodeVerifier::~CSecurityCodeVerifier() + { + Cancel(); + } + +void CSecurityCodeVerifier::Start(TDesC8& aPassword, RMobilePhone::TMobilePhoneSecurityCode& aSecurityCode) + { + TRACE_FUNC_ENTRY + RMobilePhone::TMobilePassword code; + code.Copy(aPassword); + + iPhone.VerifySecurityCode(iStatus, aSecurityCode, code, code); + SetActive(); + TRACE_FUNC_EXIT + } + +void CSecurityCodeVerifier::RunL() + { + TRACE_FUNC_ENTRY + Trace(KDebugPrintD, "iStatus.Int(): ", iStatus.Int()); + iCLCKHandler->HandlePasswordVerification(iStatus.Int()); + TRACE_FUNC_EXIT + } + +void CSecurityCodeVerifier::DoCancel() + { + TRACE_FUNC_ENTRY + iPhone.CancelAsyncRequest(EMobilePhoneNotifySecurityEvent); + TRACE_FUNC_EXIT + } diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/atmisccmdplugin/src/securityeventhandler.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/atmisccmdplugin/src/securityeventhandler.cpp Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,71 @@ +/* + * 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 "securityeventhandler.h" + +#include "clckcommandhandler.h" +#include "debug.h" + +/** + * AO class for monitoring security events + */ +CSecurityEventHandler* CSecurityEventHandler::NewL(CCLCKCommandHandler* aCLCKHandler, RMobilePhone& aPhone) + { + TRACE_FUNC_ENTRY + CSecurityEventHandler* self = new(ELeave) CSecurityEventHandler(aCLCKHandler,aPhone); + TRACE_FUNC_EXIT + return self; + } + +CSecurityEventHandler::CSecurityEventHandler(CCLCKCommandHandler* aCLCKHandler, RMobilePhone& aPhone) : + CActive(EPriorityNormal), + iCLCKHandler(aCLCKHandler), + iPhone(aPhone) + { + TRACE_FUNC_ENTRY + CActiveScheduler::Add(this); + TRACE_FUNC_EXIT + } + +CSecurityEventHandler::~CSecurityEventHandler() + { + Cancel(); + } + +void CSecurityEventHandler::Start() + { + TRACE_FUNC_ENTRY + iPhone.NotifySecurityEvent(iStatus, iSecurityEvent); + SetActive(); + TRACE_FUNC_EXIT + } + +void CSecurityEventHandler::RunL() + { + TRACE_FUNC_ENTRY + Trace(KDebugPrintD, "iStatus.Int(): ", iStatus.Int()); + Trace(KDebugPrintD, "iSecurityEvent: ", iSecurityEvent); + + iCLCKHandler->HandleSecurityEvent(iStatus.Int(), iSecurityEvent); + TRACE_FUNC_EXIT + } + +void CSecurityEventHandler::DoCancel() + { + TRACE_FUNC_ENTRY + iPhone.CancelAsyncRequest(EMobilePhoneVerifySecurityCode); + TRACE_FUNC_EXIT + } + diff -r f7fbeaeb166a -r b23265fb36da cbsatplugin/group/bld.inf --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/cbsatplugin/group/bld.inf Tue Apr 27 16:49:44 2010 +0300 @@ -0,0 +1,33 @@ + +/* + * Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * Initial Contributors: + * Nokia Corporation - initial contribution. + * + * Contributors: + * Description :This file provides the information required for building the + * atcmdpluginecom.dll + * + */ + + +#include + +PRJ_PLATFORMS + +#include "../atmisccmdplugin/group/bld.inf" +PRJ_EXPORTS + +PRJ_TESTEXPORTS + +PRJ_MMPFILES + +PRJ_TESTMMPFILES + +// End of File + diff -r f7fbeaeb166a -r b23265fb36da group/bld.inf --- a/group/bld.inf Wed Apr 14 16:09:00 2010 +0300 +++ b/group/bld.inf Tue Apr 27 16:49:44 2010 +0300 @@ -22,6 +22,7 @@ #include "../btservices_pub/group/bld.inf" #include "../bluetoothengine/group/bld.inf" #include "../atcommands/group/bld.inf" +#include "../cbsatplugin/group/bld.inf" PRJ_EXPORTS