]> git.street.me.uk Git - andy/viking.git/blobdiff - src/jpg.c
Really empty GPS realtime layers.
[andy/viking.git] / src / jpg.c
index 788280ee4670a09b17215809b418a877fe8b7924..1b83b0cac1e3e22b8143d6de80717cdf26ec44c8 100644 (file)
--- a/src/jpg.c
+++ b/src/jpg.c
 #include "config.h"
 #endif
 #include "jpg.h"
+#include "file_magic.h"
+#ifdef VIK_CONFIG_GEOTAG
 #include "geotag_exif.h"
-
-#ifdef HAVE_MAGIC_H
-#include <magic.h>
 #endif
 
 /**
  * a_jpg_magic_check:
  * @filename: The file
  *
- * Returns: Whether the file is a JPG.
- *  Uses Magic library if available to determine the jpgness.
- *  Otherwise uses a rudimentary extension name check.
+ * Returns: Whether the file is a JPG
  */
 gboolean a_jpg_magic_check ( const gchar *filename )
 {
-       gboolean is_jpg = FALSE;
-#ifdef HAVE_MAGIC_H
-       magic_t myt = magic_open ( MAGIC_CONTINUE|MAGIC_ERROR|MAGIC_MIME );
-       if ( myt ) {
-#ifdef WINDOWS
-               // We have to 'package' the magic database ourselves :(
-               //  --> %PROGRAM FILES%\Viking\magic.mgc
-               magic_load ( myt, "magic.mgc" );
-#else
-               // Use system default
-               magic_load ( myt, NULL );
-#endif
-               const char* magic = magic_file (myt, filename);
-               if ( g_strcmp0 (magic, "image/jpeg; charset=binary") == 0 )
-                       is_jpg = TRUE;
-
-               magic_close ( myt );
-       }
-       else
-#endif
-               is_jpg = a_file_check_ext ( filename, ".jpg" );
-
-       return is_jpg;
+       return file_magic_check ( filename, "image/jpeg", ".jpg" );
 }
 
 /**
@@ -94,8 +69,11 @@ gboolean a_jpg_load_file ( VikAggregateLayer *top, const gchar *filename, VikVie
                create_layer = TRUE;
        }
 
-       gchar *name;
-       VikWaypoint *wp = a_geotag_create_waypoint_from_file ( filename, vik_viewport_get_coord_mode (vvp), &name );
+       gchar *name = NULL;
+       VikWaypoint *wp = NULL;
+#ifdef VIK_CONFIG_GEOTAG
+       wp = a_geotag_create_waypoint_from_file ( filename, vik_viewport_get_coord_mode (vvp), &name );
+#endif
        if ( wp ) {
                // Create name if geotag method didn't return one
                if ( !name )