// Decompiled by DJ v2.6.6.51 Copyright 2000 Atanas Neshkov  Date: 6/15/2001 17:43:15
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   com/macromedia/generator/app/FlashGeneratorApp

package com.macromedia.generator.app;

import com.macromedia.generator.api.*;
import com.macromedia.generator.platform.Mac;
import com.macromedia.generator.platform.Unix;
import com.macromedia.generator.utils.GenUtils;
import java.io.*;
import java.util.*;

// Referenced classes of package com.macromedia.generator.app:
//            CacheManager, CacheProperties, FlashCommandLog, FlashEnvironment

public class FlashGeneratorApp
    implements FlashCommandLog
{

    public FlashGeneratorApp()
    {
        projectorType = 0;
        defaultWidth = -1;
        defaultHeight = -1;
        defaultBitDepth = 0;
        exactFit = false;
        serial = null;
        publishSerialNum = true;
        cacheMgr = null;
        cacheProps = null;
        logLevel = 1;
        extFontLocation = null;
        logOpened = false;
        isPreviewMode = false;
    }

    protected String addExtension(String s, String s1)
    {
        if(s == null || s1 == null)
            return s;
        Mac mac = Mac.getMac();
        if(mac == null)
            return s;
        if(s.endsWith(s1))
            return s;
        if(!s1.startsWith(".") && !s.endsWith("."))
            s1 = "." + s1;
        return s + s1;
    }

    protected void deleteFile(String s)
    {
        if(s != null && !s.equals("-"))
        {
            File file = new File(s);
            if(file.isFile())
                file.delete();
        }
    }

    public void execute(String as[])
    {
        try
        {
            if(processArgs(as))
            {
                processTemplate();
                resetPaths();
            }
        }
        catch(Exception exception)
        {
            resetPaths();
            if(logWriter == null)
                exception.printStackTrace();
            else
                exception.printStackTrace(logWriter);
        }
    }

    protected void finalize()
        throws Throwable
    {
        if(logWriter != null)
        {
            logWriter.flush();
            logWriter.close();
            logWriter = null;
        }
        if(cacheMgr != null)
            cacheMgr = null;
    }

    protected String getPropertiesPath()
    {
        String s = System.getProperty("com.macromedia.generator.installpath");
        String s1 = System.getProperty("file.separator");
        return s + s1 + "properties" + s1 + "generator.properties";
    }

    protected String getResString(String s)
    {
        return resources.getString(s);
    }

    protected String getSerializePath()
    {
        String s = System.getProperty("com.macromedia.generator.installpath");
        String s1 = System.getProperty("file.separator");
        return s + s1 + ".serialize";
    }

    public void init()
    {
        System.runFinalizersOnExit(true);
        loadResources();
        initProperties();
        String s = System.getProperty("com.macromedia.generator.installpath");
        if(s == null)
        {
            String s1 = "/";
            Properties properties = System.getProperties();
            properties.put("com.macromedia.generator.installpath", s1);
            logMessage("Flash Generator: Install path not found, using default: " + s1);
        }
        initSerialization();
        initCaches();
    }

    protected void initCaches()
    {
        if(cacheProps != null)
            cacheMgr = new CacheManager(cacheProps);
        else
            cacheMgr = new CacheManager();
    }

    protected void initProperties()
    {
        Properties properties = new Properties();
        try
        {
            FileInputStream fileinputstream = new FileInputStream(getPropertiesPath());
            properties.load(fileinputstream);
            fileinputstream.close();
        }
        catch(IOException _ex) { }
        cacheProps = new CacheProperties();
        Properties properties1 = System.getProperties();
        Enumeration enumeration = System.getProperties().propertyNames();
        Object obj = null;
        Object obj1 = null;
        if(Mac.getMac() != null)
        {
            String s = System.getProperty("user.dir");
            s = s + System.getProperty("file.separator") + "Generator";
            Properties properties2 = System.getProperties();
            properties2.put("com.macromedia.generator.installpath", s);
            System.setProperties(properties2);
        }
        for(Enumeration enumeration1 = properties.keys(); enumeration1.hasMoreElements();)
        {
            String s1 = (String)enumeration1.nextElement();
            String s2 = (String)properties.get(s1);
            s2 = s2.trim();
            if(s1.equalsIgnoreCase("com.macromedia.generator.userclasspath"))
                properties1.put("java.class.path", (String)properties1.get("java.class.path") + properties1.get("path.separator") + properties.get(s1));
            else
            if(s1.equalsIgnoreCase("com.macromedia.generator.qastud"))
            {
                if(s2.equalsIgnoreCase("beauchamp"))
                {
                    publishSerialNum = false;
                    if(serial != null)
                        serial.setPublished(false);
                }
            } else
            {
                properties1.put(s1, (String)properties.get(s1));
            }
        }

        embeddedString = null;
    }

    protected void initSerialization()
    {
        if(serial == null)
        {
            serial = new Serial();
            Unix unix = Unix.getUnix();
            if(unix != null)
            {
                Properties properties = new Properties();
                try
                {
                    FileInputStream fileinputstream = new FileInputStream(getSerializePath());
                    properties.load(fileinputstream);
                    fileinputstream.close();
                }
                catch(IOException _ex) { }
                serial.setFirstName((String)properties.get("FirstName"));
                serial.setMiddleName((String)properties.get("MiddleName"));
                serial.setLastName((String)properties.get("LastName"));
                serial.setOrganization((String)properties.get("Organization"));
                serial.setServerNumber((String)properties.get("ServerNumber"));
            }
        }
        serial.setPublished(publishSerialNum);
    }

    protected void loadResources()
    {
        if(resources == null)
            resources = ResourceBundle.getBundle("com.macromedia.generator.resources.ResourceData", Locale.getDefault());
    }

    protected void log(String s)
    {
        if(logPath != null && logWriter == null && !logOpened)
        {
            try
            {
                logWriter = new PrintWriter(new FileOutputStream(new File(logPath)));
            }
            catch(Exception _ex)
            {
                System.err.println(getResString("LogFileInvalid") + logPath);
            }
            logOpened = true;
        }
        if(logWriter != null)
        {
            logWriter.println(s);
            logWriter.flush();
        } else
        {
            System.err.println(s);
        }
    }

    public int logLevel()
    {
        return logLevel;
    }

    public void logMessage(String s)
    {
        log(s);
    }

    public void logMessage(String s, String s1, String s2)
    {
        ResourceBundle resourcebundle = ResourceBundle.getBundle(s, Locale.getDefault());
        if(s2 == null)
            s2 = "";
        log(resourcebundle.getString(s1) + s2);
    }

    public static void main(String args[])
    {
        FlashGeneratorApp flashgeneratorapp = new FlashGeneratorApp();
        flashgeneratorapp.init();
        flashgeneratorapp.execute(args);
        flashgeneratorapp = null;
    }

    protected boolean processArgs(String as[])
    {
        Mac mac = Mac.getMac();
        params = new Vector();
        if(as.length < 1)
        {
            usage(true);
            return false;
        }
        for(int i = 0; i < as.length; i++)
        {
            String s = as[i].toLowerCase();
            if(s.equals("-h"))
            {
                log(getResString("DashHObsolete"));
                s = "-help";
            } else
            if(s.equals("-d"))
            {
                log(getResString("DashDObsolete"));
                s = "-debug";
            } else
            if(s.equals("-f"))
            {
                log(getResString("DashFObsolete"));
                s = "-swf";
            } else
            if(s.equals("-s"))
            {
                log(getResString("DashSObsolete"));
                s = "-smap";
            } else
            if(s.equals("-c"))
            {
                log(getResString("DashCObsolete"));
                s = "-cmap";
            } else
            if(s.equals("-n"))
            {
                log(getResString("DashNObsolete"));
                s = "-cmapname";
            } else
            if(s.equals("-g"))
            {
                log(getResString("DashGObsolete"));
                s = "-gif";
            } else
            if(s.equals("-l"))
            {
                log(getResString("DashLObsolete"));
                s = "-log";
            } else
            if(s.equals("-p"))
            {
                log(getResString("DashPObsolete"));
                s = "-param";
            }
            if(s.equals("-help"))
            {
                usage(true);
                return false;
            }
            if(s.equals("-swf"))
            {
                if(i + 1 < as.length)
                {
                    flashPath = as[++i];
                    if(mac != null)
                        flashPath = mac.makeJavaPretty(flashPath);
                } else
                {
                    log(getResString("DashSwfRequiresArg"));
                    usage(false);
                    return false;
                }
            } else
            if(s.equals("-gif"))
            {
                if(i + 1 < as.length)
                {
                    gifPath = as[++i];
                    if(mac != null)
                        gifPath = mac.makeJavaPretty(gifPath);
                } else
                {
                    log(getResString("DashGifRequiresArg"));
                    usage(false);
                    return false;
                }
            } else
            if(s.equals("-txt"))
            {
                if(i + 1 < as.length)
                {
                    txtPath = as[++i];
                    if(mac != null)
                        txtPath = mac.makeJavaPretty(txtPath);
                } else
                {
                    log(getResString("DashTxtRequiresArg"));
                    usage(false);
                    return false;
                }
            } else
            if(s.equals("-jpg"))
            {
                if(i + 1 < as.length)
                {
                    jpegPath = as[++i];
                    if(mac != null)
                        jpegPath = mac.makeJavaPretty(jpegPath);
                } else
                {
                    log(getResString("DashJpgRequiresArg"));
                    usage(false);
                    return false;
                }
            } else
            if(s.equals("-png"))
            {
                if(i + 1 < as.length)
                {
                    pngPath = as[++i];
                    if(mac != null)
                        pngPath = mac.makeJavaPretty(pngPath);
                } else
                {
                    log(getResString("DashPngRequiresArg"));
                    usage(false);
                    return false;
                }
            } else
            if(s.equals("-qtm"))
            {
                if(i + 1 < as.length)
                {
                    QTMPath = as[++i];
                    if(mac != null)
                        QTMPath = mac.makeJavaPretty(QTMPath);
                } else
                {
                    log(getResString("DashQTMRequiresArg"));
                    usage(false);
                    return false;
                }
            } else
            if(s.equals("-xwin32"))
            {
                if(i + 1 < as.length)
                {
                    projectorWPath = as[++i];
                } else
                {
                    log(getResString("DashWin32RequiresArg"));
                    usage(false);
                    return false;
                }
            } else
            if(s.equals("-xwin16"))
            {
                if(i + 1 < as.length)
                {
                    projectorW16Path = as[++i];
                } else
                {
                    log(getResString("DashWin16RequiresArg"));
                    usage(false);
                    return false;
                }
            } else
            if(s.equals("-xmacfat"))
            {
                if(i + 1 < as.length)
                {
                    projectorMFatPath = as[++i];
                } else
                {
                    log(getResString("DashMacFatRequiresArg"));
                    usage(false);
                    return false;
                }
            } else
            if(s.equals("-xmacppc"))
            {
                if(i + 1 < as.length)
                {
                    projectorMPPCPath = as[++i];
                } else
                {
                    log(getResString("DashWinPpcRequiresArg"));
                    usage(false);
                    return false;
                }
            } else
            if(s.equals("-xmac68k"))
            {
                if(i + 1 < as.length)
                {
                    projectorM68kPath = as[++i];
                } else
                {
                    log(getResString("DashMac68KRequiresArg"));
                    usage(false);
                    return false;
                }
            } else
            if(s.equals("-smap"))
            {
                if(i + 1 < as.length)
                {
                    serverMapPath = as[++i];
                } else
                {
                    log(getResString("DashSmapRequiresArg"));
                    usage(false);
                    return false;
                }
            } else
            if(s.equals("-cmap"))
            {
                if(i + 1 < as.length)
                {
                    clientMapPath = as[++i];
                    if(clientMapName == null)
                        clientMapName = new String("NOMAPNAME");
                } else
                {
                    log(getResString("DashCmapRequiresArg"));
                    usage(false);
                    return false;
                }
            } else
            if(s.equals("-cmapname"))
            {
                if(i + 1 < as.length)
                {
                    clientMapName = as[++i];
                } else
                {
                    log(getResString("DashCmapnameRequiresArg"));
                    usage(false);
                    return false;
                }
            } else
            if(s.equals("-log"))
            {
                if(i + 1 < as.length)
                {
                    logPath = as[++i];
                    if(mac != null)
                        logPath = mac.makeJavaPretty(logPath);
                    try
                    {
                        File file = new File(logPath);
                        logWriter = new PrintWriter(new FileOutputStream(file));
                        if(mac != null)
                            mac.setTypeAndCreator(file, "TEXT", "ttxt");
                    }
                    catch(Exception _ex)
                    {
                        System.err.println(getResString("LogFileInvalid") + logPath);
                    }
                    logOpened = true;
                } else
                {
                    log(getResString("DashLogRequiresArg"));
                    usage(false);
                    return false;
                }
            } else
            if(s.equals("-debug"))
            {
                if(i + 1 < as.length)
                {
                    try
                    {
                        logLevel = Integer.valueOf(as[++i]).intValue();
                    }
                    catch(NumberFormatException _ex)
                    {
                        logLevel = -1;
                    }
                    if(logLevel < 0 || logLevel > 3)
                    {
                        log(getResString("InvalidDashDebugArg"));
                        usage(false);
                        return false;
                    }
                } else
                {
                    log(getResString("DashDebugRequiresArg"));
                    usage(false);
                    return false;
                }
            } else
            if(s.equals("-font"))
            {
                if(i + 1 < as.length)
                {
                    extFontLocation = as[++i];
                    if(mac != null)
                        extFontLocation = mac.makeJavaPretty(extFontLocation);
                }
            } else
            if(s.equals("-param"))
            {
                if(i + 2 < as.length)
                {
                    String as1[] = new String[2];
                    as1[0] = as[i + 1];
                    as1[1] = as[i + 2];
                    as1[1] = GenUtils.replace(as1[1], "\\r", '\r');
                    as1[1] = GenUtils.replace(as1[1], "\\n", '\n');
                    params.addElement(as1);
                    i += 2;
                } else
                {
                    log(getResString("DashParamRequiresArg"));
                    usage(false);
                    return false;
                }
            } else
            if(s.equals("-t"))
            {
                if(i + 1 < as.length)
                    if(inputPath == null)
                    {
                        inputPath = as[++i];
                        if(mac != null)
                            inputPath = mac.makeJavaPretty(inputPath);
                    } else
                    {
                        log(getResString("MultipleInputFiles") + as[i]);
                        usage(false);
                        return false;
                    }
            } else
            if(s.endsWith(".swf") || s.endsWith(".swt"))
            {
                if(inputPath == null)
                {
                    inputPath = as[i];
                    if(mac != null)
                        inputPath = mac.makeJavaPretty(inputPath);
                } else
                {
                    log(getResString("MultipleInputFiles") + as[i]);
                    usage(false);
                    return false;
                }
            } else
            if(s.equals("-embed"))
            {
                if(i + 1 < as.length)
                {
                    embeddedString = as[++i];
                } else
                {
                    log(getResString("DashEmbedRequiresArg"));
                    usage(false);
                    return false;
                }
            } else
            if(s.equalsIgnoreCase("-defaultsize"))
            {
                if(i + 2 < as.length)
                {
                    try
                    {
                        defaultWidth = Integer.valueOf(as[++i]).intValue();
                        defaultHeight = Integer.valueOf(as[++i]).intValue();
                    }
                    catch(NumberFormatException _ex)
                    {
                        defaultWidth = -1;
                        defaultHeight = -1;
                    }
                    if(defaultWidth <= 0 || defaultHeight <= 0)
                    {
                        log(getResString("DashDefaultSizeInvalidArg"));
                        usage(false);
                        return false;
                    }
                } else
                {
                    log(getResString("DashDefaultSizeRequiresArg"));
                    usage(false);
                    return false;
                }
            } else
            if(s.equalsIgnoreCase("-pngBitDepth"))
            {
                if(i + 1 < as.length)
                {
                    int j = -1;
                    try
                    {
                        int k = Integer.valueOf(as[++i]).intValue();
                        switch(k)
                        {
                        case 8: // '\b'
                            j = 0;
                            break;

                        case 24: // '\030'
                            j = 1;
                            break;

                        case 32: // ' '
                            j = 2;
                            break;
                        }
                    }
                    catch(NumberFormatException _ex)
                    {
                        j = -1;
                    }
                    if(j >= 0 && j <= 2)
                    {
                        defaultBitDepth = j;
                    } else
                    {
                        log(getResString("DashBitDepthInvalidArg"));
                        usage(false);
                        return false;
                    }
                } else
                {
                    log(getResString("DashBitDepthRequiresArg"));
                    usage(false);
                    return false;
                }
            } else
            if(s.equalsIgnoreCase("-exactFit"))
            {
                exactFit = true;
            } else
            {
                log(getResString("InvalidFlag") + as[i]);
                usage(false);
                return false;
            }
        }

        if(inputPath == null)
        {
            usage(false);
            return false;
        }
        if(flashPath == null && gifPath == null && jpegPath == null && pngPath == null && QTMPath == null && serverMapPath == null && clientMapPath == null && projectorWPath == null && projectorMPPCPath == null && projectorMFatPath == null && projectorM68kPath == null && projectorW16Path == null && txtPath == null)
        {
            log(getResString("NothingToDo"));
            usage(false);
            return false;
        } else
        {
            return true;
        }
    }

    protected boolean processTemplate()
    {
        if(gifPath != null)
            deleteFile(gifPath);
        if(jpegPath != null)
            deleteFile(jpegPath);
        if(pngPath != null)
            deleteFile(pngPath);
        if(QTMPath != null)
            deleteFile(QTMPath);
        if(txtPath != null)
            deleteFile(txtPath);
        if(flashPath != null)
            deleteFile(flashPath);
        if(projectorWPath != null)
            deleteFile(projectorWPath);
        if(projectorMPPCPath != null)
            deleteFile(projectorMPPCPath);
        if(projectorMFatPath != null)
            deleteFile(projectorMFatPath);
        if(projectorM68kPath != null)
            deleteFile(projectorM68kPath);
        if(projectorW16Path != null)
            deleteFile(projectorW16Path);
        if(serverMapPath != null)
            deleteFile(serverMapPath);
        if(clientMapPath != null)
            deleteFile(clientMapPath);
        FlashEnvironment flashenvironment = new FlashEnvironment(logLevel, isPreviewMode, serial, extFontLocation, cacheMgr);
        flashenvironment.setEmbeddedString(embeddedString);
        try
        {
            Buffer buffer = flashenvironment.processTemplate(new File(inputPath), params);
            if(buffer != null)
            {
                int i = defaultWidth;
                int j = defaultHeight;
                int k = 0;
                int l = 2;
                int i1 = 0;
                int j1 = -1;
                int k1 = 128;
                boolean flag = true;
                boolean flag1 = false;
                boolean flag2 = true;
                boolean flag3 = false;
                boolean flag4 = false;
                boolean flag5 = false;
                boolean flag6 = false;
                boolean flag7 = true;
                boolean flag8 = false;
                String s1 = "";
                int l1 = defaultWidth;
                int i2 = defaultHeight;
                int j2 = 70;
                boolean flag9 = true;
                int k2 = defaultBitDepth;
                int l2 = defaultWidth;
                int i3 = defaultHeight;
                int j3 = 0;
                int k3 = 0;
                int l3 = 0;
                int i4 = 64;
                boolean flag10 = true;
                boolean flag11 = true;
                boolean flag12 = true;
                boolean flag13 = false;
                boolean flag14 = true;
                String s2 = "";
                Boolean boolean1 = (Boolean)flashenvironment.get("GifInitialized");
                if(boolean1 != null && boolean1.booleanValue())
                {
                    i = ((Integer)flashenvironment.get("GifWidth")).intValue();
                    j = ((Integer)flashenvironment.get("GifHeight")).intValue();
                    k = ((Integer)flashenvironment.get("GifLoopCount")).intValue();
                    flag = ((Boolean)flashenvironment.get("GifAnimated")).booleanValue();
                    flag1 = ((Boolean)flashenvironment.get("GifDither")).booleanValue();
                    l = ((Integer)flashenvironment.get("GifDitherType")).intValue();
                    flag2 = ((Boolean)flashenvironment.get("GifSmooth")).booleanValue();
                    flag3 = ((Boolean)flashenvironment.get("GifInterlace")).booleanValue();
                    flag4 = ((Boolean)flashenvironment.get("GifTransparent")).booleanValue();
                    flag5 = ((Boolean)flashenvironment.get("GifTransparentSmart")).booleanValue();
                    k1 = ((Integer)flashenvironment.get("GifTransparentThreshold")).intValue();
                    flag6 = ((Boolean)flashenvironment.get("GifNoGradients")).booleanValue();
                    flag7 = ((Boolean)flashenvironment.get("GifColorOpt")).booleanValue();
                    i1 = ((Integer)flashenvironment.get("GifPaletteType")).intValue();
                    j1 = ((Integer)flashenvironment.get("GifMaxColors")).intValue();
                    flag8 = ((Boolean)flashenvironment.get("GifQuality")).booleanValue();
                    s1 = (String)flashenvironment.get("GifPaletteFile");
                }
                Boolean boolean2 = (Boolean)flashenvironment.get("JPEGInitialized");
                if(boolean2 != null && boolean2.booleanValue())
                {
                    l1 = ((Integer)flashenvironment.get("JPEGWidth")).intValue();
                    i2 = ((Integer)flashenvironment.get("JPEGHeight")).intValue();
                    j2 = ((Integer)flashenvironment.get("JPEGQuality")).intValue();
                    flag9 = ((Boolean)flashenvironment.get("JPEGProgressive")).booleanValue();
                }
                Boolean boolean3 = (Boolean)flashenvironment.get("PNGInitialized");
                if(boolean3 != null && boolean3.booleanValue())
                {
                    k2 = ((Integer)flashenvironment.get("PNGType")).intValue();
                    l2 = ((Integer)flashenvironment.get("PNGWidth")).intValue();
                    i3 = ((Integer)flashenvironment.get("PNGHeight")).intValue();
                    j3 = ((Integer)flashenvironment.get("PNGOption")).intValue();
                    k3 = ((Integer)flashenvironment.get("PNGDitherType")).intValue();
                    flag10 = ((Boolean)flashenvironment.get("PNGInterlace")).booleanValue();
                    flag11 = ((Boolean)flashenvironment.get("PNGSmooth")).booleanValue();
                    flag12 = ((Boolean)flashenvironment.get("PNGDither")).booleanValue();
                    flag13 = ((Boolean)flashenvironment.get("PNGNoGradients")).booleanValue();
                    flag14 = ((Boolean)flashenvironment.get("PNGColorOpt")).booleanValue();
                    l3 = ((Integer)flashenvironment.get("PNGPaletteType")).intValue();
                    i4 = ((Integer)flashenvironment.get("PNGMaxColors")).intValue();
                    s2 = (String)flashenvironment.get("PNGPaletteFile");
                }
                if(flashPath != null)
                {
                    writeBuffer(flashPath, buffer);
                    setMacFileType(flashPath, "SWFL", "SWF2");
                }
                if(projectorWPath != null)
                {
                    String s3 = System.getProperty("com.macromedia.generator.installpath");
                    ProjectorBuilder projectorbuilder = new ProjectorBuilder();
                    Buffer buffer7 = new Buffer();
                    String s8 = System.getProperty("file.separator");
                    projectorbuilder.setPlayerFile(s3 + s8 + "bin" + s8 + "FlashPla.exe");
                    projectorbuilder.setOS(0);
                    projectorbuilder.build(buffer, buffer7);
                    writeBuffer(projectorWPath, buffer7);
                    buffer7.release();
                    projectorbuilder.release();
                    setMacFileType(projectorWPath, "TEXT", "LMAN");
                }
                if(projectorMPPCPath != null)
                {
                    String s4 = System.getProperty("com.macromedia.generator.installpath");
                    ProjectorBuilder projectorbuilder1 = new ProjectorBuilder();
                    Buffer buffer8 = new Buffer();
                    String s9 = System.getProperty("file.separator");
                    projectorbuilder1.setPlayerFile(s4 + s9 + "bin" + s9);
                    projectorbuilder1.setOS(1);
                    projectorbuilder1.build(buffer, buffer8);
                    projectorMPPCPath = addExtension(projectorMPPCPath, ".hqx");
                    writeBuffer(projectorMPPCPath, buffer8);
                    buffer8.release();
                    setMacFileType(projectorMPPCPath, "TEXT", "SITx");
                }
                if(projectorMFatPath != null)
                {
                    String s5 = System.getProperty("com.macromedia.generator.installpath");
                    ProjectorBuilder projectorbuilder2 = new ProjectorBuilder();
                    Buffer buffer9 = new Buffer();
                    String s10 = System.getProperty("file.separator");
                    projectorbuilder2.setPlayerFile(s5 + s10 + "bin" + s10);
                    projectorbuilder2.setOS(2);
                    projectorbuilder2.build(buffer, buffer9);
                    projectorMFatPath = addExtension(projectorMFatPath, ".hqx");
                    writeBuffer(projectorMFatPath, buffer9);
                    buffer9.release();
                    setMacFileType(projectorMFatPath, "TEXT", "SITx");
                }
                if(projectorM68kPath != null)
                {
                    String s6 = System.getProperty("com.macromedia.generator.installpath");
                    ProjectorBuilder projectorbuilder3 = new ProjectorBuilder();
                    Buffer buffer10 = new Buffer();
                    String s11 = System.getProperty("file.separator");
                    projectorbuilder3.setPlayerFile(s6 + s11 + "bin" + s11);
                    projectorbuilder3.setOS(3);
                    projectorbuilder3.build(buffer, buffer10);
                    projectorM68kPath = addExtension(projectorM68kPath, ".hqx");
                    writeBuffer(projectorM68kPath, buffer10);
                    buffer10.release();
                    setMacFileType(projectorM68kPath, "TEXT", "SITx");
                }
                if(projectorW16Path != null)
                {
                    String s7 = System.getProperty("com.macromedia.generator.installpath");
                    ProjectorBuilder projectorbuilder4 = new ProjectorBuilder();
                    Buffer buffer11 = new Buffer();
                    String s12 = System.getProperty("file.separator");
                    projectorbuilder4.setPlayerFile(s7 + s12 + "bin" + s12 + "FlashPla.exe");
                    projectorbuilder4.setOS(0);
                    projectorbuilder4.build(buffer, buffer11);
                    writeBuffer(projectorW16Path, buffer11);
                    buffer11.release();
                    projectorbuilder4.release();
                    setMacFileType(projectorW16Path, "TEXT", "LMAN");
                }
                if(txtPath != null)
                {
                    TextBuilder textbuilder = new TextBuilder();
                    Buffer buffer1 = new Buffer();
                    textbuilder.build(buffer, buffer1);
                    writeBuffer(txtPath, buffer1);
                    buffer1.release();
                    setMacFileType(txtPath, "TEXT", "ttxt");
                }
                if(gifPath != null)
                {
                    GifBuilder gifbuilder = new GifBuilder();
                    gifbuilder.setSerial(serial);
                    Buffer buffer2 = new Buffer();
                    gifbuilder.setDither(flag1);
                    gifbuilder.setSmooth(flag2);
                    gifbuilder.setInterlace(flag3);
                    gifbuilder.setTransparent(flag4);
                    gifbuilder.setTransparentSmart(flag5);
                    gifbuilder.setTransparentThreshold(k1);
                    gifbuilder.setGradient(flag6);
                    gifbuilder.setLoopCount(k);
                    gifbuilder.setDitherType(l);
                    gifbuilder.setColorOptimization(flag7);
                    gifbuilder.setPaletteType(i1);
                    gifbuilder.setQuality(flag8);
                    gifbuilder.setMaxColors(j1);
                    gifbuilder.setAnimated(flag);
                    Mac mac = Mac.getMac();
                    if(mac != null)
                        s1 = mac.makeSystemPretty(s1);
                    gifbuilder.setFilePalette(s1);
                    if(i > 0 && j > 0)
                        gifbuilder.setDimensions(i, j);
                    gifbuilder.setExactFit(exactFit);
                    gifbuilder.build(buffer, buffer2);
                    writeBuffer(gifPath, buffer2);
                    buffer2.release();
                    gifbuilder.release();
                    setMacFileType(gifPath, "GIFf", "MFL2");
                }
                if(jpegPath != null)
                {
                    JPEGBuilder jpegbuilder = new JPEGBuilder();
                    jpegbuilder.setSerial(serial);
                    Buffer buffer3 = new Buffer();
                    if(l1 > 0 || i2 > 0)
                        jpegbuilder.setDimensions(l1, i2);
                    jpegbuilder.setQuality(j2);
                    jpegbuilder.setProgressive(flag9);
                    jpegbuilder.setExactFit(exactFit);
                    Mac mac1 = Mac.getMac();
                    jpegbuilder.build(buffer, buffer3);
                    writeBuffer(jpegPath, buffer3);
                    buffer3.release();
                    jpegbuilder.release();
                    setMacFileType(jpegPath, "JPEG", "MFL2");
                }
                if(pngPath != null)
                {
                    PngBuilder pngbuilder = new PngBuilder();
                    pngbuilder.setSerial(serial);
                    Buffer buffer4 = new Buffer();
                    pngbuilder.setType(k2);
                    pngbuilder.setOption(j3);
                    pngbuilder.setDitherType(k3);
                    pngbuilder.setInterlace(flag10);
                    pngbuilder.setSmooth(flag11);
                    pngbuilder.setDither(flag12);
                    pngbuilder.setGradient(flag13);
                    pngbuilder.setColorOptimization(flag14);
                    pngbuilder.setPaletteType(l3);
                    pngbuilder.setMaxColors(i4);
                    pngbuilder.setExactFit(exactFit);
                    Mac mac2 = Mac.getMac();
                    if(mac2 != null)
                        s2 = mac2.makeSystemPretty(s2);
                    pngbuilder.setFilePalette(s2);
                    if(l2 > 0 && i3 > 0)
                        pngbuilder.setDimensions(l2, i3);
                    pngbuilder.build(buffer, buffer4);
                    writeBuffer(pngPath, buffer4);
                    buffer4.release();
                    pngbuilder.release();
                    setMacFileType(pngPath, "PNG", "MOSS");
                }
                if(QTMPath != null)
                {
                    byte abyte0[] = {
                        83, 87, 70, 76, 116, 101, 120, 116
                    };
                    int j4 = buffer.getBufferCount();
                    try
                    {
                        if(QTMPath != null)
                            if(!QTMPath.equals("-"))
                            {
                                File file = new File(QTMPath);
                                FileOutputStream fileoutputstream = new FileOutputStream(file);
                                fileoutputstream.write(abyte0);
                                for(int l4 = 0; l4 < j4; l4++)
                                {
                                    byte abyte2[] = buffer.getBuffer(l4);
                                    fileoutputstream.write(abyte2);
                                }

                                fileoutputstream.close();
                                setMacFileType(QTMPath, "MooV", "TVOD");
                            } else
                            {
                                System.out.write(abyte0);
                                for(int k4 = 0; k4 < j4; k4++)
                                {
                                    byte abyte1[] = buffer.getBuffer(k4);
                                    System.out.write(abyte1);
                                }

                            }
                    }
                    catch(FileNotFoundException _ex)
                    {
                        log(getResString("OutputFileInvalid") + QTMPath);
                    }
                    catch(IOException _ex)
                    {
                        log(getResString("OutputFileError") + QTMPath);
                    }
                    catch(GeneratorApiException _ex)
                    {
                        log(getResString("OutputFileError") + QTMPath);
                    }
                }
                if(serverMapPath != null)
                {
                    GifBuilder gifbuilder1 = new GifBuilder();
                    Buffer buffer5 = new Buffer();
                    gifbuilder1.setDither(flag1);
                    gifbuilder1.setSmooth(flag2);
                    gifbuilder1.setInterlace(flag3);
                    gifbuilder1.setTransparent(flag4);
                    gifbuilder1.setGradient(flag6);
                    gifbuilder1.setLoopCount(k);
                    gifbuilder1.setDitherType(l);
                    gifbuilder1.setColorOptimization(flag7);
                    gifbuilder1.setPaletteType(i1);
                    gifbuilder1.setQuality(flag8);
                    gifbuilder1.setMaxColors(j1);
                    if(i > 0 && j > 0)
                        gifbuilder1.setDimensions(i, j);
                    gifbuilder1.buildImageMap(false, 0, buffer, buffer5, null);
                    writeBuffer(serverMapPath, buffer5);
                    buffer5.release();
                }
                if(clientMapPath != null)
                {
                    GifBuilder gifbuilder2 = new GifBuilder();
                    Buffer buffer6 = new Buffer();
                    gifbuilder2.setDither(flag1);
                    gifbuilder2.setSmooth(flag2);
                    gifbuilder2.setInterlace(flag3);
                    gifbuilder2.setTransparent(flag4);
                    gifbuilder2.setGradient(flag6);
                    gifbuilder2.setLoopCount(k);
                    gifbuilder2.setDitherType(l);
                    gifbuilder2.setColorOptimization(flag7);
                    gifbuilder2.setPaletteType(i1);
                    gifbuilder2.setQuality(flag8);
                    gifbuilder2.setMaxColors(j1);
                    if(i > 0 && j > 0)
                        gifbuilder2.setDimensions(i, j);
                    gifbuilder2.buildImageMap(true, 0, buffer, buffer6, clientMapName);
                    writeBuffer(clientMapPath, buffer6);
                    buffer6.release();
                }
                buffer.release();
            }
            String s = flashenvironment.getMessages();
            if(s.length() > 0)
            {
                Date date = new Date();
                log(date.toString() + ": " + inputPath);
                log(s);
            }
        }
        catch(GeneratorApiException generatorapiexception)
        {
            log(getResString("OutputFileError") + generatorapiexception);
        }
        System.runFinalization();
        System.gc();
        return true;
    }

    protected void resetPaths()
    {
        logPath = null;
        inputPath = null;
        gifPath = null;
        jpegPath = null;
        pngPath = null;
        QTMPath = null;
        txtPath = null;
        flashPath = null;
        projectorWPath = null;
        projectorMPPCPath = null;
        projectorM68kPath = null;
        projectorMFatPath = null;
        projectorW16Path = null;
        serverMapPath = null;
        clientMapPath = null;
        clientMapName = null;
    }

    protected boolean setCacheProperty(String s, String s1)
    {
        if(cacheProps != null)
            return cacheProps.set(s, s1);
        else
            return false;
    }

    protected void setMacFileType(String s, String s1, String s2)
    {
        if(s == null || s1 == null || s2 == null)
            return;
        Mac mac = Mac.getMac();
        if(mac == null)
            return;
        File file = new File(s);
        if(file == null)
            return;
        if(file.exists())
            mac.setTypeAndCreator(file, s1, s2);
    }

    protected void usage(boolean flag)
    {
        if(flag)
        {
            if(serial != null)
            {
                if(!serial.getLimited())
                    log(getResString("Title") + " " + getResString("Version") + " " + getResString("Build") + " - " + getResString("BuildDate"));
                else
                    log(getResString("Title") + " " + getResString("Version") + " " + getResString("DevBuild") + " - " + getResString("BuildDate"));
            } else
            {
                log(getResString("Title") + " " + getResString("Version") + " " + getResString("DevBuild") + " - " + getResString("BuildDate"));
            }
            log(getResString("Copyright"));
            log(getResString("VerboseUsage"));
        } else
        {
            log(getResString("Usage"));
        }
    }

    protected void writeBuffer(String s, Buffer buffer)
    {
        try
        {
            if(s != null)
                if(!s.equals("-"))
                {
                    File file = new File(s);
                    FileOutputStream fileoutputstream = new FileOutputStream(file);
                    int k = buffer.getBufferCount();
                    for(int l = 0; l < k; l++)
                    {
                        byte abyte1[] = buffer.getBuffer(l);
                        fileoutputstream.write(abyte1);
                    }

                    fileoutputstream.close();
                } else
                {
                    int i = buffer.getBufferCount();
                    for(int j = 0; j < i; j++)
                    {
                        byte abyte0[] = buffer.getBuffer(j);
                        System.out.write(abyte0);
                    }

                }
        }
        catch(FileNotFoundException _ex)
        {
            log(getResString("OutputFileInvalid") + s);
        }
        catch(IOException _ex)
        {
            log(getResString("OutputFileError") + s);
        }
        catch(GeneratorApiException _ex)
        {
            log(getResString("OutputFileError") + s);
        }
    }

    protected int logLevel;
    protected String extFontLocation;
    protected boolean logOpened;
    protected String logPath;
    protected String inputPath;
    protected String gifPath;
    protected String jpegPath;
    protected String pngPath;
    protected String QTMPath;
    protected String txtPath;
    protected String flashPath;
    protected String projectorWPath;
    protected String projectorMPPCPath;
    protected String projectorM68kPath;
    protected String projectorMFatPath;
    protected String projectorW16Path;
    protected String serverMapPath;
    protected String clientMapPath;
    protected String clientMapName;
    protected String embeddedString;
    protected Vector params;
    protected PrintWriter logWriter;
    protected boolean isPreviewMode;
    protected int projectorType;
    protected int defaultWidth;
    protected int defaultHeight;
    protected int defaultBitDepth;
    protected boolean exactFit;
    protected ResourceBundle resources;
    protected Serial serial;
    protected boolean publishSerialNum;
    protected CacheManager cacheMgr;
    protected CacheProperties cacheProps;
}