348 lines
10 KiB
Diff
348 lines
10 KiB
Diff
|
---
|
||
|
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
|