class Settings
  attr_accessor :name, :url, :path, :filename, :plist_file, :provision_file_name, :remote_user, :host, :type, :template_file, :ipa_file, :is_enterprise
  attr_accessor :deployed_at, :icon_source_path, :icon_path
  
  def initialize(options)
    @name = options[:name]
    @filename = options[:filename]
    @url = options[:url]
    @url+= "/" unless @url.match(/\/$/)
    @host = options[:host]
    @path = options[:path]
    @type = options[:type]
    @remote_user = options[:remote_user]
    @is_enterprise = options[:enterprise]

    if @filename.nil? || @filename.empty?
      @filename = @name.gsub(" ", "_") 
    end
    
    @provision_file_name = "#{@filename}.mobileprovision"
    @plist_file = "#{@filename}.plist"
    @ipa_file = "#{@filename}.ipa"
    @plist_file_url = "#{@url}#{@plist_file}"
    @template_file = options[:template] || "#{COMBAT_ROOT}/templates/template.erb"
    @deployer = %x(whoami).strip
    
    if (type == 'android')
      @icon_source_path = "res/drawable-hdpi/icon.png"
#      @qrcode = "http://qrcode.kaywa.com/img.php?s=6&d=#{ERB::Util.url_encode(@url)}#{@filename}.apk"
    else
      @icon_source_path = "Icon@2x.png"
    end
    @qrcode = "http://qrcode.kaywa.com/img.php?s=6&d=#{ERB::Util.url_encode(@url)}"
    
    @icon_path = "icon.png"
  end
  
  def user_and_host
    "#{remote_user}@#{host}"
  end
  
  def get_binding
    binding
  end
  
  def valid?
    @name != nil && @url != nil
  end
end