void CRpsMsg::ConstructL(const TDesC8& aMsgType, const TDesC8& aOpCode, const TUint aMsgNum, const CDesCArrayFlat& aArgArray) { TUint numArgs(aArgArray.Count()); iMsgDataArray = new (ELeave)CDesC8ArrayFlat(1); // Calc the total msg length TUint msgLen(KRqstLengthNoOpCodeNoArgsNoCommas + aOpCode.Length()); for(TInt i(0); i < numArgs; ++i) { msgLen += aArgArray.MdcaPoint(i).Length(); } // add commas to calculation msgLen += KRqstMsgElementsNoArgs + numArgs - 1; // Msg Type iMsgDataArray->AppendL(aMsgType); iMsgDataArray->AppendL(KComma); // Msg Len TBuf8<KMaxMsgLenChars> mlenString; mlenString.NumFixedWidth(msgLen, EDecimal, KMaxMsgLenChars); iMsgDataArray->AppendL(mlenString); iMsgDataArray->AppendL(KComma); // Msg Seq Num TBuf8<KMaxMsgNumChars> msnString; //msnString.Num(NextMsgNum()); msnString.NumFixedWidth(aMsgNum, EDecimal, KMaxMsgNumChars); iMsgDataArray->AppendL(msnString); iMsgDataArray->AppendL(KComma); // OpCode iMsgDataArray->AppendL(aOpCode); iMsgDataArray->AppendL(KComma); // Arguments. Convert aArgArray data to 8-bit as we go. for(TInt i(0); i < numArgs; ++i) { TBuf8<KMaxElementSize> buf; buf.Copy(aArgArray.MdcaPoint(i)); iMsgDataArray->AppendL(buf); iMsgDataArray->AppendL(KComma); } // EOM iMsgDataArray->AppendL(KEOM); }
// ---------------------------------------------------------------------------- // CSCPHistoryPlugin::HandleEvent // // // Status : Approved // ---------------------------------------------------------------------------- // void CSCPHistoryPlugin :: HandleEventL( TInt aID, CSCPParamObject& aParam, CSCPParamObject& aOutParam) { Dprint ( ( _L( "CSCPHistoryPlugin::HandleEvent()" ) ) ); if ( iFs == NULL ) { return ; // Eventhandler not available } // check for Case switch ( aID ) { case ( KSCPEventValidate ) : { // Obtain the paramValue Dprint ( ( _L( "CSCPHistoryPlugin::KSCPEventValidate" ) ) ); TInt passhistoryParamValue; passhistoryParamValue = GetHistoryCountParamValue(); Dprint ( ( _L( "CSCPHistoryPlugin::HandleEvent passhistoryParamValue = %d" ), passhistoryParamValue ) ); // if all required bounds are zero, there is nothing to do. if ( passhistoryParamValue != 0) { // Get the configFile's path. // If this fails, there is something badly wrong(Private folder is not there) TInt errSCF = SetConfigFile (); if (errSCF != KErrNone) { break; // Break out from Case } // Get the historyItemCount, If the err is raised, the file is not there // This will lead to KSCPEventPasswordChanged event and new history file will // be created TInt historyItemCounter; TInt errHC = GetHistoryItemCount( historyItemCounter ); Dprint ( ( _L( "CSCPHistoryPlugin::HandleEvent historyItemCounter = %d" ), historyItemCounter ) ); if (errHC != KErrNone) { break; // Break out from Case } // continue with the KSCPEventValidate Check // Get the password from the paramObject TBuf<KSCPPasscodeMaxLength> seccode; if ( aParam.Get( KSCPParamPassword, seccode ) != KErrNone ) { // Nothing to do anymore Dprint( (_L("CSCPHistoryPlugin::HandleEvent()\ ERROR: KSCPEventValidate/KSCPParamPassword is != KErrNone") )); break; // Break out from Case } // Hash the securitycode TBuf<KSCPPasscodeMaxLength> securityhash; iEventHandler->HashInput(seccode,securityhash); // get history CDesCArrayFlat* array = NULL; TInt errGH = KErrNone; array = new CDesCArrayFlat(1); if ( array != NULL ) { TRAPD( err2, errGH = GetHistoryArrayL( *array ) ); if ( err2 != KErrNone ) { errGH = err2; } } else { errGH = KErrNoMemory; } // If for some reason err is raised, break out // If the Historyonfig file get deleted on the fly ex if (errGH != KErrNone) { array->Reset(); delete array; break; // Break out from Case } TInt correction; correction = 0; if ( array->Count() >= passhistoryParamValue ) { correction = array->Count() - passhistoryParamValue; } // check for match TBuf<KSCPPasscodeMaxLength> arrayItem; // Set the historyobject for (TInt i= 0 + correction; i < array->Count(); i++) { arrayItem = array->MdcaPoint(i); if (arrayItem.Compare(securityhash) == KErrNone) { aOutParam.Set( KSCPParamStatus, KErrSCPInvalidCode ); Dprint ( ( _L( "EDeviceLockHistoryBuffer Failed" ) ) ); aOutParam.AddtoFailedPolices(EDeviceLockHistoryBuffer); break; } // End of compare IF } // End of For // kill the local array->Reset(); delete array; } // passhistoryParamValue break; } // end of KSCPEventValidate