core,i18n,tests: Remove HTTPSeekableResponse
authorZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Fri, 8 Apr 2011 23:28:04 +0000 (02:28 +0300)
committerZeeshan Ali (Khattak) <zeeshanak@gnome.org>
Sat, 9 Apr 2011 01:40:22 +0000 (04:40 +0300)
Remove now redundant HTTPSeekableResponse class and its test.

po/POTFILES.in
po/POTFILES.skip
src/rygel/Makefile.am
src/rygel/rygel-http-seekable-response.vala [deleted file]
tests/Makefile.am
tests/rygel-http-response-test_seekable-response.vala [deleted symlink]
tests/rygel-http-response_seekable-response.vala [deleted symlink]
tests/rygel-http-seekable-response-test.vala [deleted file]
tests/rygel-http-seekable-response.vala [deleted symlink]
tests/rygel-state-machine_seekable-response.vala [deleted symlink]

index 9b0e2c8..34ab9e1 100644 (file)
@@ -128,7 +128,6 @@ src/rygel/rygel-root-device.vala
 src/rygel/rygel-search-criteria-parser.vala
 src/rygel/rygel-search-expression.vala
 src/rygel/rygel-search.vala
-src/rygel/rygel-http-seekable-response.vala
 src/rygel/rygel-simple-container.vala
 src/rygel/rygel-source-connection-manager.vala
 src/rygel/rygel-sink-connection-manager.vala
index 8be934d..4730ba2 100644 (file)
@@ -77,7 +77,6 @@ src/rygel/rygel-mp3-transcoder-bin.c
 src/rygel/rygel-plugin-loader.c
 src/rygel/rygel-root-device-factory.c
 src/rygel/rygel-search.c
-src/rygel/rygel-http-seekable-response.c
 src/rygel/rygel-subtitle-manager.c
 src/rygel/rygel-thumbnailer.c
 src/rygel/rygel-transcode-manager.c
@@ -102,7 +101,6 @@ tests/rygel-http-byte-seek.c
 tests/rygel-http-item-uri.c
 tests/rygel-http-time-seek.c
 tests/rygel-http-gst-response.c
-tests/rygel-http-seekable-response.c
 tests/rygel-http-byte-seek_http-get.c
 tests/rygel-http-get.c
 tests/rygel-http-item-uri_http-get.c
index 4313a68..32d1b78 100644 (file)
@@ -53,7 +53,6 @@ VAPI_SOURCE_FILES = \
        rygel-http-time-seek.vala \
        rygel-http-response.vala \
        rygel-http-gst-response.vala \
-       rygel-http-seekable-response.vala \
        rygel-http-gst-sink.vala \
        rygel-resource-info.vala \
        rygel-icon-info.vala \
