Пример #1
0
void editor_db_delete (int map_id) {

   char name[100];
  	const char *map_path;

   map_path = roadmap_db_map_path();
   snprintf (name, sizeof(name), "edt%05d.dat", map_id);
   
   if (roadmap_file_exists (map_path, name)) {

      char **files;
      char **cursor;
      char directory[512];
      char full_name[512];

      /* Delete notes wav files */
      /* FIXME this is broken for multiple counties */
      roadmap_path_format (directory, sizeof (directory), roadmap_path_user (), "markers");
      files = roadmap_path_list (directory, ".wav");

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

         roadmap_path_format (full_name, sizeof (full_name), directory, *cursor);
         roadmap_file_remove (NULL, full_name);
      }

      /* Remove the actual editor file */
      roadmap_file_remove (map_path, name);
   }
}
Пример #2
0
static int sync_do_upload () {
    char **files;
    char **cursor;
    const char* directory = editor_sync_get_export_path();
    int count;
    upload_context *  context;
    char * full_path;
    int size;
    const char *header;

    files = roadmap_path_list (directory, ".wud");

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

    //
    cursor = files;
    count = 0;
    //

    context= malloc(sizeof(upload_context));
    context->cursor = cursor;
    context->files = files;
    full_path = roadmap_path_join( directory, *cursor );
    context->full_path = full_path;


    SyncProgressItems = count;
    SyncProgressCurrentItem = 1;
    SyncProgressLoaded = 0;
    SyncUploadNumMessages = 0;

    // this starts the async sending sequence. Further progress is done through the callbacks.
    size = roadmap_file_length (NULL, full_path);
    header = roadmap_http_async_get_upload_header(DEFAULT_CONTENT_TYPE, full_path, size, RealTime_GetUserName(), Realtime_GetPassword());
    if (!roadmap_http_async_post_file(&gUploadCallbackFunctions, (void *)context, editor_upload_get_url(), header, full_path, size))
    {
        roadmap_log( ROADMAP_ERROR, "File upload error, couldn't start sync socket connect. for file %s ", full_path);
//	  roadmap_path_free(full_path);
//	  roadmap_path_list_free (files);
//	  free(context);
        return 0;
    }

    return 1;
}
Пример #3
0
void roadmap_car_dialog (RoadMapCallback callback) {

    char **files;
    const char *cursor;
    char **cursor2;
    char *directory;
    int count = 0; 	
    
    static roadmap_car_list_dialog context = {"roadmap_car", NULL};	
   	static char *labels[MAX_CAR_ENTRIES] ;
	static void *values[MAX_CAR_ENTRIES] ;
	static void *icons[MAX_CAR_ENTRIES];


	context.callback = callback;
    for (cursor = roadmap_path_first ("skin");
            cursor != NULL;
            cursor = roadmap_path_next ("skin", cursor)) {

	    directory = roadmap_path_join (cursor, "cars");
    	
    	files = roadmap_path_list (directory, ".png");

   		for (cursor2 = files; *cursor2 != NULL; ++cursor2) {
   	  			labels[count]  =   (char *)roadmap_lang_get(*cursor2);
   	  			values[count] =   strtok(*cursor2,".");
   	  			icons[count]   =   roadmap_path_join("cars", *cursor2);
      			count++;
   		}
   }   

    ssd_generic_icon_list_dialog_show (roadmap_lang_get ("Select your car"),
                  count,
                  (const char **)labels,
                  (const void **)values,
                  (const char **)icons,
                  NULL,
                  roadmap_car_call_back,
                  NULL,
                  &context,
                  NULL,
                  NULL,
                  70,
                  0,
                  FALSE);
                  
}
Пример #4
0
static int count_upload_files(void) {
    char **files;
    char **cursor;
    const char* directory = editor_sync_get_export_path();
    int count;

    files = roadmap_path_list (directory, ".wud");

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

    roadmap_path_list_free (files);

    return count;
}
Пример #5
0
static int sync_do_upload () {
   char **files;
   char **cursor;
   const char* directory = editor_sync_get_export_path();
   int count;
   upload_context *  context;
   char * full_path;

   files = roadmap_path_list (directory, ".wud");

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

   //
   cursor = files;
	count = 0;
	//

	context= malloc(sizeof(upload_context));
	context->cursor = cursor;
	context->files = files;
	full_path = roadmap_path_join( directory, *cursor );
	context->full_path = full_path;


   SyncProgressItems = count;
   SyncProgressCurrentItem = 1;
   SyncProgressLoaded = 0;
   SyncUploadNumMessages = 0;

   // this starts the async sending sequence. Further progress is done through the callbacks.
	if (  editor_upload_auto( full_path, &gUploadCallbackFunctions, NULL, NULL ,(void *)context) )
	{
	  roadmap_log( ROADMAP_ERROR, "File upload error, couldn't start sync socket connect. for file %s ", full_path);
	  roadmap_path_free(full_path);
	  roadmap_path_list_free (files);
	  free(context);
	  return 0;
	}

   return 1;
}
Пример #6
0
void editor_db_delete (int map_id) {

   char name[100];
  	const char *map_path;

#ifdef WIN32
	map_path = roadmap_path_join (roadmap_path_user(), "maps");
#else
   map_path = roadmap_path_first ("maps");
   while (map_path && !roadmap_file_exists (map_path,"")) {
   	map_path = roadmap_path_next ("maps", map_path);
   }
#endif
   snprintf (name, sizeof(name), "edt%05d.dat", map_id);
   
   if (roadmap_file_exists (map_path, name)) {

      char **files;
      char **cursor;
      char *directory;

      /* Delete notes wav files */
      /* FIXME this is broken for multiple counties */
      directory = roadmap_path_join (roadmap_path_user (), "markers");
      files = roadmap_path_list (directory, ".wav");

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

         char *full_name = roadmap_path_join (directory, *cursor);
         roadmap_file_remove (NULL, full_name);

         free (full_name);
      }

      free (directory);

      /* Remove the actual editor file */
      roadmap_file_remove (map_path, name);
   }
