Class: Idevice::SbservicesClient

Inherits:
C::ManagedOpaquePointer show all
Includes:
LibHelpers
Defined in:
lib/idevice/sbservices.rb

Constant Summary collapse

INTERFACE_ORIENTATIONS =
[
  :UNKNOWN,              # => 0,
  :PORTRAIT,             # => 1,
  :PORTRAIT_UPSIDE_DOWN, # => 2,
  :LANDSCAPE_RIGHT,      # => 3,
  :LANDSCAPE_LEFT,       # => 4,
]

Class Method Summary collapse

Instance Method Summary collapse

Methods included from LibHelpers

included

Methods inherited from C::ManagedOpaquePointer

#initialize

Constructor Details

This class inherits a constructor from Idevice::C::ManagedOpaquePointer

Class Method Details

.attach(opts = {}) ⇒ Object


43
44
45
46
47
48
49
50
51
52
# File 'lib/idevice/sbservices.rb', line 43

def self.attach(opts={})
  _attach_helper("com.apple.springboardservices", opts) do |idevice, ldsvc, p_sbs|
    err = C.sbservices_client_new(idevice, ldsvc, p_sbs)
    raise SbservicesError, "Springboard Services Error: #{err}" if err != :SUCCESS

    sbs = p_sbs.read_pointer
    raise SBSError, "sbservices_client_new returned a NULL client" if sbs.null?
    return new(sbs)
  end
end

.release(ptr) ⇒ Object


35
36
37
38
39
40
41
# File 'lib/idevice/sbservices.rb', line 35

def self.release(ptr)
  C::Freelock.synchronize do
    unless ptr.null?
      C.sbservices_client_free(ptr)
    end
  end
end

Instance Method Details

#get_home_screen_wallpaper_pngdataObject


103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/idevice/sbservices.rb', line 103

def get_home_screen_wallpaper_pngdata
  FFI::MemoryPointer.new(:pointer) do |p_pngdata|
    FFI::MemoryPointer.new(:uint64) do |p_pngsize|
      err = C.sbservices_get_home_screen_wallpaper_pngdata(self, p_pngdata, p_pngsize)
      raise SbservicesError, "Springboard Services Error: #{err}" if err != :SUCCESS

      pngdata = p_pngdata.read_pointer
      unless pngdata.null?
        ret=pngdata.read_bytes(p_pngsize.read_uint64)
        C.free(pngdata)
        return ret
      end
    end
  end
end

#get_icon_pngdata(bundleid) ⇒ Object


69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# File 'lib/idevice/sbservices.rb', line 69

def get_icon_pngdata(bundleid)
  FFI::MemoryPointer.new(:pointer) do |p_pngdata|
    FFI::MemoryPointer.new(:uint64) do |p_pngsize|
      err = C.sbservices_get_icon_pngdata(self, bundleid, p_pngdata, p_pngsize)
      raise SbservicesError, "Springboard Services Error: #{err}" if err != :SUCCESS

      pngdata = p_pngdata.read_pointer
      unless pngdata.null?
        ret=pngdata.read_bytes(p_pngsize.read_uint64)
        C.free(pngdata)
        return ret
      end
    end
  end
end

#get_icon_stateObject


54
55
56
57
58
59
60
# File 'lib/idevice/sbservices.rb', line 54

def get_icon_state
  FFI::MemoryPointer.new(:pointer) do |p_state|
    err = C.sbservices_get_icon_state(self, p_state, nil)
    raise SbservicesError, "Springboard Services Error: #{err}" if err != :SUCCESS
    return p_state.read_pointer.read_plist_t
  end
end

#get_interface_orientationObject


93
94
95
96
97
98
99
100
101
# File 'lib/idevice/sbservices.rb', line 93

def get_interface_orientation
  FFI::MemoryPointer.new(:int) do |p_orientation|
    err = C.sbservices_get_interface_orientation(self, p_orientation)
    raise SbservicesError, "Springboard Services Error: #{err}" if err != :SUCCESS

    orientation = p_orientation.read_int
    return (INTERFACE_ORIENTATIONS[orientation] or orientation)
  end
end

#set_icon_state(newstate) ⇒ Object

Raises:


62
63
64
65
66
67
# File 'lib/idevice/sbservices.rb', line 62

def set_icon_state(newstate)
  err = C.sbservices_set_icon_state(self, Plist_t.from_ruby(newstate))
  raise SbservicesError, "Springboard Services Error: #{err}" if err != :SUCCESS

  return true
end