Class: Net::DAAP::DAAPv2

Inherits:
Object
  • Object
show all
Defined in:
lib/net/daap.rb

Overview

This class is used for generating a Client-DAAP-Validation header for iTunes version 4.2 servers.

Instance Method Summary collapse

Constructor Details

#initializeDAAPv2

Returns a new instance of DAAPv2.



226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
# File 'lib/net/daap.rb', line 226

def initialize
  @seeds = []
  (0..255).each do |i|
    string = String.new
    string += (i & 0x80) != 0 ? "Accept-Language"     : "user-agent"
    string += (i & 0x40) != 0 ? "max-age"             : "Authorization"
    string += (i & 0x20) != 0 ? "Client-DAAP-Version" : "Accept-Encoding"
    string += (i & 0x10) != 0 ? "daap.protocolversion": "daap.songartist"
    string += (i & 0x08) != 0 ? "daap.songcomposer"   : "daap.songdatemodified"
    string += (i & 0x04) != 0 ? "daap.songdiscnumber" : "daap.songdisabled"
    string += (i & 0x02) != 0 ? "playlist-item-spec"  : "revision-number"
    string += (i & 0x01) != 0 ? "session-id"          : "content-codes"
    @seeds << Digest::MD5.new(string).to_s.upcase
  end
end

Instance Method Details

#validate(path, select = 2, req_id = nil) ⇒ Object

Returns a validation header based on MD5



242
243
244
245
246
247
# File 'lib/net/daap.rb', line 242

def validate(path, select = 2, req_id = nil)
  string = path.dup
  string += "Copyright 2003 Apple Computer, Inc."
  string += @seeds[select]
  return Digest::MD5.new(string).to_s.upcase
end