예제 #1
0
static void roadmap_trip_server_restore_favorites_cb(int exit_code, void *context){
   if (exit_code != dec_yes){
      if (gLoginChangedCallBack)
          (*gLoginChangedCallBack) ();
      return;
   }
   ssd_progress_msg_dialog_show(roadmap_lang_get("Restoring favorites..."));
   Realtime_TripServer_GetPOIs();
   if (gLoginChangedCallBack)
       (*gLoginChangedCallBack) ();
}
예제 #2
0
/*
 * 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);
}
예제 #3
0
/*  Name        : roadmap_recorder_voice_download()
 *  Purpose     : Constructs the url and downloads the voice.
 *
 *  Params     : (in) voice_id - the voice id to download
 *
 *             : (out) download_cb - the full path to the downloaded voice file - user responsibility to
 *             		deallocate the memory!!!!
 *
 *  Notes      :
 *
 */
BOOL roadmap_recorder_voice_download( const char* voice_id,  void* context_cb, VoiceDownloadCallback download_cb )
{
    BOOL res = FALSE;
    char *url;
    char  *voice_file, *voice_path;
    DownloadContext* context;

    roadmap_log( ROADMAP_DEBUG, "Downloading the voice.  ID: %s", voice_id );

    // Target file name from the voice id
    voice_file = malloc( strlen( voice_id ) + strlen( ROADMAP_VOICE_DOWNLOAD_FILE_SUFFIX ) + 1 );
    strcpy( voice_file, voice_id );
    strcat( voice_file, ROADMAP_VOICE_DOWNLOAD_FILE_SUFFIX );

    // Target full path for the output
    voice_path = roadmap_path_join( roadmap_path_voices(), voice_file );
    if (roadmap_file_exists( NULL, voice_path ) )
    {
        // Add file to cache
        download_cache_add( voice_path );
        // The file exists - no need to download
        download_cb( context_cb, 0, voice_path );
        roadmap_path_free( voice_path );
    }
    else
    {
        url = get_download_url( voice_id );
        // Init the download process context
        context = malloc( sizeof( DownloadContext ) );
        context->voice_path = voice_path;
        context->context_cb = context_cb;
        context->download_cb = download_cb;
        context->data = NULL;
        // Show the message
        ssd_progress_msg_dialog_show( roadmap_lang_get( "Downloading voice ..." ) );
        // Start the process
        roadmap_http_async_copy( &gHttpAsyncCallbacks, context, url ,0 );
        free( url );
    }

    free( voice_file );

    return res;
}
예제 #4
0
static int on_alt_routes_btn_cb(SsdWidget widget, const char *new_value){
   const RoadMapPosition *from;
   RoadMapPosition to;
   AltRouteTrip route;
   RealtimeAltRoutes_Clear();
   from =navigate_main_get_src_position ();
   navigate_get_waypoint(-1, &to);   
   ssd_progress_msg_dialog_show( roadmap_lang_get( "Calculating alternative routes, please wait..." ) );
   RealtimeAltRoutes_Init_Record(&route);
   route.srcPosition = *from;
   route.destPosition = to;
   route.iTripId = -1;
   navigate_main_stop_navigation();
   roadmap_trip_set_point ("Destination", &route.destPosition);
   roadmap_trip_set_point ("Departure", &route.srcPosition);
   RealtimeAltRoutes_Add_Route(&route);
   RealtimeAltRoutes_Route_Request (-1, from, &to, MAX_ROUTES);
   return 1;
} 
예제 #5
0
static void delayed_show_progress (void){
   roadmap_main_remove_periodic(delayed_show_progress);
   ssd_progress_msg_dialog_show( roadmap_lang_get( "Connecting Foursquare . . ." ) );
}
예제 #6
0
/* Allows other windows to be closed */
static void search_progress_message_delayed(void)
{
	roadmap_main_remove_periodic( search_progress_message_delayed );
	if( s_searching )
		ssd_progress_msg_dialog_show( roadmap_lang_get( "Searching..." ) );
}
예제 #7
0
/***********************************************************
 *  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);
}
예제 #8
0
///////////////////////////////////////////////////////
// Compress files and prepare for upload
int upload () {
   const char* directory = roadmap_path_debug();
   const char* target_url;
   char *full_path;
   upload_context * context;

#ifndef RIMAPI
   char **files = roadmap_path_list (directory, ".gz");
#else
   char ** files = malloc(sizeof(char *)*2); // temporary workaround, until path list is implemented
   files[0] = strdup(zipped_log_name);
   files[1]  = NULL;
#endif

   int count;
   int total;
   char **cursor;

   // Set the target to upload to

   sprintf (warning_message,"%s",roadmap_lang_get("Uploading logs..."));
   ssd_progress_msg_dialog_show(warning_message);
   roadmap_main_flush();

   count = 0;
   for (cursor = files; *cursor != NULL; ++cursor) {
      count++;
   }

   cursor = files;
   total = count;
   count = 0;
   target_url = roadmap_config_get ( &RMCfgDebugInfoServer);

   context= malloc(sizeof(upload_context));
   context->cursor = cursor;
   context->files = files;
   context->file_num = count;
   context->total = total;

   full_path = roadmap_path_join( directory, *cursor );

   context->full_path = full_path;

   sprintf (warning_message,"%s\n%d/%d",roadmap_lang_get("Uploading logs..."),count+1, context->total);

   ssd_progress_msg_dialog_show(warning_message);
   roadmap_main_flush();

   // this starts the async sending sequence. Further progress is done through the callbacks.
   if ( editor_upload_auto( full_path, &gUploadCallbackFunctions, target_url, LOG_UPLOAD_CONTENT_TYPE,(void *)context) )
   {
 	  roadmap_log( ROADMAP_ERROR, "File upload error. for file %s ", full_path);

 	  roadmap_path_free(full_path);
 	  roadmap_path_list_free (files);

 	  ssd_progress_msg_dialog_hide();
 	  free(context);
 	  return 0;
   }

   return 1;
}
예제 #9
0
///////////////////////////////////////////////////////
// Compress files and prepare for upload
int prepare_for_upload ()
{
   int res;
   char out_filename[256];
   char **files;
   char **cursor;
   const char* directory;
   int count;
   int total;
   time_t now;
	struct tm *tms;
   char year[5], month[5], day[5];
#ifdef RIMAPI
   timeStruct time_s;
#endif
   sprintf (warning_message,"%s",roadmap_lang_get("Preparing files for upload..."));
   ssd_progress_msg_dialog_show(warning_message);
   roadmap_main_flush();


   //Count files for upload
   directory = roadmap_path_gps();
   files = roadmap_path_list (directory, ".csv");
   count = 1; //Counting also the postmortem
   for (cursor = files; *cursor != NULL; ++cursor) {
      count++;
   }

   total = count;
   count = 0;



   //Prepare log
   count++;
   sprintf (warning_message,"%s\n%d/%d",roadmap_lang_get("Preparing files for upload..."),count, total);
   ssd_progress_msg_dialog_show(warning_message);
   roadmap_main_flush();

   // Building the filename
   time( &now );
   tms = localtime( &now );
#ifdef RIMAPI
   roadmap_time_get_time(&time_s);
   tms->tm_hour = time_s.hours;
   tms->tm_min =  time_s.minutes;
#endif
   GET_2_DIGIT_STRING( tms->tm_mday, day );
   GET_2_DIGIT_STRING( tms->tm_mon+1, month );	// Zero based from January
   GET_2_DIGIT_STRING( tms->tm_year-100, year ); // Year from 1900
   snprintf(out_filename,256, "%s%s%s__%d_%d__%s_%d_%s__%s.gz", day, month, year,
           tms->tm_hour, tms->tm_min, RealTime_GetUserName(), RT_DEVICE_ID, roadmap_start_version(), roadmap_log_filename());
#ifndef RIMAPI
   res = roadmap_zlib_compress(roadmap_log_path(), roadmap_log_filename(), roadmap_path_debug(), out_filename, COMPRESSION_LEVEL,TRUE);
#else
   // 0 = Z_OK = SUCCESS. 1 = failure.
   res = NOPH_ZLib_compress(roadmap_log_path(), roadmap_log_filename(), roadmap_path_debug(),out_filename,COMPRESSION_LEVEL);
   strcpy(zipped_log_name,out_filename); // emporary until path_list is implemented
#endif

   if (res != Z_OK) {
      ssd_progress_msg_dialog_hide();
      return 0;
   }


   //Prepare CSV files
   for (cursor = files; *cursor != NULL; ++cursor) {
      count++;
      sprintf (warning_message,"%s\n%d/%d",roadmap_lang_get("Preparing files for upload..."),count, total);
      ssd_progress_msg_dialog_show(warning_message);
      roadmap_main_flush();

      sprintf(out_filename, "%s%s.gz", *cursor, RealTime_GetUserName());
#ifndef J2ME
      res = roadmap_zlib_compress(directory, *cursor, roadmap_path_debug(), out_filename, COMPRESSION_LEVEL,FALSE);
#else
      // 0 = Z_OK = SUCCESS. 1 = failure.
      res = NOPH_ZLib_compress(directory, *cursor, roadmap_path_debug(),out_filename,COMPRESSION_LEVEL);
#endif
      if (res != Z_OK) {
         ssd_progress_msg_dialog_hide();
         return 0;
      } else {
         roadmap_file_remove(directory, *cursor);
      }
   }

   roadmap_path_list_free (files);



   ssd_progress_msg_dialog_hide();
   return 1;
}
예제 #10
0
static void on_recieved_completed (void) {
   char updateText[] = "We've made a few infrastructural changes that require re-start. Please exit and re-start waze.";
   const char *user_lang = roadmap_lang_get_user_lang();//"heb";//todomt 
   const char *force_lang = roadmap_config_get( &RoadMapConfigForceLanguage);
   // compare the old and new server id's - if different, user needs to restart
   int oldServerId = roadmap_config_get_integer(&RoadMapConfigSystemServerId);
   int newServerId = GeoConfigContext.id;

   // Save the RT server ID.
   roadmap_config_set_integer (&RoadMapConfigSystemServerId,
            GeoConfigContext.id);

#ifndef J2ME // in J2ME don't download the language until user chooses it manually // TODODAN
   //set the language
   if (!strcmp(force_lang, "")){
	   roadmap_lang_set_system_lang (GeoConfigContext.lang, NULL);
   }else{
	   roadmap_lang_set_system_lang (force_lang, NULL);
   }
#endif

   // Save version
   roadmap_config_set_integer (&RoadMapConfigGeoConfigVersion,
            GeoConfigContext.version);

   //Save new configuration
   roadmap_config_save (0);

   //Remove timer
   roadmap_main_remove_periodic (GeoConfigTimer);

   roadmap_log (ROADMAP_DEBUG,"GeoServerConfig Completed setting all parameters!!" );
   roadmap_log (ROADMAP_INFO, "GeoServerConfig: user_lang='%s' newServerId=%d", user_lang, newServerId );

   if ((user_lang[0] == 0) && (newServerId != 2)){
      roadmap_lang_download_conf_file(on_lang_conf_downloaded);
      return;
   }

   if ((user_lang[0] == 0) && (newServerId == 2)){
      roadmap_lang_set_system_lang(GeoConfigContext.lang, NULL);
   }

   if ((oldServerId==-1)){
      ssd_progress_msg_dialog_show("Downloading language");
	  roadmap_lang_download_lang_file(roadmap_lang_get_system_lang(), on_user_lang_downloaded); //on_user_lang_downloaded();//todomt 
      return;
   }

#ifndef J2ME
   roadmap_lang_download_lang_file(GeoConfigContext.lang, NULL);
#endif


   ssd_progress_msg_dialog_hide();

   clean_up();

   roadmap_screen_refresh();

   if (GeoConfigContext.callback)
      (*GeoConfigContext.callback)();

   GeoConfigContext.callback = NULL;

//   if ((oldServerId!=newServerId)&&(oldServerId!=-1)){
//
//      roadmap_lang_set_update_time("");
//#ifndef J2ME
//      roadmap_lang_set_lang_file_update_time("heb","");
//      roadmap_lang_set_lang_file_update_time("eng","");
//#endif
//      roadmap_prompts_set_update_time ("");
//      roadmap_splash_set_update_time ("");
//      roadmap_splash_reset_check_time();
//      roadmap_config_save(FALSE);
//#if (defined (IPHONE) || defined (ANDROID))
//      roadmap_tile_remove_all(roadmap_locator_active());
//#endif
//      roadmap_messagebox_cb(roadmap_lang_get("Please restart Waze"), roadmap_lang_get(updateText), restart_msg_cb);
//   }

}
예제 #11
0
/***********************************************************
 *  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" ));
}