summaryrefslogtreecommitdiffstats
path: root/swig/iphone.i
diff options
context:
space:
mode:
authorGravatar Matt Colyer2009-04-13 08:48:00 -0700
committerGravatar Matt Colyer2009-04-13 08:48:00 -0700
commit6671ca3d6de6a1fd27853e3b1ce7a81d568703f0 (patch)
tree735c5ace7ed57cd4e19f2fde423b22e6104eaa98 /swig/iphone.i
parentbd31783d7fde0b5bd101f4a3f97ca1aca2aa6fab (diff)
parent288929f45cb2641690879b52ec514097995cd41a (diff)
downloadlibimobiledevice-6671ca3d6de6a1fd27853e3b1ce7a81d568703f0.tar.gz
libimobiledevice-6671ca3d6de6a1fd27853e3b1ce7a81d568703f0.tar.bz2
Merged in Jonathan's libplist libiphone. [#2 state:resolved]
Diffstat (limited to 'swig/iphone.i')
-rw-r--r--swig/iphone.i157
1 files changed, 157 insertions, 0 deletions
diff --git a/swig/iphone.i b/swig/iphone.i
new file mode 100644
index 0000000..3ae0999
--- /dev/null
+++ b/swig/iphone.i
@@ -0,0 +1,157 @@
1 /* swig.i */
2 %module(package="libiphone") iPhone
3 %feature("autodoc", "1");
4 %{
5 /* Includes the header in the wrapper code */
6 #include <libiphone/libiphone.h>
7 #include <plist/plist.h>
8#include "../src/utils.h"
9 typedef struct {
10 iphone_device_t dev;
11 } iPhone;
12
13 typedef struct {
14 iPhone* dev;
15 iphone_lckd_client_t client;
16 } Lockdownd;
17
18 typedef struct {
19 Lockdownd* lckd;
20 iphone_msync_client_t client;
21 } MobileSync;
22
23//now declare funtions to handle creation and deletion of objects
24void my_delete_iPhone(iPhone* dev);
25Lockdownd* my_new_Lockdownd(iPhone* phone);
26void my_delete_Lockdownd(Lockdownd* lckd);
27MobileSync* my_new_MobileSync(Lockdownd* lckd);
28
29 %}
30/* Parse the header file to generate wrappers */
31%include "stdint.i"
32%include "plist/swig/plist.i"
33
34typedef struct {
35 iphone_device_t dev;
36} iPhone;
37
38typedef struct {
39 iPhone* dev;
40 iphone_lckd_client_t client;
41} Lockdownd;
42
43typedef struct {
44 Lockdownd* lckd;
45 iphone_msync_client_t client;
46} MobileSync;
47
48%inline %{
49//now define funtions to handle creation and deletion of objects
50
51
52void my_delete_iPhone(iPhone* dev) {
53 if (dev) {
54 iphone_free_device ( dev->dev );
55 free(dev);
56 }
57}
58
59Lockdownd* my_new_Lockdownd(iPhone* phone) {
60 if (!phone) return NULL;
61 Lockdownd* client = (Lockdownd*) malloc(sizeof(Lockdownd));
62 client->dev = phone;
63 client->client = NULL;
64 if (IPHONE_E_SUCCESS == iphone_lckd_new_client ( phone->dev , &(client->client))) {
65 return client;
66 }
67 else {
68 free(client);
69 return NULL;
70 }
71}
72
73void my_delete_Lockdownd(Lockdownd* lckd) {
74 if (lckd) {
75 my_delete_iPhone(lckd->dev);
76 iphone_lckd_free_client ( lckd->client );
77 free(lckd);
78 }
79}
80
81MobileSync* my_new_MobileSync(Lockdownd* lckd) {
82 if (!lckd || !lckd->dev) return NULL;
83 MobileSync* client = NULL;
84 int port = 0;
85 if (IPHONE_E_SUCCESS == iphone_lckd_start_service ( lckd->client, "com.apple.mobilesync", &port )) {
86 client = (MobileSync*) malloc(sizeof(MobileSync));
87 client->lckd = lckd;
88 client->client = NULL;
89 iphone_msync_new_client ( lckd->dev->dev, 3432, port, &(client->client));
90 }
91 return client;
92}
93
94%}
95
96
97%extend iPhone { // Attach these functions to struct iPhone
98 iPhone() {
99 iPhone* phone = (iPhone*) malloc(sizeof(iPhone));
100 phone->dev = NULL;
101 iphone_set_debug_mask(DBGMASK_LOCKDOWND | DBGMASK_MOBILESYNC);
102 return phone;
103 }
104
105 ~iPhone() {
106 my_delete_iPhone($self);
107 }
108
109 int init_device() {
110 if (IPHONE_E_SUCCESS == iphone_get_device ( &($self->dev)))
111 return 1;
112 return 0;
113 }
114
115 Lockdownd* get_lockdown_client() {
116 return my_new_Lockdownd($self);
117 }
118};
119
120
121%extend Lockdownd { // Attach these functions to struct Lockdownd
122 Lockdownd(iPhone* phone) {
123 return my_new_Lockdownd(phone);
124 }
125
126 ~Lockdownd() {
127 my_delete_Lockdownd($self);
128 }
129
130 MobileSync* get_mobile_sync_client() {
131 return my_new_MobileSync($self);
132 }
133};
134
135%extend MobileSync { // Attach these functions to struct MobileSync
136 MobileSync(Lockdownd* lckd) {
137 return my_new_MobileSync(lckd);
138 }
139
140 ~MobileSync() {
141 my_delete_Lockdownd($self->lckd);
142 iphone_msync_free_client ( $self->client );
143 free($self);
144 }
145
146 void send(PListNode* node) {
147 iphone_msync_send($self->client, node->node);
148 }
149
150 PListNode* receive() {
151 PListNode* node = (PListNode*)malloc(sizeof(PListNode));
152 node->node = NULL;
153 iphone_msync_recv($self->client, &(node->node));
154 return node;
155 }
156};
157