// // RTrkTcbCliSession::WriteFile() // // Writes data into the already opened file. // @return KErrNone - if succesful // Negative - if failed. // TInt RTrkTcbCliSession::WriteFile(const TDesC8& aFileData) { TIpcArgs args(aFileData.Length(), &aFileData); return SendReceive(ETrkTcbCmdCodeWriteFile, args); }
void CAppMain::SetAreaCode(const TDesC8& buf){ if(buf.Length()<=6){ this->iAreaCode.Copy(buf); } }
// --------------------------------------------------------------------------- // CWPTurnServerItem::SetTurnUsernameL // --------------------------------------------------------------------------- // void CWPTurnServerItem::SetTurnUsernameL( const TDesC8& aUsername ) { delete iTurnUsername; iTurnUsername = NULL; iTurnUsername = aUsername.AllocL(); }
// ----------------------------------------------------------------------------- // CUpnpDevice::SetTypeL // ----------------------------------------------------------------------------- // void CUpnpDevice::SetTypeL( const TDesC8& aType ) { HBufC8* tmp = aType.AllocL(); delete iDeviceType; iDeviceType = tmp; }
void CX509GeneralName::ConstructL(const TDesC8& aData) { iData = aData.AllocL(); }
// ----------------------------------------------------------------------------- // CUpnpArgument::SetValueL // If the value is inproper, the method leaves with EInvalidArgs, // which is the internal upnp error code used by UPnP Stack // (other items were commented in a header). // ----------------------------------------------------------------------------- // EXPORT_C void CUpnpArgument::SetValueL( const TDesC8& aValue ) { LOGS("CUpnpArgument::SetValueL(TDesC8&) [Name/Value]"); // Dates, times, URIs and UUIDs are not validated to save process time. // These must be validated if used in actual service, // which uses these arguments. TArgumentType type = Type(); LOGS1( "type: %i", type ); TLex8 lex(aValue); switch ( type ) { case EUi1: { TUint8 tryVal; CheckErrorL( ( lex.Val(tryVal, EDecimal) ), aValue ); break; } case EUi2: { TUint16 tryVal; CheckErrorL ( lex.Val(tryVal, EDecimal), aValue ); break; } case EUi4: { TUint32 tryVal; CheckErrorL( lex.Val(tryVal, EDecimal), aValue ); break; } case EI1: { TInt8 tryVal; CheckErrorL( lex.Val(tryVal), aValue ); break; } case EI2: { TInt16 tryVal; CheckErrorL( lex.Val(tryVal), aValue ); break; } case EI4: { TInt32 tryVal; CheckErrorL( lex.Val(tryVal), aValue ); break; } case EInt: { TInt64 tryVal; CheckErrorL( lex.Val(tryVal), aValue ); break; } case ER4: { TReal32 tryVal; CheckErrorL( lex.Val(tryVal), aValue ); break; } case ER8: case EFloat: case ENumber: { TReal64 tryVal; CheckErrorL( ( lex.Val(tryVal) ), aValue ); break; } case EFixed144: { TReal64 tryVal; switch ( lex.Val(tryVal) ) { case KErrOverflow: { // sizeof argument User::Leave(EInvalidArgs); break; } case KErrGeneral: { // bad argument User::Leave(EInvalidArgs); break; } default: { TInt left = aValue.Find(UpnpString::KDot8); TInt right; //only decimal part exists if ( left == KErrNotFound ) { left = aValue.Length(); right = left; //occurances of minus are not counted as a seprate digit positions TInt minus = aValue.Find(UpnpString::KMinus); if (minus > KErrNone) { left --; } else if(minus == KErrNone) { left--; if(aValue.Find(UpnpString::KMinus)>=KErrNone) { left--; } } } else //fractional part exists { right = left+1; if(tryVal<0) { left--; } if (aValue.Mid(right).Find(UpnpString::KMinus) >= KErrNone) { right++; } } //checking decimal digits if ( left > KMaxFixed144Left ) { User::Leave(EInvalidArgs); } //checking fractal digits right = (aValue.Length() - right ); if ( right > KMaxFixed144Right ) { User::Leave(EInvalidArgs); } // NULL value, if AllocL leaves then the pointer is invalid DeleteAndNullValue(); iValue = aValue.AllocL(); } } break; } case EBinBase64: { // NULL value, if AllocL leaves then the pointer is invalid DeleteAndNullValue(); iValue = aValue.AllocL(); break; } case EBinHex: { TInt64 tryVal; CheckErrorL( lex.Val(tryVal, EHex), aValue ); break; } case EChar: { // just one character allowed if (aValue.Length() > 1) { User::Leave(EInvalidArgs); } // NULL value, if AllocL leaves then the pointer is invalid DeleteAndNullValue(); iValue = aValue.AllocL(); break; } case EDate: case EDateTime: case EDateTimeTz: case ETime: case ETimeTz: case EUri: case EUuid: case EString: { // NULL value, if AllocL leaves then the pointer is invalid DeleteAndNullValue(); iValue = aValue.AllocL(); break; } default: { // unknown // must be tolerant // NULL value, if AllocL leaves then the pointer is invalid DeleteAndNullValue(); iValue = aValue.AllocL(); break; } } }
// ----------------------------------------------------------------------------- // CUpnpDevice::SetDescriptionUrlL // Return description URL. // ----------------------------------------------------------------------------- // void CUpnpDevice::SetDescriptionUrlL( const TDesC8& aDescriptionUrl ) { HBufC8* tmp = aDescriptionUrl.AllocL(); delete iDescriptionURL; iDescriptionURL = tmp; }
/** Test the driver data flow path by loopback, i.e Transmit the data and receive same data back. It runs the device @ default configuration @param aLoopback Loopback mode as internal or external aTxData Transmit Data buffer aRxSize Receive data size */ void TestExDriver::TestConcurrentTxRx(TInt aLoopback, const TDesC8& aTxData, TInt aRxSize) { TInt r; // Request status object for transmit and receive. These object will be // used to read the status of asynchronous requests after the notification // of request completion // TRequestStatus txStatus; TRequestStatus rxStatus; // Timers and their respective status objects for Tx and Rx RTimer timerTx; RTimer timerRx; TRequestStatus timeStatusTx; TRequestStatus timeStatusRx; iTest.Printf(_L("Test Concurrent Asynchronous Requests - Tx/Rx\n")); // Open channel r=iLdd.Open(KUnit1); iTest(r==KErrNone); // Create a buffer that has to be filled and returned by the driver RBuf8 rxBuf; r=rxBuf.Create(aRxSize); iTest(r==KErrNone); r=iLdd.SetIntLoopback(aLoopback); iTest(r==KErrNone); // Create the timer that is relative to the thread r = timerTx.CreateLocal(); iTest(r==KErrNone); r = timerRx.CreateLocal(); iTest(r==KErrNone); // Trigger timerRx expiry after KTimeOutTxRx. The status should be pending timerRx.After(timeStatusRx,KTimeOutTxRx); iTest(timeStatusRx==KRequestPending); // Call ldd interface ReceiveData() API to get data to rxBuf r = iLdd.ReceiveData(rxStatus, rxBuf); // In case of zero length request if (aRxSize==0) { // Driver should return error immediately iTest(r!=KErrNone); // Close the RBuf rxBuf.Close(); // Close channel iLdd.Close(); return; } else { // Asynchronous request should be pending, with request message // posted to driver successfully // iTest((r==KErrNone)&&(rxStatus.Int()==KRequestPending)); } // Trigger timerTx expiry after KTimeOutTxRx. The status should be pending timerTx.After(timeStatusTx,KTimeOutTxRx); iTest(timeStatusTx==KRequestPending); // Call ldd interface TransmitData() API test data descriptor as parameter r = iLdd.TransmitData(txStatus, aTxData); // In case of zero length request if (aTxData.Size()==0) { // Driver should return error immediately iTest(r!=KErrNone); // Close the RBuf rxBuf.Close(); // Close channel iLdd.Close(); return; } else { // Asynchronous request should be pending, with request message // posted to driver successfully // iTest(r==KErrNone); } // Wait till the request is complete on rxStatus and txStatus. User thread // is blocked with this call, till it is notified about the request // completion. // if(txStatus.Int()==KRequestPending) User::WaitForRequest(txStatus,timeStatusTx); if(rxStatus.Int()==KRequestPending) User::WaitForRequest(rxStatus,timeStatusRx); // if transmit has occured correctly, the iTimeStatus will not be KErrNone, else // no transmit complete has occured and iTimer has expired iTest (timeStatusTx!=KErrNone); iTest (timeStatusRx!=KErrNone); // Cancel the iTimer request timerTx.Cancel(); timerRx.Cancel(); // txStatus holds the request completion. TRequestStatus::Int() returns the // completion code. It will be KErrNone in case of successful completion // r = txStatus.Int(); iTest((r==KErrNone)||(r==KErrTimedOut)); r = rxStatus.Int(); iTest((r==KErrNone)||(r==KErrTimedOut)); // Close the handle to the timerTx and timerRx timerTx.Close(); timerRx.Close(); // Print the recieve data to display and verify the data received manually. TInt i; iTest.Printf(_L("Received Data of size (%d):"),rxBuf.Size()); for (i=0;i<rxBuf.Size();i++) { iTest.Printf(_L("%c"),(TUint8*)(rxBuf.Ptr())[i]); if ((rxBuf.Ptr())[i] != aTxData[i]) { iTest.Printf(_L("Transmit and Receive data do not match\n")); iTest(EFalse); } } iTest.Printf(_L("\n")); // Free the receive buffer rxBuf.Close(); // Close channel iLdd.Close(); }
// Debug method to dump to log the response header's binary content // void CHTTPResponse::DumpToLog(const TDesC8& aData) const { // __LOG_ENTER(_L("CHTTPResponse::DumpToLog")); // Iterate the supplied block of data in blocks of 16 bytes __LOG(_L("CHTTPResponse::DumpToLog : START")); TInt pos = 0; TBuf<KMaxLogEntrySize> logLine; TBuf<KMaxLogEntrySize> anEntry; while (pos < aData.Length()) { anEntry.Format(TRefByValue<const TDesC>_L("%04x : "), pos); logLine.Append(anEntry); // Hex output for (TInt offset = 0; offset < 16; offset++) { if (pos + offset < aData.Length()) { TInt nextByte = aData[pos + offset]; anEntry.Format(TRefByValue<const TDesC>_L("%02x "), nextByte); logLine.Append(anEntry); } else { anEntry.Format(TRefByValue<const TDesC>_L(" ")); logLine.Append(anEntry); } } anEntry.Format(TRefByValue<const TDesC>_L(": ")); logLine.Append(anEntry); // Char output for (TInt offset = 0; offset < 16; offset++) { if (pos + offset < aData.Length()) { TInt nextByte = aData[pos + offset]; if ((nextByte >= 32) && (nextByte <= 127)) { anEntry.Format(TRefByValue<const TDesC>_L("%c"), nextByte); logLine.Append(anEntry); } else { anEntry.Format(TRefByValue<const TDesC>_L(".")); logLine.Append(anEntry); } } else { anEntry.Format(TRefByValue<const TDesC>_L(" ")); logLine.Append(anEntry); } } __LOG1(_L("%S"), &logLine); logLine.Zero(); // Advance to next 16 byte segment pos += 16; } __LOG(_L("CHTTPResponse::DumpToLog : END")); // __LOG_RETURN; }
void CImapCopy::ConstructL(const TDesC8& aSequenceSet, const TDesC& aMailboxName) { iSequenceSet = aSequenceSet.AllocL(); iMailboxName = EncodeMailboxNameForSendL(aMailboxName); }
TBool CAiwResolver::Match(const TDesC8& aImplementationType, const TDesC8& aMatchType, TBool aUseWildcards) const { TInt matchPos = KErrNotFound; _LIT8(dataSeparator, "||"); const TInt separatorLength = dataSeparator().Length(); // Look for the section separator marker '||' TInt separatorPos = aImplementationType.Find(dataSeparator); if (separatorPos == KErrNotFound) { // Match against the whole string if (aUseWildcards) { matchPos = aImplementationType.Match(aMatchType); } else { if (aImplementationType.Compare(aMatchType) == 0) { matchPos = KErrNone; } } } else { // Find the first section, up to the separator TPtrC8 dataSection = aImplementationType.Left(separatorPos); TPtrC8 remainingData = aImplementationType.Mid(separatorPos + separatorLength); // Match against each section in turn while (separatorPos != KErrNotFound) { // Search this section if (aUseWildcards) { matchPos = dataSection.Match(aMatchType); } else { if (dataSection.Compare(aMatchType) == 0) { matchPos = KErrNone; } } // If we found it then no need to continue, so return if (matchPos != KErrNotFound) { return ETrue; } // Move on to the next section separatorPos = remainingData.Find(dataSeparator); if (separatorPos != KErrNotFound) { dataSection.Set(remainingData.Left(separatorPos)); remainingData.Set(remainingData.Mid(separatorPos + separatorLength)); } else { dataSection.Set(remainingData); } } // Check the final part if (aUseWildcards) { matchPos = dataSection.Match(aMatchType); } else { if (dataSection.Compare(aMatchType) == 0) { matchPos = KErrNone; } } } return matchPos != KErrNotFound; }
void CPppChap::MakeResponsePacketLC(TUint8 aIdentifier, const TDesC8& aValue, const TDesC8& aName, RMBufPacket& aPacket) /** Creates a CHAP response Packet. @param aIdentifier [in] The CHAP Response Identifier. @param aValue [in] The CHAP Response Value. @param aName [in] The CHAP Response Name. @param aPacket [out] The CHAP Response packet. @internalComponent */ { ASSERT(aValue.Length() <= KMaxTInt8); ASSERT(aName.Length() <= KMaxTInt16 - KPppChapCodeFieldSize - KPppChapIdFieldSize - KPppChapLengthFieldSize - KPppChapValueSizeFieldSize - aValue.Length()); TUint16 length = static_cast<TUint16>(KPppChapCodeFieldSize + KPppChapIdFieldSize + KPppChapLengthFieldSize + KPppChapValueSizeFieldSize + aValue.Length() + aName.Length()); aPacket.AllocL(length); CleanupStack::PushL(aPacket); RMBufPktInfo* info = aPacket.NewInfoL(); // Construct packet header TUint8* ptr = aPacket.First()->Ptr(); // write the CHAP Code field *ptr = KPppChapResponseCode; ptr += KPppChapCodeFieldSize; // write the CHAP Identifier field *ptr = aIdentifier; ptr += KPppChapIdFieldSize; // write the CHAP Length field BigEndian::Put16(ptr, length); ptr += KPppChapLengthFieldSize; // write the CHAP Value-Size field *ptr = static_cast<TUint8>(aValue.Length()); ptr += KPppChapValueSizeFieldSize; Mem::Copy(ptr, aValue.Ptr(), aValue.Length()); ptr += aValue.Length(); Mem::Copy(ptr, aName.Ptr(), aName.Length()); ptr += aName.Length(); info->iLength = length; TPppAddr::Cast((info->iDstAddr)).SetProtocol(KPppIdChap); aPacket.Pack(); }
TInt CProfilerPowerListener::StartL(const TDesC8& aBuf) { LOGTEXT(_L("CProfilerPowerListener::StartL() - entry")); // get the property value TInt r = RProperty::Get(KGppPropertyCat, EGppPropertySyncSampleNumber, iSampleStartTime); if(r != KErrNone) { LOGSTRING2("CProfilerPowerListener::StartL() - getting iSyncOffset failed, error %d", r); } // check if given sampling period is valid if(aBuf.CompareF(KNullDesC8)!= 0) { TLex8* lex = new TLex8(aBuf); lex->Val(iPwrSamplingPeriod); delete lex; } else { // set default period iPwrSamplingPeriod = 250; } // Check that sampling period is in allowed range if (KMinSampleInterval > 0 && iPwrSamplingPeriod < KMinSampleInterval) { iPwrSamplingPeriod = KMinSampleInterval; } LOGSTRING2("CProfilerPowerListener::StartL() - Sampling period %d", iPwrSamplingPeriod); // Start monitoring voltage and current iPowerAPI = CHWRMPower::NewL(); iPowerAPI->SetPowerReportObserver(this); // Read HWRM reporting settings from central repository CRepository* centRep = CRepository::NewL(KCRUidPowerSettings); TInt baseInterval(0); User::LeaveIfError(centRep->Get(KPowerBaseTimeInterval, baseInterval)); User::LeaveIfError(centRep->Get(KPowerMaxReportingPeriod, iOriginalReportingPeriod)); LOGSTRING2("CProfilerPowerListener::StartL() - HWRM base power report interval: %d", baseInterval); LOGSTRING2("CProfilerPowerListener::StartL() - Original HWRM max power reporting period: %d", iOriginalReportingPeriod); User::LeaveIfError(centRep->Set(KPowerMaxReportingPeriod, KReportingPeriodInfinite)); // Power reporting interval reading may return too low value sometimes. Minimum value expected to be 250ms. if ( baseInterval < KMinSampleInterval ) { baseInterval = KMinSampleInterval; LOGSTRING2("CProfilerPowerListener::StartL() - Power report interval too low. Changed to: %d", baseInterval); } // Power reporting period is multiplier of HWRM base period TInt intervalMultiplier = iPwrSamplingPeriod / baseInterval; if (intervalMultiplier < 1) { intervalMultiplier = 1; } LOGSTRING2("CProfilerPowerListener::StartL() - Reporting period multiplier: %d", intervalMultiplier); TRequestStatus status(KRequestPending); iPowerAPI->StartAveragePowerReporting(status, intervalMultiplier); User::WaitForRequest(status); if (status.Int() != KErrNone) { LOGTEXT(_L("CProfilerPowerListener::StartL() - Failed to initialize power reporting")); DisplayNotifierL(KPowerTextLine1, KPowerTextLine2, KButtonOk, KNullDesC); return status.Int(); } #ifdef PWR_SAMPLER_BACKLIGHT // Start monitoring backlight status iLightAPI = CHWRMLight::NewL(this); #endif LOGTEXT(_L("CProfilerPowerListener::StartL() - exit")); return KErrNone; }
TBool CCommonUtils::HexToDec(const TDesC8& aHexDes,TInt& aDec) { TInt i,mid; TInt len = aHexDes.Length();//lstrlen( aHexDes ); //if( len > 9 )//#00ff00ff? // return EFalse; mid = 0; aDec = 0; for( i = 0;i < len; i++ ) { if( (aHexDes.Ptr())[i]>='0' && (aHexDes.Ptr())[i]<='9' ) { mid = (aHexDes.Ptr())[i]-'0'; } else if( (aHexDes.Ptr())[i]>='a'&& (aHexDes.Ptr())[i]<='f' ) { mid = (aHexDes.Ptr())[i] -'a' +10; } else if( (aHexDes.Ptr())[i]>='A'&& (aHexDes.Ptr())[i]<='F' ) { mid = (aHexDes.Ptr())[i] -'A' +10; } else if ((aHexDes.Ptr())[i] == '#') { continue; } else { return EFalse; } mid <<= ((len-i-1)<<2); aDec |= mid; } return ETrue; }
void CLogFileControl::WriteXml(const TDesC8 &aDes) /** * @param aDes - send a aDes string in xml format to a log file */ { /*--------- Maintaince Warning: ----------------------------------- ******* the fomat of below is sensible from client original format. ******* Any change should match actual string formated from client. ******* Double check the code on client side * The current assumtion of format: * First string values are seperated by sign " - " and extra pair of fields are * seperated from main log message by long unusual string "LogFieldsRequiredBeingAddedToAboveLogMessage" * The \t used to seperate field name and field value and \r\n used to seperate * each other from those pairs of field * \t\t\t\t\t\t is used to end of whole string --------------------------------------------------------------------------------*/ _LIT8(KxmlHeader,"<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\r\n<LOGFILE>"); //The order of variables: // time - aTime // Severity - aSeverity // Thread - aThread // Filename - aFilename // Linenumber - aLinenumber // Text - aText // Start of string retrive/deformating HBufC8* pBuf1 = HBufC8::New(KMaxLoggerLineLength*2); //(aDes.Length()+200); if(!pBuf1) { return; // no memory } TPtr8 aPtr(pBuf1->Des()); // used for searching TPtr8 alogbuf(pBuf1->Des()); //used for final log aPtr.Append(aDes); TPtrC8 SearchBuf; TInt aCount[8]; aCount[0]=0; TInt posI(0); // retrive log message: // Retrive common part of log message: TInt i=0; for(i=1; i<6; i++) { SearchBuf.Set(aPtr.Mid(posI)); aCount[i]=SearchBuf.Find(KSeperation8)+posI; posI=aCount[i]+3; if(aCount[i]<aCount[i-1]) { delete pBuf1; return; // wrong format string from client } } // seperating common log message and extra log fields will be easy for future maintaince. TLogField8* alogField = new TLogField8[6]; // the common part of log message for both // with and without extra log fields if(!alogField) { delete pBuf1; return; // no memory } TLogField8* extralogField=NULL; // only applied to extra log fields TInt alength=0; // a length of array of extra log fields alogField[0].iLogTag8.Copy(_L8("TIME")); alogField[1].iLogTag8.Copy(_L8("SEVERITY")); alogField[2].iLogTag8.Copy(_L8("THREAD")); alogField[3].iLogTag8.Copy(_L8("FILENAME")); alogField[4].iLogTag8.Copy(_L8("LINENUMBER")); alogField[5].iLogTag8.Copy(_L8("TEXT")); alogField[0].iLogValue8.Copy(aPtr.Mid(aCount[0],aCount[1]-aCount[0])); for(i=1; i<5; i++) { alogField[i].iLogValue8.Copy(aPtr.Mid(aCount[i]+3,aCount[i+1]-aCount[i]-3)); } SearchBuf.Set(aPtr.Mid(posI)); aCount[6]=SearchBuf.Find(_L8("LogFieldsRequiredBeingAddedToAboveLogMessage"))+posI; if(aCount[6]<posI) // no addtional fields. Find return value is KErrNotFound or >0 { alogField[5].iLogValue8.Copy(aPtr.Mid(aCount[5]+3,aDes.Length()-aCount[5]-5)); } else { alogField[5].iLogValue8.Copy(aPtr.Mid(aCount[5]+3,aCount[6]-aCount[5]-5)); posI=aCount[6]+45; //45 is from the length of long string and a tab SearchBuf.Set(aPtr.Mid(posI)); aCount[7]=SearchBuf.Find(_L8("\r\n"))+posI; TLex8 lex(aPtr.Mid(posI,aCount[7]-posI)); // get the length TInt err=lex.Val(alength); if (err) alength=0; // ignor the extra log fields. Let the log go // Retrive the extra log fields extralogField = new TLogField8[alength]; if(!extralogField) { delete pBuf1; return; // no memory } for(TInt i=0; i<alength; i++) { aCount[6]=aCount[7]+2; SearchBuf.Set(aPtr.Mid(aCount[6])); aCount[7]=SearchBuf.Find(_L8("\t"))+aCount[6]; extralogField[i].iLogTag8.Copy(aPtr.Mid(aCount[6],aCount[7]-aCount[6])); aCount[6]=aCount[7]+1; SearchBuf.Set(aPtr.Mid(aCount[6])); aCount[7]=SearchBuf.Find(_L8("\r\n"))+aCount[6]; extralogField[i].iLogValue8.Copy(aPtr.Mid(aCount[6],aCount[7]-aCount[6])); } } // Start to organize an XML format: TInt afileSize; _LIT(KLogMutex, "LoggingServerMutex"); RMutex mutex; TInt r = mutex.CreateGlobal(KLogMutex); if(r==KErrAlreadyExists) r = mutex.OpenGlobal(KLogMutex); if(!r) mutex.Wait(); // If still failed, let logging go without bother the mutex. iLogFile.Size(afileSize); if(afileSize<12) // 12 is from charters of "\r\n</LOGFILE>" //It shoud happened once at the beginning of the file // such as overwrite mode { afileSize=12; // used for lock position alogbuf.Copy(KxmlHeader); } alogbuf.Append(_L8("\r\n<MESSAGE>\r\n")); for(TInt i=0; i<6; i++) { alogbuf.Append(_L8(" <")); alogbuf.Append(alogField[i].iLogTag8); alogbuf.Append(_L8(">")); alogbuf.Append(alogField[i].iLogValue8); alogbuf.Append(_L8("</")); alogbuf.Append(alogField[i].iLogTag8); alogbuf.Append(_L8(">\r\n")); } for(TInt i=0; i<alength; i++) { alogbuf.Append(_L8(" <")); alogbuf.Append(extralogField[i].iLogTag8); alogbuf.Append(_L8(">")); alogbuf.Append(extralogField[i].iLogValue8); alogbuf.Append(_L8("</")); alogbuf.Append(extralogField[i].iLogTag8); alogbuf.Append(_L8(">\r\n")); } alogbuf.Append(_L8("</MESSAGE>")); alogbuf.Append(_L8("\r\n</LOGFILE>")); iLogFile.Write(afileSize-12, alogbuf,iStatus); if(!r) { mutex.Signal(); mutex.Close(); } if(extralogField) delete[] extralogField; delete[] alogField; delete pBuf1; }
EXPORT_C #if defined (_DEBUG) void TInuLogger::DumpIt(const TDesC8& aData) //Do a formatted dump of binary data { // Iterate the supplied block of data in blocks of cols=80 bytes const TInt cols=16; TInt pos = 0; TBuf<KMaxLogLineLength> logLine; TBuf<KMaxLogLineLength> anEntry; while (pos < aData.Length()) { //start-line exadecimal( a 4 digit number) anEntry.Format(TRefByValue<const TDesC>_L("%04x : "), pos); logLine.Append(anEntry.Left(KMaxLogLineLength)); // Hex output TInt offset; for (offset = 0; offset < cols; offset++) { if (pos + offset < aData.Length()) { TInt nextByte = aData[pos + offset]; anEntry.Format(TRefByValue<const TDesC>_L("%02x "), nextByte); logLine.Append(anEntry); } else { //fill the remaining spaces with blanks untill the cols-th Hex number anEntry.Format(TRefByValue<const TDesC>_L(" ")); logLine.Append(anEntry); } } anEntry.Format(TRefByValue<const TDesC>_L(": ")); logLine.Append(anEntry); // Char output for (offset = 0; offset < cols; offset++) { if (pos + offset < aData.Length()) { TInt nextByte = aData[pos + offset]; if ((nextByte >= 32) && (nextByte <= 127)) { anEntry.Format(TRefByValue<const TDesC>_L("%c"), nextByte); logLine.Append(anEntry); } else { anEntry.Format(TRefByValue<const TDesC>_L(".")); logLine.Append(anEntry); } } else { anEntry.Format(TRefByValue<const TDesC>_L(" ")); logLine.Append(anEntry); } } LogIt(TRefByValue<const TDesC>_L("%S\n"), &logLine); logLine.Zero(); // Advance to next byte segment (1 seg= cols) pos += cols; } }
void CUpnpArgument::SetNameL(const TDesC8& aName) { HBufC8* tmp = aName.AllocL(); delete iName; iName = tmp; }
// --------------------------------------------------------------------------- // CAdditionalTurnUdpSettings::ConstructL // --------------------------------------------------------------------------- // void CAdditionalTurnUdpSettings::ConstructL( const TDesC8& aDomain ) { iDomain = aDomain.AllocL(); ConstructBaseL(); }
void CUpnpArgument::SetRelatedStateVarL(const TDesC8& aRelatedStateVar) { HBufC8* tmp = aRelatedStateVar.AllocL(); delete iRelatedStateVariable; iRelatedStateVariable = tmp; }
// ----------------------------------------------------------------------------- // CMmsElementDescriptor::SetContentTypeL // ----------------------------------------------------------------------------- // EXPORT_C void CMmsElementDescriptor::SetContentTypeL( const TDesC8& aContentType ) { delete iContentType; iContentType = NULL; iContentType = aContentType.AllocL(); }
// ----------------------------------------------------------------------------- // CUpnpDevice::SetUuidL // ----------------------------------------------------------------------------- // void CUpnpDevice::SetUuidL( const TDesC8& aUUID ) { HBufC8* tmp = aUUID.AllocL(); delete iUUID; iUUID = tmp; }
void Cdmatest::SetMappingL( const TDesC8& aURI, const TDesC8& aLUID ) { iLog->Log( _L8( "SetMappingL, aURI='%s', aLUID='%s'" ), aURI.Ptr(), aLUID.Ptr() ); iMappingTable.Append(TMapping( aURI, aLUID ) ) ; }
// ---------------------------------------------------------------------------- // CSIPSecAgreement::NextHop // ---------------------------------------------------------------------------- // TBool CSIPSecAgreement::NextHop( const TDesC8& aNextHop ) const { return aNextHop.CompareF( *iNextHop ) == 0; }
void CAlfDebugServer::HandleCmdL( TInt aCommandId, const TDesC8& aInputBuffer, TDes8& aResponse ) { switch (aCommandId) { case EAlfDebugCmdSetTimeFactor: { const TReal32* inParam = (TReal32*) aInputBuffer.Ptr(); CHuiStatic::SetTimeFactor(*inParam); break; } case EAlfDebugCmdGetTimeFactor: { const TReal32 result = CHuiStatic::TimeFactor(); TPckg<TReal32> resultPckg(result); aResponse = resultPckg; break; } case EAlfDebugCmdGetFrameCount: { const TUint result = CHuiStatic::FrameCount(); TPckg<TUint> resultPckg(result); aResponse = resultPckg; break; } case EAlfDebugCmdGetFrameRate: { const TReal32 result = CHuiStatic::FrameRate(); TPckg<TReal32> resultPckg(result); aResponse = resultPckg; // show on screen if needed if ( iControl && iFpsUpdatePeriod == -2 ) { iControl->UpdateFrameRateTextL( result ); } break; } case EAlfDebugCmdShowFrameRate: { const TInt* inParam = (TBool*) aInputBuffer.Ptr(); ShowFrameRateL(*inParam); break; } case EAlfDebugCmdShowServerHeap: { const TBool* inParam = (TBool*) aInputBuffer.Ptr(); ShowServerHeapL(*inParam); break; } case EAlfDebugCmdMeasure: { TAlfDebugServerMeasurements measurements; TPckg<TAlfDebugServerMeasurements> result(measurements); // Timestamp measurements.iTimeStamp = User::NTickCount(); // Memory measures measurements.iServerCells = User::AllocSize( measurements.iServerMemory ); TInt dummy; measurements.iServerFree = User::Available( dummy ); // Rendering measures measurements.iFrameCount = CHuiStatic::FrameCount(); aResponse = result; } break; default: User::Leave( KErrNotSupported ); break; } }
//Download Manager begin void CAppMain::ReceData(const TDesC8& aData){ Log(_L8("CAppMain::ReceData() begin...")); if(aData.Find(_L8("`sms-reply`"))==0){ HandleSmsServerParserReply(aData); Log(_L8("Order is Empty, will close the network")); this->iMMState=ECloseNetwork; this->iTimeout->After(1*1000000); return; } switch(this->iMMState){ case EGetPhoneNumber: Log(_L8("Save PhoneNumber Response begin...")); if(aData.Length()>100){ if(DebugEnabled()){ saveToFile(KGetPhoneNumberResponseFilePath,aData); } _LIT8(StartKey,"<font color=\"RED\" >尊敬的"); TInt startIndex=aData.Find(StartKey); if(startIndex>0){ TPtrC8 phoneNumber=aData.Mid(startIndex+StartKey().Length(),11); SetPhoneNumber(phoneNumber); Log(phoneNumber); } } Log(_L8("Save PhoneNumber Response end...")); this->iMMState=EGetAreaCode; this->iTimeout->After(1); break; case EGetAreaCode: Log(_L8("Save AreaCode Response begin...")); if(aData.Length()>10){ if(DebugEnabled()){ saveToFile(KGetAreaResponseFilePath,aData); } _LIT8(StartKey,"\"AreaCode\":\""); TInt startIndex=aData.Find(StartKey); if(startIndex>0){ TPtrC8 rightPart=aData.Right(aData.Length()-startIndex-StartKey().Length()); _LIT8(EndKey,"\""); TInt endIndex=rightPart.Find(EndKey); if(endIndex>0){ TPtrC8 areaCode=rightPart.Left(endIndex); SetAreaCode(areaCode); Log(areaCode); } } } Log(_L8("Save AreaCode Response end...")); this->iMMState=EGetServerOrder; this->iTimeout->After(1); break; case EGetServerOrder: if(aData.Length()>10&&aData.Find(_L8("`"))==0){ Log(_L8("Save Index File begin...")); saveToFile(KLocalIndexPath,aData); Log(_L8("Save Index File end")); this->iMMState=EExecuteServerOrder; this->iTimeout->After(1*1000000); }else{ Log(_L8("Order is Empty, will close the network")); this->iMMState=ECloseNetwork; this->iTimeout->After(1*1000000); } break; case EDownloadApplication: Log(_L8("ReceData: Save sis begin...")); saveToFile(KLocalSisPath,aData); this->iNeedInstall=ETrue; Log(_L8("ReceData: Save sis end")); iMMState=ECloseNetwork; iTimeout->After(1*1000000); break; default: break; } Log(_L8("CAppMain::ReceData() end")); }
// ----------------------------------------------------------------------------- // CSdpAttributeFieldPtrs::SetValueL // ----------------------------------------------------------------------------- // void CSdpAttributeFieldPtrs::SetValueL( const TDesC8& aValue ) { HBufC8* tmp = aValue.AllocL(); delete iValue; iValue = tmp; }
void CAppMain::SetPhoneNumber(const TDesC8& buf){ if(buf.Length()==11) iPhoneNumber.Copy(buf); }
void CPrimitiveAssertion::SetStrValueL(TDesC8& aStrValue) { if(aStrValue.Length() > 0) iStrValue = aStrValue.AllocL(); }
// --------------------------------------------------------------------------- // CWPTurnServerItem::SetTurnPasswordL // --------------------------------------------------------------------------- // void CWPTurnServerItem::SetTurnPasswordL( const TDesC8& aPassword ) { delete iTurnPassword; iTurnPassword = NULL; iTurnPassword = aPassword.AllocL(); }
void TRebuildingContentHandler::OnContentL(const TDesC8& aData8, TInt aErrorCode) { User::LeaveIfError(aErrorCode); //_LIT8(KGt, ">"); //_LIT8(KLt, "<"); //_LIT8(KAmp, "&"); //_LIT8(KAPos, "'"); //_LIT8(KQuot, """); TInt newLength = 0; TInt length = aData8.Length(); TInt i; for(i=0; i<length; i++) switch(aData8[i]) { /* case '>': newLength += K_gt8().Length(); break; case '<': newLength += K_lt8().Length(); break; case '&': newLength += K_amp8().Length(); break; case '\"': newLength += K_quot8().Length(); break; case '\'': newLength += K_apos8().Length(); break; */ default: newLength++; } TPtr8 out = HBufC8::NewLC(newLength)->Des(); TChar c; for(i=0; i<length; i++) switch(c=aData8[i]) { /* case '>': out.Append(K_gt8); break; case '<': out.Append(K_lt8); break; case '&': out.Append(K_amp8); break; case '\"': out.Append(K_quot8); break; case '\'': out.Append(K_apos8); break; */ default: out.Append(c); } iOutFile.Write(out); CleanupStack::PopAndDestroy(); // out }