summaryrefslogtreecommitdiffstats
path: root/swig
diff options
context:
space:
mode:
Diffstat (limited to 'swig')
-rw-r--r--swig/Makefile.am10
-rw-r--r--swig/iphone.i63
2 files changed, 54 insertions, 19 deletions
diff --git a/swig/Makefile.am b/swig/Makefile.am
index d65b984..f3f9714 100644
--- a/swig/Makefile.am
+++ b/swig/Makefile.am
@@ -1,6 +1,6 @@
-INCLUDES = -I$(top_srcdir)/include $(libplist_CFLAGS) -I$(oldincludedir)
+INCLUDES = -I$(top_srcdir)/include $(libplist_CFLAGS) $(SWIG_PYTHON_CPPFLAGS) -I$(oldincludedir)
-BUILT_SOURCES = iphone_wrap.c
+BUILT_SOURCES = iphone_wrap.cxx
SWIG_SOURCES = iphone.i
CLEANFILES = \
@@ -8,7 +8,7 @@ CLEANFILES = \
*.pyo \
_iPhone.so \
iPhone.py \
- iphone_wrap.c
+ iphone_wrap.cxx
EXTRA_DIST = \
__init__.py \
@@ -21,11 +21,11 @@ iPhonedir = $(pyexecdir)/libiphone
iPhone_PYTHON = __init__.py
nodist_iPhone_PYTHON = iPhone.py
iPhone_LTLIBRARIES = _iPhone.la
-nodist__iPhone_la_SOURCES = iphone_wrap.c $(SWIG_SOURCES)
+nodist__iPhone_la_SOURCES = iphone_wrap.cxx $(SWIG_SOURCES)
_iPhone_la_CFLAGS = $(PYTHON_CPPFLAGS) -I$(top_srcdir)/src
_iPhone_la_LDFLAGS = -module -avoid-version $(PYTHON_LDFLAGS)
_iPhone_la_LIBADD = $(top_builddir)/src/libiphone.la
-iphone_wrap.c : $(SWIG_SOURCES)
+iphone_wrap.cxx : $(SWIG_SOURCES)
$(SWIG) $(SWIG_PYTHON_OPT) $(INCLUDES) -I$(top_srcdir)/src -o $@ $<
diff --git a/swig/iphone.i b/swig/iphone.i
index ba6345a..6604c63 100644
--- a/swig/iphone.i
+++ b/swig/iphone.i
@@ -7,6 +7,7 @@
#include <libiphone/lockdown.h>
#include <libiphone/mobilesync.h>
#include <plist/plist.h>
+ #include <plist/plist++.h>
#include "../src/utils.h"
typedef struct {
iphone_device_t dev;
@@ -27,6 +28,7 @@ void my_delete_iPhone(iPhone* dev);
Lockdownd* my_new_Lockdownd(iPhone* phone);
void my_delete_Lockdownd(Lockdownd* lckd);
MobileSync* my_new_MobileSync(Lockdownd* lckd);
+PList::Node* new_node_from_plist(plist_t node);
%}
/* Parse the header file to generate wrappers */
@@ -98,6 +100,41 @@ MobileSync* my_new_MobileSync(Lockdownd* lckd) {
return client;
}
+PList::Node* new_node_from_plist(plist_t node)
+{
+ PList::Node* ret = NULL;
+ plist_type subtype = plist_get_node_type(node);
+ switch(subtype)
+ {
+ case PLIST_DICT:
+ ret = new PList::Dictionary(node);
+ break;
+ case PLIST_ARRAY:
+ ret = new PList::Array(node);
+ break;
+ case PLIST_BOOLEAN:
+ ret = new PList::Boolean(node);
+ break;
+ case PLIST_UINT:
+ ret = new PList::Integer(node);
+ break;
+ case PLIST_REAL:
+ ret = new PList::Real(node);
+ break;
+ case PLIST_STRING:
+ ret = new PList::String(node);
+ break;
+ case PLIST_DATE:
+ ret = new PList::Date(node);
+ break;
+ case PLIST_DATA:
+ ret = new PList::Data(node);
+ break;
+ default:
+ break;
+ }
+ return ret;
+}
%}
@@ -154,15 +191,14 @@ MobileSync* my_new_MobileSync(Lockdownd* lckd) {
my_delete_Lockdownd($self);
}
- void send(PListNode* node) {
- lockdownd_send($self->client, node->node);
+ void send(PList::Node* node) {
+ lockdownd_send($self->client, node->GetPlist());
}
- PListNode* receive() {
- PListNode* node = (PListNode*)malloc(sizeof(PListNode));
- node->node = NULL;
- lockdownd_recv($self->client, &(node->node));
- return node;
+ PList::Node* receive() {
+ plist_t node = NULL;
+ lockdownd_recv($self->client, &node);
+ return new_node_from_plist(node);
}
MobileSync* get_mobilesync_client() {
@@ -180,15 +216,14 @@ MobileSync* my_new_MobileSync(Lockdownd* lckd) {
free($self);
}
- void send(PListNode* node) {
- mobilesync_send($self->client, node->node);
+ void send(PList::Node* node) {
+ mobilesync_send($self->client, node->GetPlist());
}
- PListNode* receive() {
- PListNode* node = (PListNode*)malloc(sizeof(PListNode));
- node->node = NULL;
- mobilesync_recv($self->client, &(node->node));
- return node;
+ PList::Node* receive() {
+ plist_t node = NULL;
+ mobilesync_recv($self->client, &node);
+ return new_node_from_plist(node);
}
};