コード例 #1
0
ファイル: jobs.c プロジェクト: wildhart/Job-Timer
void jobs_delete_job_and_save(uint8_t index) {
  if (index>=jobs_count) return;
  
  if (timer.Active && timer.Job==index) {
    timer.Active=false;
    tick_timer_service_subscribe(MINUTE_UNIT, handle_ticktimer_tick);
  } else if (timer.Active && timer.Job > index) {
    timer.Job--;
  }
  
  Job_ptr* job_ptr = first_job_ptr;
  
  if (index) {
    Job_ptr* prev_job_ptr = NULL;
    while (index--) {
      prev_job_ptr=job_ptr;
      job_ptr=job_ptr->Next_ptr;
    }
    prev_job_ptr->Next_ptr = job_ptr->Next_ptr;
  } else {
    first_job_ptr = job_ptr->Next_ptr;
  }
  free(job_ptr->Job);
  free(job_ptr);
  
  jobs_count--;
  main_save_data();
  main_menu_update();
}
コード例 #2
0
ファイル: jobs.c プロジェクト: wildhart/Job-Timer
static void callback(const char* result, size_t result_length, void* extra) {
	// Do something with result
  int index = (int) extra;
  LOG("%d",index);
  if (index==-1) {
    jobs_list_append_job(result, 0);  
  } else {
    snprintf(jobs_list_get_index(index)->Name,JOB_NAME_LENGTH, result);
  }
  main_save_data();
  main_menu_update();
}
コード例 #3
0
void update()
{
	switch(game->state) {
		case Game_State_None:
#if DEBUG
			test_update();
#endif
			break;
		case Game_State_Menu:
			main_menu_update();
			break;
		case Game_State_Play:
			play_state_update();
			break;
		default:
			break;
	}
}
コード例 #4
0
ファイル: main.c プロジェクト: wildhart/Job-Timer
static void inbox_received_handler(DictionaryIterator *iter, void *context) {
  LOG("Inbox received...");
  JS_ready = true;
  Tuple *tuple_t;
  bool new_data_from_config_page = dict_find(iter, KEY_CONFIG_DATA);
  tuple_t= dict_find(iter, KEY_TIMESTAMP);
  uint32_t inbox_timestamp = tuple_t ? tuple_t->value->int32 : 0;

  if (new_data_from_config_page || inbox_timestamp > data_timestamp)  {
    data_timestamp=inbox_timestamp;
    tuple_t=dict_find(iter, KEY_VERSION);     stored_version = (tuple_t) ? tuple_t->value->int32 : 1;
    tuple_t=dict_find(iter, KEY_SHOW_CLOCK);  if (tuple_t && settings.Show_clock != (tuple_t->value->int8 > 0) ) main_menu_toggle_clock();
    tuple_t=dict_find(iter, KEY_AUTO_SORT);   if (tuple_t) settings.Auto_sort = tuple_t->value->int8 > 0;
    tuple_t=dict_find(iter, KEY_HRS_PER_DAY); if (tuple_t) settings.Hrs_day_x10 = tuple_t->value->int32;
    tuple_t=dict_find(iter, KEY_LAST_RESET); if (tuple_t) settings.Last_reset = tuple_t->value->int32;
    
    tuple_t=dict_find(iter,KEY_TIMER);
    if (tuple_t) {
      memcpy(&timer, tuple_t->value->data, tuple_t->length);
      tick_timer_service_subscribe(MINUTE_UNIT + SECOND_UNIT, handle_ticktimer_tick);
    } else {
      timer.Active = false;
    }
    jobs_delete_all_jobs();
    jobs_list_read_dict(iter, KEY_JOBS, stored_version);
    main_menu_update();
    main_menu_highlight_top();
    if (stored_version < CURRENT_STORAGE_VERSION) {
      update_show(stored_version);
      stored_version = CURRENT_STORAGE_VERSION;
    }
    main_save_data();
  } else if (inbox_timestamp < data_timestamp) {
    send_settings_to_phone();
  }
  
  LOG("Inbox processed.");
}
コード例 #5
0
ファイル: global_evnt.c プロジェクト: pcwalton/NetSurf
/* Bind global and menu events to event handler functions, create accelerators */
void bind_global_events( void )
{
	int i, len;
	int maxlen[NUM_MENU_TITLES]={0};
	char * m, *u, *t;
	char spare[128];
	memset( (void*)&evnt_data, 0, sizeof(struct s_evnt_data) );
	EvntDataAttach( NULL, WM_XKEYBD, global_evnt_keybd, (void*)&evnt_data );
	EvntAttach( NULL, AP_TERM, global_evnt_apterm );
	EvntAttach( NULL, MN_SELECTED,  global_evnt_menu );
	EvntAttach( NULL, WM_XM1, global_evnt_m1 );

	/* parse and update menu items:  */
	i = 0;
	while( menu_evnt_tbl[i].rid != -1 ) {
		char * str = ObjcString( h_gem_menu, menu_evnt_tbl[i].rid, NULL );
		register_menu_str( &menu_evnt_tbl[i] );
		if( menu_evnt_tbl[i].menustr != NULL ){
			MenuText( NULL, menu_evnt_tbl[i].rid, menu_evnt_tbl[i].menustr );
		}
		i++;
	}
	main_menu_update();
}