示例#1
0
const char *roadmap_db_map_path (void) {

   const char *map_path;
   static char map_path_static[512];
   static int map_path_initialized = 0;
   
   if (!map_path_initialized) { 
   
	#ifdef J2ME
      map_path = roadmap_path_preferred("maps");;
      strncpy_safe (map_path_static, map_path, sizeof (map_path_static));
	#elif defined (WIN32)
		map_path = roadmap_path_join (roadmap_path_user(), "maps");
		strncpy_safe (map_path_static, map_path, sizeof (map_path_static));
		roadmap_path_free (map_path);
	#elif IPHONE
	   map_path = roadmap_path_join (roadmap_main_bundle_path(), "maps");
	   strncpy_safe (map_path_static, map_path, sizeof (map_path_static));
	   roadmap_path_free (map_path);
	#else
	   map_path = roadmap_path_first ("maps");
	   while (map_path && !roadmap_file_exists (map_path,"")) {
	   	map_path = roadmap_path_next ("maps", map_path);
	   }
	   if (map_path) {
			strncpy_safe (map_path_static, map_path, sizeof (map_path_static));
	   } else {
	   	map_path_static[0] = '\0';
	   }
	#endif
		map_path_initialized = 1;
   }
   	
   return map_path_static;
}
示例#2
0
int editor_db_open (int map_id) {

   char name[100];
   const char *map_path;
   char *file_name;
   int do_read = 0;

   editor_log_push ("editor_db_open");

   map_path = roadmap_db_map_path();

	if (!map_path) {
      editor_log (ROADMAP_ERROR, "Can't find editor path");
      editor_log_pop ();
      return -1;
	}

   snprintf (name, sizeof(name), "edt%05d.dat", map_id);

   file_name = roadmap_path_join(map_path, name);

   if (roadmap_file_exists (map_path, name)) {
      EditorDataFile = roadmap_file_open(file_name, "rw");  
      do_read = 1;
   } else {
      roadmap_path_create (map_path);
      EditorDataFile = roadmap_file_open(file_name, "w");
   }
#ifdef WIN32
   roadmap_path_free(map_path);
#endif

	do {
	   if (!ROADMAP_FILE_IS_VALID(EditorDataFile)) {
	      editor_log (ROADMAP_ERROR, "Can't open/create new database: %s/%s",
	            map_path, name);
		   roadmap_path_free(file_name);
	      editor_log_pop ();
	      return -1;
	   }
	
	   if (do_read) {
   		do_read = 0;
	   	if (editor_db_read () == -1) {
	   		editor_db_free ();
	   		roadmap_messagebox("Error", "Offline data file is currupt: Re-Initializing data");
	   		roadmap_file_close (EditorDataFile);
	   		roadmap_file_remove (NULL, file_name);
		      EditorDataFile = roadmap_file_open(file_name, "w");
	   	}
	   }
	} while (do_read);

   roadmap_path_free(file_name);
   EditorActiveMap = map_id;
   editor_log_pop ();
   return 0;
}
示例#3
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);
}
示例#4
0
void editor_marker_voice_file(int marker, char *file, int size) {
    char *path = roadmap_path_join (roadmap_path_user (), "markers");
    char file_name[100];
    char *full_name;

    roadmap_path_create (path);
    snprintf (file_name, sizeof(file_name), "voice_%d.wav", marker);

    full_name = roadmap_path_join (path, file_name);
    strncpy_safe (file, full_name, size);

    roadmap_path_free (full_name);
    roadmap_path_free (path);
}
示例#5
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, char *last_modified, const char *format, ... ) {
    upload_context *  uContext = (upload_context *)context;
    char msg[MAX_SIZEOF_RESPONSE_MSG];
    va_list ap;
    char ** new_cursor;
    char * new_full_path;

    if(format) {
        va_start(ap, format);
        vsnprintf(msg,sizeof(msg),format,ap);
        va_end(ap);
        roadmap_log(ROADMAP_DEBUG,"done uploading file : %s. Received response : %s",*uContext->cursor,msg);
        strncpy(SyncUploadMessages[SyncUploadNumMessages], msg, MAX_SIZEOF_RESPONSE_MSG);
    }

    SyncProgressCurrentItem ++ ;
    SyncProgressLoaded = 0;
    SyncUploadNumMessages  ++;

    new_cursor = (uContext->cursor)+1;
    roadmap_file_remove(NULL, uContext->full_path); // remove the previous file

    if( (*new_cursor == NULL )  || ( SyncUploadNumMessages == MAX_MSGS ) ) {
        roadmap_path_list_free(uContext->files);
        roadmap_log(ROADMAP_DEBUG, "finished uploading editor_sync files");

    } else {
        int size;
        const char *header;

        upload_context * new_context;
        new_full_path = roadmap_path_join( editor_sync_get_export_path(), *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;
        size = roadmap_file_length (NULL, new_full_path);
        header = roadmap_http_async_get_upload_header(DEFAULT_CONTENT_TYPE, new_full_path, size, RealTime_GetUserName(), Realtime_GetPassword());
        if (!roadmap_http_async_post_file(&gUploadCallbackFunctions, (void *)new_context, editor_upload_get_url(), header, new_full_path, size))
        {
            roadmap_log( ROADMAP_ERROR, "File upload error, couldn't start sync socket connect. for file %s ", new_full_path);
            roadmap_path_free(new_full_path);
            roadmap_path_list_free (new_context->files);
            free(new_context);
        }
    }

    roadmap_path_free(uContext->full_path);
    free(uContext);
}
示例#6
0
void roadmap_skin_set_subskin (const char *sub_skin) {
   const char *base_path = roadmap_path_preferred ("skin");
   char path[1024];
   char *skin_path = NULL;
   char *subskin_path;
   const char *cursor;
   char *subskin_path2 = NULL;
   CurrentSubSkin = sub_skin;

   skin_path = roadmap_path_join (base_path, CurrentSkin);
   subskin_path = roadmap_path_join (skin_path, CurrentSubSkin);
//   offset = strlen(path);

   if (!strcmp(CurrentSubSkin,"day")){
	   if (strlen(get_map_schema())> 0) {
		  subskin_path2 = roadmap_path_join (subskin_path, get_map_schema());

		  snprintf (path, sizeof(path), "%s", subskin_path2);
		  roadmap_path_free (subskin_path2);
	   }
	   else {
		      snprintf (path, sizeof(path), "%s", subskin_path);
	   }
   }
   else{
      snprintf (path, sizeof(path), "%s", subskin_path);
   }

   for ( cursor = roadmap_path_first ("skin");
                  cursor != NULL;
			  cursor = roadmap_path_next ("skin", cursor))
   {
	 if ( !((strstr(cursor,"day") || strstr(cursor,"night")))){
	   strcat(path, ",");
		strcat(path, cursor);

	 }
   }

   roadmap_path_set ("skin", path);

   roadmap_path_free (subskin_path);
   roadmap_path_free (skin_path);

   roadmap_config_reload ("schema");
   notify_listeners ();

   roadmap_screen_redraw ();

}
示例#7
0
static void upload_done( void *context, char *last_modified, const char *format, ... ) {
    upload_context * ctx = (upload_context *)context;

    char response_message[500];
    va_list ap;
    if(format) {
        va_start(ap, format);
        vsnprintf(response_message,sizeof(response_message),format,ap);
        va_end(ap);
        roadmap_log(ROADMAP_DEBUG,"done uploading audio file : %s. Received response : %s",ctx->full_path,response_message);
    }

    // Parse the answer
    if( !strncmp( VOICE_UPLOAD_RESPONSE_PREFIX, response_message, strlen( VOICE_UPLOAD_RESPONSE_PREFIX ) ) )
    {
        roadmap_log( ROADMAP_DEBUG, "File was uploaded successfully! Response message: %s", response_message );
        // Copy the message ID to the buffer
        memcpy( ctx->voice_id, (response_message + strlen( VOICE_UPLOAD_RESPONSE_PREFIX )), ROADMAP_VOICE_ID_LEN );
        ctx->voice_id[ROADMAP_VOICE_ID_LEN] = 0;
        (*ctx->cb ) (ctx->context);
    }
    else
    {
        ctx->voice_id[0] = '\0';
        roadmap_log( ROADMAP_WARNING, "Voice upload done, received response message: %s", response_message );
        (*ctx->cb) (ctx->context);
    }

    roadmap_path_free(ctx->full_path);
    free(ctx);
}
示例#8
0
static void upload_error_callback( void *context, int connection_failure, const char *format, ...) {
    upload_context *  ctx = (upload_context *)context;
    roadmap_log(ROADMAP_ERROR,"error in uploading voice : %s",ctx->full_path);
    (*ctx->cb ) (ctx->context);
    roadmap_path_free(ctx->full_path);
    free(ctx);
}
示例#9
0
RoadMapSound roadmap_sound_load (const char *path, const char *file, int *mem)
{

   char *full_name = roadmap_path_join (path, file);
   const char *seq;
   RoadMapFileContext sound;
   char sound_filename[MAX_SOUND_NAME];

   return NULL;

   snprintf( sound_filename, sizeof(sound_filename), "%s.mp3", full_name);

   seq = roadmap_file_map (NULL, sound_filename, NULL, "r", &sound);

   roadmap_path_free (full_name);

   if (seq == NULL) {
      *mem = 0;
      return NULL;
   }

   *mem = roadmap_file_size (sound);

   return (RoadMapSound) sound;
}
示例#10
0
/*  Name        : download_done_callback( void *context )
 *  Purpose     : Download callback: Done
 *
 */
static void download_done_callback( void *context_cb, char *last_modified, const char *format, ...  )
{
    DownloadContext* context = (DownloadContext*) context_cb;
    const char* path = context->voice_path;
    RoadMapFile file;

    roadmap_log( ROADMAP_INFO, "Download is finished. Writing %d bytes to the file: %s", context->data_size, path );

    // Save the voice to the file
    file = roadmap_file_open( path, "w" );
    if ( !file )
    {
        roadmap_log( ROADMAP_WARNING, "File openning error for file: %s", path );
    }

    roadmap_file_write( file, context->data, context->data_size );

    roadmap_file_close(file);

    ssd_progress_msg_dialog_hide();

    context->download_cb( context->context_cb, 0, context->voice_path );

    // Add file to cache
    download_cache_add( path );

    // Deallocate the download context
    free( context->data );
    roadmap_path_free( context->voice_path );
    free( context );
}
示例#11
0
static int open_data_file (void) {
   char *file_name;

   if (track_file) return 0;

   file_name = roadmap_path_join(roadmap_config_get(&RoadMapConfigMapPath),
                                 "track_data.bin");                      
   track_file =
      roadmap_file_fopen(NULL, file_name, "a");

   roadmap_path_free(file_name);

   if (track_file == NULL) {
      roadmap_messagebox("Error", "Can't open track_data");
      return -1;
   }

   if (ftell(track_file) == 0) {

      unsigned char version[4] = {0, 10, 0, 1};
      if (fwrite(version, sizeof(version), 1, track_file) != 1) {
         roadmap_messagebox("Error", "Can't write to track_data");
         fclose(track_file);
         track_file = NULL;
         return -1;
      }
   }

   return 0;
}
示例#12
0
void roadmap_log_init(){
	long fileSize;
	const char *log_path;
	const char *log_path_temp;
	const char * path;
	const char * name;
	char lineFromLog[300];
#if defined (__SYMBIAN32__)
	#if defined (WINSCW)
      path = "C:\\";
      name = "waze_log.txt";
	#else
	  path = roadmap_db_map_path();
      name = "waze_log.txt";
	#endif
#elif defined(ANDROID)
      roadmap_path_sdcard();
      name = "waze_log.txt";
#elif !defined (J2ME)
      path = roadmap_path_user();
      name = "postmortem";
#endif
    
	fileSize = roadmap_file_length(path,name);
	if (fileSize > 0 ){ // file exists
		if(fileSize>MAX_SIZE_LOG_FILE){
		   FILE * LogFile = roadmap_file_fopen(path,name,"sa+");
		   FILE * tempLogFile = roadmap_file_fopen(path,"temp_log_file.txt","sa+");
		   fseek(LogFile, 0, SEEK_END-TO_KEEP_LOG_SIZE);
		   fgets (lineFromLog,300, LogFile );  
		   while (1){
		   	    fgets (lineFromLog,300, LogFile );
		   	    if(feof(LogFile))
		   	    	break;
		   		fputs (lineFromLog,tempLogFile ); 
		   }
		   fclose(LogFile);
		   fclose(tempLogFile);
		   log_path = roadmap_path_join (path, name);
		   log_path_temp = roadmap_path_join (path, "temp_log_file.txt");
	  	   roadmap_file_remove (path, name);
	  	   rename(log_path_temp,log_path);
	  	   roadmap_path_free (log_path);
	  	   roadmap_path_free (log_path_temp);
	    }
	}
}
示例#13
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;
	char msg[MAX_SIZEOF_RESPONSE_MSG];
	va_list ap;
	char ** new_cursor;
	char * new_full_path;

	if(format){
		va_start(ap, format);
		vsnprintf(msg,sizeof(msg),format,ap);
		va_end(ap);
		roadmap_log(ROADMAP_DEBUG,"done uploading file : %s. Received response : %s",*uContext->cursor,msg);
		strncpy(SyncUploadMessages[SyncUploadNumMessages], msg, MAX_SIZEOF_RESPONSE_MSG);
	}

	SyncProgressCurrentItem ++ ;
	SyncProgressLoaded = 0;
	SyncUploadNumMessages  ++;

	new_cursor = (uContext->cursor)+1;
	roadmap_file_remove(NULL, uContext->full_path); // remove the previous file

	if( (*new_cursor == NULL )  || ( SyncUploadNumMessages == MAX_MSGS ) ) {
		roadmap_path_list_free(uContext->files);
		roadmap_log(ROADMAP_DEBUG, "finished uploading editor_sync files");

	}else{
		upload_context * new_context;
		new_full_path = roadmap_path_join( editor_sync_get_export_path(), *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;
		if ( editor_upload_auto( new_full_path, &gUploadCallbackFunctions, NULL, NULL ,(void *)new_context) )
		{
		  roadmap_log( ROADMAP_ERROR, "File upload error, couldn't start sync socket connect. for file %s ", new_full_path);
		  roadmap_path_free(new_full_path);
		  roadmap_path_list_free (new_context->files);
		  free(new_context);
		}
	}

	roadmap_path_free(uContext->full_path);
	free(uContext);
}
示例#14
0
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);
}
示例#15
0
void roadmap_skin_set_subskin (const char *sub_skin) {
   const char *base_path = roadmap_path_preferred ("skin");
   char path[255];
   char *skin_path;
   char *subskin_path;

   CurrentSubSkin = sub_skin;

   skin_path = roadmap_path_join (base_path, CurrentSkin);
   subskin_path = roadmap_path_join (skin_path, CurrentSubSkin);

   snprintf (path, sizeof(path), "%s,%s", subskin_path, skin_path);

   roadmap_path_set ("skin", path);

   roadmap_path_free (subskin_path);
   roadmap_path_free (skin_path);

   roadmap_config_reload ("schema");
   notify_listeners ();

   roadmap_screen_redraw ();
}
示例#16
0
/*  Name        : roadmap_recorder_voice_uploader()
 *  Purpose     : Upload the voice to the server. Auxiliary static function
 *  Params      : (in) voice_folder
 *  			: (in) voice_file
 *              : (out) voice_id - the string containing the resulting voice ID, received from the server
 *						the input buffer must be of size ROADMAP_VOICE_ID_BUF_LEN
 *              : (out) message - parsed response from the server
 */
