Re: [Utopia] Fix gnome-volume-manager PTP camera detection



On Fri, 2005-07-29 at 17:08 +0200, Martin Pitt wrote:
> Hi!
> 
> gnome-volume-manager 1.3.2 broke PTP camera detection due to a logic
> flaw in gvm_udi_is_camera(). Even if a device had the "camera"
> capability, the subsequent check for libgphoto2 support made the
> function return FALSE.

I believe the logic is correct, but it sounds like it's failing for you
because your HAL isn't patched to ad the libgphoto2_support property.
So... I think the correct solution to this would be to make sure the
property exists before using the value returned by get_property_bool() -
this way, for people without the patch, it continues to work. I might
split the function in 2 such that the logic is clearer:

gvm_udi_is_camera()

gvm_udi_is_ptp_camera()

> 
> I'm not sure whether this "and" semantics was really intended, but at
> least it breaks when using 1.3.2 with hal 0.5.3.
> 
> In Ubuntu I applied the following patch which makes it work again:
> 
> --- gnome-volume-manager-1.3.2-old/src/manager.c        2005-07-29 17:02:13.000000000 +0200
> +++ gnome-volume-manager-1.3.2/src/manager.c    2005-07-29 17:02:13.000000000 +0200
> @@ -614,15 +614,13 @@
>  static gboolean
>  gvm_udi_is_camera (const char *udi, gboolean check_libgphoto2)
>  {
> -       if (!libhal_device_query_capability (hal_ctx, udi, "camera", NULL))
> -               return FALSE;
> -
> -       if (check_libgphoto2 && !libhal_device_get_property_bool (hal_ctx, udi, "camera.libgphoto2_support", NULL))
> -               return FALSE;
> -
> -       dbg ("Camera detected: %s\n", udi);
> +       if (libhal_device_query_capability (hal_ctx, udi, "camera", NULL) ||
> +            (check_libgphoto2 && libhal_device_get_property_bool (hal_ctx, udi, "camera.libgphoto2_support", NULL))) {
> +                dbg ("Camera detected: %s\n", udi);
> +                return TRUE;
> +        }

the new logic is such that it will still return TRUE even if
check_libgphoto2 is TRUE and libgphoto2_support is FALSE (assuming the
camera property is on the device). This should not happen.

Might as well not even bother checking libgphoto2 :)

> 
> -       return TRUE;
> +       return FALSE;
>  }
> 
>  /*
> 
> 
> Grepping the hal 0.5.3 sources for "libgphoto2_support" yields
> nothing, so in the long run the second check should just be removed.
> For now I left it in to keep compatibility with hal versions that
> still used that property.
> 
> Thanks,
> 
> Martin
> _______________________________________________
> utopia-list mailing list
> utopia-list gnome org
> http://mail.gnome.org/mailman/listinfo/utopia-list
-- 
Jeffrey Stedfast
Evolution Hacker - Novell, Inc.
fejj ximian com  - www.novell.com




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