download 2 files after a key is pressed | developer.brewmp.com download 2 files after a key is pressed | developer.brewmp.com

Developer

download 2 files after a key is pressed

Forums:

Hi,

How do I download 2 files after a key is pressed? I can download one file with connection to IWEB_GetResponse(). I want the application to continue downloading the second file after the first file download is completed. What should I change?

CALLBACK_Init(&pApp->m_Network->m_Callback, WebReadCB, pApp);

IWEB_GetResponse(pApp->m_Network->m_pIWeb,(pApp->m_Network->m_pIWeb,
&pApp->m_Network->m_pIWebResp, &pApp->m_Network->m_Callback,
pApp->m_CCApp->m_cotentTag[1].thumbnailCombineURL, WEBOPT_HANDLERDATA, pApp,
WEBOPT_HEADER, "X-Method: GET\r\n",WEBOPT_END));

IWEB_GetResponse(pApp->m_Network->m_pIWeb,(pApp->m_Network->m_pIWeb,
&pApp->m_Network->m_pIWebResp, &pApp->m_Network->m_Callback,
pApp->m_CCApp->m_cotentTag[1].downloadCombineURL, WEBOPT_HANDLERDATA, pApp,
WEBOPT_HEADER, "X-Method: GET\r\n",
WEBOPT_HEADERHANDLER, WebAction_Header,WEBOPT_END));

Thank you.

when you get ISOURCE_END in your callback (pApp->m_Network->m_Callback), make your second call to IWEB_GetResponse()..
in other words, once the first download is finished, make the second download.. i dont think you can do simultaneous downloads.
-Tyndal

when you get ISOURCE_END in your callback (pApp->m_Network->m_Callback), make your second call to IWEB_GetResponse()..
in other words, once the first download is finished, make the second download.. i dont think you can do simultaneous downloads.
-Tyndal

tyndal wrote:when you get ISOURCE_END in your callback (pApp->m_Network->m_Callback), make your second call to IWEB_GetResponse()..
in other words, once the first download is finished, make the second download.. i dont think you can do simultaneous downloads.
-Tyndal
Do you mean inside the codes I showed? Or, inside the webReadCB function? Because it only downloads one file, regardless the second IWEB_GetResponse() I put in there. How do you restart the connection and download the second file? How do you pass back ISOURCE_END back in CALLBACK_Init()?
Please give me an exact location and some pointers, thank you.
case ISOURCE_END:
if (pApp->m_Network->m_BodySize < pApp->m_Network->m_BodyAllocSize)
pApp->m_Network->m_BodyBuffer[pApp->m_Network->m_BodySize] = 0;
else
pApp->m_Network->m_BodyBuffer[pApp->m_Network->m_BodyAllocSize - 1] = 0;
if (pApp->m_Network->m_BodyBuffer) {
if(pApp->m_CCApp->m_pIFileMgr)
{
IFILEMGR_Release(pApp->m_CCApp->m_pIFileMgr);
pApp->m_CCApp->m_pIFileMgr = NULL;
}
if(pApp->m_CCApp->m_pIFileMgr==NULL)
if (ISHELL_CreateInstance(pApp->m_Applet.m_pIShell, AEECLSID_FILEMGR, (void **)(&pApp->m_CCApp->m_pIFileMgr)) == !SUCCESS)
return;
else
{
if (pApp->m_CCApp->m_cotentTag[1].downloadOrder == FALSE)
// if (pApp->m_CCApp->m_eAppState == APP_STATE_SECTION)
SPRINTF(filename, "%s/%s", MP_MEDIA_DIR, "MVI.wmv");
else if (pApp->m_CCApp->m_cotentTag[1].downloadOrder == TRUE)
SPRINTF(filename, "%s/%s", MP_MEDIA_DIR, "MVI.jpg");
else
SPRINTF(filename, "%s/%s", MP_MEDIA_DIR, "catalog.xml");
if ((pIFile = IFILEMGR_OpenFile(pApp->m_CCApp->m_pIFileMgr, filename, _OFM_CREATE)) == NULL)
{
IFILEMGR_Release(pApp->m_CCApp->m_pIFileMgr);
pApp->m_CCApp->m_pIFileMgr = NULL;
return;
}
IFILE_Write(pIFile, pApp->m_Network->m_BodyBuffer, pApp->m_Network->m_BodySize);
IFILE_Release(pIFile);
}
}

