# File m2a.rb, line 24
def doCrudeObexAppComm
    begin
        cam = getObexIOObject
        cam.puts "ls"
        cam.close_write
        lines = cam.readlines
        cam = getObexIOObject
        lines.each do |line|
            line =~ /Bild\(\d+\).jpg/
            #black-magic-ruby $& holds the match
            if !$&.nil?
                cam.puts "get"
                cam.puts $&
                cam.puts $destination+'/'+$&
                puts "copy picture "+$&+" to to "+$destination
                #delete picturea after copying? uncomment...
                #doesn't work on my phone:(
                #cam.puts "delete"
                #cam.puts $&
            end
    end
    rescue Exception => ex
        puts(ex.to_s)
    ensure
        # TODO: ensure connection is closed
        cam.puts "disconnect" 
        cam.close
    end
end