Exemplo n.º 1
0
gint MainBoxOKEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
    const char *tempisoname;

    MainBoxUnfocus();

    tempisoname = gtk_entry_get_text(GTK_ENTRY(mainbox.file));
    if (*(tempisoname) != 0)
    {
        if (IsIsoFile(tempisoname) == -4)
        {
            IsoTableRebuild(tempisoname);
            MainBoxRefocus();
            return(TRUE);
        } // ENDIF- Do we need to rebuild an image file's index before using it?

        if (IsIsoFile(tempisoname) < 0)
        {
            tempisoname = NULL;
            MainBoxRefocus();
            MessageBoxShow("Not a Valid Image File.", 1);
            return(TRUE);
        } // ENDIF- Not an ISO file? Message and Stop here.
    } // ENDIF- Is there an ISO file to check out?

    strcpy(conf.isoname, tempisoname);
    tempisoname = NULL;
    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainbox.startcheck)) == FALSE)
    {
        conf.startconfigure = 0; // FALSE
    }
    else
    {
        conf.startconfigure = 1; // TRUE
    } // ENDIF- Was this check button turned off?
    if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(mainbox.restartcheck)) == FALSE)
    {
        conf.restartconfigure = 0; // FALSE
    }
    else
    {
        conf.restartconfigure = 1; // TRUE
    } // ENDIF- Was this check button turned off?
    SaveConf();
    MainBoxCancelEvent(widget, event, data);
    return(TRUE);
} // END MainBoxOKEvent()
Exemplo n.º 2
0
gint DeviceBoxOKEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
	char templine[256];
	u8 tempbuffer[2352];
	struct IsoFile *tofile;
	const char *tempdevice;
	s32 retval;
	cdvdTD cdvdtd;
	int stop;
	int compressmethod;
	int multi;
	int imagetype;
	int i;
	DeviceBoxUnfocus();
	tempdevice = gtk_entry_get_text(GTK_ENTRY(devicebox.device));
	strcpy(conf.devicename, tempdevice); // Temporarily put in new device name
	tempdevice = NULL;
	retval = DeviceOpen();
	if (retval != 0) {
		DeviceClose();
		MessageBoxShow("Could not open the device", 2);
		return (TRUE);
	} // ENDIF- Trouble opening device? Abort here.
	DeviceTrayStatus();
	retval = DiscInserted();
	if (retval != 0) {
		DeviceClose();
		MessageBoxShow("No disc in the device\r\nPlease put a disc in and try again.", 2);
		return (TRUE);
	} // ENDIF- Trouble opening device? Abort here.
	retval = DeviceGetTD(0, &cdvdtd); // Fish for Ending Sector
	if (retval < 0) {
		DeviceClose();
		MessageBoxShow("Could not retrieve disc sector size", 2);
		return (TRUE);
	} // ENDIF- Trouble getting disc sector count?
	compressmethod = gtk_combo_box_get_active(GTK_COMBO_BOX(devicebox.compress));
	if (compressmethod > 0)  compressmethod += 2;
	multi = 0;
	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(devicebox.multi)) == TRUE)
		multi = 1;
	imagetype = 0;
	if ((disctype != CDVD_TYPE_PS2DVD) &&
	    (disctype != CDVD_TYPE_DVDV))  imagetype = 8;
	tofile = IsoFileOpenForWrite(gtk_entry_get_text(GTK_ENTRY(devicebox.file)),
	                             imagetype,
	                             multi,
	                             compressmethod);
	if (tofile == NULL) {
		DeviceClose();
		MessageBoxShow("Could not create the new ISO file", 2);
		return (TRUE);
	} // ENDIF- Trouble opening the ISO file?
	// Open Progress Bar
	sprintf(templine, "%s -> %s",
	        gtk_entry_get_text(GTK_ENTRY(devicebox.device)), tofile->name);
	ProgressBoxStart(templine, (off64_t) cdvdtd.lsn);
	tofile->cdvdtype = disctype;
	for (i = 0; i < 2048; i++)  tofile->toc[i] = tocbuffer[i];
	stop = 0;
	mainbox.stop = 0;
	progressbox.stop = 0;
	while ((stop == 0) && (tofile->sectorpos < cdvdtd.lsn)) {
		if (imagetype == 0) {
			retval = DeviceReadTrack((u32) tofile->sectorpos,
			                         CDVD_MODE_2048,
			                         tempbuffer);
		} else {
			retval = DeviceReadTrack((u32) tofile->sectorpos,
			                         CDVD_MODE_2352,
			                         tempbuffer);
		} // ENDIF- Are we reading a DVD sector? (Or a CD sector?)
		if (retval < 0) {
			for (i = 0; i < 2352; i++)
				tempbuffer[i] = 0; // NEXT i- Zeroing the buffer
		} // ENDIF- Trouble reading next block?
		retval = IsoFileWrite(tofile, tempbuffer);
		if (retval < 0) {
			MessageBoxShow("Trouble writing new file", 3);
			stop = 1;
		} // ENDIF- Trouble writing out the next block?
		ProgressBoxTick(tofile->sectorpos);
		while (gtk_events_pending())  gtk_main_iteration();
		if (mainbox.stop != 0)  stop = 2;
		if (progressbox.stop != 0)  stop = 2;
	} // ENDWHILE- No reason found to stop...
	ProgressBoxStop();
	if (stop == 0) {
		if (tofile->multi == 1)  tofile->name[tofile->multipos] = '0'; // First file
		strcpy(templine, tofile->name);
	} // ENDIF- Did we succeed with the transfer?
	DeviceClose();
	if (stop == 0) {
		IsoSaveTOC(tofile);
		tofile = IsoFileClose(tofile);
		gtk_entry_set_text(GTK_ENTRY(mainbox.file), templine);
	} else
		tofile = IsoFileCloseAndDelete(tofile); // ENDIF- (Failed to complete writing file? Get rid of the garbage files.)
	if (stop != 1)  DeviceBoxRefocus();
	if (stop == 0)  DeviceBoxCancelEvent(widget, event, data);
	return (TRUE);
} // END DeviceBoxOKEvent()
Exemplo n.º 3
0
gint ConversionBoxOKEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
	char templine[256];
	char tempblock[2352];
	const char *filename;
	int compressmethod;
	int multi;
	struct IsoFile *fromfile;
	struct IsoFile *tofile;
	int i;
	off64_t endsector;
	int stop;
	int retval;

	ConversionBoxUnfocus();

	filename = gtk_entry_get_text(GTK_ENTRY(conversionbox.file));
	if (IsIsoFile(filename) < 0)
	{
		filename = NULL;
		MessageBoxShow("Not a valid file", 3);
		return(TRUE);
	} // ENDIF- Not an Iso File? Stop early.

	compressmethod = gtk_combo_box_get_active(GTK_COMBO_BOX(conversionbox.compress));
	if (compressmethod > 0)  compressmethod += 2;
	multi = 0;
	if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(conversionbox.multi)) == TRUE)
		multi = 1;

	fromfile = NULL;
	fromfile = IsoFileOpenForRead(filename);
	if (fromfile == NULL)
	{
		filename = NULL;
		MessageBoxShow("Cannot opening the source file", 3);
		return(TRUE);
	} // ENDIF- Not an Iso File? Stop early.

	if ((compressmethod == fromfile->compress) &&
	        (multi == fromfile->multi))
	{
		fromfile = IsoFileClose(fromfile);
		filename = NULL;
		MessageBoxShow("Compress/Multifile methods match - no need to convert", 3);
		return(TRUE);
	} // ENDIF- Not an Iso File? Stop early.

	tofile = IsoFileOpenForWrite(filename,
	                             GetImageTypeConvertTo(fromfile->imagetype),
	                             multi,
	                             compressmethod);
	if (tofile == NULL)
	{
		fromfile = IsoFileClose(fromfile);
		filename = NULL;
		MessageBoxShow("Cannot create the new file", 3);
		return(TRUE);
	} // ENDIF- Not an Iso File? Stop early.

	if (fromfile->multi == 1)
	{
		i = 0;
		while ((i < 10) &&
		        (IsoFileSeek(fromfile, fromfile->multisectorend[i] + 1) == 0))  i++;
		endsector = fromfile->multisectorend[fromfile->multiend];
	}
	else
	{
		endsector = fromfile->filesectorsize;
	} // ENDIF- Get ending sector from multifile? (Or single file?)
	IsoFileSeek(fromfile, 0);

	// Open Progress Bar
	sprintf(templine, "%s: %s%s -> %s%s",
	        filename,
	        multinames[fromfile->multi],
	        compressdesc[fromfile->compress],
	        multinames[tofile->multi],
	        compressdesc[tofile->compress]);
	ProgressBoxStart(templine, endsector);

	tofile->cdvdtype = fromfile->cdvdtype;
	for (i = 0; i < 2048; i++)  tofile->toc[i] = fromfile->toc[i];

	stop = 0;
	mainbox.stop = 0;
	progressbox.stop = 0;
	while ((stop == 0) && (tofile->sectorpos < endsector))
	{
		retval = IsoFileRead(fromfile, tempblock);
		if (retval < 0)
		{
			MessageBoxShow("Trouble reading source file", 3);
			stop = 1;
		}
		else
		{
			retval = IsoFileWrite(tofile, tempblock);
			if (retval < 0)
			{
				MessageBoxShow("Trouble writing new file", 3);
				stop = 1;
			} // ENDIF- Trouble writing out the next block?
		} // ENDIF- Trouble reading in the next block?

		ProgressBoxTick(tofile->sectorpos);
		while (gtk_events_pending())  gtk_main_iteration();

		if (mainbox.stop != 0)  stop = 2;
		if (progressbox.stop != 0)  stop = 2;
	} // ENDWHILE- Not stopped for some reason...

	ProgressBoxStop();

	if (stop == 0)
	{
		if (tofile->multi == 1)  tofile->name[tofile->multipos] = '0'; // First file
		strcpy(templine, tofile->name);

		// fromfile = IsoFileCloseAndDelete(fromfile);
		fromfile = IsoFileClose(fromfile);

		IsoSaveTOC(tofile);
		tofile = IsoFileClose(tofile);
		gtk_entry_set_text(GTK_ENTRY(mainbox.file), templine);

	}
	else
	{
		fromfile = IsoFileClose(fromfile);
		tofile = IsoFileCloseAndDelete(tofile);
	} // ENDIF- Did we succeed in the transfer?

	if (stop != 1)  ConversionBoxRefocus();
	if (stop == 0)  ConversionBoxCancelEvent(widget, event, data);
	return(TRUE);
} // END ConversionBoxOKEvent()
Exemplo n.º 4
0
gint MainBoxOKEvent(GtkWidget *widget, GdkEvent event, gpointer data)
{
	const char *tempisoname1;
	const char *tempisoname2;
	struct IsoFile *tempiso1;
	struct IsoFile *tempiso2;
	int stop;
	off64_t endsector;
	off64_t sector;
	int retval;
	char tempblock1[2448];
	char tempblock2[2448];
	int i;

	MainBoxUnfocus();

	tempisoname1 = gtk_entry_get_text(GTK_ENTRY(mainbox.file1));
	tempisoname2 = gtk_entry_get_text(GTK_ENTRY(mainbox.file2));
	tempiso1 = NULL;
	tempiso2 = NULL;

	tempiso1 = IsoFileOpenForRead(tempisoname1);
	if (tempiso1 == NULL)
	{
		MainBoxRefocus();
		MessageBoxShow("First file is not a Valid Image File.", 0);
		tempisoname1 = NULL;
		tempisoname2 = NULL;
		return(TRUE);
	} // ENDIF- Not an ISO file? Message and Stop here.

	tempiso2 = IsoFileOpenForRead(tempisoname2);
	if (tempiso2 == NULL)
	{
		MainBoxRefocus();
		MessageBoxShow("Second file is not a Valid Image File.", 0);
		tempiso1 = IsoFileClose(tempiso1);
		tempisoname1 = NULL;
		tempisoname2 = NULL;
		return(TRUE);
	} // ENDIF- Not an ISO file? Message and Stop here.

	if (tempiso1->blocksize != tempiso2->blocksize)
	{
		MainBoxRefocus();
		MessageBoxShow("Block sizes in Image files do not match.", 0);
		tempiso1 = IsoFileClose(tempiso1);
		tempiso2 = IsoFileClose(tempiso2);
		tempisoname1 = NULL;
		tempisoname2 = NULL;
		return(TRUE);
	} // ENDIF- Not an ISO file? Message and Stop here.

	if (tempiso1->multi == 1)
	{
		i = 0;
		while ((i < 10) &&
		        (IsoFileSeek(tempiso1, tempiso1->multisectorend[i] + 1) == 0))  i++;
		endsector = tempiso1->multisectorend[tempiso1->multiend];
	}
	else
	{
		endsector = tempiso1->filesectorsize;
	} // ENDIF- Get ending sector from multifile? (Or single file?)
	IsoFileSeek(tempiso1, 0);

	if (tempiso2->multi == 1)
	{
		i = 0;
		while ((i < 10) &&
		        (IsoFileSeek(tempiso2, tempiso2->multisectorend[i] + 1) == 0))  i++;
		sector = tempiso2->multisectorend[tempiso2->multiend];
	}
	else
	{
		sector = tempiso2->filesectorsize;
	} // ENDIF- Get ending sector from multifile? (Or single file?)
	IsoFileSeek(tempiso2, 0);
	if (sector != endsector)
	{
		MainBoxRefocus();
		MessageBoxShow("Number of blocks in Image files do not match.", 0);
		tempiso1 = IsoFileClose(tempiso1);
		tempiso2 = IsoFileClose(tempiso2);
		tempisoname1 = NULL;
		tempisoname2 = NULL;
		return(TRUE);
	} // ENDIF- Number of blocks don't match? Say so.

	sprintf(tempblock1, "%s == %s ?", tempisoname1, tempisoname2);
	ProgressBoxStart(tempblock1, endsector);

	stop = 0;
	mainbox.stop = 0;
	progressbox.stop = 0;
	while ((stop == 0) && (tempiso1->sectorpos < endsector))
	{
		retval = IsoFileRead(tempiso1, tempblock1);
		if (retval < 0)
		{
			MainBoxRefocus();
			MessageBoxShow("Trouble reading first file.", 0);
			stop = 1;
		}
		else
		{
			retval = IsoFileRead(tempiso2, tempblock2);
			if (retval < 0)
			{
				MainBoxRefocus();
				MessageBoxShow("Trouble reading second file.", 0);
				stop = 1;
			}
			else
			{
				i = 0;
				while ((i < tempiso1->blocksize) && (tempblock1[i] == tempblock2[i])) i++;
				if (i < tempiso1->blocksize)
				{
					MainBoxRefocus();
					MessageBoxShow("Trouble reading second file.", 0);
					stop = 1;
				} // ENDIF- Sectors don't match? Say so.
			} // ENDIF- Trouble reading second file?
		} // ENDIF- Trouble reading first file?

		ProgressBoxTick(tempiso1->sectorpos);
		while (gtk_events_pending())  gtk_main_iteration();

		if (mainbox.stop != 0)  stop = 2;
		if (progressbox.stop != 0)  stop = 2;
	} // ENDWHILE- Comparing two files... sector by sector

	if (stop == 0)
	{
		MainBoxRefocus();
		MessageBoxShow("Images Match.", 0);
	} // ENDIF- Everything checked out? Say so.
	tempiso1 = IsoFileClose(tempiso1);
	tempiso2 = IsoFileClose(tempiso2);
	tempisoname1 = NULL;
	tempisoname2 = NULL;
	return(TRUE);
} // END MainBoxOKEvent()