/*
 * @(#)SaveProject.java
 *
 * This file is part of webCDwriter - Network CD Writing.
 *
 * Copyright (C) 2001 Jörg P. M. Haeger
 *
 * webCDwriter is free software. See CDcreator.java for details.
 *
 * Jörg Haeger, 05.2001
 */

import java.io.*;

/**
 * SaveProject command
 *
 * @author Jörg Haeger
 */
public class SaveProject extends Command
{
	protected DataOutputStream outStream;

	public SaveProject()
	{
		outStream = CDcreator.outStream;
	}

	public void run()
	{
		execCommand("saveProject " + spaceToEsc(State.sessionID));

		String type = null;
		if (Mode.type == Mode.audio)
			type = "audio";
		else
		if (Mode.type == Mode.data)
			if (Mode.makeImage)
				type = "data";
			else
				type = "image";
		if (type != null)
			execCommand("type " + type);

		for (int i = 0; i < Project.getNumOfCommands(); i++)
		{
			String cmd = Project.getCommandType(i)
				+ " " + spaceToEsc(Project.getCommandArg1(i));
			if (Project.getCommandArg2(i).length() > 0)
				cmd = cmd + " " + spaceToEsc(Project.getCommandArg2(i));
			execCommand(cmd);
		}

		super.run();
	}
}
