// Decompiled by DJ v2.6.6.51 Copyright 2000 Atanas Neshkov  Date: 10/2/2001 11:02:33
// Home Page : http://members.fortunecity.com/neshkov/dj.html  - Check often for new version!
// Decompiler options: packimports(3) 
// Source File Name:   com/macromedia/generator/protocol/fgftp/Handler

package com.macromedia.generator.protocol.fgftp;

import com.macromedia.generator.utils.GenUtils;
import java.io.IOException;
import java.net.*;
import sun.net.ftp.FtpClient;
import sun.net.www.protocol.http.HttpURLConnection;

// Referenced classes of package com.macromedia.generator.protocol.fgftp:
//            FgftpURLConnection

public class Handler extends URLStreamHandler
{

    public Handler()
    {
    }

    protected URLConnection openConnection(URL url)
    {
        if(!GenUtils.isJava2())
        {
            if(FtpClient.useFtpProxy && FtpClient.ftpProxyHost != null && FtpClient.ftpProxyHost.length() > 0)
                try
                {
                    return new HttpURLConnection(url, FtpClient.ftpProxyHost, FtpClient.ftpProxyPort);
                }
                catch(IOException _ex)
                {
                    return null;
                }
        } else
        if(FtpClient.getUseFtpProxy() && FtpClient.getFtpProxyHost() != null && FtpClient.getFtpProxyPort() > 0)
            try
            {
                return new HttpURLConnection(url, FtpClient.getFtpProxyHost(), FtpClient.getFtpProxyPort());
            }
            catch(IOException _ex)
            {
                return null;
            }
        return new FgftpURLConnection(url);
    }
}