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 @@
+ /* swig.i */
+ %module(package="libiphone") iPhone
+ %feature("autodoc", "1");
+ %{
+ /* Includes the header in the wrapper code */
+ #include <libiphone/libiphone.h>
+ #include <plist/plist.h>
+#include "../src/utils.h"
+ typedef struct {
+ iphone_device_t dev;
+ } iPhone;
+
+ typedef struct {
+ iPhone* dev;
+ iphone_lckd_client_t client;
+ } Lockdownd;
+
+ typedef struct {
+ Lockdownd* lckd;
+ iphone_msync_client_t client;
+ } MobileSync;
+
+//now declare funtions to handle creation and deletion of objects
+void my_delete_iPhone(iPhone* dev);
+Lockdownd* my_new_Lockdownd(iPhone* phone);
+void my_delete_Lockdownd(Lockdownd* lckd);
+MobileSync* my_new_MobileSync(Lockdownd* lckd);
+
+ %}
+/* Parse the header file to generate wrappers */
+%include "stdint.i"
+%include "plist/swig/plist.i"
+
+typedef struct {
+ iphone_device_t dev;
+} iPhone;
+
+typedef struct {
+ iPhone* dev;
+ iphone_lckd_client_t client;
+} Lockdownd;
+
+typedef struct {
+ Lockdownd* lckd;
+ iphone_msync_client_t client;
+} MobileSync;
+
+%inline %{
+//now define funtions to handle creation and deletion of objects
+
+
+void my_delete_iPhone(iPhone* dev) {
+ if (dev) {
+ iphone_free_device ( dev->dev );
+ free(dev);
+ }
+}
+
+Lockdownd* my_new_Lockdownd(iPhone* phone) {
+ if (!phone) return NULL;
+ Lockdownd* client = (Lockdownd*) malloc(sizeof(Lockdownd));
+ client->dev = phone;
+ client->client = NULL;
+ if (IPHONE_E_SUCCESS == iphone_lckd_new_client ( phone->dev , &(client->client))) {
+ return client;
+ }
+ else {
+ free(client);
+ return NULL;
+ }
+}
+
+void my_delete_Lockdownd(Lockdownd* lckd) {
+ if (lckd) {
+ my_delete_iPhone(lckd->dev);
+ iphone_lckd_free_client ( lckd->client );
+ free(lckd);
+ }
+}
+
+MobileSync* my_new_MobileSync(Lockdownd* lckd) {
+ if (!lckd || !lckd->dev) return NULL;
+ MobileSync* client = NULL;
+ int port = 0;
+ if (IPHONE_E_SUCCESS == iphone_lckd_start_service ( lckd->client, "com.apple.mobilesync", &port )) {
+ client = (MobileSync*) malloc(sizeof(MobileSync));
+ client->lckd = lckd;
+ client->client = NULL;
+ iphone_msync_new_client ( lckd->dev->dev, 3432, port, &(client->client));
+ }
+ return client;
+}
+
+%}
+
+
+%extend iPhone { // Attach these functions to struct iPhone
+ iPhone() {
+ iPhone* phone = (iPhone*) malloc(sizeof(iPhone));
+ phone->dev = NULL;
+ iphone_set_debug_mask(DBGMASK_LOCKDOWND | DBGMASK_MOBILESYNC);
+ return phone;
+ }
+
+ ~iPhone() {
+ my_delete_iPhone($self);
+ }
+
+ int init_device() {
+ if (IPHONE_E_SUCCESS == iphone_get_device ( &($self->dev)))
+ return 1;
+ return 0;
+ }
+
+ Lockdownd* get_lockdown_client() {
+ return my_new_Lockdownd($self);
+ }
+};
+
+
+%extend Lockdownd { // Attach these functions to struct Lockdownd
+ Lockdownd(iPhone* phone) {
+ return my_new_Lockdownd(phone);
+ }
+
+ ~Lockdownd() {
+ my_delete_Lockdownd($self);
+ }
+
+ MobileSync* get_mobile_sync_client() {
+ return my_new_MobileSync($self);
+ }
+};
+
+%extend MobileSync { // Attach these functions to struct MobileSync
+ MobileSync(Lockdownd* lckd) {
+ return my_new_MobileSync(lckd);
+ }
+
+ ~MobileSync() {
+ my_delete_Lockdownd($self->lckd);
+ iphone_msync_free_client ( $self->client );
+ free($self);
+ }
+
+ void send(PListNode* node) {
+ iphone_msync_send($self->client, node->node);
+ }
+
+ PListNode* receive() {
+ PListNode* node = (PListNode*)malloc(sizeof(PListNode));
+ node->node = NULL;
+ iphone_msync_recv($self->client, &(node->node));
+ return node;
+ }
+};
+