From 0ccc3a5f0a162200323f4ddb5795e6f9e03a3fa7 Mon Sep 17 00:00:00 2001 From: David Sansome Date: Mon, 9 Aug 2010 20:22:55 +0000 Subject: [PATCH] Remove dependency on libplist++ --- CMakeLists.txt | 1 - src/CMakeLists.txt | 1 - src/devices/imobiledeviceconnection.cpp | 26 ++++++++++++++++--------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d29cce720..65c3233f6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,7 +57,6 @@ else(WIN32) pkg_check_modules(GIO gio-2.0) pkg_check_modules(IMOBILEDEVICE libimobiledevice-1.0) pkg_check_modules(PLIST libplist) - pkg_check_modules(PLISTPP libplist++) pkg_check_modules(USBMUXD libusbmuxd) endif(WIN32) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3ba9735fd..85cb2a119 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -605,7 +605,6 @@ if(HAVE_IMOBILEDEVICE) target_link_libraries(clementine_lib ${IMOBILEDEVICE_LIBRARIES} ${PLIST_LIBRARIES} - ${PLISTPP_LIBRARIES} ${USBMUXD_LIBRARIES} gstafcsrc ) diff --git a/src/devices/imobiledeviceconnection.cpp b/src/devices/imobiledeviceconnection.cpp index 2f7908a85..8511eed89 100644 --- a/src/devices/imobiledeviceconnection.cpp +++ b/src/devices/imobiledeviceconnection.cpp @@ -17,7 +17,6 @@ #include "imobiledeviceconnection.h" #include -#include #include using boost::scoped_ptr; @@ -66,25 +65,34 @@ iMobileDeviceConnection::~iMobileDeviceConnection() { } } +template +T GetPListValue(plist_t node, F f) { + T ret; + f(node, &ret); + return ret; +} + QVariant iMobileDeviceConnection::GetProperty(const QString& property, const QString& domain) { plist_t node = NULL; const char* d = domain.isEmpty() ? NULL : domain.toUtf8().constData(); lockdownd_get_value(lockdown_, d, property.toUtf8().constData(), &node); - scoped_ptr n(PList::Node::FromPlist(node)); - if (!n) { + if (!node) return QVariant(); - } - switch (n->GetType()) { + switch (plist_get_node_type(node)) { case PLIST_BOOLEAN: - return static_cast(n.get())->GetValue(); + return bool(GetPListValue(node, plist_get_bool_val)); case PLIST_UINT: - return QVariant::fromValue(static_cast(n.get())->GetValue()); + return QVariant::fromValue(GetPListValue(node, plist_get_uint_val)); - case PLIST_STRING: - return QString::fromUtf8(static_cast(n.get())->GetValue().c_str()); + case PLIST_STRING: { + char* data = GetPListValue(node, plist_get_string_val); + QString ret = QString::fromUtf8(data); + free(data); + return ret; + } default: qWarning() << "Unhandled PList type";