tags 868425 + patch
tags 886079 + patch
thanks

Attached is a patch fixing this bug.  The current package doesn't
handle EOF properly and also doesn't close the stream.

Incidentally, the patch fixes #886079 as well.  This package doesn't
use GConf but ends up linking with it due to gnome-vfs-2.0.pc.
Description: Port to GIO.
Bug-Debian: https://bugs.debian.org/868425
Author: Yavor Doganov <ya...@gnu.org>
Forwarded: no
Last-Update: 2018-10-08
---


--- gmotionlive-1.0.orig/Makefile
+++ gmotionlive-1.0/Makefile
@@ -5,7 +5,7 @@
 all:   gmotionlive
 
 gmotionlive: gmotionlive.c
-       $(CC) gmotionlive.c -o gmotionlive $(CFLAGS) `pkg-config gtk+-2.0 
--cflags --libs` `pkg-config gnome-vfs-2.0 --cflags --libs`
+       $(CC) gmotionlive.c -o gmotionlive $(CFLAGS) `pkg-config gtk+-2.0 
--cflags --libs`
 
 clean:
        rm -f *.o gmotionlive
--- gmotionlive-1.0.orig/gmotionlive.c
+++ gmotionlive-1.0/gmotionlive.c
@@ -9,7 +9,6 @@
 
 #include <gtk/gtk.h>
 #include <ctype.h>
-#include <libgnomevfs/gnome-vfs.h>
 #include <string.h>
 #include <malloc.h>
 #include <stdio.h>
@@ -207,32 +206,56 @@
        return size * nmemb;
 }
 
-void read_callback (GnomeVFSAsyncHandle *handle, GnomeVFSResult result, 
gpointer buffer, GnomeVFSFileSize bytes_requested, GnomeVFSFileSize bytes_read, 
gpointer callback_data)
+void read_callback (GObject *handle, GAsyncResult *result, gpointer 
callback_data)
 {
-       if (result != GNOME_VFS_OK) {
-               failure("gmotionlive can not read from the stream");
+       GFile *file = G_FILE(callback_data);
+       GError *error = NULL;
+       gssize bytes_read;
+
+       bytes_read = g_input_stream_read_finish(G_INPUT_STREAM(handle),
+                                               result, &error);
+       if (error) {
+               g_object_unref(handle);
+               g_object_unref(file);
+               g_error_free(error);
+               failure("gmotionlive can not read from the stream");
+               return;
+       }
+
+       if (bytes_read) {
+               netcam_write(buf, 1, bytes_read, NULL);
+               g_input_stream_read_async(G_INPUT_STREAM(handle), buf, 4095,
+                                         G_PRIORITY_LOW, NULL, read_callback,
+                                         file);
        } else {
-               if (bytes_read)
-                       netcam_write(buffer, 1, bytes_read, NULL);
-               gnome_vfs_async_read(handle, buffer, 4095, read_callback, 
"read_callback");
+               g_object_unref(handle);
+               g_object_unref(file);
        }
 }
 
-void open_callback (GnomeVFSAsyncHandle *handle, GnomeVFSResult result, 
gpointer callback_data)
+void open_callback (GObject *handle, GAsyncResult *result, gpointer 
callback_data)
 {
-       if (result != GNOME_VFS_OK) {
-               failure("gmotionlive was unable to open the specified stream");
-       } else {
-               gnome_vfs_async_read(handle, buf, 4095, read_callback, 
"read_callback");
+       GFileInputStream *stream;
+       GError *error = NULL;
+
+       stream = g_file_read_finish(G_FILE(handle), result, &error);
+       if (error) {
+               g_object_unref(handle);
+               g_error_free(error);
+               failure("gmotionlive was unable to open the specified stream");
+               return;
        }
+
+       g_input_stream_read_async(G_INPUT_STREAM(stream), buf, 4095,
+                                 G_PRIORITY_LOW, NULL, read_callback, handle);
 }
 
 int transfer(char *transfer_url)
 {
-       GnomeVFSAsyncHandle *handle;
+       GFile *handle;
 
-       gnome_vfs_async_open(&handle, transfer_url, GNOME_VFS_OPEN_READ,
-           GNOME_VFS_PRIORITY_MIN, open_callback, "open_callback");
+       handle = g_file_new_for_uri(transfer_url);
+       g_file_read_async(handle, G_PRIORITY_LOW, NULL, open_callback, NULL);
 
        return 0;
 }
@@ -282,8 +305,6 @@
                return 1;
        }
 
-       gnome_vfs_init();
-
        window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
 
        gtkimage = gtk_image_new();

Reply via email to