Class: Idevice::MobileBackupClient
Overview
Used to backup and restore of all device data. (Pre iOS 4)
Constant Summary
collapse
- FLAG_RESTORE_NOTIFY_SPRINGBOARD =
(1 << 0)
- FLAG_RESTORE_PRESERVE_SETTINGS =
(1 << 1)
- FLAG_RESTORE_PRESERVE_CAMERA_ROLL =
(1 << 2)
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from LibHelpers
included
#initialize
Class Method Details
.attach(opts = {}) ⇒ Object
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/idevice/mobilebackup.rb', line 46
def self.attach(opts={})
_attach_helper("com.apple.mobilebackup", opts) do |idevice, ldsvc, p_mb|
err = C.mobilebackup_client_new(idevice, ldsvc, p_mb)
raise MobileBackupError, "Mobile backup error: #{err}" if err != :SUCCESS
mb = p_mb.read_pointer
raise MisAgentError, "mobilebackup_client_new returned a NULL client" if mb.null?
return new(mb)
end
end
|
.release(ptr) ⇒ Object
34
35
36
37
38
39
40
|
# File 'lib/idevice/mobilebackup.rb', line 34
def self.release(ptr)
C::Freelock.synchronize do
unless ptr.null?
C.mobilebackup_client_free(ptr)
end
end
end
|
Instance Method Details
#receive_plist ⇒ Object
57
58
59
60
61
62
63
64
|
# File 'lib/idevice/mobilebackup.rb', line 57
def receive_plist
FFI::MemoryPointer.new(:pointer) do |p_result|
err = C.mobilebackup_receive(self, p_result)
raise MobileBackupError, "Mobile backup error: #{err}" if err != :SUCCESS
return p_result.read_pointer.read_plist_t
end
end
|
#receive_restore_application_received ⇒ Object
114
115
116
117
118
119
120
121
|
# File 'lib/idevice/mobilebackup.rb', line 114
def receive_restore_application_received
FFI::MemoryPointer.new(:pointer) do |p_result|
err = C.mobilebackup_receive_restore_application_received(self, p_result)
raise MobileBackupError, "Mobile backup error: #{err}" if err != :SUCCESS
return p_result.read_pointer.read_plist_t
end
end
|
#receive_restore_file_received ⇒ Object
105
106
107
108
109
110
111
112
|
# File 'lib/idevice/mobilebackup.rb', line 105
def receive_restore_file_received
FFI::MemoryPointer.new(:pointer) do |p_result|
err = C.mobilebackup_receive_restore_file_received(self, p_result)
raise MobileBackupError, "Mobile backup error: #{err}" if err != :SUCCESS
return p_result.read_pointer.read_plist_t
end
end
|
#request_backup(backup_manifest = {}) ⇒ Object
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/idevice/mobilebackup.rb', line 73
def request_backup(backup_manifest={})
manifest = backup_manifest.dup
proto_version = manifest.delete(:proto_version) || '1.6'
base_path = manifest.delete(:base_path)
raise ArgumentError, "The manifest must contain a :base_path key and value" if base_path.nil?
err = C.mobilebackup_request_backup(self, Plist_t.from_ruby(manifest), base_path, proto_version)
raise MobileBackupError, "Mobile backup error: #{err}" if err != :SUCCESS
return true
end
|
#request_restore(backup_manifest = {}) ⇒ Object
93
94
95
96
97
98
99
100
101
102
103
|
# File 'lib/idevice/mobilebackup.rb', line 93
def request_restore(backup_manifest={})
manifest = backup_manifest.dup
proto_version = manifest.delete(:proto_version) || '1.6'
restore_flags = manifest.delete(:restore_flags) || 0
err = C.mobilebackup_request_restore(self, Plist_t.from_ruby(manifest), restore_flags, proto_version)
raise MobileBackupError, "Mobile backup error: #{err}" if err != :SUCCESS
return true
end
|
#send_backup_file_received ⇒ Object
86
87
88
89
90
91
|
# File 'lib/idevice/mobilebackup.rb', line 86
def send_backup_file_received
err = C.mobilebackup_send_backup_file_received(self)
raise MobileBackupError, "Mobile backup error: #{err}" if err != :SUCCESS
return true
end
|
#send_error(reason) ⇒ Object
130
131
132
133
134
135
|
# File 'lib/idevice/mobilebackup.rb', line 130
def send_error(reason)
err = C.mobilebackup_send_error(self, reason)
raise MobileBackupError, "Mobile backup error: #{err}" if err != :SUCCESS
return true
end
|
#send_plist(dict) ⇒ Object
66
67
68
69
70
71
|
# File 'lib/idevice/mobilebackup.rb', line 66
def send_plist(dict)
err = C.mobilebackup_send(self, Plist_t.from_ruby(dict))
raise MobileBackupError, "Mobile backup error: #{err}" if err != :SUCCESS
return true
end
|
#send_restore_complete ⇒ Object
123
124
125
126
127
128
|
# File 'lib/idevice/mobilebackup.rb', line 123
def send_restore_complete
err = C.mobilebackup_send_restore_complete(self)
raise MobileBackupError, "Mobile backup error: #{err}" if err != :SUCCESS
return true
end
|