A similar patch has just gone into beagle, which provides better compatibility with both libexif 0.5 and 0.6. Index: configure.in =================================================================== RCS file: /cvs/gnome/f-spot/configure.in,v retrieving revision 1.48 diff -u -B -r1.48 configure.in --- configure.in 16 Feb 2005 23:46:00 -0000 1.48 +++ configure.in 19 Feb 2005 15:58:22 -0000 @@ -48,6 +48,7 @@ LIBGNOMEUI_REQUIRED=2.2 LIBEXIF_REQUIRED_MIN=0.5.7 LIBEXIF_REQUIRED_MAX=0.7.0 +LIBEXIF_API_CHANGE=0.6.0 GTKSHARP_REQUIRED=1.0 dnl -- this check is @@ -58,6 +59,14 @@ AC_SUBST(F_CFLAGS) AC_SUBST(F_LIBS) +PKG_CHECK_MODULES(LIBEXIF_API_CHECK, libexif >= $LIBEXIF_API_CHANGE, have_old_libexif=no, have_old_libexif=yes) +if test "$have_old_libexif" = "yes"; then + CSFLAGS="-define:HAVE_OLD_LIBEXIF" +else + CSFLAGS="" +fi + +AC_SUBST(CSFLAGS) dnl --- GConf Index: src/Exif.cs =================================================================== RCS file: /cvs/gnome/f-spot/src/Exif.cs,v retrieving revision 1.6 diff -u -B -r1.6 Exif.cs --- src/Exif.cs 29 Jan 2005 21:41:34 -0000 1.6 +++ src/Exif.cs 19 Feb 2005 15:58:22 -0000 @@ -657,27 +657,22 @@ } - // FIXME this version is only valid in libexif 0.5 [DllImport ("libexif.dll")] +#if HAVE_OLD_LIBEXIF internal static extern IntPtr exif_entry_get_value (HandleRef handle); - - // FIXME this version is only valid in libexif 0.6 - [DllImport ("libexif.dll")] +#else internal static extern IntPtr exif_entry_get_value (HandleRef handle, byte [] value, int maxlen); +#endif public string Value { get { - // FIXME this is a hack to handle libexif 0.5 and 0.6 at the same time - // The signature of get_value changed between versions - - try { - return Marshal.PtrToStringAnsi (exif_entry_get_value (this.Handle)); - } catch (System.NullReferenceException e) { - byte [] value = new byte [1024]; - exif_entry_get_value (this.Handle, value, value.Length); - return System.Text.Encoding.UTF8.GetString (value); - } +#if HAVE_OLD_LIBEXIF + return Marshal.PtrToStringAnsi (exif_entry_get_value (this.Handle)); +#else + byte [] value = new byte [1024]; + return Marshal.PtrToStringAnsi (exif_entry_get_value (this.Handle, value, value.Length)); +#endif } } Index: src/ExifData.cs =================================================================== RCS file: /cvs/gnome/f-spot/src/ExifData.cs,v retrieving revision 1.13 diff -u -B -r1.13 ExifData.cs --- src/ExifData.cs 24 Jan 2005 08:53:14 -0000 1.13 +++ src/ExifData.cs 19 Feb 2005 15:58:22 -0000 @@ -238,13 +238,12 @@ readonly public uint size; readonly public _ExifContent *parent; - // FIXME this version is only valid in libexif 0.5 [DllImport ("libexif.dll")] +#if HAVE_OLD_LIBEXIF internal static extern IntPtr exif_entry_get_value (_ExifEntry *entry); - - // FIXME this version is only valid in libexif 0.6 - [DllImport ("libexif.dll")] - internal static extern IntPtr exif_entry_get_value (_ExifEntry *entry, byte [] value, int maxlen); +#else + internal static extern IntPtr exif_entry_get_value (_ExifEntry *entry, byte [] value, int maxlen); +#endif } @@ -370,16 +369,12 @@ unsafe string GetStringValue (_ExifEntry *entry) { - // FIXME this is a hack to handle libexif 0.5 and 0.6 at the same time - // The signature of get_value changed between versions - - try { - return Marshal.PtrToStringAnsi (_ExifEntry.exif_entry_get_value (entry)); - } catch (System.NullReferenceException e) { - byte [] value = new byte [1024]; - _ExifEntry.exif_entry_get_value (entry, value, value.Length); - return System.Text.Encoding.UTF8.GetString (value); - } +#if HAVE_OLD_LIBEXIF + return Marshal.PtrToStringAnsi (_ExifEntry.exif_entry_get_value (entry)); +#else + byte [] value = new byte [1024]; + return Marshal.PtrToStringAnsi (_ExifEntry.exif_entry_get_value (entry, value, value.Length)); +#endif } unsafe void AssembleContent (_ExifEntry *entry, void *callback_data)