Author: pollux
Date: 2006-12-25 19:05:35 +0000 (Mon, 25 Dec 2006)
New Revision: 24187

Modified:
   xfburn/branches/libburn_trial/xfburn/xfburn-blank-cd-dialog.c
   xfburn/branches/libburn_trial/xfburn/xfburn-burn-image-dialog.c
   xfburn/branches/libburn_trial/xfburn/xfburn-device-box.c
   xfburn/branches/libburn_trial/xfburn/xfburn-device-box.h
   xfburn/branches/libburn_trial/xfburn/xfburn-device-list.c
   xfburn/branches/libburn_trial/xfburn/xfburn-progress-dialog.c
   xfburn/branches/libburn_trial/xfburn/xfburn-progress-dialog.h
Log:
can burn iso with libburn but is still unstable

Modified: xfburn/branches/libburn_trial/xfburn/xfburn-blank-cd-dialog.c
===================================================================
--- xfburn/branches/libburn_trial/xfburn/xfburn-blank-cd-dialog.c       
2006-12-25 11:14:34 UTC (rev 24186)
+++ xfburn/branches/libburn_trial/xfburn/xfburn-blank-cd-dialog.c       
2006-12-25 19:05:35 UTC (rev 24187)
@@ -168,11 +168,9 @@
     gdk_threads_enter ();
     xfburn_progress_dialog_set_status (XFBURN_PROGRESS_DIALOG 
(dialog_progress), XFBURN_PROGRESS_DIALOG_STATUS_FAILED);
     xfce_err (_("Unable to grab drive"));
-    gtk_widget_destroy (dialog_progress);
     gdk_threads_leave ();
 
-    g_free (params);
-    return;
+    goto end;
   }
 
   drive = drive_info->drive;
@@ -228,7 +226,7 @@
   xfburn_progress_dialog_set_status (XFBURN_PROGRESS_DIALOG (dialog_progress), 
XFBURN_PROGRESS_DIALOG_STATUS_RUNNING);
   gdk_threads_leave ();
 
-  while (burn_drive_get_status(drive, &progress) != BURN_DRIVE_IDLE) {
+  while (burn_drive_get_status (drive, &progress) != BURN_DRIVE_IDLE) {
     if(progress.sectors>0 && progress.sector>=0) {
       gdouble percent = 1.0 + ((gdouble) progress.sector+1.0) / ((gdouble) 
progress.sectors) * 98.0;
       
@@ -246,15 +244,16 @@
 
  cleanup:
   burn_drive_release (drive, params->eject ? 1 : 0);
+  while (burn_drive_get_status (drive, &progress) != BURN_DRIVE_IDLE) {
+    DBG ("waiting for release");
+    usleep (500000);
+  }
   ret = burn_drive_info_forget (drive_info, 1);
   if (ret != 1)
     g_error ("Unable to drop drive %s (ret=%d). Please report problem to 
[EMAIL PROTECTED]", params->device->name, ret);
   burn_drive_info_free (drive_info);
 
-  gdk_threads_enter ();
-  gtk_widget_destroy (dialog_progress);
-  gdk_threads_leave ();
-
+ end:
   g_free (params);
 }
 
@@ -284,11 +283,9 @@
       blank_type = 1;
     }
         
-    dialog_progress = xfburn_progress_dialog_new ();
-    gtk_window_set_transient_for (GTK_WINDOW (dialog_progress), 
gtk_window_get_transient_for (GTK_WINDOW (dialog)));
+    dialog_progress = xfburn_progress_dialog_new (GTK_WINDOW (dialog));
     gtk_widget_hide (GTK_WIDGET (dialog));
 
-    xfburn_progress_dialog_set_action_text (XFBURN_PROGRESS_DIALOG 
(dialog_progress), _("Initializing"));
     gtk_widget_show (dialog_progress);
 
     params = g_new0 (ThreadBlankParams, 1);

Modified: xfburn/branches/libburn_trial/xfburn/xfburn-burn-image-dialog.c
===================================================================
--- xfburn/branches/libburn_trial/xfburn/xfburn-burn-image-dialog.c     
2006-12-25 11:14:34 UTC (rev 24186)
+++ xfburn/branches/libburn_trial/xfburn/xfburn-burn-image-dialog.c     
2006-12-25 19:05:35 UTC (rev 24187)
@@ -21,6 +21,11 @@
 #include <config.h>
 #endif /* !HAVE_CONFIG_H */
 
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <fcntl.h>
+
 #include <gtk/gtk.h>
 
 #include "xfburn-global.h"
@@ -172,57 +177,222 @@
 
   device = xfburn_device_box_get_selected_device (XFBURN_DEVICE_BOX 
(priv->device_box));
   if (device)
-    gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->check_dummy), 
!device->dummy_write);
+    gtk_widget_set_sensitive (priv->check_dummy, device->dummy_write);
 }
 
 /*************/
 /* internals */
 /*************/
