diff options
author | Jens Georg <mail@jensge.org> | 2014-11-20 07:35:36 +0100 |
---|---|---|
committer | Jens Georg <mail@jensge.org> | 2015-02-08 13:19:01 +0100 |
commit | 30088312fd62d7d4e2e72156fddafb1b0462e343 (patch) | |
tree | ea3d77780a4b67abcad79a01f9da478605ac0d92 | |
parent | 7cb3ed08fe902ee799e27659bfe51ac22ffbc485 (diff) | |
download | rygel-30088312fd62d7d4e2e72156fddafb1b0462e343.tar.gz |
server: Minor syle fixes/simplifications
Signed-off-by: Jens Georg <mail@jensge.org>
-rw-r--r-- | src/librygel-server/rygel-http-resource-handler.vala | 31 |
1 files changed, 9 insertions, 22 deletions
diff --git a/src/librygel-server/rygel-http-resource-handler.vala b/src/librygel-server/rygel-http-resource-handler.vala index dd87dc04..4dcf575e 100644 --- a/src/librygel-server/rygel-http-resource-handler.vala +++ b/src/librygel-server/rygel-http-resource-handler.vala @@ -13,18 +13,6 @@ * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS - * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, - * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL CABLE TELEVISION LABORATORIES - * INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ using GUPnP; @@ -39,22 +27,20 @@ internal class Rygel.HTTPMediaResourceHandler : HTTPGetHandler { public HTTPMediaResourceHandler (MediaObject media_object, string media_resource_name, - Cancellable? cancellable) throws HTTPRequestError - { + Cancellable? cancellable) + throws HTTPRequestError { this.media_object = media_object; this.cancellable = cancellable; this.media_resource_name = media_resource_name; - foreach (var resource in media_object.get_resource_list ()) { - if (resource.get_name () == media_resource_name) { - this.media_resource - = new MediaResource.from_resource (resource.get_name (), - resource); - } - } - if (this.media_resource == null) { + var resource = media_object.get_resource_by_name (media_resource_name); + + if (resource == null) { throw new HTTPRequestError.NOT_FOUND ("MediaResource %s not found", media_resource_name); } + + // Handler modifies the resource, so we copy it. + this.media_resource = resource.dup (); } public override void add_response_headers (HTTPGet request) @@ -97,6 +83,7 @@ internal class Rygel.HTTPMediaResourceHandler : HTTPGetHandler { protected override DIDLLiteResource add_resource (DIDLLiteObject didl_object, HTTPGet request) throws Error { + // Temporary. Needed for abstract base class. return null as DIDLLiteResource; } } |