tyndal wrote:when you get ISOURCE_END in your callback (pApp->m_Network->m_Callback), make your second call to IWEB_GetResponse()..
in other words, once the first download is finished, make the second download.. i dont think you can do simultaneous downloads.
-Tyndal
Do you mean inside the codes I showed? Or, inside the webReadCB function? Because it only downloads one file, regardless the second IWEB_GetResponse() I put in there. How do you restart the connection and download the second file? How do you pass back ISOURCE_END back in CALLBACK_Init()?
Please give me an exact location and some pointers, thank you.
case ISOURCE_END:
if (pApp->m_Network->m_BodySize < pApp->m_Network->m_BodyAllocSize)
pApp->m_Network->m_BodyBuffer[pApp->m_Network->m_BodySize] = 0;
else
pApp->m_Network->m_BodyBuffer[pApp->m_Network->m_BodyAllocSize - 1] = 0;
if (pApp->m_Network->m_BodyBuffer) {
if(pApp->m_CCApp->m_pIFileMgr)
{
IFILEMGR_Release(pApp->m_CCApp->m_pIFileMgr);
pApp->m_CCApp->m_pIFileMgr = NULL;
}
if(pApp->m_CCApp->m_pIFileMgr==NULL)
if (ISHELL_CreateInstance(pApp->m_Applet.m_pIShell, AEECLSID_FILEMGR, (void **)(&pApp->m_CCApp->m_pIFileMgr)) == !SUCCESS)
return;
else
{
if (pApp->m_CCApp->m_cotentTag[1].downloadOrder == FALSE)
// if (pApp->m_CCApp->m_eAppState == APP_STATE_SECTION)
SPRINTF(filename, "%s/%s", MP_MEDIA_DIR, "MVI.wmv");
else if (pApp->m_CCApp->m_cotentTag[1].downloadOrder == TRUE)
SPRINTF(filename, "%s/%s", MP_MEDIA_DIR, "MVI.jpg");
else
SPRINTF(filename, "%s/%s", MP_MEDIA_DIR, "catalog.xml");
if ((pIFile = IFILEMGR_OpenFile(pApp->m_CCApp->m_pIFileMgr, filename, _OFM_CREATE)) == NULL)
{
IFILEMGR_Release(pApp->m_CCApp->m_pIFileMgr);
pApp->m_CCApp->m_pIFileMgr = NULL;
return;
}
IFILE_Write(pIFile, pApp->m_Network->m_BodyBuffer, pApp->m_Network->m_BodySize);
IFILE_Release(pIFile);
}
}

How do I register a new callback? I need some code sample. Thank you.
CALLBACK_Init(&pApp->m_Network->m_Callback, WebReadCB, pApp);
IWEB_GetResponse(pApp->m_Network->m_pIWeb,(pApp->m_Network->m_pIWeb,
&pApp->m_Network->m_pIWebResp, &pApp->m_Network->m_Callback,
pApp->m_CCApp->m_cotentTag[1].thumbnailCombineURL, WEBOPT_HANDLERDATA, pApp,
WEBOPT_HEADER, "X-Method: GET\r\n",WEBOPT_END));
what do I change here to register a new callback?
CALLBACK_Init(&pApp->m_Network->m_Callback, WebReadCB, pApp);
IWEB_GetResponse(pApp->m_Network->m_pIWeb,(pApp->m_Network->m_pIWeb,
&pApp->m_Network->m_pIWebResp, &pApp->m_Network->m_Callback,
pApp->m_CCApp->m_cotentTag[1].downloadCombineURL, WEBOPT_HANDLERDATA, pApp,
WEBOPT_HEADER, "X-Method: GET\r\n",
WEBOPT_HEADERHANDLER, WebAction_Header,WEBOPT_END));

