Module: Idevice

Defined in:
lib/idevice.rb,
lib/idevice/c.rb,
lib/idevice/afc.rb,
lib/idevice/plist.rb,
lib/idevice/restore.rb,
lib/idevice/idevice.rb,
lib/idevice/version.rb,
lib/idevice/lockdown.rb,
lib/idevice/misagent.rb,
lib/idevice/heartbeat.rb,
lib/idevice/mobilesync.rb,
lib/idevice/file_relay.rb,
lib/idevice/sbservices.rb,
lib/idevice/screenshotr.rb,
lib/idevice/house_arrest.rb,
lib/idevice/mobilebackup.rb,
lib/idevice/webinspector.rb,
lib/idevice/mobilebackup2.rb,
lib/idevice/image_mounter.rb,
lib/idevice/diagnostics_relay.rb,
lib/idevice/installation_proxy.rb,
lib/idevice/notification_proxy.rb

Defined Under Namespace

Modules: C, LibHelpers, NPRecvNotifications, NPSendNotifications Classes: AFCClient, AFCError, AFCFile, DiagnosticsRelayClient, DiagnosticsRelayError, FileRelayClient, FileRelayError, HeartbeatClient, HeartbeatError, HouseArrestClient, HouseArrestError, Idevice, IdeviceConnection, IdeviceLibError, ImageMounterClient, ImageMounterError, InstProxyClient, InstProxyError, LockdownClient, LockdownError, LockdownPairRecord, LockdownServiceDescriptor, MisAgentClient, MisAgentError, MobileBackup2Client, MobileBackup2Error, MobileBackupClient, MobileBackupError, MobileSyncAnchors, MobileSyncClient, MobileSyncError, NotificationProxyClient, NotificationProxyError, Plist_t, Plist_t_Unmanaged, RestoreClient, RestoreErrror, SbservicesClient, SbservicesError, ScreenShotrClient, ScreenShotrError, WebInspectorClient, WebInspectorError

Constant Summary collapse

AFC_DEFAULT_CHUNKSIZE =
8192
AFC =

short name alias to AFCClient

AFCClient
VERSION =
"1.1.6.0"
SBSError =
SbservicesError
SBSClient =
SbservicesClient
NPError =

Aliased short name for NotificationProxyError

NotificationProxyError
NPClient =

Aliased short name for NotificationProxyClient

NotificationProxyClient

Class Method Summary collapse

Class Method Details

.debug_level=(num) ⇒ Object


46
47
48
# File 'lib/idevice.rb', line 46

def self.debug_level= num
  C.idevice_set_debug_level(num)
end

.device_listObject


50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/idevice.rb', line 50

def self.device_list
  FFI::MemoryPointer.new(:int) do |countp|
    FFI::MemoryPointer.new(:pointer) do |devices|
      ierr = C.idevice_get_device_list(devices, countp)
      if ierr == :SUCCESS
        ret = []
        count = countp.read_int
        if count > 0
          devices.read_pointer.read_array_of_pointer(count).map { |sp| ret << sp.read_string }
        end
        C.idevice_device_list_free(devices.read_pointer)
        return ret
      else
        raise Idevice::IdeviceError, "Library error: #{ierr}"
      end
    end
  end
end

.subscribeObject

listens for event connection and disconnection events


70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/idevice.rb', line 70

def self.subscribe
  finished = false

  cb = Proc.new do |eventp, junk|
    unless eventp.nil? or eventp.null?
      evt = C::DEVICE_EVENTS[eventp.read_int] || :UNKNOWN
      finished = yield(evt)
    end
  end

  begin
    C.idevice_event_subscribe(cb, nil)
    until finished
      #nop
    end
  ensure
    C.idevice_event_unsubscribe()
  end
  nil
end

.wait_for_device_add(opts = {}) ⇒ Object


91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
# File 'lib/idevice.rb', line 91

def self.wait_for_device_add(opts={})
  udid = opts[:udid]
  if udid
    return if device_list.include?(udid)
  end

  subscribe do |evt|
    if evt == :DEVICE_ADD
      if udid 
        self.device_list.include?(udid)
      else
        true
      end
    else
      false
    end
  end
end

.wait_for_device_remove(opts = {}) ⇒ Object


110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
# File 'lib/idevice.rb', line 110

def self.wait_for_device_remove(opts={})
  udid = opts[:udid]
  if udid
    return unless device_list.include?(udid)
  end

  subscribe do |evt|
    if evt == :DEVICE_REMOVE
      if udid
        (not self.device_list.include?(udid))
      else
        true
      end
    else
      false
    end
  end
end