How to make the background application still download file(using IWeb through HTTP) | developer.brewmp.com How to make the background application still download file(using IWeb through HTTP) | developer.brewmp.com

Developer

How to make the background application still download file(using IWeb through HTTP)

Forums:

hi,guys,could you tell any mistakes I maybe had made in the code?
I just want to make the application running background(quit BREW environment) hold on downloading file by CDMA 1X.

please do me a favor,thank you very much

/*===========================================================================

FILE: bgApp.c
===========================================================================*/

/*===============================================================================
INCLUDES AND VARIABLE DEFINITIONS
=============================================================================== */
#include "AEEModGen.h" // Module interface definitions
#include "AEEAppGen.h" // Applet interface definitions
#include "AEEShell.h" // Shell interface definitions
#include "AEEMenu.h"
#include "AEEWeb.h"
#include "AEEStdLib.h"
#include "AEEFile.h"
#include "AEETapi.h"
#include "bgApp_res.h"

#include "bgApp.bid"

/*-------------------------------------------------------------------
Applet structure. All variables in here are reference via "pMe->"
-------------------------------------------------------------------*/
// create an applet structure that's passed around. All variables in
// here will be able to be referenced as static.
typedef struct _bgApp {
AEEApplet a ; // First element of this structure must be AEEApplet
AEEDeviceInfo DeviceInfo; // always have access to the hardware device information
IDisplay *pIDisplay; // give a standard way to access the Display interface
IShell *pIShell; // give a standard way to access the Shell interface

// add your own variables here...
boolean m_bGoBg; // the flag running background
AEECallback m_cbMainTimer;

boolean m_bVideoCompletedDL; // flag completely download
IWeb* m_pDownIWeb;
IWebResp* m_pDownIWebResp;
AEECallback m_DownCallback;
WebRespInfo *m_pwri;
IFileMgr* m_pIFileMgr;
IFile* m_pIFile;

ITAPI* m_pITapi;

} bgApp;

/*-------------------------------------------------------------------
Function Prototypes
-------------------------------------------------------------------*/
static boolean bgApp_HandleEvent(bgApp* pMe,
AEEEvent eCode, uint16 wParam,
uint32 dwParam);
boolean bgApp_InitAppData(bgApp* pMe);
void bgApp_FreeAppData(bgApp* pMe);
static void CBTimer(bgApp* pMe);
//static void TimerCB(bgApp* pMe);
boolean bgApp_HttpDownload(bgApp* pMe);
static void HttpDownloadCB(void* cxt);
void HttpDownloadCleanup(bgApp* pMe);

/*===============================================================================
FUNCTION DEFINITIONS
=============================================================================== */