+typedef struct {
+  GtkWidget *dialog_progress;
+  XfburnDevice *device;
+  gchar *iso_path;
+  gint speed;
+  XfburnWriteMode write_mode;
+  gboolean eject;
+  gboolean dummy;
+  gboolean burnfree;
+} ThreadBurnIsoParams;
+
 static void
+thread_burn_iso (ThreadBurnIsoParams * params)
+{
+  GtkWidget *dialog_progress = params->dialog_progress;
+
+  struct burn_disc *disc;
+  struct burn_session *session;
+  struct burn_track *track;
+
+  gint fd;
+  struct stat stbuf;
+  off_t fixed_size = 0;
+  struct burn_source *data_src;
+
+  struct burn_drive_info *drive_info = NULL;
+  struct burn_drive *drive;
+
+  struct burn_write_opts * burn_options;
+  enum burn_disc_status disc_state;
+  struct burn_progress progress;
+  gint ret;
+
+  DBG ("starting the burning thread");
+
+  disc = burn_disc_create ();
+  session = burn_session_create ();
+  track = burn_track_create ();
+
+  ret = burn_disc_add_session (disc, session, BURN_POS_END);
+  if (ret == 0) {
+    xfburn_progress_dialog_burning_failed (XFBURN_PROGRESS_DIALOG 
(dialog_progress), _("Unable to create disc object"));
+    goto end;
+  }
+
+  burn_track_define_data (track, 0, 300*1024, 1, BURN_MODE1);
+
+  fd = open (params->iso_path, O_RDONLY);
+  if (fd >= 0)
+    if (fstat (fd, &stbuf) != -1)
+      if( (stbuf.st_mode & S_IFMT) == S_IFREG)
+       fixed_size = stbuf.st_size;
+  
+  if (fixed_size == 0) {
+    xfburn_progress_dialog_burning_failed (XFBURN_PROGRESS_DIALOG 
(dialog_progress), _("Unable to determine image size"));
+    goto end;
+  }
+
+  data_src = burn_fd_source_new(fd, -1, fixed_size);
+  if (data_src == NULL) {
+    xfburn_progress_dialog_burning_failed (XFBURN_PROGRESS_DIALOG 
(dialog_progress), _("Cannot open image"));
+    goto end;
+  }
+  if (burn_track_set_source (track, data_src) != BURN_SOURCE_OK) {
+    xfburn_progress_dialog_burning_failed (XFBURN_PROGRESS_DIALOG 
(dialog_progress), _("Cannot attach source object to track object"));
+    goto end;
+  }
+  
+  burn_session_add_track (session, track, BURN_POS_END);
+  DBG ("Source is '%s'\n", params->iso_path);
+  burn_source_free (data_src);
+
+  if (!xfburn_device_grab (params->device, &drive_info)) {
+    xfburn_progress_dialog_burning_failed (XFBURN_PROGRESS_DIALOG 
(dialog_progress), _("Unable to grab drive"));
+
+    goto end;
+  }
+
+  drive = drive_info->drive;
+
+  while (burn_drive_get_status (drive, NULL) != BURN_DRIVE_IDLE)
+    usleep(100001);
+ 
+  /* Evaluate drive and media */
+  while ((disc_state = burn_disc_get_status(drive)) == BURN_DISC_UNREADY)
+    usleep(100001);
+  if (disc_state == BURN_DISC_APPENDABLE && params->write_mode != 
WRITE_MODE_TAO) {
+    xfburn_progress_dialog_burning_failed (XFBURN_PROGRESS_DIALOG 
(dialog_progress), _("Cannot append data to multisession disc in this write 
mode (use TAO instead)"));
+    goto cleanup;
+  } else if (disc_state != BURN_DISC_BLANK) {
+    if (disc_state == BURN_DISC_FULL)
+      xfburn_progress_dialog_burning_failed (XFBURN_PROGRESS_DIALOG 
(dialog_progress), _("Closed media with data detected. Need blank or appendable 
media"));
+    else if (disc_state == BURN_DISC_EMPTY) 
+      xfburn_progress_dialog_burning_failed (XFBURN_PROGRESS_DIALOG 
(dialog_progress), _("No media detected in drive"));
+    else
+      xfburn_progress_dialog_burning_failed (XFBURN_PROGRESS_DIALOG 
(dialog_progress), _("Cannot recognize state of drive and media"));
+    goto cleanup;
+  }
+ 
+  burn_options = burn_write_opts_new (drive);
+  burn_write_opts_set_perform_opc (burn_options, 0);
+  burn_write_opts_set_multi (burn_options, 0);
+
+  switch (params->write_mode) {
+  case WRITE_MODE_TAO:
+    burn_write_opts_set_write_type (burn_options, BURN_WRITE_TAO, 
BURN_BLOCK_MODE1);
+    break;
+  case WRITE_MODE_SAO:
+    burn_write_opts_set_write_type (burn_options, BURN_WRITE_SAO, 
BURN_BLOCK_SAO);
+    break;
+  case WRITE_MODE_RAW16:
+    burn_write_opts_set_write_type (burn_options, BURN_WRITE_RAW, 
BURN_BLOCK_RAW16);
+    break;
+  case WRITE_MODE_RAW96P:
+    burn_write_opts_set_write_type (burn_options, BURN_WRITE_RAW, 
BURN_BLOCK_RAW96P);
+    break;
+  case WRITE_MODE_RAW96R:
+    burn_write_opts_set_write_type (burn_options, BURN_WRITE_RAW, 
BURN_BLOCK_RAW96R);
+    break;
+  default:
+    xfburn_progress_dialog_burning_failed (XFBURN_PROGRESS_DIALOG 
(dialog_progress), _("The write mode is not supported currently"));
+    goto cleanup;
+  }
+
+  burn_write_opts_set_simulate(burn_options, params->dummy ? 1 : 0);
+  burn_structure_print_disc (disc);
+  DBG ("TODO set speed");
+  burn_drive_set_speed (drive, 0, 0);
+  burn_write_opts_set_underrun_proof (burn_options, params->burnfree ? 1 : 0);
+ 
+  burn_disc_write (burn_options, disc);
+ 
+  burn_write_opts_free (burn_options);
+  while (burn_drive_get_status (drive, NULL) == BURN_DRIVE_SPAWNING)
+    usleep(1002);
+  while (burn_drive_get_status (drive, &progress) != BURN_DRIVE_IDLE) {
+    DBG ("TODO progress: %d of %d", progress.sector, progress.sectors);
+    usleep (500000);
+  }
+
+ cleanup:
+  burn_drive_release (drive, params->eject ? 1 : 0);
+  while (burn_drive_get_status (drive, &progress) != BURN_DRIVE_IDLE) {
+    DBG ("waiting for release");
+    usleep (500000);
+  }
+
+  DBG ("drive_info: %p", drive_info);
+  ret = burn_drive_info_forget (drive_info, 1);
+  if (ret != 1)
+    g_error ("Unable to drop drive %s (ret=%d). Please report problem to 
[EMAIL PROTECTED]", params->device->name, ret);
+  burn_drive_info_free (drive_info);
+
+ end:
+  burn_track_free (track);
+  burn_session_free (session);
+  burn_disc_free (disc);
+
+  g_free (params->iso_path);
+  g_free (params);
+
+  DBG ("burning thread terminated");
+}
+
+static void
 cb_device_changed (XfburnDeviceBox *box, XfburnDevice *device, 
XfburnBurnImageDialog * dialog) 
 {
   XfburnBurnImageDialogPrivate *priv = XFBURN_BURN_IMAGE_DIALOG_GET_PRIVATE 
(dialog);
 
-  gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (priv->check_dummy), 
!device->dummy_write);
+  gtk_widget_set_sensitive (priv->check_dummy, device->dummy_write);
 }
 
 static void
 cb_dialog_response (XfburnBurnImageDialog * dialog, gint response_id, gpointer 
user_data)
 {
-  /*
+
   if (response_id == GTK_RESPONSE_OK) {
     XfburnBurnImageDialogPrivate *priv = XFBURN_BURN_IMAGE_DIALOG_GET_PRIVATE 
(dialog);
+
     XfburnDevice *device;
-    gchar *iso_path, *speed, *write_mode;
-    gchar *command;
+    gchar *iso_path;
+    gint speed;
+    XfburnWriteMode write_mode;
+
     GtkWidget *dialog_progress;
-    
+    ThreadBurnIsoParams *params = NULL;
+
     iso_path = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER 
(priv->chooser_image));
 
     device = xfburn_device_box_get_selected_device (XFBURN_DEVICE_BOX 
(priv->device_box));
     speed = xfburn_device_box_get_speed (XFBURN_DEVICE_BOX (priv->device_box));
-
-    write_mode = xfburn_write_mode_combo_box_get_cdrecord_param 
(XFBURN_WRITE_MODE_COMBO_BOX (priv->combo_mode));
-
-    command = g_strconcat ("cdrecord -v gracetime=2", " dev=", 
device->node_path, " ", write_mode, " speed=", speed,
-                           gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON 
(priv->check_eject)) ? " -eject" : "",
-                           gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON 
(priv->check_dummy)) ? " -dummy" : "",
-                           gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON 
(priv->check_burnfree)) ? " driveropts=burnfree"
-                           : "", " '", iso_path, "'", NULL);
-    g_free (write_mode);
-    g_free (speed);
-    g_free (iso_path);
+    write_mode = xfburn_device_box_get_mode (XFBURN_DEVICE_BOX 
(priv->device_box));
        
-    dialog_progress = xfburn_burn_image_progress_dialog_new (GTK_WINDOW 
(dialog));
+    dialog_progress = xfburn_progress_dialog_new (GTK_WINDOW (dialog));
     gtk_window_set_transient_for (GTK_WINDOW (dialog_progress), 
gtk_window_get_transient_for (GTK_WINDOW (dialog)));
     gtk_widget_hide (GTK_WIDGET (dialog));
     
-    g_object_set_data (G_OBJECT (dialog_progress), "command", command);
-    gtk_dialog_run (GTK_DIALOG (dialog_progress));
+    gtk_widget_show (dialog_progress);
     
-    g_free (command);
+    params = g_new0 (ThreadBurnIsoParams, 1);
+    params->dialog_progress = dialog_progress;
+    params->device = device;
+    params->iso_path = iso_path;
+    params->speed = speed;
+    params->write_mode = write_mode;
+    params->eject = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON 
(priv->check_eject));
+    params->dummy = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON 
(priv->check_dummy));
+    params->burnfree = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON 
(priv->check_burnfree));
+    g_thread_create ((GThreadFunc) thread_burn_iso, params, FALSE, NULL);
   }
-  */
 }
 
 /* public */

Modified: xfburn/branches/libburn_trial/xfburn/xfburn-device-box.c
===================================================================
--- xfburn/branches/libburn_trial/xfburn/xfburn-device-box.c    2006-12-25 
11:14:34 UTC (rev 24186)
+++ xfburn/branches/libburn_trial/xfburn/xfburn-device-box.c    2006-12-25 
19:05:35 UTC (rev 24187)
@@ -309,14 +309,22 @@
     gtk_list_store_append (GTK_LIST_STORE (model), &iter);
     gtk_list_store_set (GTK_LIST_STORE (model), &iter, MODE_TEXT_COLUMN, 
"TAO", MODE_VALUE_COLUMN, WRITE_MODE_TAO, -1);
   }
-  if (device->sao_block_types) {
+  if (device->sao_block_types & BURN_BLOCK_SAO) {
     gtk_list_store_append (GTK_LIST_STORE (model), &iter);
     gtk_list_store_set (GTK_LIST_STORE (model), &iter, MODE_TEXT_COLUMN, 
"SAO", MODE_VALUE_COLUMN, WRITE_MODE_SAO, -1);
   }
-  if (device->raw_block_types) {
+  if (device->raw_block_types & BURN_BLOCK_RAW16) {
     gtk_list_store_append (GTK_LIST_STORE (model), &iter);
-    gtk_list_store_set (GTK_LIST_STORE (model), &iter, MODE_TEXT_COLUMN, 
"RAW", MODE_VALUE_COLUMN, WRITE_MODE_RAW, -1);
+    gtk_list_store_set (GTK_LIST_STORE (model), &iter, MODE_TEXT_COLUMN, 
"RAW16", MODE_VALUE_COLUMN, WRITE_MODE_RAW16, -1);
   }
+  if (device->raw_block_types & BURN_BLOCK_RAW96P) {
+    gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+    gtk_list_store_set (GTK_LIST_STORE (model), &iter, MODE_TEXT_COLUMN, 
"RAW96P", MODE_VALUE_COLUMN, WRITE_MODE_RAW96P, -1);
+  }
+  if (device->raw_block_types & BURN_BLOCK_RAW96R) {
+    gtk_list_store_append (GTK_LIST_STORE (model), &iter);
+    gtk_list_store_set (GTK_LIST_STORE (model), &iter, MODE_TEXT_COLUMN, 
"RAW96R", MODE_VALUE_COLUMN, WRITE_MODE_RAW96R, -1);
+  }
   if (device->packet_block_types) {
     gtk_list_store_append (GTK_LIST_STORE (model), &iter);
     gtk_list_store_set (GTK_LIST_STORE (model), &iter, MODE_TEXT_COLUMN, 
"packet", MODE_VALUE_COLUMN, WRITE_MODE_PACKET, -1);

Modified: xfburn/branches/libburn_trial/xfburn/xfburn-device-box.h
===================================================================
--- xfburn/branches/libburn_trial/xfburn/xfburn-device-box.h    2006-12-25 
11:14:34 UTC (rev 24186)
+++ xfburn/branches/libburn_trial/xfburn/xfburn-device-box.h    2006-12-25 
19:05:35 UTC (rev 24187)
@@ -53,7 +53,9 @@
 {
   WRITE_MODE_TAO,
   WRITE_MODE_SAO,
-  WRITE_MODE_RAW,
+  WRITE_MODE_RAW16,
+  WRITE_MODE_RAW96P,
+  WRITE_MODE_RAW96R,
   WRITE_MODE_PACKET,
 } XfburnWriteMode;
 

Modified: xfburn/branches/libburn_trial/xfburn/xfburn-device-list.c
===================================================================
--- xfburn/branches/libburn_trial/xfburn/xfburn-device-list.c   2006-12-25 
11:14:34 UTC (rev 24186)
+++ xfburn/branches/libburn_trial/xfburn/xfburn-device-list.c   2006-12-25 
19:05:35 UTC (rev 24187)
@@ -85,6 +85,7 @@
     device->cdr = drives[i].write_cdr;
     device->cdrw = drives[i].write_cdrw;
     DBG ("max speed reported by libburn: %d", burn_drive_get_write_speed 
(drives[i].drive));
+    DBG ("min speed reported by libburn: %d", burn_drive_get_min_write_speed 
(drives[i].drive));
     device->min_cdr_speed = 2;
     device->max_cdr_speed = 48;
 

Modified: xfburn/branches/libburn_trial/xfburn/xfburn-progress-dialog.c
===================================================================
--- xfburn/branches/libburn_trial/xfburn/xfburn-progress-dialog.c       
2006-12-25 11:14:34 UTC (rev 24186)
+++ xfburn/branches/libburn_trial/xfburn/xfburn-progress-dialog.c       
2006-12-25 19:05:35 UTC (rev 24187)
@@ -278,10 +278,10 @@
 cb_dialog_delete (XfburnProgressDialog * dialog, GdkEvent * event, 
XfburnProgressDialogPrivate * priv)
 {
   if (!GTK_WIDGET_SENSITIVE (priv->button_close)) {
-    gtk_dialog_response (dialog, GTK_RESPONSE_CANCEL);
+    gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
     return TRUE;
   } else {
-    gtk_dialog_response (dialog, GTK_RESPONSE_CLOSE);
+    gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CLOSE);
     return FALSE;
   }
 }
@@ -441,12 +441,21 @@
   priv->status = status;
 }
 
+void
+xfburn_progress_dialog_burning_failed (XfburnProgressDialog * dialog, const 
gchar * msg_error)
+{
+  gdk_threads_enter ();
+  xfburn_progress_dialog_set_status (dialog, 
XFBURN_PROGRESS_DIALOG_STATUS_FAILED);
+  xfce_err (msg_error);
+  gdk_threads_leave ();
+}
+
 /* constructor */
 GtkWidget *
-xfburn_progress_dialog_new ()
+xfburn_progress_dialog_new (GtkWindow *parent)
 {
   XfburnProgressDialog *obj;
-  obj = XFBURN_PROGRESS_DIALOG (g_object_new (XFBURN_TYPE_PROGRESS_DIALOG, 
NULL));
+  obj = XFBURN_PROGRESS_DIALOG (g_object_new (XFBURN_TYPE_PROGRESS_DIALOG, 
"transient-for", parent, NULL));
     
   return GTK_WIDGET (obj);
 }

Modified: xfburn/branches/libburn_trial/xfburn/xfburn-progress-dialog.h
===================================================================
--- xfburn/branches/libburn_trial/xfburn/xfburn-progress-dialog.h       
2006-12-25 11:14:34 UTC (rev 24186)
+++ xfburn/branches/libburn_trial/xfburn/xfburn-progress-dialog.h       
2006-12-25 19:05:35 UTC (rev 24187)
@@ -76,8 +76,10 @@
 void xfburn_progress_dialog_set_writing_speed (XfburnProgressDialog * dialog, 
gfloat speed);
 void xfburn_progress_dialog_set_status (XfburnProgressDialog * dialog, 
XfburnProgressDialogStatus status);
 
-GtkWidget *xfburn_progress_dialog_new ();
+void xfburn_progress_dialog_burning_failed (XfburnProgressDialog * dialog, 
const gchar * msg_error);
 
+GtkWidget *xfburn_progress_dialog_new (GtkWindow *parent);
+
 G_END_DECLS
 
 #endif /* XFBURN_PROGRESS_DIALOG_H */

_______________________________________________
Xfce4-commits mailing list
Xfce4-commits@xfce.org
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to