]> err.no Git - mapper/blobdiff - src/utils.c
Fixes to gstreamer element and caps handlings.
[mapper] / src / utils.c
index 9e96b053e830cd5061f180f067a2689973880976..65bb75657b2a59e799a88dc18b622ebe10ec0b20 100644 (file)
@@ -1,5 +1,3 @@
-#define _GNU_SOURCE
-
 #include <config.h>
 #include <unistd.h>
 #include <stdlib.h>
 #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"
 
-void sound_noise(void)
+void 
+sound_noise(void)
 {
 #ifdef WITH_HILDON
-       hildon_play_system_sound("/usr/share/sounds/ui-information_note.wav");
-#else
-
-#endif
-}
-
-void sound_speak(gchar * phrase)
-{
-#define _voice_synth_path "/usr/bin/flite"
-
-#if WITH_HILDON
-       if (!fork()) {
-               /* We are the fork child.  Synthesize the voice. */
-               sound_noise();
-               sleep(1);
-               printf("%s %s\n", _voice_synth_path, _last_spoken_phrase);
-               execl(_voice_synth_path, _voice_synth_path,
-                     "-t", _last_spoken_phrase, (char *)NULL);
-               exit(0);
-       }
+hildon_play_system_sound("/usr/share/sounds/ui-information_note.wav");
 #else
-
+gdk_beep();
 #endif
 }
 
-#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;
-       }
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-}
-
-/**
- * Calculate the distance between two lat/lon pairs.  The distance is returned
- * in kilometers and should be converted using UNITS_CONVERT[_units].
- */
-gfloat calculate_distance(gfloat lat1, gfloat lon1, gfloat lat2, gfloat lon2)
-{
-       gdouble dlat, dlon, slat, slon, a;
-
-       /* Convert to radians. */
-       lat1 *= (PI / 180.f);
-       lon1 *= (PI / 180.f);
-       lat2 *= (PI / 180.f);
-       lon2 *= (PI / 180.f);
-
-       dlat = lat2 - lat1;
-       dlon = lon2 - lon1;
-
-       slat = sinf(dlat / 2.f);
-       slon = sinf(dlon / 2.f);
-       a = (slat * slat) + (cosf(lat1) * cosf(lat2) * slon * slon);
-
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-       return ((2.f * atan2f(sqrtf(a), sqrtf(1.f - a))) * EARTH_RADIUS);
-}
-
-/**
- * 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);
-}
-
-#ifdef BT_HACK
-void reset_bluetooth()
-{
-       printf("%s()\n", __PRETTY_FUNCTION__);
-       if (system
-           ("/usr/bin/sudo -l | grep -q '/usr/sbin/hciconfig  *hci0  *reset'"
-            " && sudo /usr/sbin/hciconfig hci0 reset"))
-               popup_error(_window,
-                           _
-                           ("An error occurred while trying to reset the bluetooth "
-                            "radio.\n\n"
-                            "Did you make sure to modify\nthe /etc/sudoers file?"));
-       else if (_conn_state > RCVR_OFF) {
-               set_conn_state(RCVR_DOWN);
-               rcvr_connect_later();
-       }
-       vprintf("%s(): return\n", __PRETTY_FUNCTION__);
-}
-#else
-void reset_bluetooth()
-{
-}
-#endif