Add GPXView Geocaching application
authorMichael Büsch <mb@bu3sch.de>
Thu, 19 Aug 2010 11:28:43 +0000 (11:28 +0000)
committerMichael Büsch <mb@bu3sch.de>
Thu, 19 Aug 2010 11:28:43 +0000 (11:28 +0000)
SVN-Revision: 22714

Xorg/app/gpxview/Makefile [new file with mode: 0644]
Xorg/app/gpxview/patches/100-cross-compile.patch [new file with mode: 0644]
Xorg/app/gpxview/patches/200-fix-parallel-build.patch [new file with mode: 0644]
Xorg/app/gpxview/patches/300-remove-gnome-vfs-dependency.patch [new file with mode: 0644]

diff --git a/Xorg/app/gpxview/Makefile b/Xorg/app/gpxview/Makefile
new file mode 100644 (file)
index 0000000..c8698f4
--- /dev/null
@@ -0,0 +1,62 @@
+#
+# Copyright (C) 2010 OpenWrt.org
+#
+# This is free software, licensed under the GNU General Public License v2.
+# See /LICENSE for more information.
+#
+
+include $(TOPDIR)/rules.mk
+
+PKG_NAME:=gpxview
+PKG_VERSION_BASE:=0.9.1
+PKG_VERSION_SUFFIX:=-1
+PKG_VERSION:=$(PKG_VERSION_BASE)$(PKG_VERSION_SUFFIX)
+PKG_RELEASE:=1
+
+PKG_SOURCE:=gpxview_$(PKG_VERSION).tar.gz
+PKG_SOURCE_URL:=http://repository.maemo.org/extras/pool/chinook/free/source/g/gpxview/
+PKG_MD5SUM:=7c29b4cbfb1a54c1abe559c63e0a79db
+PKG_INSTALL:=1
+PKG_BUILD_PARALLEL:=1
+PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION_BASE)
+
+include $(INCLUDE_DIR)/package.mk
+
+define Package/gpxview
+  SECTION:=xorg-app
+  CATEGORY:=Xorg
+  SUBMENU:=app
+  TITLE:=GPXView Geocaching app
+  URL:=http://www.harbaum.org/till/maemo/index.shtml#gpxview
+  DEPENDS:=+gpsd +libxml2 +libcurl +libsoup +gtkhtml +gtk2 +libintl +libiconv
+endef
+
+define Package/gpxview/description
+  GPXView is a viewer for Geocaching.com GPX files.
+endef
+
+EXTRA_CFLAGS:= \
+       -I$(STAGING_DIR)/usr/lib/libintl/include \
+       -I$(STAGING_DIR)/usr/lib/libiconv/include
+
+EXTRA_LDFLAGS:= \
+       -L$(STAGING_DIR)/usr/lib/libintl/lib \
+       -L$(STAGING_DIR)/usr/lib/libiconv/lib \
+       -Wl,-rpath-link=$(STAGING_DIR)/usr/lib \
+       -Wl,-rpath=/usr/lib/
+
+define Build/Install
+       $(MAKE_VARS) \
+       $(MAKE) -C $(PKG_BUILD_DIR)/$(MAKE_PATH) \
+               bindir="/bin" \
+               $(MAKE_INSTALL_FLAGS) \
+               install
+endef
+
+define Package/gpxview/install
+       $(INSTALL_DIR) $(1)/usr/bin $(1)/usr/share/gpxview
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/gpxview $(1)/usr/bin/
+       $(CP) $(PKG_INSTALL_DIR)/usr/share/gpxview $(1)/usr/share/
+endef
+
+$(eval $(call BuildPackage,gpxview))
diff --git a/Xorg/app/gpxview/patches/100-cross-compile.patch b/Xorg/app/gpxview/patches/100-cross-compile.patch
new file mode 100644 (file)
index 0000000..63d088d
--- /dev/null
@@ -0,0 +1,25 @@
+---
+ src/Makefile.in |    6 +++---
+ 1 file changed, 3 insertions(+), 3 deletions(-)
+
+--- gpxview-0.9.1.orig/src/Makefile.in
++++ gpxview-0.9.1/src/Makefile.in
+@@ -33,15 +33,15 @@ OBJS = main.o gpx.o goto.o gps.o misc.o
+ DEFS = -DVERSION=\"$(VERSION)\" -DPREFIX=\"$(prefix)\" -DICONPATH=\"$(datadir)/$(APP)/\" -DAPP=\"$(APP)\"
+ CFLAGS = -Wall -O2 $(DEFS) @CFLAGS@
+-LDFLAGS = @LIBS@ -lz
++LDFLAGS = @LDFLAGS@ @LIBS@ -lz
+ all: $(APP)
+ %.o: %.c Makefile
+-      gcc $(CFLAGS) -o $@ -c $<
++      $(CC) $(CFLAGS) -o $@ -c $<
+ $(APP): $(OBJS)
+-      gcc -o $@ $(OBJS) $(LDFLAGS)
++      $(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS)
+ install:
+       install -d $(DESTDIR)$(prefix)$(bindir)
diff --git a/Xorg/app/gpxview/patches/200-fix-parallel-build.patch b/Xorg/app/gpxview/patches/200-fix-parallel-build.patch
new file mode 100644 (file)
index 0000000..377329a
--- /dev/null
@@ -0,0 +1,30 @@
+---
+ Makefile.in |   12 ++++++------
+ 1 file changed, 6 insertions(+), 6 deletions(-)
+
+--- gpxview-0.9.1.orig/Makefile.in
++++ gpxview-0.9.1/Makefile.in
+@@ -20,17 +20,17 @@ APP = @PACKAGE@
+ VERSION = $${VERSION_PREFIX}@PACKAGE_VERSION@$${VERSION_SUFFIX}
+ all:
+-      cd src && make
+-      cd data && make
++      $(MAKE) -C src
++      $(MAKE) -C data
+ install:
+-      cd src && make install
+-      cd data && make install
++      $(MAKE) -C src install
++      $(MAKE) -C data install
+ clean:
+       rm -f *~ \#*\# *.bak *-stamp
+-      cd src && make clean
+-      cd data && make clean
++      $(MAKE) -C src clean
++      $(MAKE) -C data clean
+ distclean: clean
+       rm -f Makefile src/Makefile data/Makefile config.log config.status
diff --git a/Xorg/app/gpxview/patches/300-remove-gnome-vfs-dependency.patch b/Xorg/app/gpxview/patches/300-remove-gnome-vfs-dependency.patch
new file mode 100644 (file)
index 0000000..8cd40e6
--- /dev/null
@@ -0,0 +1,347 @@
+---
+ configure     |    6 ++++
+ src/gps.c     |   74 +++++++++++++++++++++++++++++++++++++++-------------------
+ src/gps.h     |    3 --
+ src/gpx.c     |   31 +++++++++++-------------
+ src/gpxview.h |    3 --
+ src/html.c    |   15 +++++++----
+ src/main.c    |    5 ---
+ src/misc.c    |    5 ---
+ 8 files changed, 83 insertions(+), 59 deletions(-)
+
+--- gpxview-0.9.1.orig/src/main.c
++++ gpxview-0.9.1/src/main.c
+@@ -2058,7 +2058,6 @@ void cleanup(appdata_t *appdata) {
+   if(appdata->tools_menu)  submenu_cleanup(appdata->tools_menu);
+ #endif
+-  gnome_vfs_shutdown();
+   icons_free();
+   gps_release(appdata);
+@@ -2398,10 +2397,6 @@ int main(int argc, char *argv[]) {
+   icons_init();
+-  if(!gnome_vfs_init()) {
+-    g_error("Gnome VFS init failed\n");
+-  }
+-
+ #ifdef USE_MAEMO
+   /* Create the hildon program and setup the title */
+   appdata.program = HILDON_PROGRAM(hildon_program_get_instance());
+--- gpxview-0.9.1.orig/src/misc.c
++++ gpxview-0.9.1/src/misc.c
+@@ -1036,12 +1036,9 @@ void dist_entry_set(GtkWidget *widget, f
+ #ifndef USE_MAEMO
+ #ifdef ENABLE_BROWSER_INTERFACE
+-#include <libgnome/gnome-url.h>
+ int browser_url(appdata_t *appdata, char *url) {
+-  /* taken from gnome-open, part of libgnome */
+-  GError *err = NULL;
+-  gnome_url_show(url, &err);
++  printf("GPXView WARNING: browser_url() not implemented\n");
+   return 0;
+ }
+ #endif
+--- gpxview-0.9.1.orig/src/gpxview.h
++++ gpxview-0.9.1/src/gpxview.h
+@@ -79,9 +79,6 @@
+ #include <gconf/gconf.h>
+ #include <gconf/gconf-client.h>
+-#include <libgnomevfs/gnome-vfs.h>
+-#include <libgnomevfs/gnome-vfs-inet-connection.h>
+-
+ /* all include appdata_t relies on go here ... */
+ #include "gpx.h"
+ #include "settings.h"
+--- gpxview-0.9.1.orig/src/html.c
++++ gpxview-0.9.1/src/html.c
+@@ -87,15 +87,19 @@ void release_load_context(GThread *self,
+ gpointer loader_thread(gpointer data) {
+   GThread *self = g_thread_self();
+-  GnomeVFSResult result;
+-  GnomeVFSHandle *handle;
+-  char buffer[4096];
+-  GnomeVFSFileSize bytes_read;
++//  GnomeVFSResult result;
++//  GnomeVFSHandle *handle;
++//  char buffer[4096];
++//  GnomeVFSFileSize bytes_read;
+   load_context_t *context = (load_context_t*)data;
+   printf("%p: loader thread for %s running\n", self, context->url);
++  printf("GPXView WARNING: Function not implemented\n");
++  release_load_context(self, context);
++  return NULL;
++#if 0
+   result = gnome_vfs_open(&handle, context->url, GNOME_VFS_OPEN_READ);
+   if(result != GNOME_VFS_OK) {
+     g_print("%p: open error: %s\n", self, gnome_vfs_result_to_string(result));
+@@ -143,6 +147,7 @@ gpointer loader_thread(gpointer data) {
+   printf("%p: loader thread successfully finished\n", self);
+   release_load_context(self, context);
+   return NULL;
++#endif
+ }
+ #ifdef ENABLE_BROWSER_INTERFACE
+@@ -175,7 +180,7 @@ static void on_link_clicked(GtkHTML *htm
+ static void on_request_url(GtkHTML *html, const gchar *url, 
+                          GtkHTMLStream *stream, gpointer data) {
+   char buffer[4096];
+-  GnomeVFSFileSize bytes_read;
++  ssize_t bytes_read;
+   http_context_t *context = (http_context_t*)data;
+--- gpxview-0.9.1.orig/src/gpx.c
++++ gpxview-0.9.1/src/gpx.c
+@@ -21,6 +21,8 @@
+ #include <stdlib.h>
+ #include <string.h>
+ #include <math.h>
++#include <dirent.h>
++#include <errno.h>
+ #include <libxml/parser.h>
+ #include <libxml/tree.h>
+@@ -1262,10 +1264,8 @@ gpx_t *gpx_parse(gpx_dialog_t *dialog, c
+ /* scan entire directory */
+ gpx_t *gpx_parse_dir(gpx_dialog_t *dialog, char *dirname, char *username) {
+-  GnomeVFSResult result;
+-  GnomeVFSDirectoryHandle *handle;
+-  GnomeVFSFileInfo *finfo = gnome_vfs_file_info_new();;
+-
++  DIR *dir;
++  struct dirent dirent_buf, *dirent;
+   gpx_t *gpx = NULL;
+   
+   /* show busy dialog */
+@@ -1274,27 +1274,27 @@ gpx_t *gpx_parse_dir(gpx_dialog_t *dialo
+   LIBXML_TEST_VERSION;
+-  result = gnome_vfs_directory_open(&handle, dirname, 
+-                                  GNOME_VFS_FILE_INFO_DEFAULT);
+-
+-  if(result != GNOME_VFS_OK) {
++  dir = opendir(dirname);
++  if (!dir) {
+     errorf("Unable to open directory \"%s\":\n%s",
+-         dirname,  gnome_vfs_result_to_string(result));
++         dirname, strerror(errno));
+     return NULL;
+   }
+-  while(GNOME_VFS_OK == gnome_vfs_directory_read_next(handle, finfo)) {
+-    if(finfo->type == GNOME_VFS_FILE_TYPE_REGULAR) {
+-      char *ext = finfo->name+strlen(finfo->name)-4;
++  while (readdir_r(dir, &dirent_buf, &dirent) == 0) {
++    if (dirent->d_type == DT_REG) {
++      if (strlen(dirent->d_name) <= 4)
++        continue;
++      char *ext = dirent->d_name+strlen(dirent->d_name)-4;
+       /* check if file ends with .gpx or .loc */
+       if((strcasecmp(ext, ".gpx") == 0) || (strcasecmp(ext, ".loc") == 0)) {
+-      char *filename = malloc(strlen(dirname)+strlen(finfo->name)+2);
++      char *filename = malloc(strlen(dirname)+strlen(dirent->d_name)+2);
+       strcpy(filename, dirname);
+       if(strlastchr(filename) != '/')
+         strcat(filename, "/");
+-      strcat(filename, finfo->name);
++      strcat(filename, dirent->d_name);
+       xmlTextReaderPtr reader = xmlReaderForFile(filename, NULL, 0);
+       if (reader != NULL) {
+@@ -1328,8 +1328,7 @@ gpx_t *gpx_parse_dir(gpx_dialog_t *dialo
+     gpx->name = strdup(n);
+   }
+-  gnome_vfs_file_info_unref(finfo);
+-  gnome_vfs_directory_close(handle);
++  closedir(dir);
+   return gpx;
+ }
+--- gpxview-0.9.1.orig/src/gps.c
++++ gpxview-0.9.1/src/gps.c
+@@ -20,6 +20,11 @@
+ #include <stdio.h>
+ #include <string.h>
+ #include <math.h>
++#include <netinet/in.h>
++#include <unistd.h>
++#include <fcntl.h>
++#include <netdb.h>
++#include <sys/socket.h>
+ #include "gpxview.h"
+@@ -112,7 +117,11 @@ float gps_get_eph(appdata_t *appdata) {
+ }
+ static int gps_connect(gps_state_t *gps_state) {
+-  GnomeVFSResult vfs_result;
++  struct hostent hbuf, *h;
++  struct sockaddr_in addr;
++  struct timeval timeout;
++  char buffer[2048];
++  int err;
+ #ifdef USE_MAEMO
+   char errstr[256] = "";
+@@ -138,10 +147,8 @@ static int gps_connect(gps_state_t *gps_
+   /* Create a socket to interact with GPSD. */
+   int retries = 5;
+-  while(retries && 
+-      (GNOME_VFS_OK != (vfs_result = gnome_vfs_inet_connection_create(
+-              &gps_state->iconn, GPSD_HOST, GPSD_PORT, NULL)))) {
+-    printf("gps: Error creating connection to GPSD, retrying ...\n");
++  while(retries && ((gps_state->socket = socket(AF_INET, SOCK_STREAM, 0)) < 0)) {
++    printf("gps: Error creating GPSD socket, retrying ...\n");
+     retries--;
+     sleep(1);
+@@ -153,9 +160,8 @@ static int gps_connect(gps_state_t *gps_
+   }
+   retries = 5;
+-  while(retries && ((gps_state->socket = 
+-     gnome_vfs_inet_connection_to_socket(gps_state->iconn)) == NULL)) {
+-    printf("gps: Error creating connecting GPSD socket, retrying ...\n");
++  while(retries && gethostbyname_r(GPSD_HOST, &hbuf, buffer, sizeof(buffer), &h, &err)) {
++    printf("gps: Error resolving GPSD hostname, retrying ...\n");
+     retries--;
+     sleep(1);
+@@ -166,10 +172,34 @@ static int gps_connect(gps_state_t *gps_
+     return -1;
+   }
+-  GTimeVal timeout = { 10, 0 };
+-  if(GNOME_VFS_OK != (vfs_result = gnome_vfs_socket_set_timeout(
+-      gps_state->socket, &timeout, NULL))) {
+-    printf("gps: Error setting GPSD timeout\n");
++  memset(&addr, 0, sizeof(addr));
++  addr.sin_family = AF_INET;
++  memcpy(&addr.sin_addr.s_addr, h->h_addr, h->h_length);
++  addr.sin_port = htons(GPSD_PORT);
++
++  retries = 5;
++  while(retries && (connect(gps_state->socket, (struct sockaddr *)&addr, sizeof(addr)) < 0)) {
++    printf("gps: Error connecting to GPSD, retrying ...\n");
++
++    retries--;
++    sleep(1);
++  }
++
++  if(!retries) {
++    printf("gps: Finally failed ...\n");
++    return -1;
++  }
++
++  timeout.tv_sec = 10;
++  timeout.tv_usec = 0;
++  if(setsockopt(gps_state->socket, SOL_SOCKET, SO_SNDTIMEO, &timeout, sizeof(timeout)) < 0) {
++    printf("gps: Error setting GPSD send timeout\n");
++    return -1;
++  } 
++  timeout.tv_sec = 10;
++  timeout.tv_usec = 0;
++  if(setsockopt(gps_state->socket, SOL_SOCKET, SO_RCVTIMEO, &timeout, sizeof(timeout)) < 0) {
++    printf("gps: Error setting GPSD receive timeout\n");
+     return -1;
+   } 
+@@ -358,8 +388,7 @@ static gboolean gps_idle_cb(gpointer dat
+ }
+ gpointer gps_thread(gpointer data) {
+-  GnomeVFSFileSize bytes_read;
+-  GnomeVFSResult vfs_result;
++  ssize_t bytes;
+   char str[512];
+   appdata_t *appdata = (appdata_t*)data;
+   int cnt=1000;
+@@ -384,21 +413,18 @@ gpointer gps_thread(gpointer data) {
+       const char *msg;
+       if(!cnt) msg = msg_sat;
+       else     msg = msg_pos;
+-      
+-      if(GNOME_VFS_OK == 
+-         (vfs_result = gnome_vfs_socket_write(appdata->gps_state->socket,
+-                    msg, strlen(msg)+1, &bytes_read, NULL))) {
++  
++        if ((bytes = write(appdata->gps_state->socket, msg, strlen(msg)+1)) > 0) {
+         /* update every second, wait here to make sure a complete */
+         /* reply is received */
+         if(cnt <= 1) usleep(500000);
+         else         sleep(1);
+         
+-        if(bytes_read == (strlen(msg)+1)) {
+-          vfs_result = gnome_vfs_socket_read(appdata->gps_state->socket,
+-                             str, sizeof(str)-1, &bytes_read, NULL);
+-          if(vfs_result == GNOME_VFS_OK) {
+-            str[bytes_read] = 0; 
++          if(bytes == (strlen(msg)+1)) {
++            bytes = read(appdata->gps_state->socket, str, sizeof(str)-1);
++            if (bytes > 0) {
++            str[bytes] = 0; 
+           
+             //          printf("gps: msg: %s (%d)\n", str, strlen(str));
+             
+@@ -419,7 +445,7 @@ gpointer gps_thread(gpointer data) {
+     } else {
+       if(connected) {
+       printf("gps: stopping GPS connection due to user request\n");
+-      gnome_vfs_inet_connection_destroy(appdata->gps_state->iconn, NULL);
++      close(appdata->gps_state->socket);
+ #ifdef USE_MAEMO
+       gpsbt_stop(&appdata->gps_state->context);
+--- gpxview-0.9.1.orig/src/gps.h
++++ gpxview-0.9.1/src/gps.h
+@@ -111,8 +111,7 @@ typedef struct gps_state {
+   GThread* thread_p;
+   GMutex *mutex;
+-  GnomeVFSInetConnection *iconn;
+-  GnomeVFSSocket *socket;
++  int socket;
+   struct gps_data_t gpsdata;
+ #else
+--- gpxview-0.9.1.orig/configure
++++ gpxview-0.9.1/configure
+@@ -3156,6 +3156,9 @@ fi
++pkg_failed=no
++pkg_cv_gnome_vfs_module_CFLAGS=
++pkg_cv_gnome_vfs_module_LIBS=
+ if test $pkg_failed = yes; then
+ if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then
+@@ -4699,6 +4702,9 @@ fi
++pkg_failed=no
++pkg_cv_gnome2_CFLAGS=
++pkg_cv_gnome2_LIBS=
+ if test $pkg_failed = yes; then
+ if $PKG_CONFIG --atleast-pkgconfig-version 0.20; then