/*
 * Mail.java
 * Created on 2005.06.19.
 * Author:  Laszlo Felfoldi, Etixpert GmbH 
 * mail:    laszlo.felfoldi@etixpert.com
 */
package com.etixpert.evolution.app.utils;

import java.sql.Connection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.Vector;

import com.etixpert.evolution.value.DistributorValue;

public class Mail {
	public final int SEND_TYPE_ALL                = 0;
	public final int SEND_TYPE_ONLY_ONE           = 1;
	public final int SEND_TYPE_SELECTED_LEVELS    = 2;
	public final int SEND_TYPE_SELECTED_COUNTRIES = 3;
	
	private Set send(String from, Object[] to, String subject, String body, Map attachments) {
		Set ret = new HashSet();
		return ret;			
	}
	
	public Set send(Connection conn, String from, String subject, int type, String body, Map attachments) {
		Map distributors = DistributorValue.getAll(conn, DistributorValue.FLAG_NEED_EMAIL);
		Vector addresses = new Vector();
		for (Iterator it = distributors.values().iterator(); it.hasNext(); ) {
			DistributorValue dv = (DistributorValue) it.next();
			addresses.add(dv.getEmail());
		}
		return send(from, addresses.toArray(), subject, body, attachments);
	}
	
	public Set send(String from, String to, int type, String subject, String body, Map attachments) {
		return send(from, new String[] {to}, subject, body, attachments);
	}
	
	public Set send(String from, Set filterSet, int type, String subject, String body, Map attachments) {
		
		return null;		
	}	
}
