# HG changeset patch # User Dremov Kirill (Nokia-D-MSW/Tampere) # Date 1273586509 -10800 # Node ID 2702348f1fe7f7182a2aa8a6799c4438e772b91a # Parent c47ebe2ac36ca4350df28635da29d514c0054b73 Revision: 201017 Kit: 201019 diff -r c47ebe2ac36c -r 2702348f1fe7 localconnectivityservice/dun/atext/bwins/dunatextu.def --- a/localconnectivityservice/dun/atext/bwins/dunatextu.def Tue Apr 27 17:33:22 2010 +0300 +++ b/localconnectivityservice/dun/atext/bwins/dunatextu.def Tue May 11 17:01:49 2010 +0300 @@ -8,4 +8,5 @@ ?ParseCommand@CDunAtCmdHandler@@QAEHAAVTDesC8@@AAH@Z @ 7 NONAME ; int CDunAtCmdHandler::ParseCommand(class TDesC8 &, int &) ?StartUrc@CDunAtCmdHandler@@QAEHXZ @ 8 NONAME ; int CDunAtCmdHandler::StartUrc(void) ?ManageAbortRequest@CDunAtCmdHandler@@QAEHXZ @ 9 NONAME ; int CDunAtCmdHandler::ManageAbortRequest(void) + ?SendEchoCharacter@CDunAtCmdHandler@@QAEHPBVTDesC8@@PAVMDunAtCmdEchoer@@@Z @ 10 NONAME ; int CDunAtCmdHandler::SendEchoCharacter(class TDesC8 const *, class MDunAtCmdEchoer *) diff -r c47ebe2ac36c -r 2702348f1fe7 localconnectivityservice/dun/atext/eabi/dunatextu.def --- a/localconnectivityservice/dun/atext/eabi/dunatextu.def Tue Apr 27 17:33:22 2010 +0300 +++ b/localconnectivityservice/dun/atext/eabi/dunatextu.def Tue May 11 17:01:49 2010 +0300 @@ -8,4 +8,5 @@ _ZN16CDunAtCmdHandler8StartUrcEv @ 7 NONAME _ZN16CDunAtCmdHandler9ResetDataEv @ 8 NONAME _ZN16CDunAtCmdHandler18ManageAbortRequestEv @ 9 NONAME + _ZN16CDunAtCmdHandler17SendEchoCharacterEPK6TDesC8P15MDunAtCmdEchoer @ 10 NONAME diff -r c47ebe2ac36c -r 2702348f1fe7 localconnectivityservice/dun/atext/group/dunatext.mmp --- a/localconnectivityservice/dun/atext/group/dunatext.mmp Tue Apr 27 17:33:22 2010 +0300 +++ b/localconnectivityservice/dun/atext/group/dunatext.mmp Tue May 11 17:01:49 2010 +0300 @@ -27,6 +27,7 @@ VENDORID VID_DEFAULT SOURCEPATH ../src +SOURCE DunAtCmdEchoer.cpp SOURCE DunAtCmdHandler.cpp SOURCE DunAtCmdPusher.cpp SOURCE DunAtUrcHandler.cpp diff -r c47ebe2ac36c -r 2702348f1fe7 localconnectivityservice/dun/atext/inc/DunAtCmdEchoer.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/localconnectivityservice/dun/atext/inc/DunAtCmdEchoer.h Tue May 11 17:01:49 2010 +0300 @@ -0,0 +1,135 @@ +/* +* 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: Echoer for AT commands +* +*/ + +#ifndef C_CDUNATCMDECHOER_H +#define C_CDUNATCMDECHOER_H + +#include "DunDataPusher.h" + +class MDunStreamManipulator; + +/** + * Notification interface class for text mode + * + * @lib dunatext.lib + * @since TB9.2 + */ +NONSHARABLE_CLASS( MDunAtCmdEchoer ) + { + +public: + + /** + * Notifies about completed echo in text mode + * + * @since TB9.2 + * @return None + */ + virtual void NotifyEchoComplete() = 0; + + }; + +/** + * Class for AT command echoer + * + * @lib dunatext.lib + * @since TB9.2 + */ +NONSHARABLE_CLASS( CDunAtCmdEchoer ) : public CBase, + public MDunCompletionReporter + { + +public: + + /** + * Two-phased constructor. + * @param aStreamCallback Callback to stream + * @return Instance of self + */ + static CDunAtCmdEchoer* NewL( MDunStreamManipulator* aStreamCallback ); + + /** + * Destructor. + */ + virtual ~CDunAtCmdEchoer(); + + /** + * Resets data to initial values + * + * @since TB9.2 + * @return None + */ + void ResetData(); + + /** + * Sends a character to be echoed + * + * @since TB9.2 + * @param aInput Input to echo + * @param aCallback Callback to echo request completions + * @return Symbian error code on error, KErrNone otherwise + */ + TInt SendEchoCharacter( const TDesC8* aInput, MDunAtCmdEchoer* aCallback ); + +private: + + CDunAtCmdEchoer( MDunStreamManipulator* aStreamCallback ); + + void ConstructL(); + + /** + * Initializes this class + * + * @since TB9.2 + * @return None + */ + void Initialize(); + +// from base class MDunCompletionReporter + + /** + * From MDunCompletionReporter. + * Gets called when data push is complete + * + * @since S60 5.0 + * @param aAllPushed ETrue if all in the queue were pushed, EFalse otherwise + * @return None + */ + void NotifyDataPushComplete( TBool aAllPushed ); + +private: // data + + /** + * Notification interface class for echo request completions + * Not own. + */ + MDunAtCmdEchoer* iCallback; + + /** + * Callback to call when data to push + * Not own. + */ + MDunStreamManipulator* iStreamCallback; + + /** + * Current state of echoing: active or inactive + */ + TDunState iAtEchoState; + + }; + +#endif // C_CDUNATCMDECHOER_H diff -r c47ebe2ac36c -r 2702348f1fe7 localconnectivityservice/dun/atext/inc/DunAtCmdHandler.h --- a/localconnectivityservice/dun/atext/inc/DunAtCmdHandler.h Tue Apr 27 17:33:22 2010 +0300 +++ b/localconnectivityservice/dun/atext/inc/DunAtCmdHandler.h Tue May 11 17:01:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -23,6 +23,7 @@ #include #include "DunDataPusher.h" #include "DunAtCmdPusher.h" +#include "DunAtCmdEchoer.h" #include "DunAtEcomListen.h" #include "DunAtModeListen.h" #include "DunAtNvramListen.h" @@ -32,6 +33,7 @@ const TInt KDunOkBufLength = 1+1+2+1+1; // ++"OK"++ const TInt KDunErrorBufLength = 1+1+5+1+1; // ++"ERROR"++ const TInt KDunInputBufLength = (512 + 1); // 512 chars for command + +const TInt KDunEscBufLength = 1; // Escape (0x1B) character class CDunAtUrcHandler; class MDunConnMon; @@ -101,6 +103,30 @@ }; /** + * Class used for AT command editor mode related functionality + * + * @lib dunatext.lib + * @since TB9.2 + */ +NONSHARABLE_CLASS( TDunEditorModeInfo ) + { + +public: + + /** + * Flag to indicate if content found (not used if iContentFindStarted is EFalse) + */ + TBool iContentFound; + + /** + * AT command decoding related information for peeked data + * (not to be used if HandleNextDecodedCommand() returns EFalse) + */ + TDunDecodeInfo iPeekInfo; + + }; + +/** * Notification interface class for command mode start/end * * @lib dunutils.lib @@ -157,6 +183,15 @@ */ virtual void NotifyAtCmdHandlingEnd( TInt aStartIndex ) = 0; + /** + * Notifies about editor mode reply + * + * @since TB9.2 + * @param aStart ETrue if start of editor mode, EFalse otherwise + * @return None + */ + virtual void NotifyEditorModeReply( TBool aStart ) = 0; + }; /** @@ -237,6 +272,17 @@ IMPORT_C void SetEndOfCmdLine( TBool aClearInput ); /** + * Sends a character to be echoed + * + * @since TB9.2 + * @param aInput Input to echo + * @param aCallback Callback to echo request completions + * @return Symbian error code on error, KErrNone otherwise + */ + IMPORT_C TInt SendEchoCharacter( const TDesC8* aInput, + MDunAtCmdEchoer* aCallback ); + + /** * Stops sending of AT command from decode buffer * * @since S60 3.2 @@ -408,6 +454,14 @@ TBool HandleNextDecodedCommand(); /** + * Finds the start of the next command + * + * @since TB9.2 + * @return Index to the next command or Symbian error code on error + */ + TInt FindStartOfNextCommand(); + + /** * Manages end of AT command handling * * @since S60 5.0 @@ -622,6 +676,24 @@ */ void ManageCharacterChange( TUint aMode ); + /** + * Manages editor mode reply + * + * @since TB9.2 + * @param aStart ETrue if start of editor mode, EFalse otherwise + * @return Symbian error code on error, KErrNone otherwise + */ + TInt ManageEditorModeReply( TBool aStart ); + + /** + * Finds the next content from the input buffer + * + * @since TB9.2 + * @param aStart ETrue if start of editor mode, EFalse otherwise + * @return ETrue if next content found, EFalse otherwise + */ + TBool FindNextContent( TBool aStart ); + // from base class MDunAtCmdPusher /** @@ -631,6 +703,7 @@ * downstream. * * @since S60 5.0 + * @param aError Error code of command processing completion * @return None */ TInt NotifyEndOfProcessing( TInt aError ); @@ -652,6 +725,24 @@ */ TBool NotifyNextCommandPeekRequest(); + /** + * Notifies about editor mode reply + * + * @since TB9.2 + * @return Symbian error code on error, KErrNone otherwise + */ + TInt NotifyEditorModeReply(); + +// from base class MDunAtCmdEchoer + + /** + * Notifies about completed echo in text mode + * + * @since TB9.2 + * @return None + */ + void NotifyEchoComplete(); + // from base class MDunAtEcomListen /** @@ -766,6 +857,11 @@ TBuf8 iLastBuffer; /** + * Buffer for command + */ + TBuf8 iEscapeBuffer; + + /** * AT command decoding related information */ TDunDecodeInfo iDecodeInfo; @@ -776,12 +872,23 @@ TDunParseInfo iParseInfo; /** + * Information for editor mode + */ + TDunEditorModeInfo iEditorModeInfo; + + /** * AT command reply pusher * Own. */ CDunAtCmdPusher* iCmdPusher; /** + * AT command reply echoer + * Own. + */ + CDunAtCmdEchoer* iCmdEchoer; + + /** * URC message handlers * Own. */ diff -r c47ebe2ac36c -r 2702348f1fe7 localconnectivityservice/dun/atext/inc/DunAtCmdPusher.h --- a/localconnectivityservice/dun/atext/inc/DunAtCmdPusher.h Tue Apr 27 17:33:22 2010 +0300 +++ b/localconnectivityservice/dun/atext/inc/DunAtCmdPusher.h Tue May 11 17:01:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -63,6 +63,14 @@ */ virtual TBool NotifyNextCommandPeekRequest() = 0; + /** + * Notifies about editor mode reply + * + * @since TB9.2 + * @return Symbian error code on error, KErrNone otherwise + */ + virtual TInt NotifyEditorModeReply() = 0; + }; /** @@ -120,10 +128,11 @@ * Starts AT command handling * * @since S60 5.0 - * @param aCommand AT command to handle + * @param aCommand AT command or editor mode input to handle + * @param aNormalMode ETrue if request issue for normal mode * @return Symbian error code on error, KErrNone otherwise */ - TInt IssueRequest( TDesC8& aCommand ); + TInt IssueRequest( TDesC8& aCommand, TBool aNormalMode=ETrue ); /** * Stops AT command handling @@ -151,6 +160,14 @@ */ void SetEndOfCmdLine(); + /** + * Gets the editor mode status + * + * @since TB9.2 + * @return ETrue if in editor mode, EFalse otherwise + */ + TBool EditorMode(); + private: CDunAtCmdPusher( RATExt* aAtCmdExt, @@ -197,6 +214,38 @@ void SendReplyData( TBool aRecvBuffer=ETrue ); /** + * Manages change in reply type to EReplyTypeOther + * + * @since TB9.2 + * @return None + */ + void ManageReplyTypeChangeToOther(); + + /** + * Manages change in reply type to EReplyTypeOk + * + * @since TB9.2 + * @return None + */ + void ManageReplyTypeChangeToOk(); + + /** + * Manages change in reply type to EReplyTypeError + * + * @since TB9.2 + * @return None + */ + void ManageReplyTypeChangeToError(); + + /** + * Manages change in reply type to EReplyTypeEditor + * + * @since TB9.2 + * @return None + */ + void ManageReplyTypeChangeToEditor(); + + /** * Manages change in reply type * * @since S60 5.0 @@ -313,6 +362,11 @@ */ TBool iStop; + /** + * Flag indicating if in editor mode + */ + TBool iEditorMode; + }; #endif // C_CDUNATCMDPUSHER_H diff -r c47ebe2ac36c -r 2702348f1fe7 localconnectivityservice/dun/atext/src/DunAtCmdEchoer.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/localconnectivityservice/dun/atext/src/DunAtCmdEchoer.cpp Tue May 11 17:01:49 2010 +0300 @@ -0,0 +1,129 @@ +/* +* 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: Echoer for AT commands +* +*/ + +#include "DunAtCmdEchoer.h" +#include "DunDownstream.h" +#include "DunDebug.h" + +// --------------------------------------------------------------------------- +// Two-phased constructor. +// --------------------------------------------------------------------------- +// +CDunAtCmdEchoer* CDunAtCmdEchoer::NewL( + MDunStreamManipulator* aStreamCallback ) + { + CDunAtCmdEchoer* self = new (ELeave) CDunAtCmdEchoer( aStreamCallback ); + CleanupStack::PushL( self ); + self->ConstructL(); + CleanupStack::Pop( self ); + return self; + } + +// --------------------------------------------------------------------------- +// Destructor. +// --------------------------------------------------------------------------- +// +CDunAtCmdEchoer::~CDunAtCmdEchoer() + { + FTRACE(FPrint( _L("CDunAtCmdEchoer::~CDunAtCmdEchoer()") )); + ResetData(); + FTRACE(FPrint( _L("CDunAtCmdEchoer::~CDunAtCmdEchoer() complete") )); + } + +// --------------------------------------------------------------------------- +// Resets data to initial values +// --------------------------------------------------------------------------- +// +void CDunAtCmdEchoer::ResetData() + { + FTRACE(FPrint( _L("CDunAtCmdEchoer::ResetData()") )); + // Internal + Initialize(); + FTRACE(FPrint( _L("CDunAtCmdEchoer::ResetData() complete") )); + } + +// --------------------------------------------------------------------------- +// Sends a character to be echoed +// --------------------------------------------------------------------------- +// +TInt CDunAtCmdEchoer::SendEchoCharacter( + const TDesC8* aInput, + MDunAtCmdEchoer* aCallback ) + { + FTRACE(FPrint( _L("CDunAtCmdEchoer::SendEchoCharacter()") )); + if ( iAtEchoState!=EDunStateIdle || iCallback ) + { + FTRACE(FPrint( _L("CDunAtCmdEchoer::SendEchoCharacter() (not ready) complete") )); + return KErrNotReady; + } + iStreamCallback->NotifyDataPushRequest( aInput, this ); + iCallback = aCallback; + iAtEchoState = EDunStateAtCmdEchoing; + FTRACE(FPrint( _L("CDunDownstream::SendEchoCharacter() complete" ) )); + return KErrNone; + } + +// --------------------------------------------------------------------------- +// CDunAtCmdEchoer::CDunAtCmdEchoer +// --------------------------------------------------------------------------- +// +CDunAtCmdEchoer::CDunAtCmdEchoer( MDunStreamManipulator* aStreamCallback ) : + iStreamCallback( aStreamCallback ) + { + Initialize(); + } + +// --------------------------------------------------------------------------- +// CDunAtCmdEchoer::ConstructL +// --------------------------------------------------------------------------- +// +void CDunAtCmdEchoer::ConstructL() + { + FTRACE(FPrint( _L("CDunAtCmdEchoer::ConstructL()") )); + if ( !iStreamCallback ) + { + FTRACE(FPrint( _L("CDunAtCmdEchoer::ConstructL() complete") )); + User::Leave( KErrGeneral ); + } + FTRACE(FPrint( _L("CDunAtCmdEchoer::ConstructL() complete") )); + } + +// --------------------------------------------------------------------------- +// Initializes this class +// --------------------------------------------------------------------------- +// +void CDunAtCmdEchoer::Initialize() + { + // Don't initialize iStreamCallback here (it is set through NewL) + iCallback = NULL; + iAtEchoState = EDunStateIdle; + } + +// --------------------------------------------------------------------------- +// From MDunCompletionReporter. +// Gets called when data push is complete +// --------------------------------------------------------------------------- +// +void CDunAtCmdEchoer::NotifyDataPushComplete( TBool /*aAllPushed*/ ) + { + FTRACE(FPrint( _L("CDunAtCmdEchoer::NotifyDataPushComplete()") )); + MDunAtCmdEchoer* callback = iCallback; + iCallback = NULL; + iAtEchoState = EDunStateIdle; + callback->NotifyEchoComplete(); + FTRACE(FPrint( _L("CDunAtCmdEchoer::NotifyDataPushComplete() complete") )); + } diff -r c47ebe2ac36c -r 2702348f1fe7 localconnectivityservice/dun/atext/src/DunAtCmdHandler.cpp --- a/localconnectivityservice/dun/atext/src/DunAtCmdHandler.cpp Tue Apr 27 17:33:22 2010 +0300 +++ b/localconnectivityservice/dun/atext/src/DunAtCmdHandler.cpp Tue May 11 17:01:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2009-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -35,7 +35,8 @@ #include "DunDownstream.h" #include "DunDebug.h" -const TInt8 KDunCancel = 24; +const TInt8 KDunCancel = 24; // Used for line editing, cancel character +const TInt8 KDunEscape = 27; // Used for editor ending, escape character // --------------------------------------------------------------------------- // Two-phased constructor. @@ -79,6 +80,8 @@ Stop(); // NewL() DeletePluginHandlers(); + delete iCmdEchoer; + iCmdEchoer = NULL; delete iNvramListen; iNvramListen = NULL; delete iModeListen; @@ -145,7 +148,16 @@ FTRACE(FPrint( _L("CDunAtCmdHandler::ParseCommand()") )); FTRACE(FPrint( _L("CDunAtCmdHandler::ParseCommand() received:") )); FTRACE(FPrintRaw(aCommand) ); - iCommand = &aCommand; + TBool editorMode = iCmdPusher->EditorMode(); + if ( editorMode ) + { + // Note: return here with "no partial input" and some error to fool + // CDunUpstream into not reissuing the read request. + iCmdPusher->IssueRequest( aCommand, EFalse ); + aPartialInput = EFalse; + return KErrGeneral; + } + iCommand = &aCommand; // iCommand only for normal mode // Manage partial AT command TBool needsCarriage = ETrue; TBool okToExit = ManagePartialCommand( aCommand, needsCarriage ); @@ -180,7 +192,7 @@ iDecodeInfo.iFirstDecode = ETrue; iDecodeInfo.iDecodeIndex = 0; HandleNextDecodedCommand(); - FTRACE(FPrint( _L("CDunAtCmdHandler::ParseCommand() (not supported) complete") )); + FTRACE(FPrint( _L("CDunAtCmdHandler::ParseCommand() complete") )); aPartialInput = EFalse; return KErrNone; } @@ -210,6 +222,19 @@ } // --------------------------------------------------------------------------- +// Sends a character to be echoed +// --------------------------------------------------------------------------- +// +EXPORT_C TInt CDunAtCmdHandler::SendEchoCharacter( const TDesC8* aInput, + MDunAtCmdEchoer* aCallback ) + { + FTRACE(FPrint( _L("CDunAtCmdHandler::SendEchoCharacter()") )); + TInt retVal = iCmdEchoer->SendEchoCharacter( aInput, aCallback ); + FTRACE(FPrint( _L("CDunAtCmdHandler::SendEchoCharacter() complete") )); + return retVal; + } + +// --------------------------------------------------------------------------- // Stops sending of AT command from parse buffer // --------------------------------------------------------------------------- // @@ -223,7 +248,12 @@ return KErrNotReady; } iCmdPusher->Stop(); - iHandleState = EDunStateIdle; + // The line below is used in the case when this function is called by + // CDunUpstream as a result of "data mode ON" change notification. + // In this case it is possible that HandleNextDecodedCommand() returns + // without resetting the iInputBuffer because of the way it checks the + // iHandleState. + ManageEndOfCmdHandling( EFalse, ETrue, ETrue ); FTRACE(FPrint( _L("CDunAtCmdHandler::Stop() complete") )); return KErrNone; } @@ -313,28 +343,21 @@ CreateSpecialCommandsL(); // Create the plugin handlers CreatePluginHandlersL(); + // Create the echo handler + iCmdEchoer = CDunAtCmdEchoer::NewL( iDownstream ); // Create the listeners - CDunAtEcomListen* ecomListen = CDunAtEcomListen::NewLC( &iAtCmdExt, this ); - CDunAtModeListen* modeListen = CDunAtModeListen::NewLC( &iAtCmdExtCommon, - this ); - CDunAtNvramListen* nvramListen = CDunAtNvramListen::NewLC( &iAtCmdExt, - &iAtCmdExtCommon ); + iEcomListen = CDunAtEcomListen::NewL( &iAtCmdExt, this ); + iModeListen = CDunAtModeListen::NewL( &iAtCmdExtCommon, this ); + iNvramListen = CDunAtNvramListen::NewL( &iAtCmdExt, &iAtCmdExtCommon ); + iAtSpecialCmdHandler = CDunAtSpecialCmdHandler::NewL(); // Set the default modes (+report) and characters GetAndSetDefaultSettingsL(); // Start listening - ecomListen->IssueRequest(); - modeListen->IssueRequest(); - nvramListen->IssueRequest(); - CleanupStack::Pop( nvramListen ); - CleanupStack::Pop( modeListen ); - CleanupStack::Pop( ecomListen ); + iEcomListen->IssueRequest(); + iModeListen->IssueRequest(); + iNvramListen->IssueRequest(); CleanupStack::Pop( &iAtCmdExtCommon ); CleanupStack::Pop( &iAtCmdExt ); - iEcomListen = ecomListen; - iModeListen = modeListen; - iNvramListen = nvramListen; - - iAtSpecialCmdHandler = CDunAtSpecialCmdHandler::NewL(); FTRACE(FPrint( _L("CDunAtCmdHandler::ConstructL() complete") )); } @@ -356,6 +379,7 @@ iDecodeInfo.iDecodeIndex = KErrNotFound; iDecodeInfo.iPrevChar = 0; iDecodeInfo.iPrevExists = EFalse; + iEditorModeInfo.iContentFound = EFalse; iCmdPusher = NULL; iEcomListen = NULL; iModeListen = NULL; @@ -791,6 +815,34 @@ } // --------------------------------------------------------------------------- +// Finds the start of the next command +// --------------------------------------------------------------------------- +// +TInt CDunAtCmdHandler::FindStartOfNextCommand() + { + FTRACE(FPrint( _L("CDunAtCmdHandler::FindStartOfNextCommand()") )); + // Note: here we need to avoid internal recursion when parsing the + // multiple IsEndOfCommand() and IsDelimiterCharacter() markers inside the + // same upstream block. + // Skip all the extra markers except the one we already know to exist. + TInt i; + TInt startVal = iEndIndex + 1; + TInt foundIndex = KErrNotFound; + TInt count = iCommand->Length(); + for ( i=startVal; iLength(); - for ( i=startVal; iNotifyAtCmdHandlingEnd( foundIndex ); FTRACE(FPrint( _L("CDunAtCmdHandler::ManageEndOfCmdHandling() complete") )); } @@ -923,6 +959,7 @@ FTRACE(FPrint( _L("CDunAtCmdHandler::RestoreOldDecodeInfo()") )); if ( aPeek ) { + iEditorModeInfo.iPeekInfo = iDecodeInfo; iDecodeInfo = aOldInfo; } FTRACE(FPrint( _L("CDunAtCmdHandler::RestoreOldDecodeInfo() complete") )); @@ -1529,6 +1566,65 @@ } // --------------------------------------------------------------------------- +// Manages editor mode reply +// --------------------------------------------------------------------------- +// +TInt CDunAtCmdHandler::ManageEditorModeReply( TBool aStart ) + { + FTRACE(FPrint( _L("CDunAtCmdHandler::ManageEditorModeReply()" ) )); + // Two modes possible here: + // 1) Sending data directly from DTE to DCE, i.e. no subsequent data in + // the input buffer -> Reissue read request from DTE. + // 2) Sending data from input buffer to DCE -> Do not reissue read request + // from DTE: send the data in a loop + // In summary: send data byte-by-byte in editor mode until end of input. + // When end of input notify CDunUpstream to reissue the read request. + TBool nextContentFound = FindNextContent( aStart ); + if ( !nextContentFound ) + { + iUpstream->NotifyEditorModeReply( aStart ); + FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyEditorModeReply() complete") )); + return KErrNone; + } + // In block mode end the block mode by sending and hope it works. + iEscapeBuffer.Zero(); + iEscapeBuffer.Append( KDunEscape ); + iCmdPusher->IssueRequest( iEscapeBuffer, EFalse ); + FTRACE(FPrint( _L("CDunAtCmdHandler::ManageEditorModeReply() complete" ) )); + return KErrNone; + } + +// --------------------------------------------------------------------------- +// Finds the next content from the input data +// --------------------------------------------------------------------------- +// +TBool CDunAtCmdHandler::FindNextContent( TBool aStart ) + { + FTRACE(FPrint( _L("CDunAtCmdHandler::FindNextContent()" ) )); + if ( !aStart ) + { + FTRACE(FPrint( _L("CDunAtCmdHandler::FindNextContent() (skip) complete" ) )); + return iEditorModeInfo.iContentFound; + } + iEditorModeInfo.iContentFound = EFalse; + TInt foundCmdIndex = KErrNotFound; + TBool nextContentFound = ExtractNextDecodedCommand( ETrue ); // peek + if ( !nextContentFound ) + { + // Check the next subblock + foundCmdIndex = FindStartOfNextCommand(); + } + if ( !nextContentFound && foundCmdIndex<0 ) + { + FTRACE(FPrint( _L("CDunAtCmdHandler::FindNextContent() (not found) complete") )); + return EFalse; + } + iEditorModeInfo.iContentFound = ETrue; + FTRACE(FPrint( _L("CDunAtCmdHandler::FindNextContent() complete" ) )); + return ETrue; + } + +// --------------------------------------------------------------------------- // From class MDunAtCmdPusher. // Notifies about end of AT command processing. This is after all reply data // for an AT command is multiplexed to the downstream. @@ -1537,6 +1633,13 @@ TInt CDunAtCmdHandler::NotifyEndOfProcessing( TInt /*aError*/ ) { FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyEndOfProcessing()" ) )); + TBool editorMode = iCmdPusher->EditorMode(); + if ( editorMode ) + { + ManageEditorModeReply( ETrue ); + FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyEndOfProcessing() (editor) complete" ) )); + return KErrNone; + } HandleNextDecodedCommand(); FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyEndOfProcessing() complete" ) )); return KErrNone; @@ -1571,6 +1674,19 @@ } // --------------------------------------------------------------------------- +// From class MDunAtCmdPusher. +// Notifies about editor mode reply +// --------------------------------------------------------------------------- +// +TInt CDunAtCmdHandler::NotifyEditorModeReply() + { + FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyEditorModeReply()") )); + TInt retVal = ManageEditorModeReply( EFalse ); + FTRACE(FPrint( _L("CDunAtCmdHandler::NotifyEditorModeReply() complete") )); + return retVal; + } + +// --------------------------------------------------------------------------- // From class MDunAtEcomListen. // Notifies about new plugin installation // --------------------------------------------------------------------------- diff -r c47ebe2ac36c -r 2702348f1fe7 localconnectivityservice/dun/atext/src/DunAtCmdPusher.cpp --- a/localconnectivityservice/dun/atext/src/DunAtCmdPusher.cpp Tue Apr 27 17:33:22 2010 +0300 +++ b/localconnectivityservice/dun/atext/src/DunAtCmdPusher.cpp Tue May 11 17:01:49 2010 +0300 @@ -103,12 +103,12 @@ // Starts AT command handling // --------------------------------------------------------------------------- // -TInt CDunAtCmdPusher::IssueRequest( TDesC8& aCommand ) +TInt CDunAtCmdPusher::IssueRequest( TDesC8& aCommand, TBool aNormalMode ) { FTRACE(FPrint( _L("CDunAtCmdPusher::IssueRequest()") )); FTRACE(FPrint( _L("CDunAtCmdPusher::IssueRequest() send ATEXT:") )); FTRACE(FPrintRaw(aCommand) ); - if ( iAtPushState != EDunStateIdle ) + if ( iAtPushState!=EDunStateIdle && aNormalMode ) { FTRACE(FPrint( _L("CDunAtCmdPusher::IssueRequest() (not ready) complete") )); return KErrNotReady; @@ -186,10 +186,22 @@ iLastOkPush = EFalse; iCmdAbort = EFalse; iStop = EFalse; + iEditorMode = EFalse; FTRACE(FPrint( _L("CDunAtCmdPusher::SetEndOfCmdLine() complete") )); } // --------------------------------------------------------------------------- +// Gets the editor mode status +// --------------------------------------------------------------------------- +// +TBool CDunAtCmdPusher::EditorMode() + { + FTRACE(FPrint( _L("CDunAtCmdPusher::EditorMode()") )); + FTRACE(FPrint( _L("CDunAtCmdPusher::EditorMode() complete") )); + return iEditorMode; + } + +// --------------------------------------------------------------------------- // CDunAtCmdPusher::CDunAtCmdPusher // --------------------------------------------------------------------------- // @@ -303,6 +315,79 @@ } // --------------------------------------------------------------------------- +// Manages change in reply type to EReplyTypeOther +// --------------------------------------------------------------------------- +// +void CDunAtCmdPusher::ManageReplyTypeChangeToOther() + { + FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToOther()") )); + iNoErrorReceived = ETrue; + SendReplyData(); + FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToOther() complete") )); + } + +// --------------------------------------------------------------------------- +// Manages change in reply type to EReplyTypeOk +// --------------------------------------------------------------------------- +// +void CDunAtCmdPusher::ManageReplyTypeChangeToOk() + { + FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToOk()") )); + // Skip the "OK" replies if not last. Only push the "OK" reply at the end. + // iStop changes it so that the we have to send the "OK" immediately and + // only stop with NotifyDataPushComplete() + TBool found = iCallback->NotifyNextCommandPeekRequest(); + if ( !found || iStop ) + { + SendReplyData(); + } + else + { + iNoErrorReceived = ETrue; + SetToIdleAndNotifyEnd( KErrNone ); + } + FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToOk() complete") )); + } + +// --------------------------------------------------------------------------- +// Manages change in reply type to EReplyTypeError +// --------------------------------------------------------------------------- +// +void CDunAtCmdPusher::ManageReplyTypeChangeToError() + { + FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToError()") )); + if ( iNoErrorReceived ) + { + iAtCmdExt->ReportExternalHandleCommandError(); + } + SendReplyData(); + FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToError() complete") )); + } + +// --------------------------------------------------------------------------- +// Manages change in reply type to EReplyTypeEditor +// --------------------------------------------------------------------------- +// +void CDunAtCmdPusher::ManageReplyTypeChangeToEditor() + { + FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToEditor()") )); + if ( !iEditorMode ) + { + // First change to editor mode: manage it as EReplyTypeOther (prompt) + iEditorMode = ETrue; + ManageReplyTypeChangeToOther(); + FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToEditor() (editor) complete") )); + return; + } + // The same reply to editor mode as before: no reply, only notification for + // echo/forwarding purposes + iCallback->NotifyEditorModeReply(); + // Do nothing after notifying. The next ForwardEditorModeInput() triggers + // the next call of this function. + FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChangeToEditor() complete") )); + } + +// --------------------------------------------------------------------------- // Manages change in reply type // --------------------------------------------------------------------------- // @@ -314,41 +399,32 @@ case EReplyTypeOther: { FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChange() EReplyTypeOther") )); - iNoErrorReceived = ETrue; - SendReplyData(); + iEditorMode = EFalse; + ManageReplyTypeChangeToOther(); } break; case EReplyTypeOk: { FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChange() EReplyTypeOk") )); - // Skip the "OK" replies if not last. Only push the "OK" reply at the end. - // iStop changes it so that the we have to send the "OK" immediately and - // only stop with NotifyDataPushComplete() - TBool found = iCallback->NotifyNextCommandPeekRequest(); - if ( !found || iStop ) - { - SendReplyData(); - } - else - { - iNoErrorReceived = ETrue; - SetToIdleAndNotifyEnd( KErrNone ); - } + iEditorMode = EFalse; + ManageReplyTypeChangeToOk(); } break; case EReplyTypeError: { FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChange() EReplyTypeError") )); - if ( iNoErrorReceived ) - { - iAtCmdExt->ReportExternalHandleCommandError(); - } - SendReplyData(); + iEditorMode = EFalse; + ManageReplyTypeChangeToError(); } break; + case EReplyTypeEditor: + FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChange() EReplyTypeEditor") )); + ManageReplyTypeChangeToEditor(); + break; default: { FTRACE(FPrint( _L("CDunAtCmdPusher::ManageReplyTypeChange() EReplyTypeUndefined") )); + iEditorMode = EFalse; SetToIdleAndNotifyEnd( KErrNone ); } break; diff -r c47ebe2ac36c -r 2702348f1fe7 localconnectivityservice/dun/utils/inc/DunTransporter.h --- a/localconnectivityservice/dun/utils/inc/DunTransporter.h Tue Apr 27 17:33:22 2010 +0300 +++ b/localconnectivityservice/dun/utils/inc/DunTransporter.h Tue May 11 17:01:49 2010 +0300 @@ -83,6 +83,7 @@ EDunStateCallListen, // Transporter state for call state listening EDunStateAtCmdHandling, // ATEXT state for AT command handling EDunStateAtCmdPushing, // ATEXT state for AT command reply pushing + EDunStateAtCmdEchoing, // ATEXT state for AT command character echoing (text mode) EDunStateAtUrcHandling, // ATEXT state for URC handling EDunStateModeListening, // ATEXT state for mode change listening EDunStateEcomListening, // ATEXT state for ECOM change listening diff -r c47ebe2ac36c -r 2702348f1fe7 localconnectivityservice/dun/utils/inc/DunUpstream.h --- a/localconnectivityservice/dun/utils/inc/DunUpstream.h Tue Apr 27 17:33:22 2010 +0300 +++ b/localconnectivityservice/dun/utils/inc/DunUpstream.h Tue May 11 17:01:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2007-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" @@ -22,6 +22,7 @@ #include "DunTransUtils.h" #include "DunStream.h" #include "DunAtCmdHandler.h" +#include "DunAtCmdEchoer.h" #include "DunDataPusher.h" class MDunCmdModeMonitor; @@ -132,7 +133,8 @@ NONSHARABLE_CLASS( CDunUpstream ) : public CDunStream, public MDunAtCmdHandler, public MDunCmdModeMonitor, - public MDunAtCmdStatusReporter + public MDunAtCmdStatusReporter, + public MDunAtCmdEchoer { public: @@ -284,6 +286,15 @@ */ void NotifyAtCmdHandlingEnd( TInt aStartIndex ); + /** + * Notifies about editor mode reply + * + * @since TB9.2 + * @param aStart ETrue if start of editor mode, EFalse otherwise + * @return Symbian error code on error, KErrNone otherwise + */ + void NotifyEditorModeReply( TBool aStart ); + // from base class MDunAtCmdHandler /** @@ -322,6 +333,16 @@ */ void NotifyCommandModeEnd(); +// from base class MDunAtCmdEchoer + + /** + * Notifies about completed echo in text mode + * + * @since TB9.2 + * @return None + */ + void NotifyEchoComplete(); + private: // data /** diff -r c47ebe2ac36c -r 2702348f1fe7 localconnectivityservice/dun/utils/src/DunUpstream.cpp --- a/localconnectivityservice/dun/utils/src/DunUpstream.cpp Tue Apr 27 17:33:22 2010 +0300 +++ b/localconnectivityservice/dun/utils/src/DunUpstream.cpp Tue May 11 17:01:49 2010 +0300 @@ -1,5 +1,5 @@ /* -* Copyright (c) 2008-2009 Nokia Corporation and/or its subsidiary(-ies). +* Copyright (c) 2008-2010 Nokia Corporation and/or its subsidiary(-ies). * All rights reserved. * This component and the accompanying materials are made available * under the terms of "Eclipse Public License v1.0" @@ -499,6 +499,31 @@ } // --------------------------------------------------------------------------- +// From class MDunAtCmdStatusReporter +// Notifies about editor mode reply +// --------------------------------------------------------------------------- +// +void CDunUpstream::NotifyEditorModeReply( TBool aStart ) + { + FTRACE(FPrint( _L("CDunUpstream::NotifyEditorModeReply()" ))); + if ( iParseData.iDataMode ) + { + FTRACE(FPrint( _L("CDunUpstream::NotifyEditorModeReply() (not ready) complete" ))); + return; + } + // If start of editor mode then just reissue the read request + // If continuation then echo and reissue the read request + if ( aStart ) + { + IssueRequest(); + FTRACE(FPrint( _L("CDunUpstream::NotifyEditorModeReply() (start) complete" ))); + return; + } + iParseData.iAtCmdHandler->SendEchoCharacter( iBufferPtr, this ); + FTRACE(FPrint( _L("CDunUpstream::NotifyEditorModeReply() complete" ))); + } + +// --------------------------------------------------------------------------- // From class MDunAtCmdHandler // Starts URC message handling // --------------------------------------------------------------------------- @@ -581,3 +606,15 @@ IssueRequest(); FTRACE(FPrint( _L("CDunUpstream::NotifyCommandModeEnd() complete" ))); } + +// --------------------------------------------------------------------------- +// From class MDunAtCmdEchoer. +// Notifies about command mode end +// --------------------------------------------------------------------------- +// +void CDunUpstream::NotifyEchoComplete() + { + FTRACE(FPrint( _L("CDunUpstream::NotifyEchoComplete()" ))); + IssueRequest(); + FTRACE(FPrint( _L("CDunUpstream::NotifyEchoComplete() complete" ))); + } diff -r c47ebe2ac36c -r 2702348f1fe7 localconnectivityservice/obexreceiveservices/bip/src/BIPController.cpp --- a/localconnectivityservice/obexreceiveservices/bip/src/BIPController.cpp Tue Apr 27 17:33:22 2010 +0300 +++ b/localconnectivityservice/obexreceiveservices/bip/src/BIPController.cpp Tue May 11 17:01:49 2010 +0300 @@ -32,7 +32,7 @@ #include #include #include -#include // provides interface for quering system paths +#include #include #include #include @@ -635,21 +635,14 @@ iDrive = EDriveZ; // Intialize iDrive to Z TInt filesize = iBTObject->Length(); - TFileName mmcRoot = PathInfo::MemoryCardRootPath(); // e.g. "E:\\" - TInt mmcDrive = KDefaultDrive; // External memory card TInt imsDrive = KDefaultDrive; // Internal mass storage - if ( mmcRoot == _L("E:\\")) - { - mmcDrive = EDriveE; - imsDrive = EDriveF; - } - else if ( mmcRoot == _L("F:\\") ) - { - mmcDrive = EDriveF; - imsDrive = EDriveE; - } + User::LeaveIfError(DriveInfo::GetDefaultDrive(DriveInfo::EDefaultMassStorage, imsDrive)); + User::LeaveIfError(DriveInfo::GetDefaultDrive(DriveInfo::EDefaultRemovableMassStorage, mmcDrive)); + + TRACE_INFO( (_L( "[oppreceiveservice] CheckCapacityL imsDrive=%d; mmcDrive=%d\t" ),imsDrive, mmcDrive ) ); + TVolumeInfo volumeInfo; TInt err = iFs.Volume(volumeInfo, imsDrive); diff -r c47ebe2ac36c -r 2702348f1fe7 localconnectivityservice/obexreceiveservices/opp/src/oppcontroller.cpp --- a/localconnectivityservice/obexreceiveservices/opp/src/oppcontroller.cpp Tue Apr 27 17:33:22 2010 +0300 +++ b/localconnectivityservice/obexreceiveservices/opp/src/oppcontroller.cpp Tue May 11 17:01:49 2010 +0300 @@ -31,7 +31,7 @@ #include #include #include -#include // provides interface for quering system paths +#include #include #include @@ -570,23 +570,15 @@ RFs rfs ; User::LeaveIfError(rfs.Connect()); - - TFileName mmcRoot = PathInfo::MemoryCardRootPath(); // e.g. "E:\\" - + TInt mmcDrive = KDefaultDrive; // External memroy card - TInt imsDrive = KDefaultDrive; // Internal mass storage + TInt imsDrive = KDefaultDrive; // Internal mass storage + + User::LeaveIfError(DriveInfo::GetDefaultDrive(DriveInfo::EDefaultMassStorage, imsDrive)); + User::LeaveIfError(DriveInfo::GetDefaultDrive(DriveInfo::EDefaultRemovableMassStorage, mmcDrive)); - if ( mmcRoot == _L("E:\\")) - { - mmcDrive = EDriveE; - imsDrive = EDriveF; - } - else if ( mmcRoot == _L("F:\\") ) - { - mmcDrive = EDriveF; - imsDrive = EDriveE; - } - + TRACE_INFO( (_L( "[oppreceiveservice] CheckCapacityL imsDrive=%d; mmcDrive=%d\t" ),imsDrive, mmcDrive ) ); + TVolumeInfo volumeInfo; TInt err = rfs.Volume(volumeInfo, imsDrive); @@ -595,7 +587,7 @@ if ( !err ) { // Check capacity on Internal mass storage - TRACE_INFO( (_L( "[oppreceiveservice] CheckCapacityL Internal mass storage E\t" )) ); + TRACE_INFO( (_L( "[oppreceiveservice] CheckCapacityL Internal mass storage\t" )) ); if ( !SysUtil::DiskSpaceBelowCriticalLevelL( &rfs, filesize, imsDrive ) ) { iDrive = imsDrive; @@ -607,7 +599,7 @@ if ( !err ) { // Check capacity on Internal mass storage - TRACE_INFO( (_L( "[oppreceiveservice] CheckCapacityL Checking memory card F\t" )) ); + TRACE_INFO( (_L( "[oppreceiveservice] CheckCapacityL Checking memory card\t" )) ); if ( !SysUtil::DiskSpaceBelowCriticalLevelL( &rfs, filesize, mmcDrive ) ) { iDrive = mmcDrive;