package pl.helion.j2mepp.czytnikrss;

import javax.microedition.io.*;
import java.io.*;
public class WatekPobierania extends Thread
{
	public WatekPobierania(String _url, CzytnikRSSMIDlet _midlet, Parser _parser)
	{
		url = _url;
		midlet = _midlet;
		parser = _parser;
	}
	public void run()
	{
		try
		{
			pol = (HttpConnection)Connector.open(url);
			in = pol.openInputStream();
			parser.ustawStrumien(in, midlet.pobierzIlosc());
		}
		catch (IOException e)
		{
			e.printStackTrace();
			this.zakoncz();
			midlet.pokazBlad(e.getMessage());
			return;
		}
	}
	public void zakoncz()
	{
		try
		{
			if (pol!=null)
				pol.close();
			if (in!=null)
				in.close();
		} catch (Exception e){}
	}
	private HttpConnection pol;
	private CzytnikRSSMIDlet midlet;
	private String url;
	private InputStream in;
	private Parser parser;
}

