Exemplo n.º 1
0
static void action_delete_system_save_data_update(ui_view* view, void* data, float* progress, char* progressText) {
    delete_system_save_data_data* deleteData = (delete_system_save_data_data*) data;

    FS_SystemSaveDataInfo sysInfo = {.mediaType = MEDIATYPE_NAND, .saveId = deleteData->info->systemSaveDataId};
    Result res = FSUSER_DeleteSystemSaveData(sysInfo);

    progressbar_destroy(view);
    ui_pop();

    if(R_FAILED(res)) {
        error_display_res(deleteData->info, ui_draw_system_save_data_info, res, "Failed to delete system save data.");
    } else {
        *deleteData->populated = false;

        ui_push(prompt_create("Success", "System save data deleted.", COLOR_TEXT, false, deleteData->info, NULL, ui_draw_system_save_data_info, action_delete_system_save_data_success_onresponse));
    }

    free(data);
}

static void action_delete_system_save_data_onresponse(ui_view* view, void* data, bool response) {
    prompt_destroy(view);

    if(response) {
        ui_push(progressbar_create("Deleting System Save Data", "", data, action_delete_system_save_data_update, action_delete_system_save_data_draw_top));
    } else {
        free(data);
    }
}
Exemplo n.º 2
0
static void error_onresponse(ui_view* view, void* data, bool response) {
    prompt_destroy(view);
    free(data);
}
Exemplo n.º 3
0
int main (int argc, char *argv[])
{

	char my_ip[STRING_IP_SIZE];
	int my_port = MY_PORT;
	char host_ip[STRING_IP_SIZE];
	int host_port;
	char *resource = NULL, *response;
	socket_t *socket_tcp;
	unsigned short command_op, op, len;
	struct prompt_t prompt;
	int client_error = 0;


	/* Obtener los argumentos */
	if ( retrieve_arguments(argc, argv, &host_port, host_ip, &resource) )
	{
		printf("(cliente) el uso debe ser --> cliente -l SLR -p PSLR -r REC\n");
		return -1;
	}

	/* Obtiene la ip del host local  */
	if( get_my_ip(my_ip) )
	{
		printf("(cliente) no se puede obtener ip local.\n");
		return -1;
	}

	/* Localizacion del recurso en el SLR */
	if ( (locate_resource_from_slr( my_port, my_ip, &host_port, host_ip, resource )) )
	{
		printf("(cliente) no se ha localizado el recurso en el slr.\n");
		return -1;
	}

	// strncpy(host_ip, "192.168.1.34", 15);
	// host_port = 7000;
	printf("(cliente) recurso localizado en servidor SPR [con IP: %s y puerto remoto: %d].\n", host_ip, host_port);

	socket_tcp = socket_create(my_port, my_ip, host_port, host_ip, SOCK_STREAM);
	if ( socket_connect(socket_tcp ) )
	{
		printf("(cliente) connect error.\n");
		return -1;
	}
	/* Establece el timeout de respuestas */
	socket_setrcvtimeout(socket_tcp, TIMEOUT);

	printf ("(cliente) conexion establecida con servidor SPR [con IP: %s y puerto remoto: %d].\n", host_ip, host_port);
	printf ("(cliente) enviando solicitud de conexion.\n");
	if ( conection_request( socket_tcp ) )
	{
		printf("(cliente) solicitud de conexion rechazada.\n");
		return -1;
	}

	prompt_init();

	do
	{
		prompt_read_command(&prompt);
		command_op = cmdtous(prompt.command);
		if ( command_op == OP_UNKNOW )
		{
			printf ("(cliente) orden desconocida.\n");
			continue;
		}

		if( !(client_error = operation_request(socket_tcp, command_op, prompt.parameters)) )
		{
			op = OP_RESPONSE( socket_readushort(socket_tcp) );
			if ( socket_tcp->expire_timeout ) break;
			len = socket_readushort(socket_tcp);
			if ( socket_tcp->expire_timeout ) break;
			response = socket_readnchar(socket_tcp, len);
			if ( socket_tcp->expire_timeout ) break;


			if (op != command_op && op != ERROR)		
			{
				printf ("(cliente) recibida respuesta desconocida.\n");
				client_error = 1;
			}
			else
				prompt_print(NULL, response);

			free(response);
		}
	} 
	while( command_op != OP_SALIR && !client_error );

	prompt_destroy();	
	/* Cierra el socket */
	socket_destroy(socket_tcp);

	printf ("(cliente) conexion cerrada con servidor SPR.\n");

	return(0);
}
Exemplo n.º 4
0
static void action_delete_system_save_data_success_onresponse(ui_view* view, void* data, bool response) {
    prompt_destroy(view);
}
Exemplo n.º 5
0
static void action_copy_files_success_onresponse(ui_view* view, void* data, bool response) {
    prompt_destroy(view);
}