localconnectivityservice/dun/utils/src/DunUpstream.cpp
branchRCL_3
changeset 38 3dcb815346df
parent 19 2702348f1fe7
equal deleted inserted replaced
37:7e0ecb5b116a 38:3dcb815346df
   122         return retTrap;
   122         return retTrap;
   123         }
   123         }
   124     atCmdHandler->AddCmdModeCallback( aCallbackUp );
   124     atCmdHandler->AddCmdModeCallback( aCallbackUp );
   125     atCmdHandler->AddCmdModeCallback( aCallbackDown );
   125     atCmdHandler->AddCmdModeCallback( aCallbackDown );
   126     iParseData.iDataMode = EFalse;
   126     iParseData.iDataMode = EFalse;
   127     iParseData.iParseNeeded = ETrue;
       
   128     iParseData.iHandling = EFalse;
       
   129     iParseData.iAtCmdHandler = atCmdHandler;
   127     iParseData.iAtCmdHandler = atCmdHandler;
   130     FTRACE(FPrint( _L("CDunUpstream::InitializeForAtParsing() complete" ) ));
   128     FTRACE(FPrint( _L("CDunUpstream::InitializeForAtParsing() complete" ) ));
   131     return KErrNone;
   129     return KErrNone;
   132     }
   130     }
   133 
   131 
   243     // Don't initialize iUtility here (it is set through NewL)
   241     // Don't initialize iUtility here (it is set through NewL)
   244     iActivityData.iActivityCallback = NULL;
   242     iActivityData.iActivityCallback = NULL;
   245     iActivityData.iDataRead = EFalse;
   243     iActivityData.iDataRead = EFalse;
   246     iActivityData.iNotified = EFalse;
   244     iActivityData.iNotified = EFalse;
   247     iParseData.iDataMode = EFalse;
   245     iParseData.iDataMode = EFalse;
   248     iParseData.iParseNeeded = EFalse;
       
   249     iParseData.iHandling = EFalse;
       
   250     iParseData.iAtCmdHandler = NULL;
   246     iParseData.iAtCmdHandler = NULL;
   251     }
   247     }
   252 
   248 
   253 // ---------------------------------------------------------------------------
   249 // ---------------------------------------------------------------------------
   254 // Issues transfer request for this stream
   250 // Issues transfer request for this stream
   321 //
   317 //
   322 TBool CDunUpstream::ProcessReadData()
   318 TBool CDunUpstream::ProcessReadData()
   323     {
   319     {
   324     FTRACE(FPrint( _L("CDunUpstream::ProcessReadData()" )));
   320     FTRACE(FPrint( _L("CDunUpstream::ProcessReadData()" )));
   325     // The following will be transferred to Dataport
   321     // The following will be transferred to Dataport
   326     if ( iParseData.iDataMode || !iParseData.iParseNeeded )
   322     if ( iParseData.iDataMode )
   327         {
   323         {
   328         iOperationType = EDunOperationTypeWrite;
   324         iOperationType = EDunOperationTypeWrite;
   329         FTRACE(FPrint( _L("CDunUpstream::ProcessReadData() (next write) complete" )));
   325         FTRACE(FPrint( _L("CDunUpstream::ProcessReadData() (next write) complete" )));
   330         return ETrue;
   326         return ETrue;
   331         }
   327         }
   334         FTRACE(FPrint( _L("CDunUpstream::ProcessReadData() (no handler) complete" )));
   330         FTRACE(FPrint( _L("CDunUpstream::ProcessReadData() (no handler) complete" )));
   335         return ETrue;
   331         return ETrue;
   336         }
   332         }
   337     // The following will be transferred to parser
   333     // The following will be transferred to parser
   338     TInt retTemp = KErrNone;
   334     TInt retTemp = KErrNone;
   339     TBool partialInput = EFalse;
   335     TBool moreNeeded = EFalse;
   340     retTemp = iParseData.iAtCmdHandler->ParseCommand( *iBufferPtr,
   336     retTemp = iParseData.iAtCmdHandler->AddDataForParsing( *iBufferPtr,
   341                                                       partialInput );
   337                                                            moreNeeded );
   342     if ( retTemp!=KErrNone || !partialInput )
   338     if ( retTemp!=KErrNone || !moreNeeded )
   343         {
   339         {
       
   340         // If error or no error but no more data needed, don't reissue
   344         FTRACE(FPrint( _L("CDunUpstream::ProcessReadData() (no reissue) complete" )));
   341         FTRACE(FPrint( _L("CDunUpstream::ProcessReadData() (no reissue) complete" )));
   345         return EFalse;
   342         return EFalse;
   346         }
   343         }
       
   344     // If no error and more data needed, reissue
   347     FTRACE(FPrint( _L("CDunUpstream::ProcessReadData() (reissue) complete" )));
   345     FTRACE(FPrint( _L("CDunUpstream::ProcessReadData() (reissue) complete" )));
   348     return ETrue;
   346     return ETrue;
   349     }
   347     }
   350 
   348 
   351 // ---------------------------------------------------------------------------
   349 // ---------------------------------------------------------------------------
   444     {
   442     {
   445     }
   443     }
   446 
   444 
   447 // ---------------------------------------------------------------------------
   445 // ---------------------------------------------------------------------------
   448 // From class MDunAtCmdStatusReporter
   446 // From class MDunAtCmdStatusReporter
   449 // Notifies about AT command handling start
   447 // Notifies about parser's need to get more data
   450 // ---------------------------------------------------------------------------
   448 // ---------------------------------------------------------------------------
   451 //
   449 //
   452 void CDunUpstream::NotifyAtCmdHandlingStart()
   450 void CDunUpstream::NotifyParserNeedsMoreData()
   453     {
   451     {
   454     FTRACE(FPrint( _L("CDunUpstream::NotifyAtCmdHandlingStart()" )));
   452     FTRACE(FPrint( _L("CDunUpstream::NotifyParserNeedsMoreData()" )));
   455     if ( iParseData.iHandling )
   453     IssueRequest();  // iOperationType must be read here (don't set)
   456         {
   454     FTRACE(FPrint( _L("CDunUpstream::NotifyParserNeedsMoreData() complete" )));
   457         FTRACE(FPrint( _L("CDunUpstream::NotifyAtCmdHandlingStart() (already set!)" )));
       
   458         }
       
   459     iParseData.iHandling = ETrue;
       
   460     FTRACE(FPrint( _L("CDunUpstream::NotifyAtCmdHandlingStart() complete" )));
       
   461     }
       
   462 
       
   463 // ---------------------------------------------------------------------------
       
   464 // From class MDunAtCmdStatusReporter
       
   465 // Notifies about AT command handling end
       
   466 // ---------------------------------------------------------------------------
       
   467 //
       
   468 void CDunUpstream::NotifyAtCmdHandlingEnd( TInt aStartIndex )
       
   469     {
       
   470     FTRACE(FPrint( _L("CDunUpstream::NotifyAtCmdHandlingEnd()" )));
       
   471     if ( !iParseData.iHandling )
       
   472         {
       
   473         FTRACE(FPrint( _L("CDunUpstream::NotifyAtCmdHandlingEnd() (already set!)" )));
       
   474         }
       
   475     iParseData.iHandling = EFalse;
       
   476     // Next check the offset to the next command inside this block
       
   477     TInt length = iBufferPtr->Length();
       
   478     if ( aStartIndex < 0 )
       
   479         {
       
   480         // Start of the next command not found so here we need to just reissue
       
   481         // the read request and not clear the input buffer.
       
   482         iParseData.iAtCmdHandler->SetEndOfCmdLine( EFalse );
       
   483         IssueRequest();  // iOperationType must be read here (don't set)
       
   484         FTRACE(FPrint( _L("CDunUpstream::NotifyAtCmdHandlingEnd() (not found) complete" )));
       
   485         return;
       
   486         }
       
   487     // Here the start of next command was found so try to directly handle that
       
   488     // command using ProcessReadData() for the next subblock.
       
   489     iParseData.iAtCmdHandler->SetEndOfCmdLine( ETrue );
       
   490     TInt maxLength = iBufferPtr->MaxLength();
       
   491     iBufferPtr->Set( &(*iBufferPtr)[aStartIndex], length-aStartIndex, maxLength );
       
   492     TBool reIssue = ProcessReadData();
       
   493     if ( reIssue )
       
   494         {
       
   495         // Note: should come here only if something went wrong
       
   496         IssueRequest();
       
   497         }
       
   498     FTRACE(FPrint( _L("CDunUpstream::NotifyAtCmdHandlingEnd() complete" )));
       
   499     }
   455     }
   500 
   456 
   501 // ---------------------------------------------------------------------------
   457 // ---------------------------------------------------------------------------
   502 // From class MDunAtCmdStatusReporter
   458 // From class MDunAtCmdStatusReporter
   503 // Notifies about editor mode reply
   459 // Notifies about editor mode reply