Ejemplo n.º 1
0
static int	_AppEntry(t_AmsModuleId id, t_sparam sparam, t_lparam lparam)
{
	int ret = EBADPARM;
	call_glob_t *glob;
	switch(id){
		case MOD_CALL_DIALER:
			{
				t_HWindow h;

				glob = call_glob_new(MOD_CALL_DIALER);
				app_set_data(glob);

				h = wnd_create_by_resid(call_PanelWndMsgHandler, sparam, lparam, brd_get(PACK_GUID_SELF), RESID_WIN_PANEL);
				if(wnd_show(h))
					ret = app_loop(NULL);
				call_glob_destroy(glob);
			}
			break;
		case MOD_CALL_INCOMING:
			{
				int cid = *((int *)lparam);

				glob = call_glob_new(MOD_CALL_INCOMING);
				app_set_data(glob);

				if(call_LoadIncoming(cid))
					ret = app_loop(NULL);
				call_glob_destroy(glob);
			}
			break;
		case MOD_CALL_SEND:
			{
				t_MSArgContact *param = (t_MSArgContact *)lparam;
				t_ContactInfo *cinfo = contact_get_info(param->sid);
				
				glob = call_glob_new(MOD_CALL_SEND);
				app_set_data(glob);

				if(cinfo == NULL && param->number[0] == 0){
					ret = msgbox_show("Call", _RSK(BACK), 0, 0, "No cell number provided!");
				}else{
					if(cinfo)
						strcpy(glob->strPhone, cinfo->number);
					else
						strcpy(glob->strPhone, param->number);
					contact_free_info(cinfo);
					if(call_LoadOutgoing(0xFF, glob->strPhone, param->sid))
						ret = app_loop(NULL);
				}
				call_glob_destroy(glob);
				ret = SUCCESS;
			}
			break;
	}
	return ret;
}
Ejemplo n.º 2
0
//2 <sparam>=0, check & start calib if not calibrated
//2 <sparam>=1, force to start calib
int 		TSCalibAppMsgHandler(t_sparam sparam, t_lparam lparam)
{
	t_TSCalibData *glob;
	int ret = EBADPARM;
	
	t_TsdInterface *vtbl;
	char *model = NULL;
	gboolean force = *((gboolean*)lparam);
	
	vtbl = ams_query_interface("tsd");
	if(vtbl && vtbl->GetModel)
		model = vtbl->GetModel();
	if(vtbl == NULL || model == 0 || *model == 0 || vtbl->StartCalib == NULL){
		return SUCCESS;
	}
	
	glob = MALLOC(sizeof(t_TSCalibData));
	memset(glob, 0, sizeof(t_TSCalibData));
	app_set_data(glob);
	
	glob->vtbl = vtbl;
	if(vtbl->Init)vtbl->Init();
	if(vtbl->Wakeup)vtbl->Wakeup();
	
	if(force == FALSE){
		int fd = fsi_open(TS_CALIB_FILE, _O_RDONLY, _S_IREAD);
		if(fd < 0){
			goto start_calib;
		}
		if(fsi_read(fd, &glob->points, sizeof(glob->points)) != sizeof(glob->points)){
			fsi_close(fd);
			goto start_calib;
		}
		fsi_close(fd);
		if(vtbl->StartCalib){
			glob->points.n--;
			if(vtbl->StartCalib(&gs_calib_const, &glob->points) == FALSE){
				goto start_calib;
			}
		}
		ret = SUCCESS;
		goto out;
	}
start_calib:
	amos_set_tscalib(TRUE);
	glob->points.n = 0;
	glob->gdi = lcd_create_gdi();
	if(wnd_show(wnd_create(tscalib_WndMsgHandler, FALSE, 0)))
		ret = app_loop(NULL);
out:	
	amos_set_tscalib(FALSE);
	if(glob){
		g_object_unref(glob->gdi);
		FREE(glob);
	}
	return ret;
}
Ejemplo n.º 3
0
static int	bluetooth_AppEntry(t_AmsModuleId id, t_sparam sparam, t_lparam lparam)
{
	int ret = EBADPARM;
	switch(id){
		case MOD_ID_MAIN:
			{
				bluetooth_glob_t *glob;
				glob = bluetooth_glob_new(sparam, lparam);
				app_set_data(glob);
				if(wnd_show(wnd_create_by_resid(bluetooth_MainWndMsgHandler, 0, 0, brd_get(PACK_GUID_SELF), RESID_WIN_MAIN)))
					ret = app_loop(NULL);
				bluetooth_glob_destroy(glob);
			}
			break;
	}
	return ret;
}
Ejemplo n.º 4
0
static int	mainmenu_AppEntry(t_AmsModuleId id, t_sparam sparam, t_lparam lparam)
{
	int ret = EBADPARM;
	switch(id){
		case MOD_ID_MAIN:
			{
				t_HWindow h;

				h = wnd_create_by_resid(mainmenu_MainWndMsgHandler, 0, 0, brd_get(PACK_GUID_SELF), RESID_WIN_MAIN);

				if(wnd_show(h))
					ret = app_loop(NULL);
			}
			break;
	}
	return ret;
}
Ejemplo n.º 5
0
/*******************************************************************************
 * Function Name  : main.
 * Description    : main routine.
 * Input          : None.
 * Output         : None.
 * Return         : None.
 *******************************************************************************/