/*===========================================================================
FUNCTION: AEEClsCreateInstance
===========================================================================*/
int AEEClsCreateInstance(AEECLSID ClsId, IShell *pIShell, IModule *po, void **ppObj)
{
*ppObj = NULL;

if( ClsId == AEECLSID_BGAPP )
{
// Create the applet and make room for the applet structure
if( AEEApplet_New(sizeof(bgApp),
ClsId,
pIShell,
po,
(IApplet**)ppObj,
(AEEHANDLER)bgApp_HandleEvent,
(PFNFREEAPPDATA)bgApp_FreeAppData) ) // the FreeAppData function is called after sending EVT_APP_STOP to the HandleEvent function

{
//Initialize applet data, this is called before sending EVT_APP_START
// to the HandleEvent function
if(bgApp_InitAppData((bgApp*)*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);

/*===========================================================================
FUNCTION SampleAppWizard_HandleEvent
===========================================================================*/
static boolean bgApp_HandleEvent(bgApp* pMe, AEEEvent eCode, uint16 wParam, uint32 dwParam)
{
AECHAR szText[] = {'D','o','w','n','l','o','a','d','e','d','\0'};
switch (eCode)
{
// App is told it is starting up
case EVT_APP_START:
{
if (!pMe->m_bVideoCompletedDL) {
DBGPRINTF("set timer");
CALLBACK_Init(&pMe->m_cbMainTimer, CBTimer, pMe);
ISHELL_SetTimerEx(pMe->pIShell, 3000, &pMe->m_cbMainTimer); // bgApp_HttpDownload(pMe);
}else {
IDISPLAY_ClearScreen(pMe->pIDisplay);
IDISPLAY_DrawText(pMe->pIDisplay,
AEE_FONT_BOLD,
szText,
-1,
0,
0,
NULL,
IDF_ALIGN_CENTER | IDF_ALIGN_MIDDLE);
IDISPLAY_Update (pMe->pIDisplay);
}
}
return(TRUE);

// App is told it is exiting
case EVT_APP_STOP:
// Add your code here...
if (pMe->m_bGoBg) {
*((boolean*)dwParam) = FALSE;
}
DBGPRINTF("OK");
return(TRUE);

// App is being suspended
case EVT_APP_SUSPEND:
// Add your code here...

return(TRUE);

// App is being resumed
case EVT_APP_RESUME:
// Add your code here...

return(TRUE);

// An SMS message has arrived for this app. Message is in the dwParam above as (char *)
// sender simply uses this format "//BREW:ClassId:Message", example //BREW:0x00000001:Hello World
case EVT_APP_MESSAGE:
// Add your code here...

return(TRUE);

// A key was pressed. Look at the wParam above to see which key was pressed. The key
// codes are in AEEVCodes.h. Example "AVK_1" means that the "1" key was pressed.
case EVT_KEY:
// Add your code here...
switch(wParam) {
case AVK_CLR:
ISHELL_CloseApplet(pMe->a.m_pIShell, FALSE);
break;
default:
break;
}
return(TRUE);

// If nothing fits up to this point then we'll just break out
default:
break;
}

return FALSE;

static void CBTimer(bgApp* pMe)
{
TAPIStatus ps;
if (ISHELL_CreateInstance(pMe->pIShell, AEECLSID_TAPI, (void **)&pMe->m_pITapi) != SUCCESS) {
DBGPRINTF("create m_pITapi failed");
}
if (ITAPI_GetStatus(pMe->m_pITapi, &ps) == SUCCESS) {
DBGPRINTF("before bg AEEPhoneState=%d", ps.state);
}else{
DBGPRINTF("L230 ITAPI GetStatus failed");
}
CALLBACK_Cancel(&pMe->m_cbMainTimer);
pMe->m_bGoBg = TRUE;
if (pMe->m_bGoBg) { ISHELL_CloseApplet(pMe->pIShell, FALSE);// don't quit the BREW environment,the application can hold on downloading,use CLR or END to quit the BREW environment,the application stop downloading. ISHELL_CloseApplet(pMe->pIShell, TRUE);// quit the BREW environment, the application stop downloading,the network is closed.Why?
}
DBGPRINTF("in CBTimer, run in background");

if (ITAPI_GetStatus(pMe->m_pITapi, &ps) == SUCCESS) {
DBGPRINTF("running background AEEPhoneState=%d", ps.state);
}else{
DBGPRINTF("L241 ITAPI GetStatus failed");
}
bgApp_HttpDownload(pMe);
if (ITAPI_GetStatus(pMe->m_pITapi, &ps) == SUCCESS) {
DBGPRINTF("after httpd AEEPhoneState=%d", ps.state);
}else{
DBGPRINTF("L247 ITAPI GetStatus failed");
}

// this function is called when your application is starting up
boolean bgApp_InitAppData(bgApp* pMe)
{
// Get the device information for this handset.
// Reference all the data by looking at the pMe->DeviceInfo structure
// Check the API reference guide for all the handy device info you can get
pMe->DeviceInfo.wStructSize = sizeof(pMe->DeviceInfo);
ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&pMe->DeviceInfo);
// The display and shell interfaces are always created by
// default, so we'll asign them so that you can access
// them via the standard "pMe->" without the "a."
pMe->pIDisplay = pMe->a.m_pIDisplay;
pMe->pIShell = pMe->a.m_pIShell;
// Insert your code here for initializing or allocating resources...
pMe->m_bGoBg = FALSE;
pMe->m_bVideoCompletedDL = FALSE;
// if there have been no failures up to this point then return success
return TRUE;

// this function is called when your application is exiting
void bgApp_FreeAppData(bgApp* pMe)
{
if (pMe->m_pITapi) {
ITAPI_Release(pMe->m_pITapi);
pMe->m_pITapi = NULL;
}
// insert your code here for freeing any resources you have allocated...
HttpDownloadCleanup(pMe);

boolean bgApp_HttpDownload(bgApp* pMe)
{
if (!pMe->m_pDownIWeb) {
if (ISHELL_CreateInstance(pMe->pIShell, AEECLSID_WEB, (void**)(&pMe->m_pDownIWeb)) != SUCCESS)
{
DBGPRINTF("create pMe->m_pDownIWeb failed");
HttpDownloadCleanup(pMe);
return FALSE;
}
DBGPRINTF("create pMe->m_pDownIWeb success");
}
CALLBACK_Init(&pMe->m_DownCallback, HttpDownloadCB, pMe);
IWEB_GetResponse(pMe->m_pDownIWeb, (pMe->m_pDownIWeb, &pMe->m_pDownIWebResp, &pMe->m_DownCallback,
"http://XXX.XXX.XXX.XXX/brew/uni.avi",
WEBOPT_HANDLERDATA, pMe,
WEBOPT_END));
DBGPRINTF("in bgApp_HttpDownload");
return TRUE;

static void HttpDownloadCB(void* cxt)
{
bgApp *pMe = (bgApp*)cxt;
char filename[50] = {0};
char* szName;
int fsize;
int res;
int ByteCount;
char buf[2048];
TAPIStatus ps;
MEMSET(buf, 0, sizeof(buf));
if (!pMe->m_pITapi) {
if (ISHELL_CreateInstance(pMe->pIShell, AEECLSID_TAPI, (void **)&pMe->m_pITapi) != SUCCESS) {
DBGPRINTF("create m_pITapi failed");
}
}
if (ITAPI_GetStatus(pMe->m_pITapi, &ps) == SUCCESS) {
DBGPRINTF("in httpdCB AEEPhoneState=%d", ps.state);
}else{
DBGPRINTF("L330 ITAPI GetStatus failed");
}
pMe->m_pwri = IWEBRESP_GetInfo(pMe->m_pDownIWebResp);
fsize = pMe->m_pwri->lContentLength;
DBGPRINTF("file length=%d", fsize);
if (WEB_ERROR_SUCCEEDED(pMe->m_pwri->nCode)) {
DBGPRINTF("request successful!");
}else{ // failed to connect,then activate the application
res = WEB_ERROR_MAP(pMe->m_pwri->nCode);
DBGPRINTF("%d", res);
DBGPRINTF("request failed %i", pMe->m_pwri->nCode);
if (pMe->m_bGoBg) {
pMe->m_bGoBg = FALSE;
ISHELL_StartApplet(pMe->a.m_pIShell, AEECLSID_BGAPP);
}
IDISPLAY_ClearScreen(pMe->pIDisplay);
}
if ((ISource *)0 != pMe->m_pwri->pisMessage) {
ISource *pISource = pMe->m_pwri->pisMessage;
ByteCount = ISOURCE_Read(pISource, (char *)buf, sizeof(buf));
switch(ByteCount) {
case ISOURCE_WAIT: DBGPRINTF("Waiting to read...");
ISOURCE_Readable(pISource, &pMe->m_DownCallback);
return;
case ISOURCE_ERROR:
DBGPRINTF("ERROR");
break;
case ISOURCE_END: pMe->m_bVideoCompletedDL = TRUE;
DBGPRINTF("Video Completely Download");
// download completely,then activate the application
if (pMe->m_bGoBg) {
pMe->m_bGoBg = FALSE;
ISHELL_StartApplet(pMe->pIShell, AEECLSID_BGAPP);
}
HttpDownloadCleanup(pMe);
break;
default:
DBGPRINTF("Downloading...");
STRCAT(filename, "uni.avi");
if (!pMe->m_pIFileMgr) {
if (ISHELL_CreateInstance(pMe->pIShell, AEECLSID_FILEMGR, (void **)&pMe->m_pIFileMgr) != SUCCESS) {
return;
}
}
if (IFILEMGR_Test(pMe->m_pIFileMgr, filename) != SUCCESS) {
if ((pMe->m_pIFile = IFILEMGR_OpenFile(pMe->m_pIFileMgr, filename, _OFM_CREATE)) == NULL) {
IFILEMGR_Release(pMe->m_pIFileMgr);
pMe->m_pIFileMgr = NULL;
return;
}
}
if (!pMe->m_pIFile){
pMe->m_pIFile = IFILEMGR_OpenFile(pMe->m_pIFileMgr, filename, _OFM_READWRITE);
}
if (IFILE_Seek(pMe->m_pIFile, _SEEK_END, 0) == SUCCESS) {
DBGPRINTF("File seek to end");
}
if (IFILE_Write(pMe->m_pIFile, buf, ByteCount) != ByteCount) {
DBGPRINTF("Write to file failed");
}
ISOURCE_Readable(pISource, &pMe->m_DownCallback);
// ISHELL_Resume(pMe->a.m_pIShell, &pMe->m_DownCallback);
return;
}
}
HttpDownloadCleanup(pMe);
return;

void HttpDownloadCleanup(bgApp* pMe)
{
CALLBACK_Cancel(&pMe->m_DownCallback);
if (pMe->m_pDownIWeb) {
IWEB_Release(pMe->m_pDownIWeb);
pMe->m_pDownIWeb = NULL;
}
if (pMe->m_pDownIWebResp) {
IWEBRESP_Release(pMe->m_pDownIWebResp);
pMe->m_pDownIWebResp = NULL;
}
if (pMe->m_pIFileMgr) {
IFILEMGR_Release(pMe->m_pIFileMgr);
pMe->m_pIFileMgr = NULL;
}
if (pMe->m_pIFile) {
IFILE_Release(pMe->m_pIFile);
pMe->m_pIFile = NULL;
}

/*--------------------------------------------------------------------------------------------------
* file end
*--------------------------------------------------------------------------------------------------*/

// this function is called when your application is starting up
boolean bgApp_InitAppData(bgApp* pMe)
{
// Get the device information for this handset.
// Reference all the data by looking at the pMe->DeviceInfo structure
// Check the API reference guide for all the handy device info you can get
pMe->DeviceInfo.wStructSize = sizeof(pMe->DeviceInfo);
ISHELL_GetDeviceInfo(pMe->a.m_pIShell,&pMe->DeviceInfo);
// The display and shell interfaces are always created by
// default, so we'll asign them so that you can access
// them via the standard "pMe->" without the "a."
pMe->pIDisplay = pMe->a.m_pIDisplay;
pMe->pIShell = pMe->a.m_pIShell;
// Insert your code here for initializing or allocating resources...
pMe->m_bGoBg = FALSE;
pMe->m_bVideoCompletedDL = FALSE;
// if there have been no failures up to this point then return success
return TRUE;

// this function is called when your application is exiting
void bgApp_FreeAppData(bgApp* pMe)
{
if (pMe->m_pITapi) {
ITAPI_Release(pMe->m_pITapi);
pMe->m_pITapi = NULL;
}
// insert your code here for freeing any resources you have allocated...
HttpDownloadCleanup(pMe);

boolean bgApp_HttpDownload(bgApp* pMe)
{
if (!pMe->m_pDownIWeb) {
if (ISHELL_CreateInstance(pMe->pIShell, AEECLSID_WEB, (void**)(&pMe->m_pDownIWeb)) != SUCCESS)
{
DBGPRINTF("create pMe->m_pDownIWeb failed");
HttpDownloadCleanup(pMe);
return FALSE;
}
DBGPRINTF("create pMe->m_pDownIWeb success");
}
CALLBACK_Init(&pMe->m_DownCallback, HttpDownloadCB, pMe);
IWEB_GetResponse(pMe->m_pDownIWeb, (pMe->m_pDownIWeb, &pMe->m_pDownIWebResp, &pMe->m_DownCallback,
"http://XXX.XXX.XXX.XXX/brew/uni.avi",
WEBOPT_HANDLERDATA, pMe,
WEBOPT_END));
DBGPRINTF("in bgApp_HttpDownload");
return TRUE;

static void HttpDownloadCB(void* cxt)
{
bgApp *pMe = (bgApp*)cxt;
char filename[50] = {0};
char* szName;
int fsize;
int res;
int ByteCount;
char buf[2048];
TAPIStatus ps;
MEMSET(buf, 0, sizeof(buf));
if (!pMe->m_pITapi) {
if (ISHELL_CreateInstance(pMe->pIShell, AEECLSID_TAPI, (void **)&pMe->m_pITapi) != SUCCESS) {
DBGPRINTF("create m_pITapi failed");
}
}
if (ITAPI_GetStatus(pMe->m_pITapi, &ps) == SUCCESS) {
DBGPRINTF("in httpdCB AEEPhoneState=%d", ps.state);
}else{
DBGPRINTF("L330 ITAPI GetStatus failed");
}
pMe->m_pwri = IWEBRESP_GetInfo(pMe->m_pDownIWebResp);
fsize = pMe->m_pwri->lContentLength;
DBGPRINTF("file length=%d", fsize);
if (WEB_ERROR_SUCCEEDED(pMe->m_pwri->nCode)) {
DBGPRINTF("request successful!");
}else{ // failed to connect,then activate the application
res = WEB_ERROR_MAP(pMe->m_pwri->nCode);
DBGPRINTF("%d", res);
DBGPRINTF("request failed %i", pMe->m_pwri->nCode);
if (pMe->m_bGoBg) {
pMe->m_bGoBg = FALSE;
ISHELL_StartApplet(pMe->a.m_pIShell, AEECLSID_BGAPP);
}
IDISPLAY_ClearScreen(pMe->pIDisplay);
}
if ((ISource *)0 != pMe->m_pwri->pisMessage) {
ISource *pISource = pMe->m_pwri->pisMessage;
ByteCount = ISOURCE_Read(pISource, (char *)buf, sizeof(buf));
switch(ByteCount) {
case ISOURCE_WAIT: DBGPRINTF("Waiting to read...");
ISOURCE_Readable(pISource, &pMe->m_DownCallback);
return;
case ISOURCE_ERROR:
DBGPRINTF("ERROR");
break;
case ISOURCE_END: pMe->m_bVideoCompletedDL = TRUE;
DBGPRINTF("Video Completely Download");
// download completely,then activate the application
if (pMe->m_bGoBg) {
pMe->m_bGoBg = FALSE;
ISHELL_StartApplet(pMe->pIShell, AEECLSID_BGAPP);
}
HttpDownloadCleanup(pMe);
break;
default:
DBGPRINTF("Downloading...");
STRCAT(filename, "uni.avi");
if (!pMe->m_pIFileMgr) {
if (ISHELL_CreateInstance(pMe->pIShell, AEECLSID_FILEMGR, (void **)&pMe->m_pIFileMgr) != SUCCESS) {
return;
}
}
if (IFILEMGR_Test(pMe->m_pIFileMgr, filename) != SUCCESS) {
if ((pMe->m_pIFile = IFILEMGR_OpenFile(pMe->m_pIFileMgr, filename, _OFM_CREATE)) == NULL) {
IFILEMGR_Release(pMe->m_pIFileMgr);
pMe->m_pIFileMgr = NULL;
return;
}
}
if (!pMe->m_pIFile){
pMe->m_pIFile = IFILEMGR_OpenFile(pMe->m_pIFileMgr, filename, _OFM_READWRITE);
}
if (IFILE_Seek(pMe->m_pIFile, _SEEK_END, 0) == SUCCESS) {
DBGPRINTF("File seek to end");
}
if (IFILE_Write(pMe->m_pIFile, buf, ByteCount) != ByteCount) {
DBGPRINTF("Write to file failed");
}
ISOURCE_Readable(pISource, &pMe->m_DownCallback);
// ISHELL_Resume(pMe->a.m_pIShell, &pMe->m_DownCallback);
return;
}
}
HttpDownloadCleanup(pMe);
return;

void HttpDownloadCleanup(bgApp* pMe)
{
CALLBACK_Cancel(&pMe->m_DownCallback);
if (pMe->m_pDownIWeb) {
IWEB_Release(pMe->m_pDownIWeb);
pMe->m_pDownIWeb = NULL;
}
if (pMe->m_pDownIWebResp) {
IWEBRESP_Release(pMe->m_pDownIWebResp);
pMe->m_pDownIWebResp = NULL;
}
if (pMe->m_pIFileMgr) {
IFILEMGR_Release(pMe->m_pIFileMgr);
pMe->m_pIFileMgr = NULL;
}
if (pMe->m_pIFile) {
IFILE_Release(pMe->m_pIFile);
pMe->m_pIFile = NULL;
}

/*--------------------------------------------------------------------------------------------------
* file end
*--------------------------------------------------------------------------------------------------*/

Is the code right?
anybody can help me?
Thanks

Is the code right?
anybody can help me?
Thanks

I dont see the code for setting the app to background app. I am not sure if you are mentioning about "BREW-BACKGROUP application" or just an logical assumption of the app as bg-app.
The closeapplet with TRUE/FALSE either case means it will close the app. The one will go to OEM(all the way out), the other will go to app list(under brew applications/getitnow....).
If you want to do real bg-app, then look for the document about that.

I dont see the code for setting the app to background app. I am not sure if you are mentioning about "BREW-BACKGROUP application" or just an logical assumption of the app as bg-app.
The closeapplet with TRUE/FALSE either case means it will close the app. The one will go to OEM(all the way out), the other will go to app list(under brew applications/getitnow....).
If you want to do real bg-app, then look for the document about that.

bru wrote:I dont see the code for setting the app to background app. I am not sure if you are mentioning about "BREW-BACKGROUP application" or just an logical assumption of the app as bg-app.
The closeapplet with TRUE/FALSE either case means it will close the app. The one will go to OEM(all the way out), the other will go to app list(under brew applications/getitnow....).
If you want to do real bg-app, then look for the document about that.
Thank you very much for your reply.
you know, the blue font, I set a timer at EVT_APP_START such as:
CALLBACK_Init(&pMe->m_cbMainTimer, CBTimer, pMe);
ISHELL_SetTimerEx(pMe->pIShell, 3000, &pMe->m_cbMainTimer);
then after 3 minutes, the CBTimer would be called.
I used the code to set the applet to running background
CALLBACK_Cancel(&pMe->m_cbMainTimer);
pMe->m_bGoBg = TRUE;
if (pMe->m_bGoBg) {
// ISHELL_CloseApplet(pMe->a.m_pIShell, FALSE);
ISHELL_CloseApplet(pMe->a.m_pIShell, TRUE);
}
so you know after 3 munites,the applet will be running background.

bru wrote:I dont see the code for setting the app to background app. I am not sure if you are mentioning about "BREW-BACKGROUP application" or just an logical assumption of the app as bg-app.
The closeapplet with TRUE/FALSE either case means it will close the app. The one will go to OEM(all the way out), the other will go to app list(under brew applications/getitnow....).
If you want to do real bg-app, then look for the document about that.
Thank you very much for your reply.
you know, the blue font, I set a timer at EVT_APP_START such as:
CALLBACK_Init(&pMe->m_cbMainTimer, CBTimer, pMe);
ISHELL_SetTimerEx(pMe->pIShell, 3000, &pMe->m_cbMainTimer);
then after 3 minutes, the CBTimer would be called.
I used the code to set the applet to running background
CALLBACK_Cancel(&pMe->m_cbMainTimer);
pMe->m_bGoBg = TRUE;
if (pMe->m_bGoBg) {
// ISHELL_CloseApplet(pMe->a.m_pIShell, FALSE);
ISHELL_CloseApplet(pMe->a.m_pIShell, TRUE);
}
so you know after 3 munites,the applet will be running background.

CALLBACK_Cancel(&pMe->m_cbMainTimer);
pMe->m_bGoBg = TRUE;
if (pMe->m_bGoBg) {
// ISHELL_CloseApplet(pMe->a.m_pIShell, FALSE);
ISHELL_CloseApplet(pMe->a.m_pIShell, TRUE);
}
DBGPRINTF("in CBTimer, run in background");
bgApp_HttpDownload(pMe);
when the applet running background, I use the function bgApp_HttpDownload to send a downloading requirement.
But it return failed.
in called function HttpDownloadCB:
pMe->m_pwri = IWEBRESP_GetInfo(pMe->m_pDownIWebResp);
fsize = pMe->m_pwri->lContentLength;
DBGPRINTF("file length=%d", fsize);
if (WEB_ERROR_SUCCEEDED(pMe->m_pwri->nCode)) {
DBGPRINTF("request successful!");
}else{
res = WEB_ERROR_MAP(pMe->m_pwri->nCode);
DBGPRINTF("%d", res);
DBGPRINTF("request failed %i", pMe->m_pwri->nCode);
if (pMe->m_bGoBg) {
// bgApp_HttpDownload(pMe);
// pMe->m_bGoBg = FALSE;
// ISHELL_StartApplet(pMe->a.m_pIShell, AEECLSID_BGAPP);
}
IDISPLAY_ClearScreen(pMe->pIDisplay);
// MP_DialogOut(pMe, IDS_ERR_INTERNAL);
}
the return file length is -1, and res is 1298
so the problem is:
when I quit BREW environment to IDLE screen, the background application couldn't connect CDMA 1x, it is stoped to download file.
Why?
Could I still hold on connecting to CDMA 1x, when I quit BREW environment tp IDLE screen?
thx so much
Best wishes.
Yoming.Wong

CALLBACK_Cancel(&pMe->m_cbMainTimer);
pMe->m_bGoBg = TRUE;
if (pMe->m_bGoBg) {
// ISHELL_CloseApplet(pMe->a.m_pIShell, FALSE);
ISHELL_CloseApplet(pMe->a.m_pIShell, TRUE);
}
DBGPRINTF("in CBTimer, run in background");
bgApp_HttpDownload(pMe);
when the applet running background, I use the function bgApp_HttpDownload to send a downloading requirement.
But it return failed.
in called function HttpDownloadCB:
pMe->m_pwri = IWEBRESP_GetInfo(pMe->m_pDownIWebResp);
fsize = pMe->m_pwri->lContentLength;
DBGPRINTF("file length=%d", fsize);
if (WEB_ERROR_SUCCEEDED(pMe->m_pwri->nCode)) {
DBGPRINTF("request successful!");
}else{
res = WEB_ERROR_MAP(pMe->m_pwri->nCode);
DBGPRINTF("%d", res);
DBGPRINTF("request failed %i", pMe->m_pwri->nCode);
if (pMe->m_bGoBg) {
// bgApp_HttpDownload(pMe);
// pMe->m_bGoBg = FALSE;
// ISHELL_StartApplet(pMe->a.m_pIShell, AEECLSID_BGAPP);
}
IDISPLAY_ClearScreen(pMe->pIDisplay);
// MP_DialogOut(pMe, IDS_ERR_INTERNAL);
}
the return file length is -1, and res is 1298
so the problem is:
when I quit BREW environment to IDLE screen, the background application couldn't connect CDMA 1x, it is stoped to download file.
Why?
Could I still hold on connecting to CDMA 1x, when I quit BREW environment tp IDLE screen?
thx so much
Best wishes.
Yoming.Wong

Still I dont see the core statement, that would be
case EVT_APP_STOP:
if(pMe->m_bGoBg)
*((boolean*) dwParam) = FALSE; // set dwParam to run in bg
return TRUE;
This dwParam gets assigned inorder to have the application to run background
Then only all the other code gets meaning.

Still I dont see the core statement, that would be
case EVT_APP_STOP:
if(pMe->m_bGoBg)
*((boolean*) dwParam) = FALSE; // set dwParam to run in bg
return TRUE;
This dwParam gets assigned inorder to have the application to run background
Then only all the other code gets meaning.