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 inte易做图ce
IShell *pIShell; // give a standard way to access the Shell inte易做图ce
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);
}
希望个位高手 指点一下 到底是哪里出了问题 --------------------编程问答-------------------- .... 你的IP地址不对,你也没有代理! --------------------编程问答-------------------- 是不是请求没有发送正确?需要通过错误信息来判读哪里的原因 --------------------编程问答-------------------- 最近研究这个
我猜大概是你的默认网络链接设置的问题(默认或者是第一个)
不能用ctwap和cmwap,需要用net之类的apn --------------------编程问答-------------------- 这类问题我遇到过的,我以前一直返回失败,你是在模拟器上还是在真机上测试, --------------------编程问答-------------------- 返回的错误值是多少? --------------------编程问答-------------------- 我也有类似的错误:
在网络连接的WebCbk()回调函数中调用pInfo = IWEBRESP_GetInfo(pMe->pWebResp);然后WEB_ERROR_SUCCEEDED(pInfo->nCode)判断错误为:WebResponse Error: -1285。
我查了aeeerror.h后对应的错误提示是:#define WEB_ERROR_UNSUPSCHEME (WEB_ERROR_BASE+5) /* unsupported scheme, no handler found */
在网上搜索unsupported scheme得到:Each handler knows how to open URLs for a particular URL scheme (http, ftp, etc.),
估计和协议有关吧。
因为是在回调函数中调用I接口,好像没办法trace再跟踪了,查看ppp log也没任何网络连接记录,但通过浏览器可打开我们的目标网址。我们想不到其他方法了,各位大侠帮忙啊
--------------------编程问答-------------------- 顶一个 --------------------编程问答-------------------- 我也出现过 -1285 的错误。
出现这个的情况是 URL 写的不对,也许是服务器没有打开,或者是参数传错了。
另外,IWEB_GetResponse 的参数设置也会引起这个错误。
这样写试试:
IWEB_GetResponse(pMe->m_pWeb,
(pMe->m_pWeb, &(pMe->m_pWebResp), &(pMe->callback),pMe->m_pUrl,
WEBOPT_CONNECTTIMEOUT, 5000,
WEBOPT_METHOD,"POST",
WEBOPT_END)); --------------------编程问答-------------------- llfshow 说得对, 这个的情况是 URL 写的不对,也许是服务器没有打开,或者是参数传错了 --------------------编程问答-------------------- 留名关注后续 --------------------编程问答-------------------- IHTMLViewer 本身具有上网下载内容的功能,不必使用IWEB_GetResponse去下载。
如果使用外网,有一个关键环节是设置ctwap 网关。
补充:移动开发 , Brew