]> err.no Git - mapper/blobdiff - src/utils.c
Fixes to gstreamer element and caps handlings.
[mapper] / src / utils.c
index 229e19b5dd52ce53d1c0d63bf8ab33b3d1ccea4b..65bb75657b2a59e799a88dc18b622ebe10ec0b20 100644 (file)
@@ -1,5 +1,3 @@
-#define _GNU_SOURCE
-
 #include <config.h>
 #include <unistd.h>
 #include <stdlib.h>
@@ -8,23 +6,14 @@
 #include <stddef.h>
 #include <locale.h>
 #include <math.h>
-#include <errno.h>
-#include <sys/wait.h>
 #include <glib/gstdio.h>
-#include <gtk/gtk.h>
-#include <fcntl.h>
-#include <gdk/gdkkeysyms.h>
-#include <libgnomevfs/gnome-vfs.h>
-#include <curl/multi.h>
-#include <gconf/gconf-client.h>
-#include <libxml/parser.h>
 
+#include "path.h"
 #include "utils.h"
-#include "gps.h"
 #include "mapper-types.h"
-#include "bt.h"
 
-void sound_noise(void)
+void 
+sound_noise(void)
 {
 #ifdef WITH_HILDON
 hildon_play_system_sound("/usr/share/sounds/ui-information_note.wav");
@@ -33,132 +22,3 @@ gdk_beep();
 #endif
 }
 
-void sound_speak(gchar * phrase)
-{
-#ifdef WITH_ESPEAK
-#define _voice_synth_path "/usr/bin/espeak"
-#else
-#define _voice_synth_path "/usr/bin/flite"
-#endif
-
-if (!fork()) {
-       /* We are the fork child.  Synthesize the voice. */
-       sound_noise();
-       sleep(1);
-       printf("%s %s\n", _voice_synth_path, phrase);
-       execl(_voice_synth_path, _voice_synth_path, "-t", phrase, (char *)NULL);
-       exit(0);
-}
-
-}
-
-#if 0
-void latlon2unit(gfloat lat, gfloat lon, gint *unitx_, gint *unity_)
-{
-       gfloat tmp;
-
-       gint unitx = &unitx_;
-       gint unity = &unity_;
-
-       unitx = (lon + 180.f) * (WORLD_SIZE_UNITS / 360.f) + 0.5f;
-       tmp = sinf(lat * (PI / 180.f));
-       unity = 0.5f + (WORLD_SIZE_UNITS / MERCATOR_SPAN)
-           * (logf((1.f + tmp) / (1.f - tmp)) * 0.5f - MERCATOR_TOP);
-}
-
-void unit2latlon(gint unitx, gint unity, gfloat *lat, gfloat *lon)
-{
-       (lon) = ((unitx) * (360.f / WORLD_SIZE_UNITS)) - 180.f;
-       (lat) = (360.f * (atanf(expf(((unity)
-                                     * (MERCATOR_SPAN / WORLD_SIZE_UNITS))
-                                    + MERCATOR_TOP)))) * (1.f / PI) - 90.f;
-}
-#endif
-
-void
-deg_format(DegFormat degformat, gfloat coor, gchar * scoor, gchar neg_char,
-          gchar pos_char)
-{
-       gfloat min;
-       gfloat acoor = fabs(coor);
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       switch (degformat) {
-       case DDPDDDDD:
-               sprintf(scoor, "%.5f°", coor);
-               break;
-       case DDPDDDDD_NSEW:
-               sprintf(scoor, "%.5f° %c", acoor,
-                       coor < 0.f ? neg_char : pos_char);
-               break;
-
-       case DD_MMPMMM:
-               sprintf(scoor, "%d°%06.3f'",
-                       (int)coor, (acoor - (int)acoor) * 60.0);
-               break;
-       case DD_MMPMMM_NSEW:
-               sprintf(scoor, "%d°%06.3f' %c",
-                       (int)acoor, (acoor - (int)acoor) * 60.0,
-                       coor < 0.f ? neg_char : pos_char);
-               break;
-
-       case DD_MM_SSPS:
-               min = (acoor - (int)acoor) * 60.0;
-               sprintf(scoor, "%d°%02d'%04.1f\"", (int)coor, (int)min,
-                       ((min - (int)min) * 60.0));
-               break;
-       case DD_MM_SSPS_NSEW:
-               min = (acoor - (int)acoor) * 60.0;
-               sprintf(scoor, "%d°%02d'%04.1f\" %c", (int)acoor, (int)min,
-                       ((min - (int)min) * 60.0),
-                       coor < 0.f ? neg_char : pos_char);
-               break;
-       default:;
-       }
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-}
-
-/**
- * Convert the float lat/lon/speed/heading data into integer units.
- */
-void integerize_data()
-{
-       gfloat tmp;
-       printf("%s()\n", __PRETTY_FUNCTION__);
-
-       latlon2unit(_gps.lat, _gps.lon, _pos.unitx, _pos.unity);
-
-       tmp = (_gps.heading * (1.f / 180.f)) * PI;
-       _vel_offsetx = (gint) (floorf(_gps.speed * sinf(tmp) + 0.5f));
-       _vel_offsety = -(gint) (floorf(_gps.speed * cosf(tmp) + 0.5f));
-
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-}
-
-gint
-download_comparefunc(const ProgressUpdateInfo * a,
-                    const ProgressUpdateInfo * b, gpointer user_data)
-{
-       gint diff = (a->priority - b->priority);
-       if (diff)
-               return diff;
-       diff = (a->tilex - b->tilex);
-       if (diff)
-               return diff;
-       diff = (a->tiley - b->tiley);
-       if (diff)
-               return diff;
-       diff = (a->zoom - b->zoom);
-       if (diff)
-               return diff;
-       diff = (a->repo - b->repo);
-       if (diff)
-               return diff;
-       /* Otherwise, deletes are "greatest" (least priority). */
-       if (!a->retries)
-               return (b->retries ? -1 : 0);
-       else if (!b->retries)
-               return (a->retries ? 1 : 0);
-       /* Do updates after non-updates (because they'll both be done anyway). */
-       return (a->retries - b->retries);
-}