How do I register a new callback? I need some code sample. Thank you.
CALLBACK_Init(&pApp->m_Network->m_Callback, WebReadCB, pApp);
IWEB_GetResponse(pApp->m_Network->m_pIWeb,(pApp->m_Network->m_pIWeb,
&pApp->m_Network->m_pIWebResp, &pApp->m_Network->m_Callback,
pApp->m_CCApp->m_cotentTag[1].thumbnailCombineURL, WEBOPT_HANDLERDATA, pApp,
WEBOPT_HEADER, "X-Method: GET\r\n",WEBOPT_END));
what do I change here to register a new callback?
CALLBACK_Init(&pApp->m_Network->m_Callback, WebReadCB, pApp);
IWEB_GetResponse(pApp->m_Network->m_pIWeb,(pApp->m_Network->m_pIWeb,
&pApp->m_Network->m_pIWebResp, &pApp->m_Network->m_Callback,
pApp->m_CCApp->m_cotentTag[1].downloadCombineURL, WEBOPT_HANDLERDATA, pApp,
WEBOPT_HEADER, "X-Method: GET\r\n",
WEBOPT_HEADERHANDLER, WebAction_Header,WEBOPT_END));

Have a class which wraps around http code(Iweb interface). Create multiple instance of this class for multiple simultaneous http request. Depending upon your phone, number of sockets vary. Some phone supports 5/6 simultaneous socket.
You are using pApp->m_Network->m_pIWeb sequentially twice to get simultaneously download. Since you are using same pointer, your second request will overwrite the first one and you will have memory leak.

Have a class which wraps around http code(Iweb interface). Create multiple instance of this class for multiple simultaneous http request. Depending upon your phone, number of sockets vary. Some phone supports 5/6 simultaneous socket.
You are using pApp->m_Network->m_pIWeb sequentially twice to get simultaneously download. Since you are using same pointer, your second request will overwrite the first one and you will have memory leak.

ruben wrote:Have a class which wraps around http code(Iweb interface). Create multiple instance of this class for multiple simultaneous http request. Depending upon your phone, number of sockets vary. Some phone supports 5/6 simultaneous socket.
You are using pApp->m_Network->m_pIWeb sequentially twice to get simultaneously download. Since you are using same pointer, your second request will overwrite the first one and you will have memory leak.
Thanks a lot. Do you have a code example of this? I just want to see how this works in implementation.

ruben wrote:Have a class which wraps around http code(Iweb interface). Create multiple instance of this class for multiple simultaneous http request. Depending upon your phone, number of sockets vary. Some phone supports 5/6 simultaneous socket.
You are using pApp->m_Network->m_pIWeb sequentially twice to get simultaneously download. Since you are using same pointer, your second request will overwrite the first one and you will have memory leak.
Thanks a lot. Do you have a code example of this? I just want to see how this works in implementation.

It is rather straight forward. Your network request class header can be something like this,
class NetworkHttpRequest
{
public:
typedef struct _WebReq
{
IWeb *m_pIWeb;// BREW web interface support
IWebResp*m_pIWebResp;// BREW web transaction response interface
AEECallbackm_WebCallBack; // Callback pointer for IWEB interface
WebReq, *WebReqPtr;
void RequestURL();
static void RequestURLCallback();
void CancelURLRequest();
private:
WebReq m_WebReq;
;
Now have multiple instance of NetworkHttpRequest class for your multiple simultaneous download.

It is rather straight forward. Your network request class header can be something like this,
class NetworkHttpRequest
{
public:
typedef struct _WebReq
{
IWeb *m_pIWeb;// BREW web interface support
IWebResp*m_pIWebResp;// BREW web transaction response interface
AEECallbackm_WebCallBack; // Callback pointer for IWEB interface
WebReq, *WebReqPtr;
void RequestURL();
static void RequestURLCallback();
void CancelURLRequest();
private:
WebReq m_WebReq;
;
Now have multiple instance of NetworkHttpRequest class for your multiple simultaneous download.