static void roadmap_pointer_moved (RoadMapGuiPoint *point) { if (cancel_dragging || is_testing_double_click || (!is_button_down && !is_dragging)) return; if (!is_dragging) { /* Less sensitive, since a car is not a quiet environment... */ if ((abs(point->x - last_pointer_point.x) <= get_drag_movement_thr()) && (abs(point->y - last_pointer_point.y) <= get_drag_movement_thr())) return; // roadmap_main_remove_periodic(roadmap_pointer_button_timeout); exec_callbacks (DRAG_START, &last_pointer_point); last_pointer_point = *point; is_drag_flow_control_on = 1; roadmap_main_set_periodic (DRAG_FLOW_CONTROL_TIMEOUT, drag_flow_control); is_dragging = 1; } else { /* the flow control timer will execute the handler */ last_pointer_point = *point; if (!is_drag_flow_control_on) { is_drag_flow_control_on = 1; roadmap_main_set_periodic (DRAG_FLOW_CONTROL_TIMEOUT, drag_flow_control); } } }
static int on_venue_item_selected(SsdWidget widget, const char* selection,const void *value, void* context) { int index = (int)value; #ifdef IPHONE_NATIVE index -= 10; #endif //IPHONE_NATIVE gsRequestType = ROADMAP_FOURSQUARE_CHECKIN; roadmap_main_set_periodic(FOURSQUARE_REQUEST_TIMEOUT, request_time_out); #ifdef IPHONE delayed_show_progress(); #else roadmap_main_set_periodic(100, delayed_show_progress); #endif //IPHONE create_address (&gsVenuesList[index], &gsCheckInInfo); ssd_dialog_hide_all(dec_close); Realtime_FoursquareCheckin(gsVenuesList[index].sId, roadmap_foursquare_is_tweet_badge_enabled() && roadmap_twitter_logged_in()); return 1; }
// Draw the warning on the screen void roadmap_alerter_display(void){ if (alert_should_be_visible) { if (the_active_alert.active_alert_id == -1){ return; } if ((!alert_active) || (prev_alert.active_alert_id != the_active_alert.active_alert_id)){ if (alert_active) hide_alert_dialog(); kill_timer(); prev_alert.active_alert_id = the_active_alert.active_alert_id; show_alert_dialog(); if (the_active_alert.alert_type == ALERT) roadmap_alerter_audio(); alert_active = TRUE; } else{ update_alert(); } } else { if (alert_active && !alert_should_be_visible) { if (AlerterTimerCallback == NULL){ SsdWidget text = ssd_widget_get(dialog, "Distance"); ssd_text_set_text(text, " "); g_seconds = 5; AlerterTimerCallback = hide_alert_timeout; roadmap_main_set_periodic (1000, AlerterTimerCallback); } } } }
void RealtimeBonus_Animate_Pacman (void) { static char pacman_name[50]; static int index = 1; static int repeat = 0; #ifndef J2ME if ( (index == 5) && (repeat == 8)) { roadmap_main_remove_periodic (RealtimeBonus_Animate_Pacman); editor_screen_set_override_car (NULL); index = 1; repeat = 0; } else if (index == 5) { index = 2; repeat++; sprintf (pacman_name, "pacman%d", index); editor_screen_set_override_car (pacman_name); } else { index++; sprintf (pacman_name, "pacman%d", index); editor_screen_set_override_car (pacman_name); } if (index == 2) roadmap_main_set_periodic (300, RealtimeBonus_Animate_Pacman); #endif }
static void update_activity (void) { if ( RoadMapNetMonEnabled ) { if (!LastActivityTime) roadmap_main_set_periodic (1000, periodic_callack); LastActivityTime = time(NULL); } //roadmap_screen_mark_redraw (); }
static int onBonusAdd (RTBonus *pApdon) { if (pApdon->bIsCustomeBonus){ roadmap_main_set_periodic(1000, SpeedCheck_Timer); } else{ if (roadmap_map_settings_road_goodies()) AddBonusToMap(pApdon, FALSE); } return TRUE; }
void roadmap_splash_login_cb(void){ if (should_check_for_new_file()) roadmap_main_set_periodic(START_DOWNLOAD_DELAY,roadmap_splash_delayed_start_download); Realtime_NotifySplashUpdateTime(roadmap_splash_get_update_time()); if (SplashNextLoginCb) { SplashNextLoginCb (); SplashNextLoginCb = NULL; } }
void roadmap_foursquare_login (const char *user_name, const char *password) { BOOL success; gsRequestType = ROADMAP_FOURSQUARE_LOGIN; #ifdef IPHONE delayed_show_progress(); #else roadmap_main_set_periodic(100, delayed_show_progress); #endif //IPHONE roadmap_main_set_periodic(FOURSQUARE_REQUEST_TIMEOUT, request_time_out); success = Realtime_FoursquareConnect(user_name, password, roadmap_foursquare_is_tweet_login_enabled() && roadmap_twitter_logged_in()); if (!success) { roadmap_main_remove_periodic(request_time_out); ssd_progress_msg_dialog_hide(); gsRequestType = ROADMAP_FOURSQUARE_NONE; roadmap_main_set_periodic (100, foursquare_network_error); } }
static int on_login_ok() { BOOL logged_in; const char * user_name = ssd_dialog_get_value("FoursquareUserName"); const char * password = ssd_dialog_get_value("FoursquarePassword"); logged_in = roadmap_foursquare_logged_in(); if (!strcasecmp((const char*) ssd_dialog_get_data("FoursquareSendLogin"), yesno[0])) roadmap_foursquare_enable_tweet_login(); else roadmap_foursquare_disable_tweet_login(); if (!strcasecmp((const char*) ssd_dialog_get_data("FoursquareSendBadgeUnlock"), yesno[0])) roadmap_foursquare_enable_tweet_badge(); else roadmap_foursquare_disable_tweet_badge(); if (user_name[0] != 0 && password[0] != 0) { roadmap_foursquare_set_username(user_name); roadmap_foursquare_set_password(password); roadmap_foursquare_login (user_name, password); return 1; } else if (!logged_in){ if (user_name[0] == 0) { roadmap_main_set_periodic (100, foursquare_un_empty); return 1; } if (password[0] == 0) { roadmap_main_set_periodic (100, foursquare_pw_empty); return 1; } } return 0; }
void roadmap_foursquare_checkin(void) { const RoadMapPosition *coordinates; if (!roadmap_foursquare_logged_in()) { gsCheckInOnLogin = TRUE; roadmap_foursquare_login_dialog(); return; } gsCheckInOnLogin = FALSE; gsRequestType = ROADMAP_FOURSQUARE_SEARCH; gsVenuesCount = 0; roadmap_main_set_periodic(FOURSQUARE_REQUEST_TIMEOUT, request_time_out); #ifdef IPHONE delayed_show_progress(); #else roadmap_main_set_periodic(100, delayed_show_progress); #endif //IPHONE coordinates = roadmap_trip_get_position( "Location" ); Realtime_FoursquareSearch((RoadMapPosition *)coordinates); }
static void roadmap_pointer_button_pressed (RoadMapGuiPoint *point) { first_pointer_point = *point; last_pointer_point = *point; /* The dragging can be cancelled from the callback, using the roadmap_pointer_cancel_dragging() */ cancel_dragging = 0; is_button_down = 1; exec_callbacks (PRESSED, point); is_long_click_expired = 0; roadmap_main_set_periodic (LONG_CLICK_TIMEOUT, long_click_flow_control); }
static void roadmap_pointer_button_released (RoadMapGuiPoint *point) { if (is_drag_flow_control_on) { roadmap_main_remove_periodic(drag_flow_control); is_drag_flow_control_on = 0; } if ( !is_button_down ) return; roadmap_main_remove_periodic( long_click_flow_control ); is_button_down = 0; cancel_dragging = 0; /* * Clicks are at higher priority */ if ( is_short_click( point ) ) { if ( is_testing_double_click ) { roadmap_main_remove_periodic(double_click_flow_control); is_testing_double_click = 0; exec_callbacks ( DOUBLE_CLICK, &last_pointer_point ); } else if ( is_double_click_enabled ) { is_dragging = 0; is_double_click_enabled = 0; is_testing_double_click = 1; roadmap_main_set_periodic(DOUBLE_CLICK_TIMEOUT, double_click_flow_control); /* * Don't call events' handlers at this stage */ return; } else { exec_callbacks (SHORT_CLICK, point); } } else if ( is_dragging ) { exec_callbacks (DRAG_END, point); } is_dragging = 0; exec_callbacks (RELEASED, point); }
static int ssd_button_short_click (SsdWidget widget, const RoadMapGuiPoint *point) { struct ssd_button_data *data = (struct ssd_button_data *) widget->data; static RoadMapSoundList list; if (data->state == BUTTON_STATE_DISABLED) return 1; widget->force_click = FALSE; #ifdef PLAY_CLICK if (!list) { list = roadmap_sound_list_create (SOUND_LIST_NO_FREE); roadmap_sound_list_add (list, "click"); roadmap_res_get (RES_SOUND, 0, "click"); } roadmap_sound_play_list (list); #endif //IPHONE #ifdef TOUCH_SCREEN if (widget->callback == NULL){ data->state = BUTTON_STATE_NORMAL; roadmap_screen_redraw (); return 0; } else{ delayed_widget = widget; widget->in_focus = TRUE; data->state = BUTTON_STATE_SELECTED; roadmap_main_set_periodic (100, button_callback); return 1; } #else if (widget->callback) { (*widget->callback) ( widget, SSD_BUTTON_SHORT_CLICK ); return 1; } data->state = BUTTON_STATE_NORMAL; roadmap_screen_redraw (); #endif return 0; }
void roadmap_ticker_show(void){ char text[256]; gTickerHide = FALSE; if (! roadmap_message_format (text, sizeof(text), "%*|%X")) { roadmap_message_set('*', "%d", 0); roadmap_ticker_set_last_event(default_event); } if (gTickerSupressHide) roadmap_main_remove_periodic (roadmap_ticker_supress_hide); roadmap_main_set_periodic (15000, roadmap_ticker_supress_hide); gTickerSupressHide = TRUE; if (!roadmap_screen_refresh()) roadmap_screen_redraw(); }
static void on_search(void) { SsdWidget list_cont; SsdWidget edit; const char* text; roadmap_result rc; SsdWidget dlg = generic_search_dlg_get_search_dlg(search_local); if (!RealTimeLoginState()){ roadmap_messagebox( roadmap_lang_get( "Search location"), roadmap_lang_get( "Search requires internet connection." "Please make sure you are connected.")); return; } edit = generic_search_dlg_get_search_edit_box(search_local); s_searching = TRUE; roadmap_main_set_periodic( 100, search_progress_message_delayed ); text = ssd_text_get_text( edit ); list_cont= dlg->context; rc = local_search_resolve_address( list_cont, on_address_resolved, text ); if( succeeded == rc) { roadmap_main_set_cursor( ROADMAP_CURSOR_WAIT); roadmap_log(ROADMAP_DEBUG, "local_search_dlg::on_search() - Started Web-Service transaction: Resolve address"); } else { const char* err = roadmap_result_string( rc); s_searching = FALSE; roadmap_log(ROADMAP_ERROR, "local_search_dlg::on_search() - Resolve process transaction failed to start"); /* Close the progress message */ ssd_progress_msg_dialog_hide(); roadmap_messagebox_cb ( roadmap_lang_get( "Search location"), roadmap_lang_get( err ), on_search_error_message ); } }
static int roadmap_screen_obj_pressed (RoadMapGuiPoint *point) { int state = 0; RoadMapScreenObjSelected = roadmap_screen_obj_by_pos (point); if (!RoadMapScreenObjSelected) return 0; /* There is no draggable objects on the screen. In the future if there will be such an * objects the short/long click handling for the small drag has to be in the drag_end event * like in the ssd_dialog */ roadmap_pointer_cancel_dragging(); if (RoadMapScreenObjSelected->state_fn) { state = (*RoadMapScreenObjSelected->state_fn) (); if ((state < 0) || (state >= MAX_STATES)) return 1; } if (RoadMapScreenObjSelected->images[state]) { RoadMapGuiPoint pos; roadmap_screen_obj_pos (RoadMapScreenObjSelected, &pos); roadmap_canvas_draw_image (RoadMapScreenObjSelected->images[state], &pos, RoadMapScreenObjSelected->opacity, IMAGE_SELECTED); } roadmap_canvas_refresh (); if (RoadMapScreenObjSelected->flags & OBJ_FLAG_REPEAT) { if (RoadMapScreenObjSelected->action) { (*(RoadMapScreenObjSelected->action->callback)) (); } roadmap_main_set_periodic (OBJ_REPEAT_TIMEOUT, roadmap_screen_obj_repeat); } return 1; }
int ssd_dialog_drag_end (RoadMapGuiPoint *point) { uint32_t time_diff, drag_diff, speed; SsdDialog dialog = RoadMapDialogCurrent; if (dialog == NULL) return 0; if (dialog->container->flags & SSD_DIALOG_FLOAT){ if (LastPointerPoint.x == -1) return 0; else return 1; } dialog->drag_end_time_ms = roadmap_time_get_millis(); dialog->drag_end_motion.y = point->y; dialog->drag_end_motion.x = point->x; time_diff = dialog->drag_end_time_ms - dialog->drag_start_time_ms; drag_diff = abs(dialog->drag_end_motion.y - dialog->drag_start_point.y); if (time_diff > 0) speed = (int)(drag_diff*10)/time_diff; #if 0 if ((dialog->scroll_counter < SCROLL_AFTER_END_COUNTER) && (drag_diff > 40)){ dialog->drag_speed = speed; roadmap_main_set_periodic (30, keep_dragging); dialog->time_active = TRUE; return 1; } #endif if (dialog->scroll_container && dialog->scroll_container->drag_end) return (*dialog->scroll_container->drag_end)(dialog->container, point); else if ((dialog->scroll_container) && (dialog->scroll)){ SsdWidget title; SsdSize size, size2; int height; int goffsef = (int)(1 * (point->y - dialog->drag_start_point.y ) + dialog->stop_offset); title = ssd_widget_get (RoadMapDialogCurrent->container, "title_bar"); height = roadmap_canvas_height() - title->cached_size.height - 4; ssd_widget_reset_cache(dialog->scroll_container); ssd_widget_get_size(dialog->scroll_container, &size, NULL); if (size.height == roadmap_canvas_height() +1){ ssd_widget_reset_cache(dialog->scroll_container); size2.width = SSD_MIN_SIZE; size2.height = SSD_MIN_SIZE; ssd_widget_get_size(dialog->scroll_container, &size, &size2); } if (size.height < height) goffsef = 0; else if ((goffsef + size.height) > height) { if (goffsef + dialog->scroll_container->position.y > dialog->container->children->cached_size.height) goffsef = 0 ; } else if ((goffsef + dialog->scroll_container->position.y + size.height ) < roadmap_canvas_height()){ goffsef = height - size.height -2 ; } ssd_widget_set_offset(dialog->scroll_container,0,goffsef); dialog->stop_offset = goffsef; ssd_dialog_draw(); } return 1; }
/*********************************************************** * Name : ssd_progress_msg_dialog_show_timed * * Purpose : Shows the dialog with the given name, for a given amount of time * * Params : [in] dlg_text - the text to be displayed in message * : [in] seconds - the time to be displayed * Author : Dan Friedman * Returns : void */ void ssd_progress_msg_dialog_show_timed( const char* dlg_text , int seconds) { ssd_progress_msg_dialog_show(dlg_text); roadmap_main_set_periodic (seconds * 1000, hide_timer); }
static void on_search(void) { SsdWidget list_cont; SsdWidget edit; const char* text; roadmap_result rc; const char* dl_prefix = roadmap_lang_get ("map:"); SsdWidget dlg = generic_search_dlg_get_search_dlg(search_address); edit = generic_search_dlg_get_search_edit_box(search_address); if ( !strcmp( DEBUG_LEVEL_SET_PATTERN, ssd_text_get_text( edit ) ) ) { roadmap_start_reset_debug_mode(); return; } if ( !strcmp( "##@coord", ssd_text_get_text( edit ) ) ) { roadmap_gps_reset_show_coordinates(); return; } if ( !strcmp( "##@il", ssd_text_get_text( edit ) ) ) { roadmap_geo_config_il(NULL); return; } if ( !strcmp( "##@usa", ssd_text_get_text( edit ) ) ) { roadmap_geo_config_usa(NULL); return; } if ( !strcmp( "##@other", ssd_text_get_text( edit ) ) ) { roadmap_geo_config_other(NULL); return; } if ( !strcmp( "##@stg", ssd_text_get_text( edit ) ) ) { roadmap_geo_config_stg(NULL); return; } if ( !strcmp( "##@heb", ssd_text_get_text( edit ) ) ) { roadmap_lang_set_system_lang("heb", TRUE); roadmap_messagebox("", "Language changed to Hebrew, please restart waze"); return; } if ( !strcmp( "##@eng", ssd_text_get_text( edit ) ) ) { roadmap_lang_set_system_lang("eng", TRUE); roadmap_messagebox("","Language changed to English, please restart waze"); return; } if ( !strcmp( "cc@tts", ssd_text_get_text( edit ) ) ) { tts_clear_cache(); roadmap_messagebox("","TTS cache has been cleared!"); return; } if ( !strcmp( "##@tts", ssd_text_get_text( edit ) ) ) { tts_set_feature_enabled( !tts_feature_enabled() ); if ( tts_feature_enabled() ) { roadmap_messagebox("","TTS Feature is enabled!\nPlease restart WAZE."); } else { roadmap_messagebox("","TTS Feature is disabled!"); } navigate_main_override_nav_settings(); return; } if ( !strcmp( "dbg@tts", ssd_text_get_text( edit ) ) ) { if ( !strcmp( tts_was_provider_voices_set(), TTS_WAS_VOICES_SET_PRODUCTION ) ) { tts_was_provider_apply_voices_set( TTS_WAS_VOICES_SET_DEBUG ); roadmap_messagebox("","TTS Feature is running in debug mode!\nPlease restart WAZE."); } else { tts_was_provider_apply_voices_set( TTS_WAS_VOICES_SET_PRODUCTION ); roadmap_messagebox("","TTS Feature is running in production mode!\nPlease restart WAZE."); } return; } if ( !strncmp( dl_prefix, ssd_text_get_text( edit ), strlen( dl_prefix ) ) ) { roadmap_map_download_region( ssd_text_get_text( edit ) + strlen( dl_prefix ), roadmap_locator_static_county() ); ssd_dialog_hide_all( dec_close); if (!roadmap_screen_refresh ()) roadmap_screen_redraw(); return; } s_searching = TRUE; roadmap_main_set_periodic( 100, search_progress_message_delayed ); text = ssd_text_get_text( edit ); list_cont= dlg->context; rc = address_search_resolve_address( list_cont, on_address_resolved, text ); if( succeeded == rc) { roadmap_main_set_cursor( ROADMAP_CURSOR_WAIT); roadmap_log(ROADMAP_DEBUG, "address_search_dlg::on_search() - Started Web-Service transaction: Resolve address"); } else { const char* err = roadmap_result_string( rc); s_searching = FALSE; roadmap_log(ROADMAP_ERROR, "address_search_dlg::on_search() - Resolve process transaction failed to start"); /* Close the progress message */ ssd_progress_msg_dialog_hide(); roadmap_messagebox_cb ( roadmap_lang_get( "Resolve Address"), roadmap_lang_get( err ), on_search_error_message ); } }
/*********************************************************** * Name : ssd_progress_msg_dialog_show_timed * * Purpose : Shows the dialog with the given name, for a given amount of time * * Params : [in] dlg_text - the text to be displayed in message * : [in] seconds - the time to be displayed * Author : Dan Friedman * Returns : void */ void ssd_progress_msg_dialog_show_timed( const char* dlg_text , int seconds) { ssd_progress_msg_dialog_show(dlg_text); roadmap_main_set_periodic (seconds * 1000, hide_timer); ssd_widget_hide(ssd_widget_get(gProgressMsgDlg, "Hide Button" )); }
void roadmap_messagebox_timeout (const char *title, const char *text, int seconds) { roadmap_messagebox (title, text); MessageBoxCallback = close_messagebox; roadmap_main_set_periodic (seconds * 1000, close_messagebox); }
// should be called once during initialization void roadmap_main_register_seconds_timer_mgr(){ roadmap_main_set_periodic(1000,roadmap_main_seconds_timer_mgr); }
static void on_search(void) { SsdWidget list_cont; SsdWidget edit; const char* text; roadmap_result rc; const char* dl_prefix = roadmap_lang_get ("map:"); SsdWidget dlg = generic_search_dlg_get_search_dlg(search_address); edit = generic_search_dlg_get_search_edit_box(search_address); if ( !strcmp( DEBUG_LEVEL_SET_PATTERN, ssd_text_get_text( edit ) ) ) { roadmap_start_reset_debug_mode(); return; } if ( !strcmp( "##@il", ssd_text_get_text( edit ) ) ) { roadmap_geo_config_il(NULL); return; } if ( !strcmp( "##@usa", ssd_text_get_text( edit ) ) ) { roadmap_geo_config_usa(NULL); return; } if ( !strcmp( "##@heb", ssd_text_get_text( edit ) ) ) { roadmap_lang_set_system_lang("heb"); roadmap_messagebox("", "changed to hebrew, please restart wase"); return; } if ( !strcmp( "##@eng", ssd_text_get_text( edit ) ) ) { roadmap_messagebox("","changed to english, please restart wase"); roadmap_lang_set_system_lang("eng"); return; } if ( !strncmp( dl_prefix, ssd_text_get_text( edit ), strlen( dl_prefix ) ) ) { roadmap_map_download_region( ssd_text_get_text( edit ) + strlen( dl_prefix ), roadmap_locator_static_county() ); ssd_dialog_hide_all( dec_close); if (!roadmap_screen_refresh ()) roadmap_screen_redraw(); return; } s_searching = TRUE; roadmap_main_set_periodic( 100, search_progress_message_delayed ); text = ssd_text_get_text( edit ); list_cont= dlg->context; rc = address_search_resolve_address( list_cont, on_address_resolved, text ); if( succeeded == rc) { roadmap_main_set_cursor( ROADMAP_CURSOR_WAIT); roadmap_log(ROADMAP_DEBUG, "address_search_dlg::on_search() - Started Web-Service transaction: Resolve address"); } else { const char* err = roadmap_result_string( rc); s_searching = FALSE; roadmap_log(ROADMAP_ERROR, "address_search_dlg::on_search() - Resolve process transaction failed to start"); /* Close the progress message */ ssd_progress_msg_dialog_hide(); roadmap_messagebox_cb ( roadmap_lang_get( "Resolve Address"), roadmap_lang_get( err ), on_search_error_message ); } }
static const char* parse_search_results(roadmap_result* rc, int NumParams, const char* pData) { //Expected data: // VenueList,<id>,<name>,<address>,<crossstreet>,<city>,<state>,<zip>,<geolat>,<geolong>,<phone>,<distance>[,<id>,.....] FoursquareVenue venue; int i; char CommandName[128]; int iBufferSize; double dValue; int count; iBufferSize = 128; if (NumParams == 0) return pData; if ((NumParams - 1) % ROADMAP_FOURSQUARE_VENUE_ENTRIES != 0) { (*rc) = err_parser_unexpected_data; return NULL; } pData = ExtractNetworkString( pData, // [in] Source string CommandName,// [out] Output buffer &iBufferSize, // [in,out] Buffer size / Size of extracted string ",\r\n", // [in] Array of chars to terminate the copy operation 1); // [in] Remove additional termination chars if (strcmp(CommandName, "VenueList") != 0) { roadmap_log(ROADMAP_ERROR, "Foursquare - parse_search_results(): could not find command: VenueList (received: '%s')", CommandName); (*rc) = err_parser_unexpected_data; return NULL; } count = (NumParams - 1) / ROADMAP_FOURSQUARE_VENUE_ENTRIES; if (!(*pData) || count == 0) { roadmap_log(ROADMAP_DEBUG, "Foursquare - received empty venues list"); ssd_dialog_hide_all(dec_close); #ifdef IPHONE_NATIVE roadmap_main_show_root(1); #endif //IPHONE_NATIVE roadmap_messagebox_timeout("Foursquare", "We can't find anything nearby.", 5); return pData; } for (i = 0; i < count; ++i){ // 1. id iBufferSize = ROADMAP_FOURSQUARE_ID_MAX_SIZE; pData = ExtractNetworkString( pData, // [in] Source string venue.sId, // [out,opt]Output buffer &iBufferSize, // [in,out] Buffer size / Size of extracted string ",", // [in] Array of chars to terminate the copy operation 1); // [in] Remove additional termination chars if( !pData || !(*pData)) { roadmap_log( ROADMAP_ERROR, "Foursquare - parse_search_results(): Failed to read venue id=%s", venue.sId); (*rc) = err_parser_unexpected_data; return NULL; } // 2. name iBufferSize = ROADMAP_FOURSQUARE_NAME_MAX_SIZE; pData = ExtractNetworkString( pData, // [in] Source string venue.sName, // [out,opt]Output buffer &iBufferSize, // [in,out] Buffer size / Size of extracted string ",", // [in] Array of chars to terminate the copy operation 1); // [in] Remove additional termination chars if( !pData || !(*pData)) { roadmap_log( ROADMAP_ERROR, "Foursquare - parse_search_results(): Failed to read venue name=%s", venue.sName); (*rc) = err_parser_unexpected_data; return NULL; } // 3. address iBufferSize = ROADMAP_FOURSQUARE_ADDRESS_MAX_SIZE; pData = ExtractNetworkString( pData, // [in] Source string venue.sAddress, // [out,opt]Output buffer &iBufferSize, // [in,out] Buffer size / Size of extracted string ",", // [in] Array of chars to terminate the copy operation 1); // [in] Remove additional termination chars if( !pData || !(*pData)) { roadmap_log( ROADMAP_ERROR, "Foursquare - parse_search_results(): Failed to read venue address=%s", venue.sAddress); (*rc) = err_parser_unexpected_data; return NULL; } // 4. crossstreet iBufferSize = ROADMAP_FOURSQUARE_CROSS_STREET_MAX_SIZE; pData = ExtractNetworkString( pData, // [in] Source string venue.sCrossStreet, // [out,opt]Output buffer &iBufferSize, // [in,out] Buffer size / Size of extracted string ",", // [in] Array of chars to terminate the copy operation 1); // [in] Remove additional termination chars if( !pData || !(*pData)) { roadmap_log( ROADMAP_ERROR, "Foursquare - parse_search_results(): Failed to read venue crossname=%s", venue.sCrossStreet); (*rc) = err_parser_unexpected_data; return NULL; } // 5. city iBufferSize = ROADMAP_FOURSQUARE_CITY_MAX_SIZE; pData = ExtractNetworkString( pData, // [in] Source string venue.sCity, // [out,opt]Output buffer &iBufferSize, // [in,out] Buffer size / Size of extracted string ",", // [in] Array of chars to terminate the copy operation 1); // [in] Remove additional termination chars if( !pData || !(*pData)) { roadmap_log( ROADMAP_ERROR, "Foursquare - parse_search_results(): Failed to read venue city=%s", venue.sCity); (*rc) = err_parser_unexpected_data; return NULL; } // 6. state iBufferSize = ROADMAP_FOURSQUARE_STATE_MAX_SIZE; pData = ExtractNetworkString( pData, // [in] Source string venue.sState, // [out,opt]Output buffer &iBufferSize, // [in,out] Buffer size / Size of extracted string ",", // [in] Array of chars to terminate the copy operation 1); // [in] Remove additional termination chars if( !pData || !(*pData)) { roadmap_log( ROADMAP_ERROR, "Foursquare - parse_search_results(): Failed to read venue state=%s", venue.sState); (*rc) = err_parser_unexpected_data; return NULL; } // 7. zip iBufferSize = ROADMAP_FOURSQUARE_ZIP_MAX_SIZE; pData = ExtractNetworkString( pData, // [in] Source string venue.sZip, // [out,opt]Output buffer &iBufferSize, // [in,out] Buffer size / Size of extracted string ",", // [in] Array of chars to terminate the copy operation 1); // [in] Remove additional termination chars if( !pData || !(*pData)) { roadmap_log( ROADMAP_ERROR, "Foursquare - parse_search_results(): Failed to read venue zip=%s", venue.sZip); (*rc) = err_parser_unexpected_data; return NULL; } // 8. lat pData = ReadDoubleFromString( pData, // [in] Source string ",", // [in,opt] Value termination NULL, // [in,opt] Allowed padding &dValue, // [out] Output value 1); // [in] TRIM_ALL_CHARS, DO_NOT_TRIM, or 'n' venue.iLatitude = (int) (dValue * 1000000); if( !pData || !(*pData)) { roadmap_log( ROADMAP_ERROR, "Foursquare - parse_search_results(): Failed to read venue lat=%d", venue.iLatitude); (*rc) = err_parser_unexpected_data; return NULL; } // 9. lon pData = ReadDoubleFromString( pData, // [in] Source string ",", // [in,opt] Value termination NULL, // [in,opt] Allowed padding &dValue, // [out] Output value 1); // [in] TRIM_ALL_CHARS, DO_NOT_TRIM, or 'n' venue.iLongitude = (int) (dValue * 1000000); if( !pData || !(*pData)) { roadmap_log( ROADMAP_ERROR, "Foursquare - parse_search_results(): Failed to read venue lon=%d", venue.iLongitude); (*rc) = err_parser_unexpected_data; return NULL; } // 10. phone iBufferSize = ROADMAP_FOURSQUARE_PHONE_MAX_SIZE; pData = ExtractNetworkString( pData, // [in] Source string venue.sPhone, // [out,opt]Output buffer &iBufferSize, // [in,out] Buffer size / Size of extracted string ",", // [in] Array of chars to terminate the copy operation 1); // [in] Remove additional termination chars if( !pData || !(*pData)) { roadmap_log( ROADMAP_ERROR, "Foursquare - parse_search_results(): Failed to read venue phone=%s", venue.sPhone); (*rc) = err_parser_unexpected_data; return NULL; } // 11. distance pData = ReadIntFromString( pData, // [in] Source string ",\r\n", // [in,opt] Value termination NULL, // [in,opt] Allowed padding &venue.iDistance, // [out] Put it here 1); // [in] Remove additional termination CHARS if( !pData || (!(*pData) && i < count-1)) { roadmap_log( ROADMAP_ERROR, "Foursquare - parse_search_results(): Failed to read venue distance=%d", venue.iDistance); (*rc) = err_parser_unexpected_data; return NULL; } if (gsVenuesCount < ROADMAP_FOURSQUARE_MAX_VENUE_COUNT) { //skip if more venues received create_description (&venue); gsVenuesList[gsVenuesCount++] = venue; } } roadmap_main_set_periodic(100,roadmap_foursquare_venues_list); return pData; }
static void ssd_dialog_disable_key (void) { RoadMapDialogKeyEnabled = 0; roadmap_main_set_periodic (350, ssd_dialog_enable_callback); }
static const char* parse_checkin_results(roadmap_result* rc, int NumParams, const char* pData) { //Expected data: // CheckinResult,<checkin_message>,<score_points> char CommandName[128]; int iBufferSize; iBufferSize = 128; if (NumParams == 0) return pData; if ((NumParams - 1) % ROADMAP_FOURSQUARE_CHECKIN_ENTRIES != 0) { (*rc) = err_parser_unexpected_data; return NULL; } pData = ExtractNetworkString( pData, // [in] Source string CommandName,// [out] Output buffer &iBufferSize, // [in,out] Buffer size / Size of extracted string ",", // [in] Array of chars to terminate the copy operation 1); // [in] Remove additional termination chars if (strcmp(CommandName, "CheckinResult") != 0) { roadmap_log(ROADMAP_ERROR, "Foursquare - parse_search_results(): could not find command: CheckinResult (received: '%s')", CommandName); (*rc) = err_parser_unexpected_data; return NULL; } // 1. checkin message iBufferSize = ROADMAP_FOURSQUARE_MESSAGE_MAX_SIZE; pData = ExtractNetworkString( pData, // [in] Source string gsCheckInInfo.sCheckinMessage, // [out,opt]Output buffer &iBufferSize, // [in,out] Buffer size / Size of extracted string ",", // [in] Array of chars to terminate the copy operation 1); // [in] Remove additional termination chars if( !pData || !(*pData)) { roadmap_log( ROADMAP_ERROR, "Foursquare - parse_checkin_results(): Failed to read checkin message=%s", gsCheckInInfo.sCheckinMessage); (*rc) = err_parser_unexpected_data; return NULL; } // 2. name iBufferSize = ROADMAP_FOURSQUARE_SCORE_PT_MAX_SIZE; pData = ExtractNetworkString( pData, // [in] Source string gsCheckInInfo.sScorePoints, // [out,opt]Output buffer &iBufferSize, // [in,out] Buffer size / Size of extracted string ",\r\n", // [in] Array of chars to terminate the copy operation 1); // [in] Remove additional termination chars if( !pData) { roadmap_log( ROADMAP_ERROR, "Foursquare - parse_checkin_results(): Failed to read score points=%s", gsCheckInInfo.sScorePoints); (*rc) = err_parser_unexpected_data; return NULL; } roadmap_main_set_periodic(100, roadmap_foursquare_checkedin_dialog); return pData; }
static void roadmap_skin_gps_listener (time_t gps_time, const RoadMapGpsPrecision *dilution, const RoadMapGpsPosition *position){ time_t rawtime_sunset, rawtime_sunrise; static int has_run = 0; time_t now ; int timer_t; struct tm realtime, *tmp_tm; struct tm *realtime2; static int num_points = 0; //time_t now = time(NULL); if (num_points < 3){ num_points++; return; } now = gps_time; //realtime = localtime (&now); // printf ("gpstime %s", asctime (realtime) ); roadmap_gps_unregister_listener(roadmap_skin_gps_listener); if (has_run) return; has_run = TRUE; rawtime_sunrise = roadmap_sunrise (position, now); tmp_tm = localtime (&rawtime_sunrise); realtime = *tmp_tm; // printf ("sunrise: %d:%d\n", tmp_tm->tm_hour, tmp_tm->tm_min); rawtime_sunset = roadmap_sunset (position, now); realtime2 = localtime (&rawtime_sunset); //printf ("sunset: %d:%d\n", realtime2->tm_hour, realtime2->tm_min); //printf ("sunrise: %d:%d\n", realtime->tm_hour, realtime->tm_min); //printf ("sunset %s\n\n", asctime (realtime2) ); //sprintf(msg, "sunset: %d:%d %d-%d\n sunrise: %d:%d %d-%d\n", realtime2->tm_hour, realtime2->tm_min, realtime2->tm_mday, realtime2->tm_mon+1,realtime->tm_hour, realtime->tm_min, realtime->tm_mday, realtime->tm_mon+1); //printf("%s\n", msg); if (rawtime_sunset > rawtime_sunrise){ roadmap_skin_set_subskin ("night"); timer_t = rawtime_sunrise - now; if ((timer_t > 0) && (timer_t < 1800)) roadmap_main_set_periodic (timer_t*1000, toggle_skin_timer); } else{ timer_t = rawtime_sunset - now; if ((timer_t > 0) && (timer_t < 1800)){ ToggleToNightMode = TRUE; roadmap_main_set_periodic (timer_t*1000, toggle_skin_timer); } } }
void ssd_confirm_dialog_timeout (const char *title, const char *text, BOOL default_yes, ConfirmDialogCallback callback, void *context, int seconds) { ssd_confirm_dialog (title, text,default_yes,callback, context); MessageBoxCallback = ssd_confirm_dialog_close; roadmap_main_set_periodic (seconds * 1000, ssd_confirm_dialog_close ); }
static void roadmap_trip_server_after_login (void) { roadmap_main_set_periodic(1000*30, roadmap_trip_server_after_login_delayed); if (gLoginCallBack) (*gLoginCallBack) (); }