Hi,
My code ia as follows
where iRLbsimage is a RFile obj....Code:void CTRM_SymbianClientEngine::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent &aEvent) { switch(aEvent.iStatus) { case THTTPEvent::EGotResponseHeaders: { _LIT(KA13,"Response text from MHFRunL->EGotResponseHeaders"); ((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KA13); RHTTPResponse resp = aTransaction.Response(); TBuf<30> buf; buf.Copy(resp.StatusText().DesC()); ((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(buf); } break; case THTTPEvent::EGotResponseBodyData: { _LIT(KA14,"Response text from MHFRunL->EGotResponseBodyData"); ((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KA14); MHTTPDataSupplier* body=aTransaction.Response().Body(); TPtrC8 dataChunk; TBool isLast=body->GetNextDataPart(dataChunk); TInt aPos=0; if(iMhfState==0) { _LIT(KA15,"before seek iMhfState==0"); ((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KA15); iRLbsImage.Seek(ESeekCurrent,aPos); _LIT(KK," before write"); ((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KK); iRLbsImage.Write(dataChunk); _LIT(KA17,"after write"); ((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KA17); } if(iMhfState==1) { if(dataChunk.Length()) { //iRLbsImage.Seek(ESeekStart,0); _LIT(KK," before write iMhfState==1"); ((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KK); iRLbsImage.Write(0,dataChunk); _LIT(KA17,"after write"); ((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KA17); iMhfState=0; } else { _LIT(RR," empty datachunk"); ((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(RR); } } body->ReleaseData(); } break; case THTTPEvent::EResponseComplete: { _LIT(KA15,"Response text from MHFRunL->EResponseComplete"); ((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KA15); } break; case THTTPEvent::ESucceeded: { _LIT(KA16,"Response text from MHFRunL->ESucceeded"); ((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KA16); aTransaction.Close(); TInt er=iRLbsImage.Flush(); if(er==KErrNone) { _LIT(RR1," No err in flushig file"); ((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(RR1); } else { _LIT(RR2,"err in flushing file"); ((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(RR2); } iRLbsImage.Close(); iMhfState=1; //set image CTRM_SymbianReadImageFromRFileConvertToBitmap* iImgConverter=CTRM_SymbianReadImageFromRFileConvertToBitmap::NewL(); iAppView->SetImgConverter(iImgConverter); iImgConverter->ConvertFileToBitMap(KTxtFileName);//pass file name } break; case THTTPEvent::EFailed: { _LIT(KA17,"Response text from MHFRunL->EFailed"); ((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KA17); //((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KA16); aTransaction.Close(); } break; default: { _LIT(KA18,"Response text from MHFRunL->default"); ((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KA18); if(aEvent.iStatus<0) { aTransaction.Close(); } else { // Other events are not errors (e.g. permanent and temporary // redirections) } } break; } }
and its implementation is as follows
Here I guess The reason for crash is as --------Code:void CTRM_SymbianClientEngine::PrepareFileToReceiveGpsImage() { _LIT(KXMLFilePath,"c:\\Data\\Images"); TFileName aGpsImage; aGpsImage.Append(KXMLFilePath); aGpsImage.Append(_L("\\LbsSample.jpg")); TInt i=CCoeEnv::Static()->FsSession().Delete(KXMLFilePath); TInt err=iRLbsImage.Replace(CCoeEnv::Static()->FsSession(),aGpsImage,EFileWrite); if(err==KErrNotFound)//file does not exist - create it { err=iRLbsImage.Create(CCoeEnv::Static()->FsSession(),aGpsImage,EFileWrite); if(err!=KErrNone) { _LIT(KGpsFileNtCreated,"Gps File is not created"); ((CTRM_SymbianAppUi*)(CCoeEnv::Static()->AppUi()))->PrintL(KGpsFileNtCreated); } } }
------------------------------------------------
the "aPos" argument of iRLbsImage.Seek function always points to the last position of the file accessed.
So, in 1 st http request it works fine.
But in case of 2nd one, the APos is required to have value zero. But I guess it actually acquires a value that was the previous position to which it wrote. And starting to write with this value of aPos, the value of aPos soon crosses the max value(that is the allowable size of file). So it crashes. Whether or not the app crashes, my right requirement is that the value of aPos should be zero at this point.
Now I guess, using seek() may not be right issue for me..
Then what function should I select.
As per my requirements
--------------------------
The socket downloads images.
each image comes in 4 parts---
with 4 successive calls to
and finally a call toCode:case THTTPEvent::EGotResponseBodyData: body->GetNextDataPart(dataChunk); body->ReleaseData();
Code:case THTTPEvent::EResponseComplete: where the image download completes.