diff --git a/src/rygel/rygel-http-seekable-response.vala b/src/rygel/rygel-http-seekable-response.vala
deleted file mode 100644 (file)
index 5192892..0000000
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * Copyright (C) 2008 Zeeshan Ali (Khattak) <zeeshanak@gnome.org>.
- * Copyright (C) 2008 Nokia Corporation.
- *
- * Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
- *                               <zeeshan.ali@nokia.com>
- *
- * This file is part of Rygel.
- *
- * Rygel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Rygel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-using GUPnP;
-
-internal class Rygel.HTTPSeekableResponse : Rygel.HTTPResponse {
-    private const size_t BUFFER_LENGTH = 65536;
-
-    private HTTPSeek seek;
-    private File file;
-    private FileInputStream input_stream;
-
-    private uint8[] buffer;
-    private size_t total_length;
-
-    public HTTPSeekableResponse (HTTPGet        request,
-                                 HTTPGetHandler request_handler) throws Error {
-        string uri;
-        int64 file_length;
-
-        if (request.subtitle != null) {
-            uri = request.subtitle.uri;
-            file_length = request.subtitle.size;
-        } else if (request.thumbnail != null) {
-            uri = request.thumbnail.uri;
-            file_length = request.thumbnail.size;
-        } else {
-            var item = request.item;
-
-            if (item.uris.size == 0) {
-                throw new HTTPRequestError.NOT_FOUND
-                                        (_("Item '%s' didn't provide a URI"),
-                                         item.id);
-            }
-
-            uri = item.uris.get (0);
-            file_length = item.size;
-        }
-
-        var partial = request.seek.length < file_length;
-
-        base (request, request_handler, partial);
-
-        this.msg.response_headers.set_encoding (Soup.Encoding.CONTENT_LENGTH);
-
-        this.seek = request.seek;
-        this.total_length = (size_t) this.seek.length;
-
-        if (this.total_length > BUFFER_LENGTH) {
-            this.buffer = new uint8[HTTPSeekableResponse.BUFFER_LENGTH];
-        } else {
-            this.buffer = new uint8[this.total_length];
-        }
-
-        this.file = File.new_for_uri (uri);
-    }
-
-    public override async void run () {
-        try {
-           this.input_stream = yield this.file.read_async (this.priority,
-                                                           this.cancellable);
-        } catch (Error err) {
-            warning (_("Failed to read from URI: %s: %s"),
-                     file.get_uri (),
-                     err.message);
-            this.end (false, Soup.KnownStatusCode.NOT_FOUND);
-
-            return;
-        }
-
-        yield this.perform_seek ();
-    }
-
-    private async void perform_seek () {
-        try {
-            this.input_stream.seek (this.seek.start,
-                                    SeekType.SET,
-                                    this.cancellable);
-        } catch (Error err) {
-            // Failed to seek to media segment (defined by first and last
-            // byte positions).
-            warning (_("Failed to seek to %s-%s on URI %s: %s"),
-                     seek.start.to_string (),
-                     seek.stop.to_string (),
-                     file.get_uri (),
-                     err.message);
-            this.end (false,
-                      Soup.KnownStatusCode.REQUESTED_RANGE_NOT_SATISFIABLE);
-            return;
-        }
-
-        yield this.start_reading ();
-    }
-
-    private async void start_reading () {
-        try {
-            yield this.read_contents ();
-        } catch (IOError.CANCELLED cancelled_err) {
-            // This is OK
-        } catch (Error err) {
-            warning (_("Failed to read contents from URI: %s: %s"),
-                     this.file.get_uri (),
-                     err.message);
-            this.end (false, Soup.KnownStatusCode.NOT_FOUND);
-
-            return;
-        }
-
-        yield this.close_stream ();
-    }
-
-    private async void read_contents () throws Error {
-        var bytes_read = yield this.input_stream.read_async (this.buffer,
-                                                             this.priority,
-                                                             this.cancellable);
-        this.msg.wrote_chunk.connect ((msg) => {
-            if (this.run_continue != null) {
-                this.run_continue ();
-            }
-        });
-
-        while (bytes_read > 0) {
-            var to_push = size_t.min (bytes_read, this.total_length);
-
-            this.push_data (this.buffer[0:to_push]);
-            this.total_length -= to_push;
-
-            if (this.total_length <= 0) {
-                break;
-            }
-
-            this.run_continue = read_contents.callback;
-            // We return from this call when wrote_chunk signal is emitted
-            // and the handler we installed before the loop is called for it.
-            yield;
-            this.run_continue = null;
-
-            if (this.cancellable != null && this.cancellable.is_cancelled ()) {
-                break;
-            }
-
-            bytes_read = yield this.input_stream.read_async (this.buffer,
-                                                             this.priority,
-                                                             this.cancellable);
-        }
-    }
-
-    private async void close_stream () {
-        try {
-            yield this.input_stream.close_async (this.priority,
-                                                 this.cancellable);
-        } catch (Error err) {
-            warning (_("Failed to close stream to URI %s: %s"),
-                     this.file.get_uri (),
-                     err.message);
-        }
-
-        if (this.cancellable == null || !this.cancellable.is_cancelled ()) {
-            this.end (false, Soup.KnownStatusCode.NONE);
-        }
-    }
-}
-
index 16792d9..6fa71e7 100644 (file)
@@ -27,7 +27,6 @@ AM_VALAFLAGS = --disable-warnings --thread \
 
 check_PROGRAMS = rygel-http-item-uri-test \
                 rygel-http-gst-response-test \
-                rygel-http-seekable-response-test \
                 rygel-http-byte-seek-test \
                 rygel-http-time-seek-test \
                 rygel-http-get-test \
@@ -47,13 +46,6 @@ rygel_http_gst_response_test_SOURCES = rygel-http-gst-response-test.vala \
                                   rygel-http-gst-sink.vala \
                                   rygel-gst-utils.vala
 
-rygel_http_seekable_response_test_SOURCES = \
-                                  rygel-http-seekable-response-test.vala \
-                                  rygel-http-seekable-response.vala \
-                                   rygel-http-response-test_seekable-response.vala \
-                                  rygel-http-response_seekable-response.vala \
-                                  rygel-state-machine_seekable-response.vala
-
 rygel_http_byte_seek_test_SOURCES = rygel-http-byte-seek-test.vala \
                                    rygel-http-byte-seek.vala \
                                    rygel-http-seek.vala
