控制循环

sasadouble 2009-09-07 10:21:39
void CCallLogUploadEngine::MHFRunL(RHTTPTransaction aTransaction, const THTTPEvent& aEvent)
{
switch (aEvent.iStatus)
{
case THTTPEvent::EGotResponseHeaders:
{}
break;
case THTTPEvent::EGotResponseBodyData:
{
MHTTPDataSupplier* body = aTransaction.Response().Body();
TPtrC8 dataChunk;
TBool isLast = body->GetNextDataPart(dataChunk);
determine when body is completely

if (isLast)
{
TBuf<256> uri;
uri.Copy(dataChunk);
CAknInformationNote* informationNote;
informationNote = new ( ELeave ) CAknInformationNote;
informationNote->ExecuteLD( uri);

}
body->ReleaseData();
}
break;

case THTTPEvent::EResponseComplete:
{
User::After(2000000);
if ( iApplicationUi )
iApplicationUi->RemoveWaitDialogL();
}
break;

case THTTPEvent::ESucceeded:
{
aTransaction.Close();
iSession.Close();
iRunning = EFalse;

HBufC* textResource = StringLoader::LoadLC(R_COMMAND2_TEXT);
CAknInformationNote* informationNote;
informationNote = new ( ELeave ) CAknInformationNote;
informationNote->ExecuteLD( *textResource);
CleanupStack::PopAndDestroy(textResource);
}
break;

case THTTPEvent::EFailed:
{
aTransaction.Close();
iRunning = EFalse;
}

break;
default:
TBuf<256> text;
if (aEvent.iStatus < 0)
{
aTransaction.Close();
iSession.Close();
iRunning = EFalse;
}
else {
}
}
break;
}
}

这个是上传文件的方法,我想在连接服务器失败的时候,提示重新连接,循环5次,如果还连接不上,提示连接失败,请高手指点~~~
...全文
73 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
sasadouble 2009-09-08
  • 打赏
  • 举报
回复
我想尝试在 default中再次调用dopostL方法,但是程序运行到这里就自动退出了~~,高手帮帮忙!!
sasadouble 2009-09-08
  • 打赏
  • 举报
回复
··建立连接在这里~~~
void CCallLogUploadEngine::doPostL(const TDesC8& aUri, const TDesC8& aContentType, const TDesC8& aIMEI)
{
Uri = aUri;
ContentType = aContentType;
IMEI = aIMEI;
TUriParser8 uri;
User::LeaveIfError(uri.Parse(aUri));
RFs aFs;
RFile aFile;
User::LeaveIfError(aFs.Connect());
_LIT(KLogFile,"C:\\Data\\CallLog.txt");
User::LeaveIfError(aFile.Open(aFs, KLogFile, EFileRead));
TInt iSize;
User::LeaveIfError(aFile.Size(iSize));
HBufC8* heapBuf = HBufC8::NewL(iSize);
TPtr8 aPtr = heapBuf->Des();
aFile.Read(0, aPtr, iSize);
aFile.Close();
aFs.Close();
_LIT8(KDataStart,"--AaB03x");
_LIT8(KCrlf,"\r\n");
_LIT8(KContent,"Content-Disposition: form-data; name=\"CallLog\"; filename=\"");
_LIT8(KFilePath,"C:\\Data\\CallLog.txt");
_LIT8(KFileCompletion,"\"");
_LIT8(KContent2,"Content-Type: text/plain");
_LIT8(KDataEnd,"--AaB03x--");
iPostData = HBufC8::NewL(650+aPtr.Length());
TPtr8 iPostDataPtr = iPostData->Des();
iPostDataPtr.Zero();
iPostDataPtr.Append(KCrlf);
iPostDataPtr.Append(KDataStart);
iPostDataPtr.Append(KCrlf);
iPostDataPtr.Append(KContent);
iPostDataPtr.Append(KFilePath);
iPostDataPtr.Append(KFileCompletion);
iPostDataPtr.Append(KCrlf);
iPostDataPtr.Append(KContent2);
iPostDataPtr.Append(KCrlf);
iPostDataPtr.Append(KCrlf);
iPostDataPtr.Append(aPtr); //the file in binary
iPostDataPtr.Append(KCrlf);
iPostDataPtr.Append(KDataEnd);
iPostDataPtr.Append(KCrlf);
RStringF method = iSession.StringPool().StringF(HTTP::EPOST, RHTTPSession::GetTable());
iTransaction = iSession.OpenTransactionL(uri, *this, method);
RHTTPHeaders hdr = iTransaction.Request().GetHeaderCollection();
SetHeaderL(hdr, HTTP::EUserAgent, KUserAgent);
SetHeaderL(hdr, HTTP::EAccept, KAccept);
SetHeaderL(hdr, HTTP::EContentType, aContentType);
MHTTPDataSupplier* dataSupplier = this;
iTransaction.Request().SetBody(*dataSupplier);
iTransaction.SubmitL();
}
  • 打赏
  • 举报
回复
在那里重新建立连接的呢?

3,119

社区成员

发帖
与我相关
我的任务
社区描述
塞班系统(Symbian系统)是塞班公司为手机而设计的操作系统,它的前身是英国宝意昂公司的 EP ( Electronic Piece of cheese)操作系统。
社区管理员
  • Symbian社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