#ifdef WIN32
   roadmap_path_free(map_path);
#endif
}
Пример #7
0
void roadmap_mood_dialog (RoadMapCallback callback) {

    char **files;
    const char *cursor;
    char **cursor2;
    char *directory = NULL;
    int count = 0;
    SsdWidget moodDlg;
    SsdWidget list;
    SsdWidget exclusive_list;
    SsdWidget baby_list;
    SsdWidget text;
    int i;
    BOOL only_baby_mood = Realtime_IsNewbie();
    int row_height = ssd_container_get_row_height();
    SsdListCallback exclusive_callback = NULL;

    SsdListCallback regular_mood_callback = roadmap_mood_call_back;
    int flags = 0;
    int width = SSD_MAX_SIZE;

    static roadmap_mood_list_dialog context = {"roadmap_mood", NULL};
    static char *labels[MAX_MOOD_ENTRIES] ;
    static void *values[MAX_MOOD_ENTRIES] ;
    static void *icons[MAX_MOOD_ENTRIES];

    static char *exclusive_labels[MAX_EXCLUSIVE_ICONS] ;
    static void *exclusive_values[MAX_EXCLUSIVE_ICONS] ;
    static void *exclusive_icons[MAX_EXCLUSIVE_ICONS];

    static char *baby_labels[1] ;
    static void *baby_values[1] ;
    static void *baby_icons[1];


    flags |= SSD_ALIGN_CENTER|SSD_CONTAINER_BORDER|SSD_CONTAINER_FLAGS;
    width = ssd_container_get_width();


    moodDlg   = ssd_dialog_new ( "MoodDlg", roadmap_lang_get ("Select your mood"), NULL, SSD_CONTAINER_TITLE);
    moodDlg->context = (void *)callback;
    exclusive_list = ssd_list_new ("list", width, SSD_MAX_SIZE, inputtype_none, flags, NULL);

    ssd_list_resize ( exclusive_list, row_height );

    baby_list = ssd_list_new ("baby_list", width, SSD_MAX_SIZE, inputtype_none, flags, NULL);

    ssd_list_resize ( baby_list, row_height );

    exclusive_labels[0] = (char *)roadmap_lang_get("wazer_gold");
    exclusive_values[0] = "wazer_gold";
    exclusive_icons[0] = "wazer_gold";

    exclusive_labels[1] = (char *)roadmap_lang_get("wazer_silver");
    exclusive_values[1] = "wazer_silver";
    exclusive_icons[1] = "wazer_silver";

    exclusive_labels[2] = (char *)roadmap_lang_get("wazer_bronze");
    exclusive_values[2] = "wazer_bronze";
    exclusive_icons[2] = "wazer_bronze";

    if (roadmap_mood_get_exclusive_moods() > 0){
       exclusive_callback = roadmap_exclusive_mood_call_back;
    }

    ssd_list_populate (exclusive_list, 3, (const char **)exclusive_labels, (const void **)exclusive_values, (const char **)exclusive_icons, NULL, exclusive_callback, NULL, FALSE);

    if (only_baby_mood){
       char msg[150];
       baby_labels[0] = (char *)roadmap_lang_get("Baby");
       baby_values[0] = "wazer_baby";
       baby_icons[0] = "wazer_baby";
       ssd_list_populate (baby_list, 1, (const char **)baby_labels, (const void **)baby_values, (const char **)baby_icons, NULL, NULL, NULL, FALSE);

       ssd_dialog_add_hspace(moodDlg, 20, 0);
       text = ssd_text_new ("Baby Mood Txt", roadmap_lang_get("Waze newbie"), SSD_HEADER_TEXT_SIZE, SSD_TEXT_NORMAL_FONT | SSD_END_ROW);
       ssd_widget_add(moodDlg, text);
       ssd_dialog_add_hspace(moodDlg, 20, 0);
       snprintf(msg, sizeof(msg), roadmap_lang_get("(Gotta drive %d+ %s to access other moods)"), roadmap_mood_get_number_of_newbie_miles(), roadmap_lang_get(roadmap_math_trip_unit()));
       text = ssd_text_new ("Gold Mood Txt", msg, 12, SSD_END_ROW|SSD_TEXT_NORMAL_FONT);
       ssd_widget_add(moodDlg, text);
       ssd_widget_add (moodDlg, baby_list);

    }
    ssd_dialog_add_vspace(moodDlg, ADJ_SCALE(5),0);
    ssd_dialog_add_hspace(moodDlg, 20, 0);
    text = ssd_text_new ("Gold Mood Txt", roadmap_lang_get("Exclusive moods"), SSD_HEADER_TEXT_SIZE, SSD_TEXT_NORMAL_FONT | SSD_END_ROW);
    ssd_widget_add(moodDlg, text);
    ssd_dialog_add_hspace(moodDlg, 20, 0);
    text = ssd_text_new ("Gold Mood Txt", roadmap_lang_get("(Available only to top weekly scoring wazers)"), SSD_FOOTER_TEXT_SIZE, SSD_END_ROW|SSD_TEXT_NORMAL_FONT);
    ssd_widget_add(moodDlg, text);
    ssd_dialog_add_vspace(moodDlg, ADJ_SCALE(3),0);
    ssd_widget_add (moodDlg, exclusive_list);

    for (i = 0; i < (3 - roadmap_mood_get_exclusive_moods()); i++){
           SsdWidget row = ssd_list_get_row(exclusive_list, i);
           if (row){
              SsdWidget label = ssd_widget_get(row,"label");
              if (label)
                 ssd_text_set_color(label,"#999999");
           }
    }



    list = ssd_list_new ("list", width, SSD_MAX_SIZE, inputtype_none, flags, NULL);
    exclusive_list->key_pressed = NULL;
    ssd_dialog_add_vspace(moodDlg, ADJ_SCALE(10), 0);
    ssd_dialog_add_hspace(moodDlg, 20, 0);
    text = ssd_text_new ("Gold Mood Txt", roadmap_lang_get("Everyday moods"), SSD_HEADER_TEXT_SIZE, SSD_TEXT_NORMAL_FONT | SSD_END_ROW);
    ssd_widget_add(moodDlg, text);
    ssd_dialog_add_hspace(moodDlg, 20, 0);
    text = ssd_text_new ("Gold Mood Txt", roadmap_lang_get("(Available to all)"), SSD_FOOTER_TEXT_SIZE, SSD_END_ROW|SSD_TEXT_NORMAL_FONT);
    ssd_widget_add(moodDlg, text);
    ssd_dialog_add_vspace(moodDlg, ADJ_SCALE(3),0);
    ssd_widget_add (moodDlg, list);
    ssd_list_resize ( list, row_height );

    context.callback = callback;
    for (cursor = roadmap_path_first ("skin");
            cursor != NULL;
            cursor = roadmap_path_next ("skin", cursor)) {

       directory = roadmap_path_join (cursor, "moods");

      files = roadmap_path_list (directory, ".png");
      if ( *files == NULL )
      {
         files = roadmap_path_list (directory, NULL);
      }

         for (cursor2 = files; *cursor2 != NULL; ++cursor2) {
               labels[count]  =   (char *)(strtok(*cursor2,"."));
               count++;
         }
   }


    qsort((void *) &labels[0], count, sizeof(void *), cstring_cmp);

    for (i = 0; i< count; i++){
       values[i] = labels[i];
       icons[i]   =   roadmap_path_join("moods", labels[i]);
       labels[i] = (char *)roadmap_lang_get(labels[i]);
    }



    if (only_baby_mood){
       regular_mood_callback = NULL;
    }

    free(directory);
    ssd_list_populate (list, count, (const char **)labels, (const void **)values, (const char **)icons, NULL, regular_mood_callback, NULL, FALSE);

    if (only_baby_mood){
       for (i = 0; i< count; i++){
          SsdWidget row = ssd_list_get_row(list, i);
          if (row){
             SsdWidget label = ssd_widget_get(row,"label");
             if (label)
                ssd_text_set_color(label,"#999999");
          }
       }
    }
//    else{
//       SsdWidget row = ssd_list_get_row(baby_list,0 );
//       if (row){
//          SsdWidget label = ssd_widget_get(row,"label");
//          if (label)
//             ssd_text_set_color(label,"#999999");
//       }
//    }

    exclusive_list->key_pressed = NULL;
    ssd_dialog_activate ("MoodDlg", NULL);
    ssd_dialog_draw ();

}
Пример #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;
}