 {Pathway}      = require 'xpath'
 
 {tryThrow, tryCatch} = require 'util/try'
+
+DEFAULT_TIMEOUTS =
+  action:    60 # 1m
+  global:   300 # 5m
+  security: 180 # 3m
 
 class Player
   @register: (params) ->

func           = require 'lang/func'
type           = require 'lang/type'
event          = require 'util/event'
dateForElement = (require 'dom/date').forElement
dir            = require 'io/dir'
file           = require 'io/file'

    logger.warn args... if args.length
    delete @tmp.account

  setErrorTimeout: (timeoutType) ->
    duration = (prefs.get "wesabe.download.player.timeout.#{timeoutType}") or DEFAULT_TIMEOUTS[timeoutType]
    tt = @_timeouts
    tt ||= @_timeouts = {}

    @clearErrorTimeout timeoutType

    logger.debug "Timeout ", timeoutType, " set (", duration, " seconds)"

    tt[timeoutType] = setTimeout =>
      event.trigger this, 'timeout', [timeoutType]
      return if @job.done
      logger.error "Timeout ", timeoutType, " (", duration, " seconds) reached, abandoning job"
      tryCatch "Player#setErrorTimeout(page dump)", =>
        @page?.dumpPrivately()
      @job.fail 504, "timeout.#{timeoutType}"
    , duration * 1000

  clearErrorTimeout: (timeoutType) ->
    if @_timeouts?[timeoutType]