void app_setup_and_loop(void)
{
    system_part2_post_init();
    HAL_Core_Init();
    // We have running firmware, otherwise we wouldn't have gotten here
    DECLARE_SYS_HEALTH(ENTERED_Main);
    PMIC().begin();
    FuelGauge().wakeup();

    DEBUG("Hello from Particle!");
    String s = spark_deviceID();
    INFO("Device %s started", s.c_str());

    manage_safe_mode();

#if defined (START_DFU_FLASHER_SERIAL_SPEED) || defined (START_YMODEM_FLASHER_SERIAL_SPEED)
    USB_USART_LineCoding_BitRate_Handler(system_lineCodingBitRateHandler);
#endif

    bool threaded = system_thread_get_state(NULL) != spark::feature::DISABLED &&
      (system_mode()!=SAFE_MODE);

    Network_Setup(threaded);

#if PLATFORM_THREADING
    if (threaded)
    {
        SystemThread.start();
        ApplicationThread.start();
    }
    else
    {
        SystemThread.setCurrentThread();
        ApplicationThread.setCurrentThread();
    }
#endif
    if(!threaded) {
        /* Main loop */
        while (1) {
            app_loop(false);
        }
    }
}
Ejemplo n.º 6
0
//
// weather_today_loop
//
int weather_loop() {

	char weather[200];

	Window *w = window[curr_window_idx];

	Element_t *e = window_get_element_byName(w, "weather");

	/* format weather file name */
	sprintf(weather, weatherFileTemplate, curr_window_idx - 1);

	e->surface = IMG_Load(weather);

	window_update(window[curr_window_idx]);

	SDL_FreeSurface(e->surface);

	// calling `app_loop`
	return app_loop();

}
Ejemplo n.º 7
0
static int	email_AppEntry(t_AmsModuleId id, t_sparam sparam, t_lparam lparam)
{
	int ret = EBADPARM;
	switch(id){
		case MOD_ID_MAIN:
			{
				email_glob_t *glob;
				t_HWindow h;

				glob = email_glob_new(sparam, lparam);
				app_set_data(glob);

				if(glob->user->email[0] == 0)
					h = wnd_create_by_resid(email_UserProfileWndMsgHandler, 0, 1, brd_get(PACK_GUID_SELF), RESID_WIN_USER_PROFILE);
				else
					h = wnd_create_by_resid(email_MainWndMsgHandler, 0, 0, brd_get(PACK_GUID_SELF), RESID_WIN_MAIN);
				if(wnd_show(h))
					ret = app_loop(NULL);
				email_glob_destroy(glob);
			}
			break;
	}
	return ret;
}
Ejemplo n.º 8
0
static int	audioplayer_AppEntry(t_AmsModuleId id, t_sparam sparam, t_lparam lparam)
{
	int ret = EBADPARM;
	audioplayer_glob_t *glob;
	switch(id){
		case MOD_ID_MAIN:
			glob = audioplayer_glob_new(sparam, lparam);
			app_set_data(glob);
			
			if(wnd_show(wnd_create_by_resid(audioplayer_MainWndMsgHandler, 0, 0, brd_get(PACK_GUID_SELF), RESID_WIN_MAIN)))
				ret = app_loop(NULL);
			
			audioplayer_glob_destroy(glob);
			break;
		case MOD_ID_FILE_OPEN:
			{
				const char *fname = (const char *)lparam;
				t_HWindow h;
				int result;
				t_HMedia codec;
				t_DBRecordID rid_playlist, rid_filelist;

				//2 Check codec
				if((codec = g_media_new_for_file(fname)) == NULL){
					msgbox_show(NULL, _CSK(OK), 0, 0, "Invalid format");
					task_exit(0);
					return SUCCESS;
				}
				g_object_unref_0(codec);
				
				glob = audioplayer_glob_new(sparam, lparam);
				app_set_data(glob);
				
				h = wnd_create_by_resid(audioplayer_OpenFileWndMsgHandler, 0, 0, brd_get(PACK_GUID_SELF), RESID_WIN_AUDIO_OPEN);
				result = wnd_modal(h);
				
				if(result < 0){
					//2 Cancel
					ret = 0;
				}else if(result == 0){
					//2 Play it!
					h = wnd_create_by_resid(audioplayer_PlayerWndMsgHandler, sparam, lparam, brd_get(PACK_GUID_SELF), RESID_WIN_PLAYER);
					wnd_show(h);
					ret = app_loop(NULL);
				}else{
					//2 Add to playlist(result)
					rid_playlist = result;
					rid_filelist = db_add_file_to_playlist(glob->hdb_filelist, (char*)fname, glob->hdb_playlist, rid_playlist);
					if(rid_filelist == DB_RID_NULL){
						msgbox_show(NULL, _CSK(OK), 0, 0, "Error to add to playlist");
						ret = 0;
					}else{
						glob->ap_view = AP_VIEW_FILELIST;
						h = wnd_create_by_resid(audioplayer_MainWndMsgHandler, rid_playlist, rid_filelist, brd_get(PACK_GUID_SELF), RESID_WIN_MAIN);
						wnd_show(h);
						ret = app_loop(NULL);
					}
				}
				audioplayer_glob_destroy(glob);
			}
			break;
	}
	return ret;
}
Ejemplo n.º 9
0
void app_thread_idle()
{
    app_loop(true);
}