[gvfs/gnome-3-12] afc: Check for iOS >= 3.1.2 to enable house arrest



commit 1a43c46737a11ed985549528ef7b342fdc6b35e5
Author: Bastien Nocera <hadess hadess net>
Date:   Wed Sep 18 14:48:22 2013 +0200

    afc: Check for iOS >= 3.1.2 to enable house arrest
    
    https://bugzilla.gnome.org/show_bug.cgi?id=676187

 monitor/afc/afcvolume.c |   54 +++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)
---
diff --git a/monitor/afc/afcvolume.c b/monitor/afc/afcvolume.c
index c8a4f85..ae2c4d2 100644
--- a/monitor/afc/afcvolume.c
+++ b/monitor/afc/afcvolume.c
@@ -6,6 +6,8 @@
 
 #include <config.h>
 #include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
 #include <glib.h>
 #include <gio/gio.h>
 #include <glib/gi18n.h>
@@ -71,6 +73,52 @@ g_vfs_afc_volume_class_init (GVfsAfcVolumeClass *klass)
   gobject_class->finalize = g_vfs_afc_volume_finalize;
 }
 
+static gboolean
+_g_vfs_afc_volume_check_house_arrest_version (lockdownd_client_t lockdown_cli)
+{
+  plist_t value;
+  lockdownd_error_t lerr;
+  gboolean retval;
+
+  value = NULL;
+  retval = FALSE;
+
+  lerr = lockdownd_get_value (lockdown_cli, NULL, "ProductVersion", &value);
+  if (G_LIKELY(lerr == LOCKDOWN_E_SUCCESS))
+    {
+      if (plist_get_node_type(value) == PLIST_STRING)
+        {
+          char *version_string = NULL;
+
+          plist_get_string_val(value, &version_string);
+          if (version_string)
+            {
+              /* parse version */
+              int maj = 0;
+              int min = 0;
+              int rev = 0;
+
+              sscanf(version_string, "%d.%d.%d", &maj, &min, &rev);
+              free(version_string);
+
+              if (maj > 3)
+                {
+                    retval = TRUE;
+                }
+              else if (maj == 3)
+                {
+                  if (min > 1)
+                        retval = TRUE;
+                  if (min == 1 && rev >= 2)
+                        retval = TRUE;
+              }
+            }
+        }
+    }
+
+  return retval;
+}
+
 static int
 _g_vfs_afc_volume_update_metadata (GVfsAfcVolume *self)
 {
@@ -101,6 +149,12 @@ _g_vfs_afc_volume_update_metadata (GVfsAfcVolume *self)
           idevice_free (dev);
           return 0;
         }
+      if (!_g_vfs_afc_volume_check_house_arrest_version (lockdown_cli))
+        {
+          lockdownd_service_descriptor_free (lockdown_service);
+          idevice_free (dev);
+          return 0;
+        }
       lerr = lockdownd_start_service(lockdown_cli, "com.apple.mobile.house_arrest", &lockdown_service);
       lockdownd_service_descriptor_free (lockdown_service);
       if (lerr != LOCKDOWN_E_SUCCESS)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]