diff options
| author | 2009-01-13 18:57:52 +0100 | |
|---|---|---|
| committer | 2009-01-13 18:57:52 +0100 | |
| commit | d4694679f918750e920a2238d891cd2fbb741a90 (patch) | |
| tree | ea52b9d253993b31ec71cbad35280d7c5eeab957 | |
| parent | 564aebf941f2f0c5fb57d2f86091b37d6331b9d9 (diff) | |
| download | libimobiledevice-d4694679f918750e920a2238d891cd2fbb741a90.tar.gz libimobiledevice-d4694679f918750e920a2238d891cd2fbb741a90.tar.bz2 | |
Add parts of a python binding to libiphone that also include libplist (using SWIG).
| -rw-r--r-- | Makefile.am | 4 | ||||
| -rwxr-xr-x | autogen.sh | 2 | ||||
| -rw-r--r-- | configure.ac | 8 | ||||
| -rw-r--r-- | include/libiphone/libiphone.h | 11 | ||||
| -rw-r--r-- | m4/ac_pkg_swig.m4 | 122 | ||||
| -rw-r--r-- | m4/ac_python_devel.m4 | 265 | ||||
| -rw-r--r-- | m4/swig_python.m4 | 65 | ||||
| -rw-r--r-- | src/MobileSync.c | 4 | ||||
| -rw-r--r-- | src/MobileSync.h | 9 | ||||
| -rw-r--r-- | swig/Makefile.am | 18 | ||||
| -rw-r--r-- | swig/__init__.py | 1 | ||||
| -rw-r--r-- | swig/iphone.i | 123 |
12 files changed, 618 insertions, 14 deletions
diff --git a/Makefile.am b/Makefile.am index f103377..982f42b 100644 --- a/Makefile.am +++ b/Makefile.am | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | AUTOMAKE_OPTIONS = foreign | 1 | AUTOMAKE_OPTIONS = foreign |
| 2 | 2 | ACLOCAL_AMFLAGS = -I m4 | |
| 3 | SUBDIRS = src include fdi $(DEV_SUB) | 3 | SUBDIRS = src include fdi swig $(DEV_SUB) |
| 4 | 4 | ||
| 5 | pkgconfigdir = $(libdir)/pkgconfig | 5 | pkgconfigdir = $(libdir)/pkgconfig |
| 6 | pkgconfig_DATA = libiphone-1.0.pc | 6 | pkgconfig_DATA = libiphone-1.0.pc |
| @@ -1,5 +1,5 @@ | |||
| 1 | #!/bin/sh | 1 | #!/bin/sh |
| 2 | aclocal | 2 | aclocal -I m4 |
| 3 | libtoolize | 3 | libtoolize |
| 4 | autoheader | 4 | autoheader |
| 5 | automake --add-missing | 5 | automake --add-missing |
diff --git a/configure.ac b/configure.ac index 9516ec4..87ed8dc 100644 --- a/configure.ac +++ b/configure.ac | |||
| @@ -6,9 +6,15 @@ AC_INIT(libiphone, 0.1.0, nospam@nowhere.com) | |||
| 6 | AM_INIT_AUTOMAKE(libiphone, 0.1.0) | 6 | AM_INIT_AUTOMAKE(libiphone, 0.1.0) |
| 7 | AC_CONFIG_SRCDIR([src/]) | 7 | AC_CONFIG_SRCDIR([src/]) |
| 8 | AC_CONFIG_HEADER([config.h]) | 8 | AC_CONFIG_HEADER([config.h]) |
| 9 | AC_CONFIG_MACRO_DIR([m4]) | ||
| 9 | 10 | ||
| 10 | AC_PROG_LIBTOOL | 11 | AC_PROG_LIBTOOL |
| 11 | 12 | ||
| 13 | AM_PATH_PYTHON(2.3) | ||
| 14 | AC_PROG_SWIG(1.3.21) | ||
| 15 | SWIG_PYTHON | ||
| 16 | |||
| 17 | |||
| 12 | # Checks for programs. | 18 | # Checks for programs. |
| 13 | AC_PROG_CC | 19 | AC_PROG_CC |
| 14 | AM_PROG_CC_C_O | 20 | AM_PROG_CC_C_O |
| @@ -60,4 +66,4 @@ if test "$no_debug_code" = true; then | |||
| 60 | AC_DEFINE(STRIP_DEBUG_CODE,1,[Strip debug reporting code]) | 66 | AC_DEFINE(STRIP_DEBUG_CODE,1,[Strip debug reporting code]) |
| 61 | fi | 67 | fi |
| 62 | 68 | ||
| 63 | AC_OUTPUT(Makefile src/Makefile include/Makefile fdi/Makefile dev/Makefile libiphone-1.0.pc) | 69 | AC_OUTPUT(Makefile src/Makefile include/Makefile fdi/Makefile dev/Makefile swig/Makefile libiphone-1.0.pc) |
diff --git a/include/libiphone/libiphone.h b/include/libiphone/libiphone.h index aab7fdb..59d2de2 100644 --- a/include/libiphone/libiphone.h +++ b/include/libiphone/libiphone.h | |||
| @@ -78,6 +78,9 @@ typedef struct iphone_afc_client_int *iphone_afc_client_t; | |||
| 78 | struct iphone_afc_file_int; | 78 | struct iphone_afc_file_int; |
| 79 | typedef struct iphone_afc_file_int *iphone_afc_file_t; | 79 | typedef struct iphone_afc_file_int *iphone_afc_file_t; |
| 80 | 80 | ||
| 81 | struct iphone_msync_client_int; | ||
| 82 | typedef struct iphone_msync_client_int *iphone_msync_client_t; | ||
| 83 | |||
| 81 | //device related functions | 84 | //device related functions |
| 82 | void iphone_set_debug(int level); | 85 | void iphone_set_debug(int level); |
| 83 | iphone_error_t iphone_get_device ( iphone_device_t *device ); | 86 | iphone_error_t iphone_get_device ( iphone_device_t *device ); |
| @@ -120,6 +123,14 @@ iphone_error_t iphone_afc_rename_file ( iphone_afc_client_t client, const char * | |||
| 120 | iphone_error_t iphone_afc_mkdir ( iphone_afc_client_t client, const char *dir); | 123 | iphone_error_t iphone_afc_mkdir ( iphone_afc_client_t client, const char *dir); |
| 121 | 124 | ||
| 122 | 125 | ||
| 126 | |||
| 127 | iphone_error_t iphone_msync_new_client(iphone_device_t device, int src_port, int dst_port, | ||
| 128 | iphone_msync_client_t * client); | ||
| 129 | iphone_error_t iphone_msync_free_client(iphone_msync_client_t client); | ||
| 130 | |||
| 131 | iphone_error_t iphone_msync_recv(iphone_msync_client_t client, plist_t * plist); | ||
| 132 | iphone_error_t iphone_msync_send(iphone_msync_client_t client, plist_t plist); | ||
| 133 | |||
| 123 | #ifdef __cplusplus | 134 | #ifdef __cplusplus |
| 124 | } | 135 | } |
| 125 | #endif | 136 | #endif |
diff --git a/m4/ac_pkg_swig.m4 b/m4/ac_pkg_swig.m4 new file mode 100644 index 0000000..738f69d --- /dev/null +++ b/m4/ac_pkg_swig.m4 | |||
| @@ -0,0 +1,122 @@ | |||
| 1 | # =========================================================================== | ||
| 2 | # http://autoconf-archive.cryp.to/ac_pkg_swig.html | ||
| 3 | # =========================================================================== | ||
| 4 | # | ||
| 5 | # SYNOPSIS | ||
| 6 | # | ||
| 7 | # AC_PROG_SWIG([major.minor.micro]) | ||
| 8 | # | ||
| 9 | # DESCRIPTION | ||
| 10 | # | ||
| 11 | # This macro searches for a SWIG installation on your system. If found you | ||
| 12 | # should call SWIG via $(SWIG). You can use the optional first argument to | ||
| 13 | # check if the version of the available SWIG is greater than or equal to | ||
| 14 | # the value of the argument. It should have the format: N[.N[.N]] (N is a | ||
| 15 | # number between 0 and 999. Only the first N is mandatory.) | ||
| 16 | # | ||
| 17 | # If the version argument is given (e.g. 1.3.17), AC_PROG_SWIG checks that | ||
| 18 | # the swig package is this version number or higher. | ||
| 19 | # | ||
| 20 | # In configure.in, use as: | ||
| 21 | # | ||
| 22 | # AC_PROG_SWIG(1.3.17) | ||
| 23 | # SWIG_ENABLE_CXX | ||
| 24 | # SWIG_MULTI_MODULE_SUPPORT | ||
| 25 | # SWIG_PYTHON | ||
| 26 | # | ||
| 27 | # LAST MODIFICATION | ||
| 28 | # | ||
| 29 | # 2008-04-12 | ||
| 30 | # | ||
| 31 | # COPYLEFT | ||
| 32 | # | ||
| 33 | # Copyright (c) 2008 Sebastian Huber <sebastian-huber@web.de> | ||
| 34 | # Copyright (c) 2008 Alan W. Irwin <irwin@beluga.phys.uvic.ca> | ||
| 35 | # Copyright (c) 2008 Rafael Laboissiere <rafael@laboissiere.net> | ||
| 36 | # Copyright (c) 2008 Andrew Collier <colliera@ukzn.ac.za> | ||
| 37 | # | ||
| 38 | # This program is free software; you can redistribute it and/or modify it | ||
| 39 | # under the terms of the GNU General Public License as published by the | ||
| 40 | # Free Software Foundation; either version 2 of the License, or (at your | ||
| 41 | # option) any later version. | ||
| 42 | # | ||
| 43 | # This program is distributed in the hope that it will be useful, but | ||
| 44 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 45 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
| 46 | # Public License for more details. | ||
| 47 | # | ||
| 48 | # You should have received a copy of the GNU General Public License along | ||
| 49 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 50 | # | ||
| 51 | # As a special exception, the respective Autoconf Macro's copyright owner | ||
| 52 | # gives unlimited permission to copy, distribute and modify the configure | ||
| 53 | # scripts that are the output of Autoconf when processing the Macro. You | ||
| 54 | # need not follow the terms of the GNU General Public License when using | ||
| 55 | # or distributing such scripts, even though portions of the text of the | ||
| 56 | # Macro appear in them. The GNU General Public License (GPL) does govern | ||
| 57 | # all other use of the material that constitutes the Autoconf Macro. | ||
| 58 | # | ||
| 59 | # This special exception to the GPL applies to versions of the Autoconf | ||
| 60 | # Macro released by the Autoconf Macro Archive. When you make and | ||
| 61 | # distribute a modified version of the Autoconf Macro, you may extend this | ||
| 62 | # special exception to the GPL to apply to your modified version as well. | ||
| 63 | |||
| 64 | AC_DEFUN([AC_PROG_SWIG],[ | ||
| 65 | AC_PATH_PROG([SWIG],[swig]) | ||
| 66 | if test -z "$SWIG" ; then | ||
| 67 | AC_MSG_WARN([cannot find 'swig' program. You should look at http://www.swig.org]) | ||
| 68 | SWIG='echo "Error: SWIG is not installed. You should look at http://www.swig.org" ; false' | ||
| 69 | elif test -n "$1" ; then | ||
| 70 | AC_MSG_CHECKING([for SWIG version]) | ||
| 71 | [swig_version=`$SWIG -version 2>&1 | grep 'SWIG Version' | sed 's/.*\([0-9][0-9]*\.[0-9][0-9]*\.[0-9][0-9]*\).*/\1/g'`] | ||
| 72 | AC_MSG_RESULT([$swig_version]) | ||
| 73 | if test -n "$swig_version" ; then | ||
| 74 | # Calculate the required version number components | ||
| 75 | [required=$1] | ||
| 76 | [required_major=`echo $required | sed 's/[^0-9].*//'`] | ||
| 77 | if test -z "$required_major" ; then | ||
| 78 | [required_major=0] | ||
| 79 | fi | ||
| 80 | [required=`echo $required | sed 's/[0-9]*[^0-9]//'`] | ||
| 81 | [required_minor=`echo $required | sed 's/[^0-9].*//'`] | ||
| 82 | if test -z "$required_minor" ; then | ||
| 83 | [required_minor=0] | ||
| 84 | fi | ||
| 85 | [required=`echo $required | sed 's/[0-9]*[^0-9]//'`] | ||
| 86 | [required_patch=`echo $required | sed 's/[^0-9].*//'`] | ||
| 87 | if test -z "$required_patch" ; then | ||
| 88 | [required_patch=0] | ||
| 89 | fi | ||
| 90 | # Calculate the available version number components | ||
| 91 | [available=$swig_version] | ||
| 92 | [available_major=`echo $available | sed 's/[^0-9].*//'`] | ||
| 93 | if test -z "$available_major" ; then | ||
| 94 | [available_major=0] | ||
| 95 | fi | ||
| 96 | [available=`echo $available | sed 's/[0-9]*[^0-9]//'`] | ||
| 97 | [available_minor=`echo $available | sed 's/[^0-9].*//'`] | ||
| 98 | if test -z "$available_minor" ; then | ||
| 99 | [available_minor=0] | ||
| 100 | fi | ||
| 101 | [available=`echo $available | sed 's/[0-9]*[^0-9]//'`] | ||
| 102 | [available_patch=`echo $available | sed 's/[^0-9].*//'`] | ||
| 103 | if test -z "$available_patch" ; then | ||
| 104 | [available_patch=0] | ||
| 105 | fi | ||
| 106 | if test $available_major -ne $required_major \ | ||
| 107 | -o $available_minor -ne $required_minor \ | ||
| 108 | -o $available_patch -lt $required_patch ; then | ||
| 109 | AC_MSG_WARN([SWIG version >= $1 is required. You have $swig_version. You should look at http://www.swig.org]) | ||
| 110 | SWIG='echo "Error: SWIG version >= $1 is required. You have '"$swig_version"'. You should look at http://www.swig.org" ; false' | ||
| 111 | else | ||
| 112 | AC_MSG_NOTICE([SWIG executable is '$SWIG']) | ||
| 113 | SWIG_LIB=`$SWIG -swiglib` | ||
| 114 | AC_MSG_NOTICE([SWIG library directory is '$SWIG_LIB']) | ||
| 115 | fi | ||
| 116 | else | ||
| 117 | AC_MSG_WARN([cannot determine SWIG version]) | ||
| 118 | SWIG='echo "Error: Cannot determine SWIG version. You should look at http://www.swig.org" ; false' | ||
| 119 | fi | ||
| 120 | fi | ||
| 121 | AC_SUBST([SWIG_LIB]) | ||
| 122 | ]) | ||
diff --git a/m4/ac_python_devel.m4 b/m4/ac_python_devel.m4 new file mode 100644 index 0000000..7cec10f --- /dev/null +++ b/m4/ac_python_devel.m4 | |||
| @@ -0,0 +1,265 @@ | |||
| 1 | # =========================================================================== | ||
| 2 | # http://autoconf-archive.cryp.to/ac_python_devel.html | ||
| 3 | # =========================================================================== | ||
| 4 | # | ||
| 5 | # SYNOPSIS | ||
| 6 | # | ||
| 7 | # AC_PYTHON_DEVEL([version]) | ||
| 8 | # | ||
| 9 | # DESCRIPTION | ||
| 10 | # | ||
| 11 | # Note: Defines as a precious variable "PYTHON_VERSION". Don't override it | ||
| 12 | # in your configure.ac. | ||
| 13 | # | ||
| 14 | # This macro checks for Python and tries to get the include path to | ||
| 15 | # 'Python.h'. It provides the $(PYTHON_CPPFLAGS) and $(PYTHON_LDFLAGS) | ||
| 16 | # output variables. It also exports $(PYTHON_EXTRA_LIBS) and | ||
| 17 | # $(PYTHON_EXTRA_LDFLAGS) for embedding Python in your code. | ||
| 18 | # | ||
| 19 | # You can search for some particular version of Python by passing a | ||
| 20 | # parameter to this macro, for example ">= '2.3.1'", or "== '2.4'". Please | ||
| 21 | # note that you *have* to pass also an operator along with the version to | ||
| 22 | # match, and pay special attention to the single quotes surrounding the | ||
| 23 | # version number. Don't use "PYTHON_VERSION" for this: that environment | ||
| 24 | # variable is declared as precious and thus reserved for the end-user. | ||
| 25 | # | ||
| 26 | # This macro should work for all versions of Python >= 2.1.0. As an end | ||
| 27 | # user, you can disable the check for the python version by setting the | ||
| 28 | # PYTHON_NOVERSIONCHECK environment variable to something else than the | ||
| 29 | # empty string. | ||
| 30 | # | ||
| 31 | # If you need to use this macro for an older Python version, please | ||
| 32 | # contact the authors. We're always open for feedback. | ||
| 33 | # | ||
| 34 | # LAST MODIFICATION | ||
| 35 | # | ||
| 36 | # 2008-04-12 | ||
| 37 | # | ||
| 38 | # COPYLEFT | ||
| 39 | # | ||
| 40 | # Copyright (c) 2008 Sebastian Huber <sebastian-huber@web.de> | ||
| 41 | # Copyright (c) 2008 Alan W. Irwin <irwin@beluga.phys.uvic.ca> | ||
| 42 | # Copyright (c) 2008 Rafael Laboissiere <rafael@laboissiere.net> | ||
| 43 | # Copyright (c) 2008 Andrew Collier <colliera@ukzn.ac.za> | ||
| 44 | # Copyright (c) 2008 Matteo Settenvini <matteo@member.fsf.org> | ||
| 45 | # Copyright (c) 2008 Horst Knorr <hk_classes@knoda.org> | ||
| 46 | # | ||
| 47 | # This program is free software: you can redistribute it and/or modify it | ||
| 48 | # under the terms of the GNU General Public License as published by the | ||
| 49 | # Free Software Foundation, either version 3 of the License, or (at your | ||
| 50 | # option) any later version. | ||
| 51 | # | ||
| 52 | # This program is distributed in the hope that it will be useful, but | ||
| 53 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 54 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
| 55 | # Public License for more details. | ||
| 56 | # | ||
| 57 | # You should have received a copy of the GNU General Public License along | ||
| 58 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 59 | # | ||
| 60 | # As a special exception, the respective Autoconf Macro's copyright owner | ||
| 61 | # gives unlimited permission to copy, distribute and modify the configure | ||
| 62 | # scripts that are the output of Autoconf when processing the Macro. You | ||
| 63 | # need not follow the terms of the GNU General Public License when using | ||
| 64 | # or distributing such scripts, even though portions of the text of the | ||
| 65 | # Macro appear in them. The GNU General Public License (GPL) does govern | ||
| 66 | # all other use of the material that constitutes the Autoconf Macro. | ||
| 67 | # | ||
| 68 | # This special exception to the GPL applies to versions of the Autoconf | ||
| 69 | # Macro released by the Autoconf Macro Archive. When you make and | ||
| 70 | # distribute a modified version of the Autoconf Macro, you may extend this | ||
| 71 | # special exception to the GPL to apply to your modified version as well. | ||
| 72 | |||
| 73 | AC_DEFUN([AC_PYTHON_DEVEL],[ | ||
| 74 | # | ||
| 75 | # Allow the use of a (user set) custom python version | ||
| 76 | # | ||
| 77 | AC_ARG_VAR([PYTHON_VERSION],[The installed Python | ||
| 78 | version to use, for example '2.3'. This string | ||
| 79 | will be appended to the Python interpreter | ||
| 80 | canonical name.]) | ||
| 81 | |||
| 82 | AC_PATH_PROG([PYTHON],[python[$PYTHON_VERSION]]) | ||
| 83 | if test -z "$PYTHON"; then | ||
| 84 | AC_MSG_ERROR([Cannot find python$PYTHON_VERSION in your system path]) | ||
| 85 | PYTHON_VERSION="" | ||
| 86 | fi | ||
| 87 | |||
| 88 | # | ||
| 89 | # Check for a version of Python >= 2.1.0 | ||
| 90 | # | ||
| 91 | AC_MSG_CHECKING([for a version of Python >= '2.1.0']) | ||
| 92 | ac_supports_python_ver=`$PYTHON -c "import sys, string; \ | ||
| 93 | ver = string.split(sys.version)[[0]]; \ | ||
| 94 | print ver >= '2.1.0'"` | ||
| 95 | if test "$ac_supports_python_ver" != "True"; then | ||
| 96 | if test -z "$PYTHON_NOVERSIONCHECK"; then | ||
| 97 | AC_MSG_RESULT([no]) | ||
| 98 | AC_MSG_FAILURE([ | ||
| 99 | This version of the AC@&t@_PYTHON_DEVEL macro | ||
| 100 | doesn't work properly with versions of Python before | ||
| 101 | 2.1.0. You may need to re-run configure, setting the | ||
| 102 | variables PYTHON_CPPFLAGS, PYTHON_LDFLAGS, PYTHON_SITE_PKG, | ||
| 103 | PYTHON_EXTRA_LIBS and PYTHON_EXTRA_LDFLAGS by hand. | ||
| 104 | Moreover, to disable this check, set PYTHON_NOVERSIONCHECK | ||
| 105 | to something else than an empty string. | ||
| 106 | ]) | ||
| 107 | else | ||
| 108 | AC_MSG_RESULT([skip at user request]) | ||
| 109 | fi | ||
| 110 | else | ||
| 111 | AC_MSG_RESULT([yes]) | ||
| 112 | fi | ||
| 113 | |||
| 114 | # | ||
| 115 | # if the macro parameter ``version'' is set, honour it | ||
| 116 | # | ||
| 117 | if test -n "$1"; then | ||
| 118 | AC_MSG_CHECKING([for a version of Python $1]) | ||
| 119 | ac_supports_python_ver=`$PYTHON -c "import sys, string; \ | ||
| 120 | ver = string.split(sys.version)[[0]]; \ | ||
| 121 | print ver $1"` | ||
| 122 | if test "$ac_supports_python_ver" = "True"; then | ||
| 123 | AC_MSG_RESULT([yes]) | ||
| 124 | else | ||
| 125 | AC_MSG_RESULT([no]) | ||
| 126 | AC_MSG_ERROR([this package requires Python $1. | ||
| 127 | If you have it installed, but it isn't the default Python | ||
| 128 | interpreter in your system path, please pass the PYTHON_VERSION | ||
| 129 | variable to configure. See ``configure --help'' for reference. | ||
| 130 | ]) | ||
| 131 | PYTHON_VERSION="" | ||
| 132 | fi | ||
| 133 | fi | ||
| 134 | |||
| 135 | # | ||
| 136 | # Check if you have distutils, else fail | ||
| 137 | # | ||
| 138 | AC_MSG_CHECKING([for the distutils Python package]) | ||
| 139 | ac_distutils_result=`$PYTHON -c "import distutils" 2>&1` | ||
| 140 | if test -z "$ac_distutils_result"; then | ||
| 141 | AC_MSG_RESULT([yes]) | ||
| 142 | else | ||
| 143 | AC_MSG_RESULT([no]) | ||
| 144 | AC_MSG_ERROR([cannot import Python module "distutils". | ||
| 145 | Please check your Python installation. The error was: | ||
| 146 | $ac_distutils_result]) | ||
| 147 | PYTHON_VERSION="" | ||
| 148 | fi | ||
| 149 | |||
| 150 | # | ||
| 151 | # Check for Python include path | ||
| 152 | # | ||
| 153 | AC_MSG_CHECKING([for Python include path]) | ||
| 154 | if test -z "$PYTHON_CPPFLAGS"; then | ||
| 155 | python_path=`$PYTHON -c "import distutils.sysconfig; \ | ||
| 156 | print distutils.sysconfig.get_python_inc();"` | ||
| 157 | if test -n "${python_path}"; then | ||
| 158 | python_path="-I$python_path" | ||
| 159 | fi | ||
| 160 | PYTHON_CPPFLAGS=$python_path | ||
| 161 | fi | ||
| 162 | AC_MSG_RESULT([$PYTHON_CPPFLAGS]) | ||
| 163 | AC_SUBST([PYTHON_CPPFLAGS]) | ||
| 164 | |||
| 165 | # | ||
| 166 | # Check for Python library path | ||
| 167 | # | ||
| 168 | AC_MSG_CHECKING([for Python library path]) | ||
| 169 | if test -z "$PYTHON_LDFLAGS"; then | ||
| 170 | # (makes two attempts to ensure we've got a version number | ||
| 171 | # from the interpreter) | ||
| 172 | py_version=`$PYTHON -c "from distutils.sysconfig import *; \ | ||
| 173 | from string import join; \ | ||
| 174 | print join(get_config_vars('VERSION'))"` | ||
| 175 | if test "$py_version" == "[None]"; then | ||
| 176 | if test -n "$PYTHON_VERSION"; then | ||
| 177 | py_version=$PYTHON_VERSION | ||
| 178 | else | ||
| 179 | py_version=`$PYTHON -c "import sys; \ | ||
| 180 | print sys.version[[:3]]"` | ||
| 181 | fi | ||
| 182 | fi | ||
| 183 | |||
| 184 | PYTHON_LDFLAGS=`$PYTHON -c "from distutils.sysconfig import *; \ | ||
| 185 | from string import join; \ | ||
| 186 | print '-L' + get_python_lib(0,1), \ | ||
| 187 | '-lpython';"`$py_version | ||
| 188 | fi | ||
| 189 | AC_MSG_RESULT([$PYTHON_LDFLAGS]) | ||
| 190 | AC_SUBST([PYTHON_LDFLAGS]) | ||
| 191 | |||
| 192 | # | ||
| 193 | # Check for site packages | ||
| 194 | # | ||
| 195 | AC_MSG_CHECKING([for Python site-packages path]) | ||
| 196 | if test -z "$PYTHON_SITE_PKG"; then | ||
| 197 | PYTHON_SITE_PKG=`$PYTHON -c "import distutils.sysconfig; \ | ||
| 198 | print distutils.sysconfig.get_python_lib(0,0);"` | ||
| 199 | fi | ||
| 200 | AC_MSG_RESULT([$PYTHON_SITE_PKG]) | ||
| 201 | AC_SUBST([PYTHON_SITE_PKG]) | ||
| 202 | |||
| 203 | # | ||
| 204 | # libraries which must be linked in when embedding | ||
| 205 | # | ||
| 206 | AC_MSG_CHECKING(python extra libraries) | ||
| 207 | if test -z "$PYTHON_EXTRA_LIBS"; then | ||
| 208 | PYTHON_EXTRA_LIBS=`$PYTHON -c "import distutils.sysconfig; \ | ||
| 209 | conf = distutils.sysconfig.get_config_var; \ | ||
| 210 | print conf('LOCALMODLIBS'), conf('LIBS')"` | ||
| 211 | fi | ||
| 212 | AC_MSG_RESULT([$PYTHON_EXTRA_LIBS]) | ||
| 213 | AC_SUBST(PYTHON_EXTRA_LIBS) | ||
| 214 | |||
| 215 | # | ||
| 216 | # linking flags needed when embedding | ||
| 217 | # | ||
| 218 | AC_MSG_CHECKING(python extra linking flags) | ||
| 219 | if test -z "$PYTHON_EXTRA_LDFLAGS"; then | ||
| 220 | PYTHON_EXTRA_LDFLAGS=`$PYTHON -c "import distutils.sysconfig; \ | ||
| 221 | conf = distutils.sysconfig.get_config_var; \ | ||
| 222 | print conf('LINKFORSHARED')"` | ||
| 223 | fi | ||
| 224 | AC_MSG_RESULT([$PYTHON_EXTRA_LDFLAGS]) | ||
| 225 | AC_SUBST(PYTHON_EXTRA_LDFLAGS) | ||
| 226 | |||
| 227 | # | ||
| 228 | # final check to see if everything compiles alright | ||
| 229 | # | ||
| 230 | AC_MSG_CHECKING([consistency of all components of python development environment]) | ||
| 231 | AC_LANG_PUSH([C]) | ||
| 232 | # save current global flags | ||
| 233 | LIBS="$ac_save_LIBS $PYTHON_LDFLAGS" | ||
| 234 | CPPFLAGS="$ac_save_CPPFLAGS $PYTHON_CPPFLAGS" | ||
| 235 | AC_TRY_LINK([ | ||
| 236 | #include <Python.h> | ||
| 237 | ],[ | ||
| 238 | Py_Initialize(); | ||
| 239 | ],[pythonexists=yes],[pythonexists=no]) | ||
| 240 | |||
| 241 | AC_MSG_RESULT([$pythonexists]) | ||
| 242 | |||
| 243 | if test ! "$pythonexists" = "yes"; then | ||
| 244 | AC_MSG_ERROR([ | ||
| 245 | Could not link test program to Python. Maybe the main Python library has been | ||
| 246 | installed in some non-standard library path. If so, pass it to configure, | ||
| 247 | via the LDFLAGS environment variable. | ||
| 248 | Example: ./configure LDFLAGS="-L/usr/non-standard-path/python/lib" | ||
| 249 | ============================================================================ | ||
| 250 | ERROR! | ||
| 251 | You probably have to install the development version of the Python package | ||
| 252 | for your distribution. The exact name of this package varies among them. | ||
| 253 | ============================================================================ | ||
| 254 | ]) | ||
| 255 | PYTHON_VERSION="" | ||
| 256 | fi | ||
| 257 | AC_LANG_POP | ||
| 258 | # turn back to default flags | ||
| 259 | CPPFLAGS="$ac_save_CPPFLAGS" | ||
| 260 | LIBS="$ac_save_LIBS" | ||
| 261 | |||
| 262 | # | ||
| 263 | # all done! | ||
| 264 | # | ||
| 265 | ]) | ||
diff --git a/m4/swig_python.m4 b/m4/swig_python.m4 new file mode 100644 index 0000000..2496976 --- /dev/null +++ b/m4/swig_python.m4 | |||
| @@ -0,0 +1,65 @@ | |||
| 1 | # =========================================================================== | ||
| 2 | # http://autoconf-archive.cryp.to/swig_python.html | ||
| 3 | # =========================================================================== | ||
| 4 | # | ||
| 5 | # SYNOPSIS | ||
| 6 | # | ||
| 7 | # SWIG_PYTHON([use-shadow-classes = {no, yes}]) | ||
| 8 | # | ||
| 9 | # DESCRIPTION | ||
| 10 | # | ||
| 11 | # Checks for Python and provides the $(SWIG_PYTHON_CPPFLAGS), and | ||
| 12 | # $(SWIG_PYTHON_OPT) output variables. | ||
| 13 | # | ||
| 14 | # $(SWIG_PYTHON_OPT) contains all necessary SWIG options to generate code | ||
| 15 | # for Python. Shadow classes are enabled unless the value of the optional | ||
| 16 | # first argument is exactly 'no'. If you need multi module support | ||
| 17 | # (provided by the SWIG_MULTI_MODULE_SUPPORT macro) use | ||
| 18 | # $(SWIG_PYTHON_LIBS) to link against the appropriate library. It contains | ||
| 19 | # the SWIG Python runtime library that is needed by the type check system | ||
| 20 | # for example. | ||
| 21 | # | ||
| 22 | # LAST MODIFICATION | ||
| 23 | # | ||
| 24 | # 2008-04-12 | ||
| 25 | # | ||
| 26 | # COPYLEFT | ||
| 27 | # | ||
| 28 | # Copyright (c) 2008 Sebastian Huber <sebastian-huber@web.de> | ||
| 29 | # Copyright (c) 2008 Alan W. Irwin <irwin@beluga.phys.uvic.ca> | ||
| 30 | # Copyright (c) 2008 Rafael Laboissiere <rafael@laboissiere.net> | ||
| 31 | # Copyright (c) 2008 Andrew Collier <colliera@ukzn.ac.za> | ||
| 32 | # | ||
| 33 | # This program is free software; you can redistribute it and/or modify it | ||
| 34 | # under the terms of the GNU General Public License as published by the | ||
| 35 | # Free Software Foundation; either version 2 of the License, or (at your | ||
| 36 | # option) any later version. | ||
| 37 | # | ||
| 38 | # This program is distributed in the hope that it will be useful, but | ||
| 39 | # WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 40 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General | ||
| 41 | # Public License for more details. | ||
| 42 | # | ||
| 43 | # You should have received a copy of the GNU General Public License along | ||
| 44 | # with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 45 | # | ||
| 46 | # As a special exception, the respective Autoconf Macro's copyright owner | ||
| 47 | # gives unlimited permission to copy, distribute and modify the configure | ||
| 48 | # scripts that are the output of Autoconf when processing the Macro. You | ||
| 49 | # need not follow the terms of the GNU General Public License when using | ||
| 50 | # or distributing such scripts, even though portions of the text of the | ||
| 51 | # Macro appear in them. The GNU General Public License (GPL) does govern | ||
| 52 | # all other use of the material that constitutes the Autoconf Macro. | ||
| 53 | # | ||
| 54 | # This special exception to the GPL applies to versions of the Autoconf | ||
| 55 | # Macro released by the Autoconf Macro Archive. When you make and | ||
| 56 | # distribute a modified version of the Autoconf Macro, you may extend this | ||
| 57 | # special exception to the GPL to apply to your modified version as well. | ||
| 58 | |||
| 59 | AC_DEFUN([SWIG_PYTHON],[ | ||
| 60 | AC_REQUIRE([AC_PROG_SWIG]) | ||
| 61 | AC_REQUIRE([AC_PYTHON_DEVEL]) | ||
| 62 | test "x$1" != "xno" || swig_shadow=" -noproxy" | ||
| 63 | AC_SUBST([SWIG_PYTHON_OPT],[-python$swig_shadow]) | ||
| 64 | AC_SUBST([SWIG_PYTHON_CPPFLAGS],[$PYTHON_CPPFLAGS]) | ||
| 65 | ]) | ||
diff --git a/src/MobileSync.c b/src/MobileSync.c index ae22f4b..a2a361e 100644 --- a/src/MobileSync.c +++ b/src/MobileSync.c | |||
| @@ -115,11 +115,11 @@ static void iphone_msync_stop_session(iphone_msync_client_t client) | |||
| 115 | array = NULL; | 115 | array = NULL; |
| 116 | } | 116 | } |
| 117 | 117 | ||
| 118 | void iphone_msync_free_client(iphone_msync_client_t client) | 118 | iphone_error_t iphone_msync_free_client(iphone_msync_client_t client) |
| 119 | { | 119 | { |
| 120 | iphone_msync_stop_session(client); | 120 | iphone_msync_stop_session(client); |
| 121 | 121 | ||
| 122 | iphone_mux_free_client(client->connection); | 122 | return iphone_mux_free_client(client->connection); |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | /** Polls the iPhone for MobileSync data. | 125 | /** Polls the iPhone for MobileSync data. |
diff --git a/src/MobileSync.h b/src/MobileSync.h index b59547c..7655b59 100644 --- a/src/MobileSync.h +++ b/src/MobileSync.h | |||
| @@ -27,19 +27,12 @@ | |||
| 27 | 27 | ||
| 28 | #include <plist/plist.h> | 28 | #include <plist/plist.h> |
| 29 | 29 | ||
| 30 | struct iphone_msync_client_int; | 30 | |
| 31 | typedef struct iphone_msync_client_int *iphone_msync_client_t; | ||
| 32 | 31 | ||
| 33 | struct iphone_msync_client_int { | 32 | struct iphone_msync_client_int { |
| 34 | iphone_umux_client_t connection; | 33 | iphone_umux_client_t connection; |
| 35 | }; | 34 | }; |
| 36 | 35 | ||
| 37 | iphone_error_t iphone_msync_new_client(iphone_device_t device, int src_port, int dst_port, | ||
| 38 | iphone_msync_client_t * client); | ||
| 39 | void iphone_msync_free_client(iphone_msync_client_t client); | ||
| 40 | |||
| 41 | iphone_error_t iphone_msync_recv(iphone_msync_client_t client, plist_t * plist); | ||
| 42 | iphone_error_t iphone_msync_send(iphone_msync_client_t client, plist_t plist); | ||
| 43 | 36 | ||
| 44 | iphone_error_t iphone_msync_get_all_contacts(iphone_msync_client_t client); | 37 | iphone_error_t iphone_msync_get_all_contacts(iphone_msync_client_t client); |
| 45 | 38 | ||
diff --git a/swig/Makefile.am b/swig/Makefile.am new file mode 100644 index 0000000..e47356b --- /dev/null +++ b/swig/Makefile.am | |||
| @@ -0,0 +1,18 @@ | |||
| 1 | INCLUDES = -I$(top_srcdir)/include $(libplist_CFLAGS) | ||
| 2 | |||
| 3 | BUILT_SOURCES = $(srcdir)/iphone_wrap.c | ||
| 4 | SWIG_SOURCES = iphone.i | ||
| 5 | |||
| 6 | swigincludedir =$(includedir)/libiphone/swig | ||
| 7 | swiginclude_HEADERS = $(SWIG_SOURCES) | ||
| 8 | |||
| 9 | pkgpython_PYTHON = iPhone.py __init__.py | ||
| 10 | pkgpyexec_LTLIBRARIES = _iPhone.la | ||
| 11 | _iPhone_la_SOURCES = $(srcdir)/iphone_wrap.c $(SWIG_SOURCES) | ||
| 12 | _iPhone_la_CFLAGS = $(PYTHON_CPPFLAGS) -I$(top_srcdir)/src | ||
| 13 | _iPhone_la_LDFLAGS = -module $(PYTHON_LDFLAGS) | ||
| 14 | _iPhone_la_LIBADD = ../src/libiphone.la | ||
| 15 | |||
| 16 | $(srcdir)/iphone_wrap.c : $(SWIG_SOURCES) | ||
| 17 | $(SWIG) $(SWIG_PYTHON_OPT) $(INCLUDES) -I$(top_srcdir)/src -o $@ $< | ||
| 18 | |||
diff --git a/swig/__init__.py b/swig/__init__.py new file mode 100644 index 0000000..8d1c8b6 --- /dev/null +++ b/swig/__init__.py | |||
| @@ -0,0 +1 @@ | |||
diff --git a/swig/iphone.i b/swig/iphone.i new file mode 100644 index 0000000..fb16208 --- /dev/null +++ b/swig/iphone.i | |||
| @@ -0,0 +1,123 @@ | |||
| 1 | /* swig.i */ | ||
| 2 | %module(package="libiphone") iPhone | ||
| 3 | %{ | ||
| 4 | /* Includes the header in the wrapper code */ | ||
| 5 | #include <libiphone/libiphone.h> | ||
| 6 | #include <plist/plist.h> | ||
| 7 | |||
| 8 | typedef struct { | ||
| 9 | iphone_device_t dev; | ||
| 10 | } iPhone; | ||
| 11 | |||
| 12 | typedef struct { | ||
| 13 | iphone_device_t dev; | ||
| 14 | iphone_lckd_client_t client; | ||
| 15 | } Lockdownd; | ||
| 16 | |||
| 17 | typedef struct { | ||
| 18 | iphone_msync_client_t client; | ||
| 19 | } MobileSync; | ||
| 20 | //typedef struct { | ||
| 21 | // plist_t node; | ||
| 22 | //} PListNode; | ||
| 23 | %} | ||
| 24 | /* Parse the header file to generate wrappers */ | ||
| 25 | %include "plist/swig/plist.i" | ||
| 26 | //(module="libplist.PList")override module name until package path gets fixed in swig (1.3.37) | ||
| 27 | |||
| 28 | typedef struct { | ||
| 29 | iphone_device_t dev; | ||
| 30 | } iPhone; | ||
| 31 | |||
| 32 | typedef struct { | ||
| 33 | iphone_device_t dev; | ||
| 34 | iphone_lckd_client_t client; | ||
| 35 | } Lockdownd; | ||
| 36 | |||
| 37 | typedef struct { | ||
| 38 | iphone_msync_client_t client; | ||
| 39 | } MobileSync; | ||
| 40 | |||
| 41 | %extend iPhone { // Attach these functions to struct iPhone | ||
| 42 | iPhone() { | ||
| 43 | iPhone* phone = (iPhone*) malloc(sizeof(iPhone)); | ||
| 44 | if (IPHONE_E_SUCCESS == iphone_get_device ( &phone->dev )) | ||
| 45 | return phone; | ||
| 46 | free(phone); | ||
| 47 | return NULL; | ||
| 48 | } | ||
| 49 | |||
| 50 | ~iPhone() { | ||
| 51 | iphone_free_device ( $self->dev ); | ||
| 52 | free($self); | ||
| 53 | } | ||
| 54 | |||
| 55 | Lockdownd* GetLockdownClient() { | ||
| 56 | Lockdownd* client = (Lockdownd*) malloc(sizeof(Lockdownd)); | ||
| 57 | client->client = NULL; | ||
| 58 | if (IPHONE_E_SUCCESS == iphone_lckd_new_client ( $self->dev , &(client->client)) ) { | ||
| 59 | client->dev = $self->dev; | ||
| 60 | return client; | ||
| 61 | } | ||
| 62 | free(client); | ||
| 63 | return NULL; | ||
| 64 | } | ||
| 65 | }; | ||
| 66 | |||
| 67 | %extend Lockdownd { // Attach these functions to struct Lockdownd | ||
| 68 | Lockdownd(iPhone* phone) { | ||
| 69 | if (!phone) return NULL; | ||
| 70 | Lockdownd* client = (Lockdownd*) malloc(sizeof(Lockdownd)); | ||
| 71 | client->client = NULL; | ||
| 72 | if (IPHONE_E_SUCCESS == iphone_lckd_new_client ( phone->dev , &client->client)) { | ||
| 73 | client->dev = phone->dev; | ||
| 74 | return client; | ||
| 75 | } | ||
| 76 | else { | ||
| 77 | free(client); | ||
| 78 | return NULL; | ||
| 79 | } | ||
| 80 | } | ||
| 81 | |||
| 82 | ~Lockdownd() { | ||
| 83 | iphone_lckd_free_client ( $self->client ); | ||
| 84 | free($self); | ||
| 85 | } | ||
| 86 | |||
| 87 | MobileSync* GetMobileSyncClient() { | ||
| 88 | int port = 0; | ||
| 89 | if (IPHONE_E_SUCCESS == iphone_lckd_start_service ( $self->client, "com.apple.mobilesync", &port )) { | ||
| 90 | MobileSync* client = (MobileSync*) malloc(sizeof(MobileSync)); | ||
| 91 | client->client = NULL; | ||
| 92 | if (IPHONE_E_SUCCESS == iphone_msync_new_client ( $self->dev, 3432, port, &(client->client))) | ||
| 93 | return client; | ||
| 94 | } | ||
| 95 | return NULL; | ||
| 96 | } | ||
| 97 | }; | ||
| 98 | |||
| 99 | %extend MobileSync { // Attach these functions to struct MobileSync | ||
| 100 | MobileSync(iPhone* phone, int src_port, int dst_port) { | ||
| 101 | if (!phone) return NULL; | ||
| 102 | MobileSync* client = (MobileSync*) malloc(sizeof(MobileSync)); | ||
| 103 | client->client = NULL; | ||
| 104 | iphone_msync_new_client ( phone->dev, src_port, dst_port, &client->client); | ||
| 105 | return client; | ||
| 106 | } | ||
| 107 | |||
| 108 | ~MobileSync() { | ||
| 109 | iphone_msync_free_client ( $self->client ); | ||
| 110 | free($self); | ||
| 111 | } | ||
| 112 | |||
| 113 | void Send(PListNode* node) { | ||
| 114 | iphone_msync_send($self->client, node->node); | ||
| 115 | } | ||
| 116 | |||
| 117 | PListNode* Receive() { | ||
| 118 | PListNode* node = NULL; | ||
| 119 | iphone_msync_recv($self->client, &(node->node)); | ||
| 120 | return node; | ||
| 121 | } | ||
| 122 | }; | ||
| 123 | |||
