コード例 #1
0
ファイル: roadmap_debug_info.c プロジェクト: GitPicz/waze
/*
 * 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);
}
コード例 #2
0
ファイル: editor_sync.c プロジェクト: NoamSheffer/WazeWP7
/*
 * 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);
}
コード例 #3
0
ファイル: editor_sync.c プロジェクト: NoamSheffer/WazeWP7
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;
}
コード例 #4
0
ファイル: roadmap_debug_info.c プロジェクト: GitPicz/waze
///////////////////////////////////////////////////////
// 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;
}