📄 imagetestappui.cpp
字号:
/*
============================================================================
Name : ImageTestAppUi.cpp
Author :
Copyright : Your copyright notice
Description : CImageTestAppUi implementation
============================================================================
*/
// INCLUDE FILES
#include <avkon.hrh>
#include <aknmessagequerydialog.h>
#include <aknnotewrappers.h>
#include <stringloader.h>
#include <f32file.h>
#include <s32file.h>
#include <hlplch.h>
#include <e32des8.h>
#include <ImageTest_0xE99B3F8E.rsg>
#include <STRING.H>
#include <STDIO.H>
#include <REENT.H>
//#include "ImageTest_0xE99B3F8E.hlp.hrh"
#include "ImageTest.hrh"
#include "ImageTest.pan"
#include "ImageTestApplication.h"
#include "ImageTestAppUi.h"
#include "ImageTestAppView.h"
#include "HttpxxxTools.h"
_LIT(KFileName, "C:\\private\\E99B3F8E\\ImageTest.txt");
_LIT(KText, "Hello World!");
// ============================ MEMBER FUNCTIONS ===============================
// -----------------------------------------------------------------------------
// CImageTestAppUi::ConstructL()
// Symbian 2nd phase constructor can leave.
// -----------------------------------------------------------------------------
//
void CImageTestAppUi::ConstructL()
{
// Initialise app UI with standard value.
BaseConstructL(CAknAppUi::EAknEnableSkin);
// Create view object
iAppView = CImageTestAppView::NewL(ClientRect() );
iHttpEngine = CHttpxxxTools::NewL(*this);
}
// -----------------------------------------------------------------------------
// CImageTestAppUi::CImageTestAppUi()
// C++ default constructor can NOT contain any code, that might leave.
// -----------------------------------------------------------------------------
//
CImageTestAppUi::CImageTestAppUi()
{
// No implementation required
}
// -----------------------------------------------------------------------------
// CImageTestAppUi::~CImageTestAppUi()
// Destructor.
// -----------------------------------------------------------------------------
//
CImageTestAppUi::~CImageTestAppUi()
{
if (iAppView)
{
delete iAppView;
iAppView = NULL;
}
if(iHttpEngine)
{
delete iHttpEngine;
iHttpEngine = NULL;
}
CloseSTDLIB();
}
// -----------------------------------------------------------------------------
// CImageTestAppUi::HandleCommandL()
// Takes care of command handling.
// -----------------------------------------------------------------------------
//
void CImageTestAppUi::HandleCommandL(TInt aCommand)
{
switch (aCommand)
{
case EEikCmdExit:
case EAknSoftkeyExit:
Exit();
break;
case ECommand1:
{
char* uril = "http://hair.sg.com.cn/uploadfiles/2009/1/6/200916B1EC3FF600514A538F13F50C611587D9.jpg";
iHttpEngine ->HttpGet(uril);
}
break;
case ECommand2:
{
RFile rFile;
//Open file where the stream text is
User::LeaveIfError(rFile.Open(CCoeEnv::Static()->FsSession(), KFileName, EFileStreamText));//EFileShareReadersOnly));// EFileStreamText));
CleanupClosePushL(rFile);
// copy stream from file to RFileStream object
RFileReadStream inputFileStream(rFile);
CleanupClosePushL(inputFileStream);
// HBufC descriptor is created from the RFileStream object.
HBufC* fileData = HBufC::NewLC(inputFileStream, 32);
CAknInformationNote* informationNote;
informationNote = new ( ELeave ) CAknInformationNote;
// Show the information Note
informationNote->ExecuteLD( *fileData);
// Pop loaded resources from the cleanup stack
CleanupStack::PopAndDestroy(3); // filedata, inputFileStream, rFile
}
break;
case EHelp:
{
CArrayFix<TCoeHelpContext>* buf = CCoeAppUi::AppHelpContextL();
HlpLauncher::LaunchHelpApplicationL(iEikonEnv->WsSession(), buf);
}
break;
case EAbout:
{
CAknMessageQueryDialog* dlg = new (ELeave)CAknMessageQueryDialog();
dlg->PrepareLC(R_ABOUT_QUERY_DIALOG);
HBufC* title = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TITLE);
dlg->QueryHeading()->SetTextL(*title);
CleanupStack::PopAndDestroy(); //title
HBufC* msg = iEikonEnv->AllocReadResourceLC(R_ABOUT_DIALOG_TEXT);
dlg->SetMessageTextL(*msg);
CleanupStack::PopAndDestroy(); //msg
dlg->RunLD();
}
break;
default:
Panic(EImageTestUi);
break;
}
}
// -----------------------------------------------------------------------------
// Called by the framework when the application status pane
// size is changed. Passes the new client rectangle to the
// AppView
// -----------------------------------------------------------------------------
//
void CImageTestAppUi::HandleStatusPaneSizeChange()
{
iAppView->SetRect(ClientRect() );
}
CImageTestAppView* CImageTestAppUi::ReturnContainer()
{
return iAppView;
}
void CImageTestAppUi::WriteDAtaToFile(char* aFileName, char* aFileData, int aFiledDataLenth)
{
FILE *pFile;
//以写方式打开文件
pFile=fopen(aFileName,"wb");
if(pFile)
{
//移动指针到文件头
fseek(pFile,0,SEEK_SET);
//写入数据
fwrite(aFileData,aFiledDataLenth,1,pFile);
//关闭文件
fclose(pFile);
}
}
void CImageTestAppUi::WriteNULL()
{
// char* Ppath = "c:\\Data\\httptest.txt";
// char* pData = "test";
//
// FILE *fFile;
// fFile = fopen(Ppath, "wb");
// fwrite(pData, strlen(pData), 1,fFile);
// fclose(fFile);
}
// End of File
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -