commit 6b765b21bfc43edc516f1c1a1517ec663152c9a7
Author: Christophe Fergeau <[email protected]>
Date:   Tue Nov 17 00:53:29 2009 +0100

    split iphone callout out of the main hal callout
    
    Doing the same things as the callout for regular iPods is scary since
    the only way to browse an iPhone filesystem is through the (userland)
    afc protocol, which might not be already set up when we are in a hal
    callout. The most important things provided by the hal callout are
    1. the SysInfoExtended file
    2. the iPod name
    3. the iPod model (to get a nice icon)
    
    Since 2. and 3. are already done in another way by the GVFS AFC backend,
    let's just do 1. in the iPhone hal callout, makes things less scary and
    thus more maintainable.

 tools/20-libgpod-sysinfo-extended.fdi  |    2 +-
 tools/Makefile.am                      |   17 ++++++-----------
 tools/hal-callout.c                    |   28 ++--------------------------
 tools/{test-afc.c => iphone-callout.c} |   13 ++++++++++---
 4 files changed, 19 insertions(+), 41 deletions(-)
---
diff --git a/tools/20-libgpod-sysinfo-extended.fdi 
b/tools/20-libgpod-sysinfo-extended.fdi
index f5fa87c..f5eef07 100644
--- a/tools/20-libgpod-sysinfo-extended.fdi
+++ b/tools/20-libgpod-sysinfo-extended.fdi
@@ -11,7 +11,7 @@
     </match>
     <!-- iPhone/iPod Touch -->
     <match key="info.capabilities" contains="afc">
-      <append key="info.callouts.add" type="strlist">libgpod-callout</append>
+      <append key="info.callouts.add" type="strlist">iphone-callout</append>
     </match>
   </device>
 </deviceinfo>
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 5d83f04..2f2bafd 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -11,8 +11,13 @@ if HAVE_LIBIPHONE
 ipod_read_sysinfo_extended_SOURCES+=ipod-lockdown.c
 ipod_read_sysinfo_extended_CFLAGS+=$(LIBIPHONE_CFLAGS)
 ipod_read_sysinfo_extended_LDADD+=$(LIBIPHONE_LIBS)
+endif
 
-bin_PROGRAMS+=test-afc
+if HAVE_LIBIPHONE
+bin_PROGRAMS+=iphone-callout
+iphone_callout_SOURCES = iphone-callout.c ipod-lockdown.c
+iphone_callout_CFLAGS = $(LIBIPHONE_CFLAGS)
+iphone_callout_LDADD = $(LIBIPHONE_LIBS)
 endif
 
 if HAVE_HAL
@@ -39,16 +44,6 @@ fdi_DATA = 20-libgpod-sysinfo-extended.fdi
 
 EXTRA_DIST = $(fdi_DATA)
 
-if HAVE_LIBIPHONE
-libgpod_callout_SOURCES += ipod-lockdown.c
-libgpod_callout_CFLAGS += $(LIBIPHONE_CFLAGS)
-libgpod_callout_LDADD += $(LIBIPHONE_LIBS)
-
-test_afc_SOURCES = ipod-lockdown.c test-afc.c
-test_afc_CFLAGS = $(LIBIPHONE_CFLAGS)
-test_afc_LDADD = $(LIBIPHONE_LIBS)
-endif
-
 if HAVE_SGUTILS
 libgpod_callout_SOURCES += ipod-scsi.c
 libgpod_callout_CFLAGS += $(SGUTILS_CFLAGS)
diff --git a/tools/hal-callout.c b/tools/hal-callout.c
index 1128fa9..02ef439 100644
--- a/tools/hal-callout.c
+++ b/tools/hal-callout.c
@@ -44,9 +44,6 @@
 #ifdef HAVE_SGUTILS
 extern char *read_sysinfo_extended (const char *device);
 #endif
-#ifdef HAVE_LIBIPHONE
-extern char *read_sysinfo_extended_by_uuid (const char *uuid);
-#endif
 
 struct _ProductionInfo {
        gchar *factory_id;
@@ -771,34 +768,13 @@ int main (int argc, char **argv)
        SysInfoIpodProperties *props;
        LibHalContext *ctx; 
        const char *udi;
-#ifdef HAVE_LIBIPHONE
-       char *caps = NULL;
-#endif
 
        g_type_init ();
 
-#ifdef HAVE_LIBIPHONE
-        caps = (char *)g_getenv ("HAL_PROP_INFO_CAPABILITIES");
-        if (caps == NULL) {
-                return -1;
-        }
-        else
-        {
-                /* iPhone/iPod Touch devices with custom usb protocol */
-                if (strstr (caps, "afc") != NULL) {
-                        xml = read_sysinfo_extended_by_uuid(g_getenv 
("HAL_PROP_USB_SERIAL"));
-                }
-                else /* regular usb mass storage ipod */
-                {
-#endif
 #ifdef HAVE_SGUTILS
-                        xml = read_sysinfo_extended (g_getenv 
("HAL_PROP_BLOCK_DEVICE"));
+        xml = read_sysinfo_extended (g_getenv ("HAL_PROP_BLOCK_DEVICE"));
 #else
-                        return -1;
-#endif
-#ifdef HAVE_LIBIPHONE
-                }
-        }
+        return -1;
 #endif
         if (xml == NULL) {
                 return -1;
diff --git a/tools/test-afc.c b/tools/iphone-callout.c
similarity index 81%
rename from tools/test-afc.c
rename to tools/iphone-callout.c
index 09360cc..b9e5492 100644
--- a/tools/test-afc.c
+++ b/tools/iphone-callout.c
@@ -31,9 +31,16 @@ static gboolean write_sysinfo_extended (const char *uuid)
 int main (int argc, char **argv)
 {
     int daemonize_failed;
+    const char *uuid;
 
-    if (argc != 2) {
-        g_print ("Usage: %s <uuid>\n", argv[0]);
+    if (argc != 1) {
+        g_print ("%s should only be ran by HAL\n", argv[0]);
+        return 1;
+    }
+
+    uuid = g_getenv ("HAL_PROP_USB_SERIAL");
+    if (uuid == NULL) {
+        g_print ("%s should only be ran by HAL\n", argv[0]);
         return 1;
     }
 
@@ -48,6 +55,6 @@ int main (int argc, char **argv)
         return 1;
     }
 
-    return write_sysinfo_extended (argv[1]);
+    return write_sysinfo_extended (uuid);
 }
 

------------------------------------------------------------------------------
Return on Information:
Google Enterprise Search pays you back
Get the facts.
http://p.sf.net/sfu/google-dev2dev
_______________________________________________
gtkpod-cvs2 mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gtkpod-cvs2

Reply via email to