/* * Called once one file was sent successfully. Starts the sending of the next file, if there is one. */ static void upload_done( void *context, const char *format, ... ) { upload_context * uContext = (upload_context *)context; int new_count; char ** new_cursor; const char * target_url; char * new_full_path; char msg[500]; int total; va_list ap; if(format){ va_start(ap, format); vsnprintf(msg,sizeof(msg),format,ap); va_end(ap); roadmap_log(ROADMAP_DEBUG,"done uploading log file : %s. Received response : %s",*uContext->cursor,msg); } new_cursor = (uContext->cursor)+1; new_count = (uContext->file_num)+1; total = uContext->total; roadmap_file_remove(NULL, uContext->full_path); // remove the previous file if(new_count==total){ // finished - sent all the files! in_process = 0 ; roadmap_path_list_free(uContext->files); ssd_progress_msg_dialog_hide(); roadmap_messagebox_timeout("Thank you!!!", "Logs submitted successfully to waze",3); }else{ // still more files - call the next one upload_context * new_context; sprintf (warning_message,"%s\n%d/%d",roadmap_lang_get("Uploading logs..."),new_count+1, total); ssd_progress_msg_dialog_show(warning_message); roadmap_main_flush(); new_full_path = roadmap_path_join( roadmap_path_debug(), *new_cursor ); new_context= malloc(sizeof(upload_context)); new_context->cursor = new_cursor; new_context->files = uContext->files; new_context->full_path = new_full_path; new_context->file_num = new_count; new_context->total = total; target_url = roadmap_config_get ( &RMCfgDebugInfoServer); if ( editor_upload_auto( new_full_path, &gUploadCallbackFunctions, target_url, LOG_UPLOAD_CONTENT_TYPE,(void *)new_context) ) { roadmap_log( ROADMAP_ERROR, "File upload error. for file %s , number %d", new_full_path, new_count); roadmap_path_free(new_full_path); roadmap_path_list_free (new_context->files); ssd_progress_msg_dialog_hide(); roadmap_messagebox_timeout("Error", "Error sending files",5); in_process = 0; } } roadmap_path_free(uContext->full_path); free(uContext); }
static void delete_callback(int exit_code, void *context) { BOOL success; if (exit_code != dec_yes) return; success = (* (RoadMapAlertProvidors.providor[the_active_alert.alert_providor]->cancel))(the_active_alert.active_alert_id); if (success) roadmap_messagebox_timeout("Thank you!!!", "Your request was sent to the server",3); }
void RealtimeAltRoutes_OnTripRouteRC (NavigateRouteRC rc, int protocol_rc, const char *description){ if ((protocol_rc != 200) || (rc != route_succeeded)){ roadmap_log (ROADMAP_ERROR,"RealtimeAltRoutes_OnTripRouteRC - %s (rc=%d)", description, rc); if (roadmap_alternative_routes_suggest_dlg_active()){ ssd_dialog_hide_all(dec_close); if (!roadmap_screen_refresh()) roadmap_screen_redraw(); roadmap_messagebox_timeout("Oops", description, 5); } } }
static void upload_error_callback( void *context) { upload_context * uContext = (upload_context *)context; ssd_progress_msg_dialog_hide(); roadmap_messagebox_timeout("Error", "Error sending files",5); in_process = 0; roadmap_file_remove(NULL, uContext->full_path); roadmap_path_list_free(uContext->files); roadmap_path_free(uContext->full_path); free(uContext); }
/////////////////////////////////////////////////////// // Submit all debug info - confirmation callback static void roadmap_confirmed_debug_info_submit(int exit_code, void *context){ if (exit_code != dec_yes) return; #ifdef J2ME roadmap_log_close_log_file(); #endif in_process = 1; if (!prepare_for_upload()) { roadmap_messagebox_timeout("Oops", "Error sending files",5); in_process = 0; return; } if (!upload()) { roadmap_messagebox_timeout("Oops", "Error sending files",5); in_process = 0; return; } }
static void route_request_timeout(void) { roadmap_main_remove_periodic( route_request_timeout ); ssd_progress_msg_dialog_hide(); if (CalculatingAltRoutes) { char msg[128]; snprintf(msg, sizeof(msg), "%s.\n%s", roadmap_lang_get("Routing service timed out"), roadmap_lang_get("Please try again later")); roadmap_messagebox_timeout("Oops",msg ,5); roadmap_analytics_log_event (ANALYTICS_EVENT_ROUTE_ERROR, ANALYTICS_EVENT_INFO_ERROR, "TimeOut"); navigate_route_cancel_request(); CalculatingAltRoutes = FALSE; } }
static void delete_callback(int exit_code, void *context){ BOOL success; if (exit_code != dec_yes) return; success = (* (RoadMapAlertProviders.provider[the_active_alert.alert_provider]->cancel))(the_active_alert.active_alert_id); alert_active = FALSE; the_active_alert.active_alert_id = -1; alert_should_be_visible = FALSE; if (success) roadmap_messagebox_timeout("Thank you!!!", "Your request was sent to the server",5); ssd_dialog_hide("Alert_Dlg", dec_close); }
int RealtimeBonus_CollectedPointsConfirmed(int iID, int iType, int iPoints, BOOL bHasGift, BOOL bIsBigPrize, const char *gift){ if (iType == BONUS_TYPE_POINTS){ if (iPoints != 0){ roadmap_log( ROADMAP_DEBUG, "RealtimeBonus_CollectedPointsRes() - (id =%d, points = %d)", iID, iPoints); editor_points_add_new_points (iPoints); editor_points_display_new_points_timed (iPoints, 6, bonus_points); } else{ roadmap_log( ROADMAP_ERROR, "RealtimeBonus_CollectedPointsRes() - Failed (id =%d, points = %d)", iID, iPoints); } } else if (iType == BONUS_TYPE_TREASURE){ if (!bHasGift){ // The chest box was empty roadmap_messagebox_timeout("", roadmap_lang_get ("Bummer, this treasure chest was emptied. Keep searching for other chests, some have valuable prizes in them."), 10); } else{ // We got a gift! char msg[250]; if (iPoints != 0){ snprintf(msg, sizeof(msg),roadmap_lang_get ("Huray! You just won %s and an extra %d points. Check your email for info."), roadmap_lang_get(gift), iPoints); roadmap_messagebox("",msg); editor_points_add_new_points (iPoints); editor_points_display_new_points_timed (iPoints, 6, bonus_points); } else{ if (bIsBigPrize){ snprintf(msg, sizeof(msg),roadmap_lang_get ("Huray!!! You won the big prize: %s . Check your email for info."), roadmap_lang_get(gift)); roadmap_messagebox("",msg); } else{ snprintf(msg, sizeof(msg),roadmap_lang_get ("Huray! You just won %s. Check your email for info."), roadmap_lang_get(gift)); roadmap_messagebox("",msg); } } } } else{ roadmap_log( ROADMAP_ERROR, "RealtimeBonus_CollectedPointsRes() - Unknown type = %d (ID=%d)", iType,iID); } return TRUE; }
int RealtimeBonus_HandleEvent (int iID) { RTBonus *pbonus = RealtimeBonus_Get (iID); if (!pbonus) return TRUE; if (pbonus->collected) return TRUE; pbonus->collected = TRUE; if (roadmap_map_settings_road_goodies()){ if ((pbonus->iType == BONUS_TYPE_TREASURE) && Realtime_is_random_user()){ roadmap_messagebox_timeout("", roadmap_lang_get ("There may be presents in this treasure chest but you need to be a registered user in order to get them. Register in 'Settings > Profile'"), 10); return TRUE; } roadmap_log( ROADMAP_DEBUG, "Yeahhh Collecting a gift id=%d)", iID); Play_Animation_Sound (); RealtimeBonus_Animate_Pacman (); } if (pbonus->bIsCustomeBonus){ Realtime_CollectCustomBonus(iID, roadmap_twitter_is_munching_enabled() && roadmap_twitter_logged_in(), roadmap_facebook_is_munching_enabled() && roadmap_facebook_logged_in()); editor_points_add_new_points (pbonus->iNumPoints); } else{ Realtime_CollectBonus(iID, pbonus->iToken, roadmap_twitter_is_munching_enabled() && roadmap_twitter_logged_in(), roadmap_facebook_is_munching_enabled() && roadmap_facebook_logged_in()); } onBonusDelete(pbonus); return TRUE; }
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 lang_changed_delayed_message(void){ roadmap_main_remove_periodic(lang_changed_delayed_message); roadmap_messagebox_timeout("","Language changed, Please restart waze",5); }
const char* on_get_pois_res(int NumParams,const char* pData){ int i; int iBufferSize; int longitude; int latitude; char poiName[MAX_POI_NAME]; char *argv[ahi__count]; char temp[20]; char msg[100]; int numRecords = NumParams/3; roadmap_log( ROADMAP_WARNING, "roadmap_tripserver_response- got GetPOIsRes (Num parameters= %d )",NumParams ); if (numRecords > 0) purge_old_favorites(); for (i = 0; i < numRecords; i++){ //POI name iBufferSize = sizeof(poiName); pData = ExtractNetworkString( pData, // [in] Source string poiName, // [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 (!pData){ roadmap_log( ROADMAP_ERROR, "Tripserver::on_get_pois_res() - Failed to read POI name"); return NULL; } //POI Lon pData = ReadIntFromString( pData, // [in] Source string ",", // [in,opt] Value termination NULL, // [in,opt] Allowed padding &longitude, // [out] Put it here 1); // [in] Remove if (!pData){ roadmap_log( ROADMAP_ERROR, "Tripserver::on_get_pois_res() - Failed to read Destination longitude. POI Name=%s",poiName ); return NULL; } //POI Lat pData = ReadIntFromString( pData, // [in] Source string ",\r\n", // [in,opt] Value termination NULL, // [in,opt] Allowed padding &latitude, // [out] Put it here TRIM_ALL_CHARS);// [in] Remove if (!pData){ roadmap_log( ROADMAP_ERROR, "Tripserver::on_get_pois_res() - Failed to read Destination latitude. POI Name=%s",poiName ); return NULL; } argv[ahi_house_number] = ""; argv[ahi_street] = ""; argv[ahi_city] = ""; argv[ahi_state] = ""; argv[ahi_name] = (char *)poiName; sprintf(temp, "%d", latitude); argv[ahi_latitude] = strdup(temp); sprintf(temp, "%d", longitude); argv[ahi_longtitude] = strdup(temp); argv[ahi_synced] = "true"; roadmap_log( ROADMAP_WARNING, "roadmap_tripserver_response- GetPOIsRes Adding favorite (name=%s, lat=%s, lon=%s )", argv[ahi_name], argv[ahi_latitude], argv[ahi_longtitude]); roadmap_history_add (ADDRESS_FAVORITE_CATEGORY, (const char **)argv); } ssd_progress_msg_dialog_hide(); if (numRecords == 0) sprintf(msg, "%s", roadmap_lang_get("No favorite destinations were found")); else if (numRecords == 1) sprintf(msg, "%s", roadmap_lang_get("1 destination was restored to your favorites")); else sprintf(msg, "%d %s", numRecords, roadmap_lang_get("destinations were restored to your favorites")); roadmap_messagebox_timeout("Favorites", msg, 5); roadmap_history_save(); return pData; }