Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

this is my code::::::

 

boolean geturlforbanner(AEEApplet *pApplet,CNetwork * pNetwork){  //WebAllocations(pApplet,1); CAPP *pMe = (CAPP*)pApplet; pNetwork= (CNetwork*) MALLOC(sizeof(CNetwork)*512);

 // char *banbuf;// banbuf=MALLOC(512 *sizeof(char));// pNetwork->m_pszURL=MALLOC(512 *sizeof(char));// banbuf=urlbanner;// DBGPRINTF(banbuf);// STRCPY(pNetwork->m_pszURL,banbuf);

 ISHELL_CreateInstance(pApplet->m_pIShell,AEECLSID_WEB, (void**)&pNetwork->m_pIWeb);

// pMe->ban=1; CALLBACK_Init(&pNetwork->m_Callback, receivebanner_buff, pApplet);  IWEB_GetResponse(pNetwork->m_pIWeb,  (pNetwork->m_pIWeb, &pNetwork->m_pIWebResp,   &pNetwork->m_Callback,   urlbanner,     WEBOPT_END));

 //DBGPRINTF(&pNetwork->m_pIWebResp); // m_pWebRespInfo = IWEBRESP_GetInfo(pNetwork->m_pIWebResp);// receive(CApp *pMe); return TRUE;

  }

boolean receivebanner_buff(CNetwork * pNetwork,AEEApplet *pApplet){

 CAPP *pMe = (CAPP*)pApplet;  int MEMORYCHUNK; char fbuf[2048];     int byteCount; WebRespInfo* m_pWebRespInfo= NULL;// WebRespInfo* m_pWebRespInfo = IWEBRESP_GetInfo(pNetwork->m_pIWebResp); //pNetwork= (CNetwork*) MALLOC(sizeof(CNetwork)*512); MEMORYCHUNK=0;

 m_pWebRespInfo = IWEBRESP_GetInfo(pNetwork->m_pIWebResp);////ISOURCE_Read(m_pWebRespInfo->pisMessage,pMe->Buffer,11000);

//// pMe->Buffer=0;// m_pWebRespInfo =MALLOC (512);

     if(!m_pWebRespInfo){return(FALSE);} 

 if(m_pWebRespInfo && WEB_ERROR_SUCCEEDED(m_pWebRespInfo->nCode)) {

    ISource* m_pISource = m_pWebRespInfo->pisMessage;  /*ISHELL_CreateInstance(pMe->pIshell,AEECLSID_SOURCE,(void**)&pMe->pISource);*/  byteCount = ISOURCE_Read(m_pISource, fbuf, sizeof(fbuf));      switch (byteCount)   {       case ISOURCE_WAIT:          ISOURCE_Readable(m_pISource,&pNetwork->m_Callback);         return TRUE;   case ISOURCE_ERROR: // Error occurred ProcessError(¡­);        case ISOURCE_END:       IDISPLAY_ClearScreen(pMe->m_pIDisplay);           IDISPLAY_Update (pMe->m_pIDisplay);        Display_Image(pMe);           return TRUE;        default:     if(byteCount>0)    {     IDISPLAY_DrawText(pMe->m_pIDisplay,AEE_FONT_BOLD,L"Downloading Image...",-1,0,0,NULL,IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE);      IDISPLAY_Update(pMe->m_pIDisplay);       //if((byteCount ) > (MEMORYCHUNK -pMe->BPos))     {       MEMORYCHUNK+=byteCount;       pMe->Buffer=(byte*)REALLOC(pMe->Buffer,MEMORYCHUNK);     }         MEMCPY(pMe->Buffer+pMe->BPos,fbuf,byteCount);    DBGPRINTF(" pMe->Buffer+pMe->BPos==%s",pMe->Buffer+pMe->BPos);         DBGPRINTF(" Bpos==%d==",pMe->BPos);             pMe->BPos += byteCount;    }    ISOURCE_Readable(m_pISource,&pNetwork->m_Callback);       return TRUE;

  }   }

 

 return FALSE; }

 

 

from the first function ::geturlforbanner... the get the following values  mentioned below:::

&pNetwork->m_Callback==0x00f3c800

pNetwork->m_pIWeb==0x00f3c7f8

pNetwork==0x00f3c7f8

&pNetwork->m_pIWebResp==0x003c7fc

 

but when i enter the second function receivebanner_buff " i get access violation at the line "::::

""" m_pWebRespInfo = IWEBRESP_GetInfo(pNetwork->m_pIWebResp);  """"

so plz give me solution asap so that i can allocate a value to m_pWebResInfo

 

Thanks in advance :::rohanc

 

the problem is in your code:-
 
CALLBACK_Init(&pNetwork->m_Callback, receivebanner_buff, pApplet); 
you pass a AEEApplet* pApplet here as pData to be received in the callback.
 
When the function receivebanner_buff(CNetwork * pNetwork,AEEApplet *pApplet) would be called
pNetwork would actually be a pointer to AEEApplet*, hence the code crashes.
___
correct should way should be:
 
CALLBACK_Init(&pNetwork->m_Callback, receivebanner_buff, pNetwork);  where pNetwork is CNetwork* in your case.
receivebanner_buff function should be declared as :
void receivebanner_buff(CNetwork *pNetwork);
 
it should work after making these changes.

 
 

the problem is in your code:-
 
CALLBACK_Init(&pNetwork->m_Callback, receivebanner_buff, pApplet); 
you pass a AEEApplet* pApplet here as pData to be received in the callback.
 
When the function receivebanner_buff(CNetwork * pNetwork,AEEApplet *pApplet) would be called
pNetwork would actually be a pointer to AEEApplet*, hence the code crashes.
___
correct should way should be:
 
CALLBACK_Init(&pNetwork->m_Callback, receivebanner_buff, pNetwork);  where pNetwork is CNetwork* in your case.
receivebanner_buff function should be declared as :
void receivebanner_buff(CNetwork *pNetwork);
 
it should work after making these changes.

 
 

I have done the changes as you said, now the code is working fine.
thanks shivendra ... 

I have done the changes as you said, now the code is working fine.
thanks shivendra ...