     constructor: (settings) ->
       @settings = utils.buildSettings settings
       @__files = []
+
+      @finalized = false
+
+      @onFileAdded = $.Callbacks()
+      @onFileRemoved = $.Callbacks()
 
       @__uploadDf = $.Deferred()
       @__infoDf = $.Deferred()

          .fail =>
            @__infoDf.reject('info')

    # returns object that act like single file
    asSingle: ->
      pr = @__singleFileDf.promise()
      pr.cancel = @__cancel

    __progressInfo: ->
      progress = 0

        cb(info)

    __finalize: ->
      unless @finalized
        @finalized = true
        @add = @remove = ->
          throw new Error("group can't be changed after save")
        $.when(@__files...)
          .then(@__uploadDf.resolve, @__uploadDf.reject)
        # if one file fails all fails
        @__uploadDf.fail @cancel

    __createGroup: ->
      # tmp
      return $.when({group_id: '123~4'})

      # df = $.Deferred()
      # @__fileInfos (infos...) ->
      #   data =
      #     pub_key: @settings.publicKey
      #   for info, i in infos
      #     data["file_id[#{i}]"] = info.fileId
      #   $.ajax("#{@settings.urlBase}/group/create/", {data, dataType: 'jsonp'})
      #     .then(df.resolve, df.reject)
      # return df.promise()


