brew开发浏览器问题
为什么调用 IWEBRESP_GetInfo返回一个失败的东西呢?代码如下:
#include "AEEAppGen.h" // Applet helper file
#include "helloworld.bid" // Applet-specific header that contains class ID
#include "nmdef.h"
#include "AEEWeb.h"
#include "AEEHtmlViewer.h"
typedef struct _helloworld {
AEEApplet a ; // First element of this structure must be AEEApplet
AEEDeviceInfo DeviceInfo; // always have access to the hardware device information
AEECallback cbWeb;
WebRespInfo *pRespInfo;
IWebResp *pIWebResp;
IDisplay *pIDisplay; // give a standard way to access the Display interface
IShell *pIShell; // give a standard way to access the Shell interface
IHtmlViewer *pIHtmlView;
// add your own variables here...
IWeb *pIWeb;
char *buffer;
} helloworld;
/*-------------------------------------------------------------------
Static function prototypes
-------------------------------------------------------------------*/
static boolean HelloWorld_HandleEvent(AEEApplet * pme, AEEEvent eCode,uint16 wParam, uint32 dwParam);
boolean helloworld_InitAppData(helloworld* pMe);
void helloworld_FreeAppData(helloworld* pMe);
static void WebDemo_cbWeb(helloworld *pMe);
static void HtmlViewerNofity(void *p,HViewNotify *pHViewNotify);
void WebDemo_GetPage(helloworld *pMe,char*pUrl);
void JumPage(helloworld *pMe,HViewNotify *pHViewNotify);
int AEEClsCreateInstance(AEECLSID ClsId,IShell * pIShell,IModule * pMod,void ** ppObj)
{
*ppObj = NULL;
if( ClsId == AEECLSID_HELLOWORLD )
{
// Create the applet and make room for the applet structure
if( AEEApplet_New(sizeof(helloworld),
ClsId,
pIShell,
pMod,
(IApplet**)ppObj,
(AEEHANDLER)HelloWorld_HandleEvent,
(PFNFREEAPPDATA)helloworld_FreeAppData) ) // the FreeAppData function is called after sending EVT_APP_STOP to the HandleEvent function
{
if(helloworld_InitAppData((helloworld*)*ppObj))
{
//Data initialized successfully
return(AEE_SUCCESS);
}
else
{
//Release the applet. This will free the memory allocated for the applet when
// AEEApplet_New was called.
IAPPLET_Release((IApplet*)*ppObj);
return EFAILED;
}
} // end AEEApplet_New
}
return(EFAILED);
}
static boolean HelloWorld_HandleEvent(helloworld * pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
AECHAR szText[] = {'H','e','l','l','o',' ','W','o', 'r', 'l', 'd','d', '\0'};
switch (eCode){
case EVT_APP_START:
WebDemo_GetPage(pMe,"http://192.168.1.126:8009/showle/myspace.jsp");
IHTMLVIEWER_SetActive(pMe->pIHtmlView,TRUE);
return(TRUE);
case EVT_APP_STOP:
return(TRUE);
case EVT_KEY:
if (IHTMLVIEWER_HandleEvent(pMe->pIHtmlView,eCode,wParam,dwParam))
return TRUE;
default:
break;
}
return(FALSE);
}
boolean helloworld_InitAppData(helloworld* pMe)
{
int err = 0;
AEERect rect;
pMe->pIDisplay = pMe->a.m_pIDisplay;
pMe->pIShell = pMe->a.m_pIShell;
ISHELL_GetDeviceInfo(pMe->pIShell,&pMe->DeviceInfo);
err = ISHELL_CreateInstance(pMe->pIShell,AEECLSID_WEB,(void **)&pMe->pIWeb);
if(err != SUCCESS)
return FALSE;
err=ISHELL_CreateInstance(pMe->pIShell,AEECLSID_HTML,(void **)&pMe->pIHtmlView);
if(err != SUCCESS)
return FALSE;
CALLBACK_Init(&pMe->cbWeb,WebDemo_cbWeb,pMe);
SETAEERECT(&rect,0,0,pMe->DeviceInfo.cxScreen,pMe->DeviceInfo.cyScreen);
IHTMLVIEWER_SetRect(pMe->pIHtmlView,&rect);
return TRUE;
}
static void WebDemo_cbWeb(helloworld *pMe)
{
char *pData = NULL;
pMe->pRespInfo = IWEBRESP_GetInfo(pMe->pIWebResp); //获取服务器的响应内容 存储在pMe->pRespInfo中
pData = MALLOC(pMe->pRespInfo->lContentLength);
if(WEB_ERROR_SUCCEEDED(pMe->pRespInfo->nCode))
{
ISOURCE_Read(pMe->pRespInfo->pisMessage,pData,pMe->pRespInfo->lContentLength);
IHTMLVIEWER_SetData(pMe->pIHtmlView,pData,pMe->pRespInfo->lContentLength);
IHTMLVIEWER_SetNotifyFn(pMe->pIHtmlView,HtmlViewerNofity,pMe);
}
}
static void HtmlViewerNofity(void *p,HViewNotify *pHViewNotify)
{
int len =-1;
helloworld *pMe = (helloworld *)p;
switch(pHViewNotify->code)
{
case HVN_DONE:
IHTMLVIEWER_Redraw(((helloworld *)pMe)->pIHtmlView);
case HVN_JUMP:
case HVN_SUBMIT:
JumPage(pMe,pHViewNotify);
break;
}
}
void WebDemo_GetPage(helloworld *pMe,char*pUrl)
{
IWEB_GetResponse(pMe->pIWeb,(pMe->pIWeb,&pMe->pIWebResp,&pMe->cbWeb,pUrl/*,WEBOPT_END*/)); //启动一个WEB 访问
}
void helloworld_FreeAppData(helloworld* pMe)
{
IWEB_Release(pMe->pIWeb);
IHTMLVIEWER_Release(pMe->pIHtmlView);
}
void JumPage(helloworld *pMe,HViewNotify *pHViewNotify)
{
int len = STRLEN(pHViewNotify->u.jump.pszURL);
char *pos,*buffer;
buffer = (char *)MALLOC(len);
pMe->buffer = (char *)MALLOC(len);
MEMSET(buffer,0,len);
pos = STRSTR(pHViewNotify->u.jump.pszURL,"http");
MEMCPY(buffer,pos,len-(pos-pHViewNotify->u.jump.pszURL));
{
IWebUtil *piwu;
ISHELL_CreateInstance(pMe->pIShell,AEECLSID_WEBUTIL,(void **)&piwu);
IWEBUTIL_UrlDecode(piwu,buffer,&len,pMe->buffer,&len);
}
IWEBRESP_Release(pMe->pIWebResp);
IWEB_Release(pMe->pIWeb);
ISHELL_CreateInstance(pMe->pIShell,AEECLSID_WEB,(void **)&pMe->pIWeb);
CALLBACK_Init(&pMe->cbWeb,WebDemo_cbWeb,pMe);
WebDemo_GetPage(pMe,pMe->buffer);
}
希望个位高手 指点一下 到底是哪里出了问题