From b54841dbdeace0aeee0926a09b7d0911a675853b Mon Sep 17 00:00:00 2001 From: Mario Danic Date: Tue, 1 Apr 2008 21:30:41 +0000 Subject: [PATCH] Created experimental ecdb module, and imported initial source --- experimental/ecdb/AUTHORS | 1 + experimental/ecdb/COPYING | 28 +++++ experimental/ecdb/ChangeLog | 1 + experimental/ecdb/INSTALL | 3 + experimental/ecdb/Makefile.am | 11 ++ experimental/ecdb/NEWS | 0 experimental/ecdb/README | 3 + experimental/ecdb/TODO | 2 + experimental/ecdb/autogen.sh | 16 +++ experimental/ecdb/configure.in | 89 +++++++++++++++ experimental/ecdb/src/Makefile.am | 14 +++ experimental/ecdb/src/ecdb.c | 60 ++++++++++ experimental/ecdb/src/ecdb.h | 128 ++++++++++++++++++++++ experimental/ecdb/src/ecdb_burn.c | 158 +++++++++++++++++++++++++++ experimental/ecdb/src/ecdb_burn.h | 6 + experimental/ecdb/src/ecdb_drives.c | 163 ++++++++++++++++++++++++++++ experimental/ecdb/src/ecdb_drives.h | 8 ++ experimental/ecdb/src/ecdb_image.c | 128 ++++++++++++++++++++++ experimental/ecdb/src/ecdb_image.h | 7 ++ experimental/ecdb/src/ecdb_misc.c | 44 ++++++++ experimental/ecdb/src/ecdb_misc.h | 9 ++ 21 files changed, 879 insertions(+) create mode 100644 experimental/ecdb/AUTHORS create mode 100644 experimental/ecdb/COPYING create mode 100644 experimental/ecdb/ChangeLog create mode 100644 experimental/ecdb/INSTALL create mode 100644 experimental/ecdb/Makefile.am create mode 100644 experimental/ecdb/NEWS create mode 100644 experimental/ecdb/README create mode 100644 experimental/ecdb/TODO create mode 100755 experimental/ecdb/autogen.sh create mode 100644 experimental/ecdb/configure.in create mode 100644 experimental/ecdb/src/Makefile.am create mode 100644 experimental/ecdb/src/ecdb.c create mode 100644 experimental/ecdb/src/ecdb.h create mode 100644 experimental/ecdb/src/ecdb_burn.c create mode 100644 experimental/ecdb/src/ecdb_burn.h create mode 100644 experimental/ecdb/src/ecdb_drives.c create mode 100644 experimental/ecdb/src/ecdb_drives.h create mode 100644 experimental/ecdb/src/ecdb_image.c create mode 100644 experimental/ecdb/src/ecdb_image.h create mode 100644 experimental/ecdb/src/ecdb_misc.c create mode 100644 experimental/ecdb/src/ecdb_misc.h diff --git a/experimental/ecdb/AUTHORS b/experimental/ecdb/AUTHORS new file mode 100644 index 00000000..54c6f4a3 --- /dev/null +++ b/experimental/ecdb/AUTHORS @@ -0,0 +1 @@ +Jaime Thomas (avi.thomas@gmail.com) diff --git a/experimental/ecdb/COPYING b/experimental/ecdb/COPYING new file mode 100644 index 00000000..fa65c126 --- /dev/null +++ b/experimental/ecdb/COPYING @@ -0,0 +1,28 @@ +Copyright (C) 2007 Jaime Thomas and various contributors (see AUTHORS) + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to +deal in the Software without restriction, including without limitation the +rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +sell copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies of the Software and its Copyright notices. In addition publicly +documented acknowledgment must be given that this software has been used if no +source code of this software is made available publicly. This includes +acknowledgments in either Copyright notices, Manuals, Publicity and Marketing +documents or any documentation provided with any product containing this +software. This License does not apply to any software that links to the +libraries provided by this software (statically or dynamically), but only to +the software provided. + +Please see the COPYING.PLAIN for a plain-english explanation of this notice +and it's intent. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/experimental/ecdb/ChangeLog b/experimental/ecdb/ChangeLog new file mode 100644 index 00000000..906184ee --- /dev/null +++ b/experimental/ecdb/ChangeLog @@ -0,0 +1 @@ +First post diff --git a/experimental/ecdb/INSTALL b/experimental/ecdb/INSTALL new file mode 100644 index 00000000..ea49af67 --- /dev/null +++ b/experimental/ecdb/INSTALL @@ -0,0 +1,3 @@ +INSTALL + +See README file for instructions. diff --git a/experimental/ecdb/Makefile.am b/experimental/ecdb/Makefile.am new file mode 100644 index 00000000..c4dbf6dc --- /dev/null +++ b/experimental/ecdb/Makefile.am @@ -0,0 +1,11 @@ +## Process this file with automake to produce Makefile.in + +SUBDIRS = src + +EXTRA_DIST = \ + README AUTHORS COPYING + +MAINTAINERCLEANFILES = Makefile.in aclocal.m4 config.* \ +configure install-sh ltconfig ltmain.sh missing mkinstalldirs \ +stamp-h.in Makefile + diff --git a/experimental/ecdb/NEWS b/experimental/ecdb/NEWS new file mode 100644 index 00000000..e69de29b diff --git a/experimental/ecdb/README b/experimental/ecdb/README new file mode 100644 index 00000000..f9cd6d68 --- /dev/null +++ b/experimental/ecdb/README @@ -0,0 +1,3 @@ +CD Burner + +INFO++; diff --git a/experimental/ecdb/TODO b/experimental/ecdb/TODO new file mode 100644 index 00000000..a75949c6 --- /dev/null +++ b/experimental/ecdb/TODO @@ -0,0 +1,2 @@ +-> Detect if the media in a drive has changed and update the drive info (dbus?). +-> Creating images is right now rather inflexible (no special/symlinks, etc) and have to do all file managment outside before creating image. diff --git a/experimental/ecdb/autogen.sh b/experimental/ecdb/autogen.sh new file mode 100755 index 00000000..0846992b --- /dev/null +++ b/experimental/ecdb/autogen.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +rm -rf autom4te.cache +rm -f aclocal.m4 ltmain.sh + +touch README + +echo "Running aclocal..." ; aclocal $ACLOCAL_FLAGS || exit 1 +echo "Running autoheader..." ; autoheader || exit 1 +echo "Running autoconf..." ; autoconf || exit 1 +echo "Running libtoolize..." ; (libtoolize --copy --automake || glibtoolize --automake) || exit 1 +echo "Running automake..." ; automake --add-missing --copy --gnu || exit 1 + +if [ -z "$NOCONFIGURE" ]; then + ./configure "$@" +fi diff --git a/experimental/ecdb/configure.in b/experimental/ecdb/configure.in new file mode 100644 index 00000000..712223db --- /dev/null +++ b/experimental/ecdb/configure.in @@ -0,0 +1,89 @@ +dnl Process this file with autoconf to produce a configure script. + +# get rid of that stupid cache mechanism +rm -f config.cache + +AC_INIT(configure.in) +AM_INIT_AUTOMAKE(ecdb, 0.0.1) +AM_CONFIG_HEADER(src/config.h) + +AC_ISC_POSIX +AC_PROG_CC +AM_PROG_CC_STDC +AC_HEADER_STDC +AC_C_CONST +AM_ENABLE_SHARED +AM_PROG_LIBTOOL + +AM_WITH_DMALLOC + +dnl Add the languages which your application supports here. +ALL_LINGUAS="" + +dnl Set PACKAGE_LOCALE_DIR in config.h. +if test "x${prefix}" = "xNONE"; then + AC_DEFINE_UNQUOTED(PACKAGE_LOCALE_DIR, "${ac_default_prefix}/${DATADIRNAME}/locale", [Locale-specific data directory]) +else + AC_DEFINE_UNQUOTED(PACKAGE_LOCALE_DIR, "${prefix}/${DATADIRNAME}/locale", [Locale-specific data directory]) +fi + +dnl Set PACKAGE_DATA_DIR in config.h. +if test "x${prefix}" = "xNONE"; then + AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${ac_default_prefix}/share/${PACKAGE}", [PACKAGE_DATA_DIR]) +else + AC_DEFINE_UNQUOTED(PACKAGE_DATA_DIR, "${prefix}/share/${PACKAGE}", [PACKAGE_DATA_DIR]) +fi + +dnl Set PACKAGE_BIN_DIR in config.h. +if test "x${datadir}" = 'x${prefix}/bin'; then + if test "x${prefix}" = "xNONE"; then + AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${ac_default_prefix}/bin", [Installation directory for user executables]) + else + AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${prefix}/bin", [Installation directory for user executables]) + fi +else + AC_DEFINE_UNQUOTED(PACKAGE_BIN_DIR, "${bindir}", [Installation directory for user executables]) +fi + +dnl Set PACKAGE_LIB_DIR in config.h. +if test "x${datadir}" = 'x${prefix}/lib'; then + if test "x${prefix}" = "xNONE"; then + AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, "${ac_default_prefix}/lib", [Installation directory for libraries]) + else + AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, "${prefix}/lib", [Installation directory for libraries]) + fi +else + AC_DEFINE_UNQUOTED(PACKAGE_LIB_DIR, "${libdir}", [Installation directory for libraries]) +fi + +dnl Set PACKAGE_SOURCE_DIR in config.h. +packagesrcdir=`cd $srcdir && pwd` +AC_DEFINE_UNQUOTED(PACKAGE_SOURCE_DIR, "${packagesrcdir}", [Source code directory]) + +dnl Use -Wall if we have gcc. +changequote(,)dnl +if test "x$GCC" = "xyes"; then + case " $CFLAGS " in + *[\ \ ]-Wall[\ \ ]*) ;; + *) CFLAGS="$CFLAGS -Wall" ;; + esac +fi +changequote([,])dnl + +LIBBURN_REQUIRED=0.4.2 +LIBISOFS_REQUIRED=0.6.2 + +PKG_CHECK_MODULES(ECDB, [ + libburn-1 >= $LIBBURN_REQUIRED + libisofs-1 >= $LIBISOFS_REQUIRED + ecore + ewl + edje + efreet-mime +]) + +AC_OUTPUT([ +Makefile +src/Makefile +]) + diff --git a/experimental/ecdb/src/Makefile.am b/experimental/ecdb/src/Makefile.am new file mode 100644 index 00000000..9dab2bd1 --- /dev/null +++ b/experimental/ecdb/src/Makefile.am @@ -0,0 +1,14 @@ +## Process this file with automake to produce Makefile.in + +bin_PROGRAMS = ecdb + +ecdb_SOURCES = \ + ecdb.c ecdb.h \ + ecdb_drives.c ecdb_drives.h \ + ecdb_image.c ecdb_image.h \ + ecdb_burn.c ecdb_burn.h \ + ecdb_misc.c ecdb_misc.h + +ecdb_CFLAGS = @ECDB_CFLAGS@ +ecdb_LDADD = @ECDB_LIBS@ + diff --git a/experimental/ecdb/src/ecdb.c b/experimental/ecdb/src/ecdb.c new file mode 100644 index 00000000..2b489aa0 --- /dev/null +++ b/experimental/ecdb/src/ecdb.c @@ -0,0 +1,60 @@ +#include "ecdb.h" + +Ecdb_Main *em; +int ecdb_setup(); +void ecdb_shutdown(); + +int +main(int argc, char **argv) +{ + Ecdb_Project *proj; + int i; + + if (!ecdb_setup()) + { + printf("Setup failed\n"); + return 1; + } + + ecdb_print_drive_info(); + ecdb_burn_init(); + + proj = ecdb_project_new(); + + i = 1; + while ((i < argc) && (argv)) + { + ecore_list_append(proj->files, strdup(argv[i])); + i++; + } + proj->simulate = FALSE; + proj->publisher_id = proj->data_preparer_id = proj->system_id = + proj->application_id = proj->copywrite_id = proj->abstract_id = + proj->biblio_id = "ecdb"; + ecdb_aquire_drive(proj, 0); + ecdb_burn_project(proj); + sleep(7000); + + /* End testing */ + burn_finish(); + ecdb_shutdown(); + return 0; +}; + +int +ecdb_setup(void) +{ + em = NULL; + em = calloc(1, sizeof(Ecdb_Main)); + em->drives = NULL; + em->projects = ecore_list_new(); + + if (!ecdb_aquire_drive_info()) + { + printf("Aquiring drives failed!\n"); + return 0; + } + + return 1; +} + diff --git a/experimental/ecdb/src/ecdb.h b/experimental/ecdb/src/ecdb.h new file mode 100644 index 00000000..9099b9fc --- /dev/null +++ b/experimental/ecdb/src/ecdb.h @@ -0,0 +1,128 @@ +#ifndef ECDB_H +#define ECDB_H + +#include "config.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#undef FREE +#define FREE(dat) \ +{ \ + if (dat) { free(dat); dat = NULL; } \ +} + +/* Typdefs */ +typedef struct burn_source BurnSource; +typedef struct burn_disc BurnDisc; +typedef struct burn_session BurnSession; +typedef struct burn_write_opts BurnWriteOpts; +typedef struct burn_track BurnTrack; +typedef struct burn_progress BurnProgress; +typedef struct burn_drive_info BurnDriveInfo; +typedef enum burn_drive_status BurnDriveStatus; + +/* ECDB Global Variables */ +typedef struct _Ecdb_Main Ecdb_Main; + +struct _Ecdb_Main +{ + Ecore_List *projects; + Ecore_List *drives; +}; + +extern Ecdb_Main *em; + +typedef struct _Ecdb_Drive_Info Ecdb_Drive_Info; + +struct _Ecdb_Drive_Info +{ + /* Speeds */ + int *read_speeds; + int *write_speeds; + + /* Profiles */ + char *profile_name; + int profile_loaded; + + /* Drive info */ + char *vendor; + char *product; + char *revision; + char *location; + + unsigned char read_dvdram:1; + unsigned char read_dvdr:1; + unsigned char read_dvdrom:1; + unsigned char read_cdr:1; + unsigned char read_cdrw:1; + unsigned char write_dvdram:1; + unsigned char write_dvdr:1; + unsigned char write_cdr:1; + unsigned char write_simulate:1; + + BurnDriveInfo *tangible; +}; + +typedef struct _Ecdb_Project_Info Ecdb_Project; + +struct _Ecdb_Project_Info +{ + /* Files are important here */ + Ecore_List *files; + + /* Ids */ + char *volume_id; + char *publisher_id; + char *data_preparer_id; + char *system_id; + char *application_id; + char *copywrite_id; + char *abstract_id; + char *biblio_id; + + /* iso options */ + unsigned char iso_level:1; + unsigned char use_joliet:1; + unsigned char use_rockridge:1; + unsigned char follow_symlinks:1; + unsigned char ignore_hidden:1; + unsigned char ignore_special:1; + unsigned char iso1990:1; + + /* burn options */ + unsigned char opc:1; + unsigned char multi:1; + unsigned char simulate:1; + unsigned char underrun_proof:1; + int speed; + + /* burn stuff */ + int fifo_chunksize; + int fifo_chunks; + int burn_mode; + + /* The drive reference */ + Ecdb_Drive_Info *drive; + BurnProgress progress; +}; + +#include "ecdb_drives.h" +#include "ecdb_image.h" +#include "ecdb_burn.h" +#include "ecdb_misc.h" + +#endif + diff --git a/experimental/ecdb/src/ecdb_burn.c b/experimental/ecdb/src/ecdb_burn.c new file mode 100644 index 00000000..77130a81 --- /dev/null +++ b/experimental/ecdb/src/ecdb_burn.c @@ -0,0 +1,158 @@ +#include "ecdb.h" + +typedef struct Burn_Data Burn_Data; +struct Burn_Data +{ + BurnDisc *disc; + BurnSession *session; + Ecore_List *sources; + Ecore_List *tracks; + Ecdb_Project *proj; +}; + +void *_progress_update(void *d); + +/* Event handlers */ +int +ecdb_burn_project(Ecdb_Project *proj) +{ + char reasons[BURN_REASONS_LEN]; + int padding, i; + Burn_Data *data; + BurnTrack *track; + BurnSource *source; + BurnWriteOpts *opts; + pthread_t progress_update; + + i = 0; + data = calloc(1, sizeof(Burn_Data)); + data->sources = ecore_list_new(); + data->tracks = ecore_list_new(); + data->proj = proj; + + if (proj->burn_mode != BURN_AUDIO) + padding = 300*1024; + + data->disc = burn_disc_create(); + data->session = burn_session_create(); + burn_disc_add_session(data->disc, data->session, BURN_POS_END); + + track = burn_track_create(); + burn_track_define_data(track, 0, padding, 1, proj->burn_mode); + + while ((source = ecdb_image_project(proj))) + { + if (burn_track_set_source(track, source) != BURN_SOURCE_OK) + { + printf("Error: Cannot attach source object to track " + "object!\n"); + return 1; + } + + burn_session_add_track(data->session, track, BURN_POS_END); + ecore_list_append(data->sources, source); + ecore_list_append(data->tracks, track); + i++; + } + + if (!i) + { + printf("Failed to add any files to burn disc!\n"); + return 1; + } + + opts = burn_write_opts_new(proj->drive->tangible[0].drive); + burn_write_opts_set_perform_opc(opts, proj->opc); + burn_write_opts_set_multi(opts, proj->multi); + if (proj->simulate) + printf("simulating!\n"); + burn_write_opts_set_simulate(opts, proj->simulate); + burn_drive_set_speed(proj->drive->tangible->drive, 0, proj->speed); + burn_write_opts_set_underrun_proof(opts, proj->underrun_proof); + + if (burn_write_opts_auto_write_type(opts, data->disc, reasons, 0) + == BURN_WRITE_NONE) + { + printf("Error: Failed to find a suitable write mode for " + "disc!\n"); + return 1; + } + + /* Not sure where to put this for now */ + burn_disc_write(opts, data->disc); + burn_write_opts_free(opts); + + pthread_create(&progress_update, NULL, _progress_update, data); + pthread_detach(progress_update); + + return 0; +} + +void * +_progress_update(void *d) +{ + Burn_Data *data; + BurnProgress p; + BurnDriveStatus stat; + struct burn_drive *drive; + + data = d; + + if (!data->proj->drive->tangible) + { + printf("No tangible drive!\n"); + pthread_exit(NULL); + } + drive = data->proj->drive->tangible[0].drive; + + + while (TRUE) + { + stat = burn_drive_get_status(drive, &p); + if (stat == BURN_DRIVE_SPAWNING) + { + sleep(3); + continue; + } + else if (stat == BURN_DRIVE_IDLE) + { + BurnTrack *track; + BurnSource *source; + + ecore_list_first_goto(data->sources); + ecore_list_first_goto(data->tracks); + + while ((source = ecore_list_remove(data->sources))) + { + burn_source_free(source); + track = ecore_list_remove(data->tracks); + burn_track_free(track); + } + + ecore_list_destroy(data->sources); + ecore_list_destroy(data->tracks); + burn_session_free(data->session); + burn_disc_free(data->disc); + burn_drive_release(drive, 0); + burn_drive_info_free(data->proj->drive->tangible); + + /* Don't keep in here */ + printf("fail\n"); + ecore_list_destroy(data->proj->files); + FREE(data->proj); + + /* End testing */ + printf("here\n"); + FREE(data); + + pthread_exit(NULL); + break; + } + + //printf("Total sectors: %d, on sector: %d\n", p.sectors, + // p.sector); + data->proj->progress = p; + sleep(5); + } +} + diff --git a/experimental/ecdb/src/ecdb_burn.h b/experimental/ecdb/src/ecdb_burn.h new file mode 100644 index 00000000..6d358d36 --- /dev/null +++ b/experimental/ecdb/src/ecdb_burn.h @@ -0,0 +1,6 @@ +#ifndef ECDB_BURN_H +#define ECDB_BURN_H + +int ecdb_burn_project(Ecdb_Project *proj); + +#endif diff --git a/experimental/ecdb/src/ecdb_drives.c b/experimental/ecdb/src/ecdb_drives.c new file mode 100644 index 00000000..b4a61ca9 --- /dev/null +++ b/experimental/ecdb/src/ecdb_drives.c @@ -0,0 +1,163 @@ +#include "ecdb.h" + +void ecdb_drive_info_free_cb(void *data); + +int +ecdb_aquire_drive_info(void) +{ + int ret, i; + unsigned int drive_num; + struct burn_drive_info *drives_current; + struct burn_speed_descriptor *speeds; + + ecdb_burn_init(); + + ret = 0; + if (em->drives) + ecore_list_destroy(em->drives); + + em->drives = ecore_list_new(); + ecore_list_free_cb_set(em->drives, ecdb_drive_info_free_cb); + + while (!ret) + ret = burn_drive_scan(&drives_current, &drive_num); + + for (i = 0; i < drive_num; i++) + { + Ecdb_Drive_Info *drive; + + drive = calloc(1, sizeof(Ecdb_Drive_Info)); + + /* It would be nice if there was an easier way to do this */ + drive->product = strdup(drives_current[i].product); + drive->vendor = strdup(drives_current[i].vendor); + drive->revision = strdup(drives_current[i].revision); + drive->location = strdup(drives_current[i].location); + drive->read_dvdram = drives_current[i].read_dvdram; + drive->read_dvdr = drives_current[i].read_dvdr; + drive->read_dvdrom = drives_current[i].read_dvdrom; + drive->read_cdr = drives_current[i].read_cdr; + drive->read_cdrw = drives_current[i].read_cdrw; + drive->write_dvdram = drives_current[i].write_dvdram; + drive->write_dvdr = drives_current[i].write_dvdr; + drive->write_cdr = drives_current[i].write_cdr; + drive->write_simulate = drives_current[i].write_simulate; + + burn_drive_get_speedlist(drives_current[i].drive, &speeds); + + drive->profile_name = strdup(speeds->profile_name); + drive->profile_loaded = speeds->profile_loaded; + + while (speeds->next) + { + i++; + speeds = speeds->next; + } + + drive->read_speeds = calloc(i + 2, sizeof(int)); + drive->write_speeds = calloc(i + 2, sizeof(int)); + + drive->read_speeds[0] = i + 1; + drive->write_speeds[0] = i + 1; + + for (ret = 1; ret <= i; ret++) + { + drive->write_speeds[ret] = speeds->write_speed; + drive->read_speeds[ret] = speeds->read_speed; + speeds = speeds->prev; + } + + burn_drive_free_speedlist(&speeds); + ecore_list_append(em->drives, drive); + } + + burn_drive_info_free(drives_current); + burn_finish(); + + return TRUE; +} + +void +ecdb_drive_info_free_cb(void *data) +{ + Ecdb_Drive_Info *info; + + info = data; + + FREE(info->read_speeds); + FREE(info->write_speeds); + FREE(info->vendor); + FREE(info->product); + FREE(info->revision); + FREE(info->location); + FREE(info->profile_name); + FREE(info); +} + +void +ecdb_print_drive_info(void) +{ + Ecdb_Drive_Info *drive; + int j, i, h; + + ecore_list_first_goto(em->drives); + while ((drive = ecore_list_next(em->drives))) + { + printf("Vendor: %s, Product: %s, Revision: %s, " + "Location: %s\n", + drive->vendor, drive->product, + drive->revision, drive->location); + printf("Profile name: %s, Loaded: %d\n", + drive->profile_name, + drive->profile_loaded); + printf("Read DVDRAM: %d, Read DVDR: %d, Read DVDROM: %d, " + "Read CDR: %d, Read CDRW: %d\n", + drive->read_dvdram, + drive->read_dvdr, + drive->read_dvdrom, + drive->read_cdr, + drive->read_cdrw); + printf("Write DVDRAM: %d, Write DVDR: %d, Write CDR: %d, " + "Write Simulate: %d\n", + drive->write_dvdram, + drive->write_dvdr, + drive->write_cdr, + drive->write_simulate); + + j = drive->read_speeds[0]; + + for (i = 1; i < j; i ++) + { + if ((h = drive->write_speeds[i])) + printf("Write: %d\n", h); + if ((h = drive->read_speeds[i])) + printf("Read: %d\n", h); + } + } +} + +int +ecdb_aquire_drive(Ecdb_Project *proj, unsigned int idx) +{ + Ecdb_Drive_Info *info; + char adr[BURN_DRIVE_ADR_LEN]; + + info = ecore_list_index_goto(em->drives, idx); + if (burn_drive_convert_fs_adr(info->location, adr) <= 0) + { + printf("Error: Address doesn't provide cd burner!\n"); + return 1; + } + + if (burn_drive_scan_and_grab(&info->tangible, adr, 1) > 0) + { + proj->drive = info; + return 0; + } + else + { + info->tangible = NULL; + return 1; + } +} + diff --git a/experimental/ecdb/src/ecdb_drives.h b/experimental/ecdb/src/ecdb_drives.h new file mode 100644 index 00000000..e51e5a2c --- /dev/null +++ b/experimental/ecdb/src/ecdb_drives.h @@ -0,0 +1,8 @@ +#ifndef ECDB_DRIVES_H +#define ECDB_DRIVES_H + +int ecdb_aquire_drive_info(void); +void ecdb_print_drive_info(void); +int ecdb_aquire_drive(Ecdb_Project *proj, unsigned int idx); + +#endif diff --git a/experimental/ecdb/src/ecdb_image.c b/experimental/ecdb/src/ecdb_image.c new file mode 100644 index 00000000..4321e8f1 --- /dev/null +++ b/experimental/ecdb/src/ecdb_image.c @@ -0,0 +1,128 @@ +#include "ecdb.h" + +/* Some limitations here need to be worked out + * Handle: audio, etc */ +BurnSource * +ecdb_image_project(Ecdb_Project *proj) +{ + IsoImage *image; + IsoDir *root; + IsoWriteOpts *opts; + BurnSource *data_src, *fifo_src; + char *path; + int ret; + + efreet_mime_init(); + + if ((!proj->files) || (ecore_list_empty_is(proj->files))) + return NULL; + else if (ecore_list_count(proj->files) == 1) + { + path = ecore_list_first(proj->files); + if ((path) && (!ecore_file_is_dir(path)) && + (!strcmp(efreet_mime_type_get(path), + "application/x-cd-image"))) + { + path = ecore_list_first_remove(proj->files); + data_src = burn_file_source_new(path, NULL); + FREE(path); + goto FIFO_CREATE; + } + } + + ecdb_image_init(); + + ret = iso_image_new(proj->volume_id, &image); + + if (!ret) + { + printf("Failed to create an iso image!\n"); + iso_finish(); + return NULL; + } + + /* Disk ids */ + if (proj->publisher_id) + iso_image_set_publisher_id(image, proj->publisher_id); + if (proj->data_preparer_id) + iso_image_set_data_preparer_id(image, + proj->data_preparer_id); + if (proj->system_id) + iso_image_set_system_id(image, proj->system_id); + if (proj->application_id) + iso_image_set_application_id(image, proj->application_id); + if (proj->copywrite_id) + iso_image_set_copyright_file_id(image, proj->copywrite_id); + if (proj->abstract_id) + iso_image_set_abstract_file_id(image, proj->abstract_id); + if (proj->biblio_id) + iso_image_set_biblio_file_id(image, proj->biblio_id); + + /* Write Options - default to distribution for now */ + ret = iso_write_opts_new(&opts, 2); + if (!ret) + { + printf("Failed to create writing options!\n"); + iso_image_unref(image); + iso_finish(); + return NULL; + } + + /* Most set by default with 2 ^ */ + iso_write_opts_set_iso_level(opts, proj->iso_level); + iso_write_opts_set_joliet(opts, proj->use_joliet); + iso_write_opts_set_rockridge(opts, proj->use_rockridge); + iso_write_opts_set_iso1999(opts, proj->iso1990); + //iso_write_opts_set_appendable(opts, proj->appendable); + + iso_tree_set_follow_symlinks(image, proj->follow_symlinks); + iso_tree_set_ignore_hidden(image, proj->ignore_hidden); + iso_tree_set_ignore_special(image, proj->ignore_special); + + root = iso_image_get_root(image); + ecore_list_first_goto(proj->files); + + ret = 0; + while ((path = ecore_list_remove(proj->files))) + { + /* For now just this, in future special, symlink */ + if (ecore_file_is_dir(path)) + iso_tree_add_dir_rec(image, root, path); + else if (ecore_file_exists(path)) + iso_tree_add_node(image, root, path, NULL); + else + { + FREE(path); + continue; + } + FREE(path); + ret++; + } + + if (!ret) + { + printf("No files appended to image!\n"); + iso_image_unref(image); + iso_write_opts_free(opts); + iso_finish(); + } + + /* Valgrind segfaults around here for some reason, otherwise not + * strange + */ + iso_image_create_burn_source(image, opts, &data_src); + iso_write_opts_free(opts); + + /* unref here? not sure from docs */ + iso_image_unref(image); + + FIFO_CREATE: + fifo_src = burn_fifo_source_new(data_src, + proj->fifo_chunksize, proj->fifo_chunks, 0); + burn_source_free(data_src); + iso_finish(); + efreet_mime_shutdown(); + + return fifo_src; +} + diff --git a/experimental/ecdb/src/ecdb_image.h b/experimental/ecdb/src/ecdb_image.h new file mode 100644 index 00000000..3beff3fe --- /dev/null +++ b/experimental/ecdb/src/ecdb_image.h @@ -0,0 +1,7 @@ +#ifndef ECDB_IMAGE_H +#define ECDB_IMAGE_H + +BurnSource *ecdb_image_project(Ecdb_Project *proj); + +#endif + diff --git a/experimental/ecdb/src/ecdb_misc.c b/experimental/ecdb/src/ecdb_misc.c new file mode 100644 index 00000000..a40b4ee7 --- /dev/null +++ b/experimental/ecdb/src/ecdb_misc.c @@ -0,0 +1,44 @@ +#include "ecdb.h" + +Ecdb_Project * +ecdb_project_new(void) +{ + Ecdb_Project *proj; + + proj = calloc(1, sizeof(Ecdb_Project)); + proj->files = ecore_list_new(); + ecore_list_append(em->projects, proj); + + /* Create some sane defaults */ + proj->burn_mode = BURN_MODE1; + proj->fifo_chunksize = 2048; + proj->fifo_chunks = 2048; + + return proj; +} + +void +ecdb_shutdown(void) +{ + if (em->projects) + ecore_list_destroy(em->projects); + if (em->drives) + ecore_list_destroy(em->drives); + free(em); +} + +void +ecdb_burn_init(void) +{ + burn_initialize(); + burn_msgs_set_severities("NEVER", "SORRY", "ecdb: "); + burn_set_signal_handling("ecdb: ", NULL, 0); +} + +void +ecdb_image_init(void) +{ + iso_init(); + iso_set_msgs_severities("NEVER", "SORRY", "ecdb: "); +} + diff --git a/experimental/ecdb/src/ecdb_misc.h b/experimental/ecdb/src/ecdb_misc.h new file mode 100644 index 00000000..c40e879e --- /dev/null +++ b/experimental/ecdb/src/ecdb_misc.h @@ -0,0 +1,9 @@ +#ifndef ECDB_MISC_H +#define ECDB_MISC_H + +Ecdb_Project *ecdb_project_new(void); +void ecdb_shutdown(void); +void ecdb_burn_init(void); +void ecdb_image_init(void); + +#endif