diff --git a/tests/rygel-http-response-test_seekable-response.vala b/tests/rygel-http-response-test_seekable-response.vala
deleted file mode 120000 (symlink)
index 0cb230f..0000000
+++ /dev/null
@@ -1 +0,0 @@
-rygel-http-response-test.vala
\ No newline at end of file
diff --git a/tests/rygel-http-response_seekable-response.vala b/tests/rygel-http-response_seekable-response.vala
deleted file mode 120000 (symlink)
index e23cfdf..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../src/rygel/rygel-http-response.vala
\ No newline at end of file
diff --git a/tests/rygel-http-seekable-response-test.vala b/tests/rygel-http-seekable-response-test.vala
deleted file mode 100644 (file)
index 8b72aeb..0000000
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * Copyright (C) 2010 Nokia Corporation.
- *
- * Author: Zeeshan Ali (Khattak) <zeeshanak@gnome.org>
- *                               <zeeshan.ali@nokia.com>
- *
- * This file is part of Rygel.
- *
- * Rygel is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * Rygel is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public License
- * along with this program; if not, write to the Free Software Foundation,
- * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- */
-
-using Soup;
-using Gee;
-
-public class Rygel.HTTPSeekableResponseTest : Rygel.HTTPResponseTest {
-    private File dummy_file;
-
-    public static int main (string[] args) {
-        try {
-            var test = new HTTPSeekableResponseTest.complete ();
-            test.run ();
-
-            test = new HTTPSeekableResponseTest.abort ();
-            test.run ();
-        } catch (TestError.SKIP error) {
-            return error.code;
-        } catch (Error error) {
-            critical ("%s", error.message);
-
-            return -1;
-        }
-
-        return 0;
-    }
-
-    private HTTPSeekableResponseTest (Cancellable? cancellable = null)
-                                      throws Error {
-        base (cancellable);
-    }
-
-    private HTTPSeekableResponseTest.complete () throws Error {
-        base.complete ();
-    }
-
-    private HTTPSeekableResponseTest.abort () throws Error {
-        base.abort ();
-    }
-
-    public override void run () throws Error {
-        this.create_dummy_file ();
-
-        base.run ();
-
-        this.dummy_file.delete (null);
-    }
-
-    private void create_dummy_file () throws Error {
-        this.dummy_file = File.new_for_uri (MediaItem.URI);
-        var stream = this.dummy_file.replace (null, false, 0, null);
-
-        // Put randon stuff into it
-        stream.write (new uint8[1024], null);
-    }
-
-    internal override HTTPResponse create_response (Soup.Message msg)
-                                                    throws Error {
-        var item = new MediaItem ();
-        var seek = new HTTPSeek (0, HTTPResponseTest.MAX_BYTES - 1, item.size);
-
-        var request = new HTTPGet (this.server.context.server,
-                                   msg,
-                                   item,
-                                   seek,
-                                   this.cancellable);
-        var handler = new HTTPGetHandler (this.cancellable);
-
-        msg.response_headers.set_content_length (seek.length);
-
-        return new HTTPSeekableResponse (request, handler);
-    }
-}
-
-public class Rygel.HTTPGet : GLib.Object {
-    public Soup.Server server;
-    public Soup.Message msg;
-
-    public Cancellable cancellable;
-
-    public MediaItem item;
-
-    internal HTTPSeek seek;
-
-    public Subtitle subtitle;
-    public Thumbnail thumbnail;
-
-    public HTTPGet (Soup.Server  server,
-                    Soup.Message msg,
-                    MediaItem    item,
-                    HTTPSeek     seek,
-                    Cancellable? cancellable) {
-        this.server = server;
-        this.msg = msg;
-        this.item = item;
-        this.seek = seek;
-        this.cancellable = cancellable;
-    }
-}
-
-public class Rygel.HTTPGetHandler : GLib.Object {
-    public Cancellable cancellable;
-
-    public HTTPGetHandler (Cancellable? cancellable) {
-        this.cancellable = cancellable;
-    }
-}
-
-public class Rygel.MediaItem {
-    public const string URI = "file:///tmp/rygel-dummy-test-file";
-
-    public string id = "Dummy";
-    public Gee.ArrayList<string> uris;
-    public int64 size = 1024;
-
-    public MediaItem () {
-        this.uris = new ArrayList<string> ();
-
-        this.uris.add (URI);
-    }
-}
-
-public class Rygel.Subtitle {
-    public string uri;
-    public int64 size = -1;   // Size in bytes
-}
-
-public class Rygel.Thumbnail {
-    public string uri;
-
-    public int64 size = -1; // Size in bytes
-}
-
-public errordomain Rygel.HTTPRequestError {
-    NOT_FOUND = Soup.KnownStatusCode.NOT_FOUND
-}
diff --git a/tests/rygel-http-seekable-response.vala b/tests/rygel-http-seekable-response.vala
deleted file mode 120000 (symlink)
index 5eaf9da..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../src/rygel/rygel-http-seekable-response.vala
\ No newline at end of file
diff --git a/tests/rygel-state-machine_seekable-response.vala b/tests/rygel-state-machine_seekable-response.vala
deleted file mode 120000 (symlink)
index 5063d68..0000000
+++ /dev/null
@@ -1 +0,0 @@
-../src/rygel/rygel-state-machine.vala
\ No newline at end of file