summaryrefslogtreecommitdiffstats
path: root/desktop/apps/gpxview/patches/300-remove-gnome-vfs-dependency.patch
blob: 8cd40e6b08c8209783a0e02e72972d61780d9ff5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
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