// ---------------------------------------------------------------------------- // // ---------------------------------------------------------------------------- // void CWrtHarvester::RemovePublisherAndObserverL( const TDesC& aBundleId ) { if( IsInMSMode() == 1 ) { HBufC *temp = aBundleId.Alloc(); TPtr ptr (temp->Des()); for( TInt i=0; i<iHSWidgets.Count(); i++ ) { if( ptr.Compare(iHSWidgets[i]->Des()) == 0) { return; } } } RemoveObserver( aBundleId ); __UHEAP_MARK; if( iCPSInterface ) { CLiwGenericParamList* inparam = CLiwGenericParamList::NewLC(); CLiwGenericParamList* outparam = CLiwGenericParamList::NewLC(); TLiwGenericParam type( KType, TLiwVariant( KPubData )); inparam->AppendL( type ); CLiwDefaultMap* cpdatamap = CLiwDefaultMap::NewLC(); CLiwDefaultMap* datamap = CLiwDefaultMap::NewLC(); // Create data map cpdatamap->InsertL( KPublisherId, TLiwVariant( KWRTPublisher )); cpdatamap->InsertL( KContentType, TLiwVariant( KTemplatedWidget )); cpdatamap->InsertL( KContentId, TLiwVariant( aBundleId )); cpdatamap->InsertL( KDataMap, TLiwVariant(datamap) ); TLiwGenericParam item( KMyItem, TLiwVariant( cpdatamap )); inparam->AppendL( item ); iCPSInterface->ExecuteCmdL( KMyDelete , *inparam, *outparam); CleanupStack::PopAndDestroy( datamap ); CleanupStack::PopAndDestroy( cpdatamap ); item.Reset(); type.Reset(); CleanupStack::PopAndDestroy(outparam); CleanupStack::PopAndDestroy(inparam); } __UHEAP_MARKEND; }
void CUrl::ConstructL(const TParseBase& aFileName) // // Non-trivial c'tor - used to create Urls for local file space only. NO scheme in aFileName { if( aFileName.IsWild() ) User::Leave(EWapErrCorruptUrl); // Convert Unicode file name into UTF8 format HBufC8* utf8 = ConvertFromUnicodeToUtf8L(aFileName.FullName()); CleanupStack::PushL(utf8); // Convert to 16-bit format HBufC* escapedFullPath = HBufC::NewLC(utf8->Length()); escapedFullPath->Des().Copy(*utf8); // Need to escape encode all the components - start with filename, then path and last the drive TPtr fullPath = escapedFullPath->Des(); if ( fullPath.Compare(KNullDesC) ) { // Convert '\' to '/' then escape encode with EUrlPath - this doesn't encode '/' and ':' for (TInt i=0; i<fullPath.Length(); ++i) { if (fullPath[i] == KPathDelimiter) fullPath[i] = '/'; } escapedFullPath = EscapeEncodeL(fullPath, EUrlPath); CleanupStack::PopAndDestroy(); // escapedFullPath (old version) CleanupStack::PushL(escapedFullPath); // new version // Replace ':' with '|' fullPath.Set(escapedFullPath->Des()); TInt colonPos = fullPath.Locate(KDriveDelimiter); if( colonPos != KErrNotFound ) fullPath[colonPos] = '|'; } // Form the url TInt size = KUrlFileSchemeSignature().Length() + KUrlPathDelimiter().Length() + fullPath.Length(); iUrlDes = HBufC::NewL(size); iUrlDes->Des().Append(KUrlFileSchemeSignature()); iUrlDes->Des().Append(KUrlPathDelimiter()); iUrlDes->Des().Append(fullPath); CleanupStack::PopAndDestroy(2); // escapedFullPath, utf8 }
EXPORT_C TBool CX520AttributeTypeAndValue::ExactMatchL(const CX520AttributeTypeAndValue& aElement) const { TBool res = EFalse; if (*(iType) != *(aElement.iType)) { return res; } HBufC* lhs = this->ValueL(); CleanupStack::PushL(lhs); HBufC* rhs = aElement.ValueL(); TPtr plhs = lhs->Des(); TPtr prhs = rhs->Des(); plhs.TrimAll(); prhs.TrimAll(); // DEF124902: Certificate name matching done in accordance to RFC3280 // RFC3280: Printable String and Email address(of value type 'IA5String') will // be compared case-insensitively. if (IsCaseInSensitiveL(iValue->Des())) { //case insensitive comparison for Printable String and IA5String (EmailAdress only). res = (plhs.CompareF(prhs) == 0); } else { // case-sensitive comparison for strings other than printable string // Exception: This may include IA5Stings other than 'EmailAddress' attiribute types. res = (plhs.Compare(prhs) == 0); } CleanupStack::PopAndDestroy(); delete rhs; return res; }
// --------------------------------------------------------- // CPosTp148::StartL // // (other items were commented in a header). // --------------------------------------------------------- // void CPosTp148::StartL() { BaflUtils::EnsurePathExistsL( iFileSession, KKMZFile ); // Delete the trace file DeleteFileL(KFileTrace); HBufC8* emptyBuffer=NULL; iLog->Log(_L("Test with Tp148KMZFile.kmz")); PrintParsedDataFromEncoderL(KKMZFile, *emptyBuffer, KErrNone, KKmzMimeType ); // Now compare tha trace file against the correct one RFile correctFile; RFile file; iLog->Log(_L(">>>>>>>Comparing files<<<<<")); TFileName filename; CreateCorrectXmlFileL( KCorrectFile, filename ); User::LeaveIfError(correctFile.Open(iFileSession, filename, EFileRead)); CleanupClosePushL(correctFile); User::LeaveIfError(file.Open(iFileSession, KFileTrace, EFileRead)); CleanupClosePushL(file); HBufC* correctLinebuffer = HBufC::NewLC( KBufSize ); TPtr correctLine = correctLinebuffer->Des(); HBufC* linebuffer = HBufC::NewLC( KBufSize ); TPtr line = linebuffer->Des(); TInt err = KErrNone; TBool done = EFalse; TInt lineNr = 0; while (ReadLn(correctFile, correctLine) != KErrEof && !done) { lineNr++; err = ReadLn(file, line); if ( err == KErrEof ) { done = ETrue; } correctLine.Trim(); line.Trim(); if ( correctLine.Compare( line ) != KErrNone ) { HBufC* buf = HBufC::NewLC( 128 ); TPtr buffer = buf->Des(); buffer.Format(_L("ERROR in TraceFile on line %d: "), lineNr); iLog->Log( buffer ); iLog->Log( correctLine ); iLog->Log( line ); iErrorsFound++; CleanupStack::PopAndDestroy( buf ); } } CleanupStack::PopAndDestroy( linebuffer ); CleanupStack::PopAndDestroy( correctLinebuffer ); CleanupStack::PopAndDestroy(&file); CleanupStack::PopAndDestroy(&correctFile); // EOF for trace file was reach before EOF in the correct file if (done) { iLog->Log(_L("ERROR: EOF for Trace file was reached to early")); iErrorsFound++; } DoCancelTestL(); if (iErrorsFound != KErrNone) { iLog->Log(_L("Errors found in TP148")); User::Leave(-1); } }
// ---------------------------------------------------------------------------- // Is called when Homescreen sends events to publisher // ---------------------------------------------------------------------------- // void CWrtHarvester::HandlePublisherNotificationL( const TDesC& aContentId, const TDesC8& aTrigger ) { //Do not send the Operations to the Widgets when in Mass storage mode.. . . if( IsInMSMode() == 1 ) { if(aTrigger == KDeActive) RemovePublisherAndObserverL(aContentId); return; } TUid uid( WidgetUid( aContentId ) ); TWidgetOperations operation( Uninitialized ); if( aTrigger == KActive ) { HBufC* temp = aContentId.Alloc(); iHSWidgets.Append( temp ); iHSCount++; // queue the activated state event only for network accessing widgets if ( CheckNetworkAccessL( uid) ) { TWrtState* widgetState = NULL; widgetState = new TWrtState( uid, EActivatedState ); if ( widgetState ) { iWidgetStateArray.AppendL( widgetState ); } } operation = LaunchMiniview; } else if ( aTrigger == KDeActive ) { iHSCount--; operation = Deactivate; HBufC *temp = aContentId.Alloc(); TPtr ptr (temp->Des()); for( TInt i=0; i<iHSWidgets.Count(); i++ ) { if( ! ptr.Compare(iHSWidgets[i]->Des())) { iHSWidgets.Remove(i); break; } } delete temp; } else if( aTrigger == KSuspend ) { operation = WidgetSuspend; } else if( aTrigger == KResume ) { TInt idx = FindWidget( uid ); // if unable to find the widget, queue the resume as usual if ( idx == -1 ) { QueueResumeL( uid ); } else { iWidgetStateArray[idx]->iState = EResumeState; } return; } else if( aTrigger == KSelected ) { operation = WidgetSelect; } else if( aTrigger == KHSOnline ) { ProcessNetworkModeL( uid, WidgetOnline ); return; } else if( aTrigger == KHSOffline ) { ProcessNetworkModeL( uid, WidgetOffline ); return; } QueueOperationL( operation, uid ); }
void CTestCImPlainTextStore::TestStoreRestore16BitChunkAsyncL() { CreateNewPlaintextMessageL(); CMsvEntry* entry = testUtils->iMsvSession->GetEntryL(newMessageId); CImEmailMessage* imEmailMessage = CImEmailMessage::NewLC(*entry); iCImPlainBodyTextStore = imEmailMessage->OpenPlainBodyTextForWriteL(); iCImPlainBodyTextStore->StoreChunkL(iFilebuf1->Des(),iActiveWaiter->iStatus); iActiveWaiter->WaitActive(); TInt bodyTextSize = iFilebuf1->Length(); iCImPlainBodyTextStore->StoreChunkL(iFilebuf2->Des(),iActiveWaiter->iStatus); iActiveWaiter->WaitActive(); bodyTextSize += iFilebuf2->Length(); iCImPlainBodyTextStore->StoreChunkL(iFilebuf3->Des(),iActiveWaiter->iStatus); iActiveWaiter->WaitActive(); bodyTextSize += iFilebuf3->Length(); iCImPlainBodyTextStore->CommitL(iActiveWaiter->iStatus); iActiveWaiter->WaitActive(); delete iCImPlainBodyTextStore; iCImPlainBodyTextStore = NULL; //Restore the data in chunks. HBufC16* filebuf11 = HBufC16::NewL(100+KTestStringLength); TInt origSize = bodyTextSize; TInt sizeOfRestoredText = 0; TPtr bufPtr = filebuf11->Des(); TInt pos = 0; iCImPlainBodyTextStore = imEmailMessage->OpenPlainBodyTextForReadL(CImEmailMessage::EThisMessageOnly,100); iCImPlainBodyTextStore->NextChunkL(bufPtr,iActiveWaiter->iStatus); iActiveWaiter->WaitActive(); RArray<TPtr> chunkArray; chunkArray.Append(bufPtr); sizeOfRestoredText += bufPtr.Length(); while(bufPtr.Length() > 0 && bufPtr.Length() == 100) { iCImPlainBodyTextStore->NextChunkL(bufPtr,iActiveWaiter->iStatus); iActiveWaiter->WaitActive(); // put retrived buffer in a array. chunkArray.Append(bufPtr); sizeOfRestoredText += bufPtr.Length(); } ASSERT_EQUALS(bodyTextSize, sizeOfRestoredText); for(TInt j=chunkArray.Count() - 1;j >0; --j ) { bufPtr.SetLength(0); iCImPlainBodyTextStore->PreviousChunkL(bufPtr,iActiveWaiter->iStatus); iActiveWaiter->WaitActive(); // Compare chunk retrieved with chunk retrieved by NextChunkL TInt comp = bufPtr.Compare(chunkArray[j-1]); ASSERT_EQUALS(comp, 0); } CleanupStack::PopAndDestroy(imEmailMessage); }
TBool CProfileListDialog::OkToExitL(TInt aButtonId) { TBool okToExit = EFalse; CEikTextListBox *lbox = ((CEikTextListBox*)Control(EProfileListDlgProfileList)); // Buffers for current and new file names and a name HBufC *fileNameBuf = HBufC::NewLC(KMaxFileName); TPtr fileName = fileNameBuf->Des(); HBufC *nameBuf = HBufC::NewLC(KMaxFileName); TPtr name = nameBuf->Des(); switch ( aButtonId ) { case ECmdProfileListConnect: { // Connect to the selected profile TInt sel = lbox->CurrentItemIndex(); if ( sel == KDefaultProfileIndex ) { iProfileFile = iDefaultProfileFile; } else { iProfileFile = iProfileDirectory; iProfileFile.Append((*iProfileArray)[sel]); } okToExit = ETrue; break; } case ECmdProfileListEdit: { // Edit the selected profile TInt sel = lbox->CurrentItemIndex(); if ( sel == KDefaultProfileIndex ) { name = KDefaultProfileName; fileName = iDefaultProfileFile; } else { name = (*iProfileArray)[sel]; fileName = iProfileDirectory; fileName.Append(name); } // Edit settings iPutty->ReadConfigFileL(fileName); Config *cfg = iPutty->GetConfig(); CSettingsDialog *dlg = new (ELeave) CSettingsDialog(name, (sel == KDefaultProfileIndex), cfg, iPutty); switch ( dlg->ExecuteLD(R_SETTINGS_DIALOG) ) { case EEikBidOk: // Handle rename first if ( (sel != KDefaultProfileIndex) && (name.Compare((*iProfileArray)[sel]) != 0) ) { MakeNameLegal(name); // Delete current file so that we can rename to a file // that maps to the same name (e.g. changes in case) User::LeaveIfError( CEikonEnv::Static()->FsSession().Delete(fileName)); MakeNameUniqueL(name); fileName = iProfileDirectory; fileName.Append(name); // Update profile list and listbox iProfileArray->Delete(sel); iProfileArray->InsertL(sel, name); lbox->DrawNow(); } // Just write, the name can be an old one or a renamed one iPutty->WriteConfigFileL(fileName); break; case ECmdSettingsDelete: if ( sel != KDefaultProfileIndex ) { // Remove the profile from the list and update // listbox iProfileArray->Delete(sel); lbox->HandleItemRemovalL(); if ( sel >= iProfileArray->Count() ) { sel = iProfileArray->Count() - 1; } lbox->SetCurrentItemIndexAndDraw(sel); // Delete profile file User::LeaveIfError( CEikonEnv::Static()->FsSession().Delete(fileName)); } break; default: break; } okToExit = EFalse; break; } case ECmdProfileListNew: { // New profile -- start with defaults, but with a new name iPutty->ReadConfigFileL(iDefaultProfileFile); Config *cfg = iPutty->GetConfig(); name = KNewProfileName; MakeNameUniqueL(name); CSettingsDialog *dlg = new (ELeave) CSettingsDialog(name, EFalse, cfg, iPutty); if ( dlg->ExecuteLD(R_SETTINGS_DIALOG) == EEikBidOk ) { // Finalize name MakeNameLegal(name); MakeNameUniqueL(name); fileName = iProfileDirectory; fileName.Append(name); // Update the listbox iProfileArray->AppendL(name); lbox->HandleItemAdditionL(); lbox->SetCurrentItemIndexAndDraw(iProfileArray->Count() - 1); // Write out new settings iPutty->WriteConfigFileL(fileName); } okToExit = EFalse; break; } case ECmdProfileListClose: okToExit = ETrue; break; default: User::Invariant(); } CleanupStack::PopAndDestroy(2); //fileNameBuf, nameBuf return okToExit; }
/** Compares two input files (ASCII & Unicode). @return the error code @param aFileOne - First file @param aFileTwo - Second file @param aIsUnicode - Whether unicode or ascii @param aIgnoreCharList - Ignore characters list @param aDiffFlag - Out parameter ETrue if the files are different @leave KErrNoMemory */ TInt TestFrameworkActionsUtils::CompareFilesL(TPtrC aFileOne, TPtrC aFileTwo, TBool aIsUnicode, CArrayFixFlat<TUint16>* aIgnoreCharList, TBool& aDiffFlag) { // Retern Code TInt retCode = KErrNone; // Streams for the file1 and file2 to compare RFileReadStream fileReadStream1; RFileReadStream fileReadStream2; // Files difference flag aDiffFlag = EFalse; RFs iFs; User::LeaveIfError(iFs.Connect()); // Open file one to compare retCode = fileReadStream1.Open( iFs, aFileOne, EFileShareReadersOnly);//EFileRead); if(retCode == KErrNone) { retCode = fileReadStream2.Open( iFs, aFileTwo, EFileShareReadersOnly);//EFileRead); if(retCode == KErrNone) { // To hold the line content of file one HBufC* lineOneBuffer = HBufC::NewLC(KDefBufferSize); TPtr ptrLineOne = lineOneBuffer->Des(); // To hold the line content of file two HBufC* lineTwoBuffer = HBufC::NewLC(KDefBufferSize); TPtr ptrLineTwo = lineTwoBuffer->Des(); // Eof indicators TBool eofOne = EFalse; TBool eofTwo = EFalse; // Read the file one and file two data do { // Read file one data eofOne = ReadDataL(fileReadStream1, ptrLineOne, aIsUnicode, aIgnoreCharList); // Read file two data eofTwo = ReadDataL(fileReadStream2, ptrLineTwo, aIsUnicode, aIgnoreCharList); // Check EOF state of the files. // Either both the files will be in EOF state or // none of the files will be in EOF state if((!eofOne && !eofTwo)||(eofOne && eofTwo)) { // Compare the read lines from file one and the file two if(ptrLineOne.Compare(ptrLineTwo) != 0) { // Different data content aDiffFlag = ETrue; } } else { //Different EOF aDiffFlag = ETrue; } } while(!eofOne && !eofTwo && !aDiffFlag); // Delete line buffers CleanupStack::PopAndDestroy(2, lineOneBuffer); } } // Close the open streams fileReadStream1.Close(); fileReadStream2.Close(); iFs.Close(); // Return the difference flag return retCode; }
// ----------------------------------------------------------------------------- // CDownloadUtils::ContentTypeL // ----------------------------------------------------------------------------- // HBufC8* CDownloadUtils::ContentTypeL ( RHttpDownload& aDownload, TBool aDrmResolve, TInt mediaObjectIndex ) { CLOG_ENTERFN("CDownloadUtils::ContentTypeL"); HBufC8* retContentType = NULL; TInt32 numMediaObjects = 0; User::LeaveIfError( aDownload.GetIntAttribute( EDlAttrNumMediaObjects, numMediaObjects ) ); if ( aDrmResolve && DrmDownloadL( aDownload ) ) { HBufC* fileName = HBufC::NewLC( KMaxPath ); TPtr fileNamePtr = fileName->Des(); // Check if this is album if ((numMediaObjects > KFirstMoIndex) && mediaObjectIndex) { User::LeaveIfError ( aDownload.GetStringAttribute( EDlAttrDestFilename, mediaObjectIndex, fileNamePtr ) ); } else { User::LeaveIfError ( aDownload.GetStringAttribute( EDlAttrDestFilename, fileNamePtr ) ); } CLOG_WRITE_FORMAT(" EDlAttrDestFilename: %S",&fileNamePtr); if(fileNamePtr.Compare(KNullDesC)) { using namespace ContentAccess; CContent* content(NULL); TRAPD( err, content = CContent::NewL(fileNamePtr,EContentShareReadWrite) ); CleanupStack::PushL(content); /* If file not present CContent::NewL() leaves with KErrNotFound. Need to ignore this error because in case of DRM paused downloads the partial downloaded file will be deleted. */ if(err != KErrNotFound) { User::LeaveIfError( err ); HBufC* mimeType = HBufC::NewL(256); TPtr ptr = mimeType->Des(); TInt fileInfoErr = content->GetStringAttribute(EMimeType,ptr); TBuf8<256> buf8; CnvUtfConverter::ConvertFromUnicodeToUtf8(buf8,ptr); iMimeType = buf8.Alloc(); if ( !fileInfoErr ) { retContentType = iMimeType; iMimeType = NULL; } // Free temp storage delete iMimeType; iMimeType = NULL; delete iContentURI; iContentURI = NULL; } CleanupStack::PopAndDestroy(content); } CleanupStack::PopAndDestroy( fileName ); } // If it's not DRM or it is, but the content type could not been got if ( retContentType == NULL ) { HBufC8* contentType = HBufC8::NewLC( KMaxContentTypeLength ); TPtr8 temp( contentType->Des() ); TInt err = 0; // Check if this is album if ((numMediaObjects > KFirstMoIndex) && mediaObjectIndex) { err = aDownload.GetStringAttribute( EDlAttrContentType, mediaObjectIndex, temp ); } else { err = aDownload.GetStringAttribute( EDlAttrContentType, temp ); } CLOG_WRITE_FORMAT(" err: %d",err); if ( err != KErrNone && err != KErrNotFound ) { User::LeaveIfError( err ); } if ( err == KErrNotFound ) { contentType->Des().Copy( KNullDesC ); } CleanupStack::Pop( contentType ); retContentType = contentType; contentType = NULL; } CLOG_LEAVEFN("CDownloadUtils::ContentTypeL"); return retContentType; }