static BOOL roadmap_recorder_voice_uploader( const char *voice_folder, const char *voice_file,
        char* voice_id, RecorderVoiceUploadCallback cb, void * context)
{
    BOOL res = FALSE;
    char* full_path;
    const char* target_url;
    upload_context *  ctx;
    int size;
    const char *header;

    if( !voice_id )
    {
        roadmap_log( ROADMAP_ERROR, "File upload error: voice id buffer is not available!!" );
        return FALSE;
    }

    // Get the full path to the file
    full_path = roadmap_path_join( voice_folder, voice_file );

    // Set the target to upload to
    target_url = get_upload_url();

    roadmap_log( ROADMAP_DEBUG, "Uploading file: %s. ", full_path );

    ctx = malloc(sizeof(upload_context));
    ctx->context = context;
    ctx->cb = cb;
    ctx->full_path = full_path;
    ctx->voice_id = voice_id;

    // Upload and get the response
    size = roadmap_file_length (NULL, full_path);
    header = roadmap_http_async_get_upload_header(VOICE_UPLOAD_CONTENT_TYPE, full_path, size, NULL, NULL);
    if (roadmap_http_async_post_file(&gUploadCallbackFunctions, (void *)ctx, target_url, header, full_path, size))
    {
        //change to debug and comment.
        roadmap_log( ROADMAP_DEBUG, "Started Async connection for file : %s", full_path );
        res = TRUE;
    }
    else
    {
        roadmap_log( ROADMAP_WARNING, "File upload error on socket connect %s", full_path );
        roadmap_path_free( full_path );
        free( ctx );
        res = FALSE;
    }

    return res;
}
示例#17
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;
}
示例#18
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;
}
示例#19
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
}
示例#20
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;
}
示例#21
0
static void upload_error_callback( void *context) {
	upload_context *  uContext = (upload_context *)context;
	roadmap_path_list_free(uContext->files);
	roadmap_path_free(uContext->full_path);
	free(uContext);
}
示例#22
0
void roadmap_canvas_agg_configure (unsigned char *buf, int width, int height, int stride) {

   roadmap_log( ROADMAP_ERROR, "roadmap_canvas_agg_configure, height =%d width=%d",height, width);
   agg_rbuf.attach(buf, width, height, stride);

   agg_renb.attach(agg_pixf);
   agg_renb.reset_clipping(true);
   ras.clip_box(0, 0, agg_renb.width() - 1, agg_renb.height() - 1);

   agg::glyph_rendering gren = agg::glyph_ren_outline;
   agg::glyph_rendering image_gren = agg::glyph_ren_agg_gray8;

   roadmap_config_declare
       ("preferences", &RoadMapConfigFont, "font.ttf", NULL);

   roadmap_config_declare
       ("preferences", &RoadMapConfigFontNormal, "font_normal.ttf", NULL);

   char *font_file = roadmap_path_join(roadmap_path_user(),
		   roadmap_config_get (&RoadMapConfigFont));

   if ((width) && (height))
      roadmap_screen_set_screen_type( width, height );

   if (!RoadMapCanvasFontLoaded) {

      if(m_feng.load_font(font_file, 0, gren) &&
            m_image_feng.load_font(font_file, 0, image_gren)) {

         m_feng.hinting(true);

         if ( roadmap_screen_is_hd_screen() )
         {
			 m_feng.height(22);
			 m_feng.width(22);
         }
         else
         {
#ifdef _WIN32
          m_feng.height(12);
          m_feng.width(12);
#else
          m_feng.height(15);
          m_feng.width(15);
#endif
         }

         m_feng.flip_y(true);

         m_image_feng.hinting(true);
         m_image_feng.flip_y(true);

         RoadMapCanvasFontLoaded = 1;
      } else {
         RoadMapCanvasFontLoaded = -1;
         char message[300];
         snprintf(message, sizeof(message), "Can't load font: %s\n", font_file);
         roadmap_messagebox("Error", message);
      }
   }
   RoadMapCanvasFontLoaded = 1;
   roadmap_path_free(font_file);

   font_file = roadmap_path_join(roadmap_path_user(),
         roadmap_config_get (&RoadMapConfigFontNormal));


   if(m_feng_nor.load_font(font_file, 0, gren) &&
            m_image_feng_nor.load_font(font_file, 0, image_gren)) {

         m_feng_nor.hinting(true);

         if ( roadmap_screen_is_hd_screen() )
         {
          m_feng_nor.height(22);
          m_feng_nor.width(22);
         }
         else
         {
#ifdef _WIN32
          m_feng_nor.height(12);
          m_feng_nor.width(12);
#else
          m_feng_nor.height(15);
          m_feng_nor.width(15);
#endif
         }

         m_feng_nor.flip_y(true);

         m_image_feng_nor.hinting(true);
         m_image_feng_nor.flip_y(true);
         RoadMapCanvasNormalFontLoaded = 1;
   }
}
示例#23
0
static void upload_error_callback( void *context, int connection_failure, const char *format, ...) {
    upload_context *  uContext = (upload_context *)context;
    roadmap_path_list_free(uContext->files);
    roadmap_path_free(uContext->full_path);
    free(uContext);
}