[rygel] mediathek: Make use of nested namespaces
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] mediathek: Make use of nested namespaces
- Date: Fri, 9 Jul 2010 14:45:00 +0000 (UTC)
commit ea4e38e6b5d84566ce7ff7807a8d19270c9f705c
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Fri Jul 9 17:33:04 2010 +0300
mediathek: Make use of nested namespaces
.../mediathek/rygel-mediathek-asx-playlist.vala | 15 +++----
src/plugins/mediathek/rygel-mediathek-plugin.vala | 6 +-
.../mediathek/rygel-mediathek-root-container.vala | 16 ++++----
.../mediathek/rygel-mediathek-rss-container.vala | 15 +++----
.../mediathek/rygel-mediathek-video-item.vala | 40 +++++++++----------
5 files changed, 43 insertions(+), 49 deletions(-)
---
diff --git a/src/plugins/mediathek/rygel-mediathek-asx-playlist.vala b/src/plugins/mediathek/rygel-mediathek-asx-playlist.vala
index d44d0f9..17456c8 100644
--- a/src/plugins/mediathek/rygel-mediathek-asx-playlist.vala
+++ b/src/plugins/mediathek/rygel-mediathek-asx-playlist.vala
@@ -25,7 +25,7 @@ using Gee;
using Soup;
using Xml;
-public errordomain Rygel.MediathekAsxPlaylistError {
+public errordomain Rygel.Mediathek.AsxPlaylistError {
XML_ERROR,
NETWORK_ERROR
}
@@ -39,11 +39,11 @@ public errordomain Rygel.MediathekAsxPlaylistError {
* This parser is //only// intended to work with the simple
* ASX files presented by the ZDF Mediathek streaming server
*/
-public class Rygel.MediathekAsxPlaylist : Object {
+public class Rygel.Mediathek.AsxPlaylist : Object {
public ArrayList<string> uris;
private string uri;
- public MediathekAsxPlaylist (string uri) {
+ public AsxPlaylist (string uri) {
this.uris = new ArrayList<string> ();
this.uri = uri;
}
@@ -58,7 +58,7 @@ public class Rygel.MediathekAsxPlaylist : Object {
* to extract all of the href attributes for every entry
* in the file
*/
- public void parse() throws MediathekAsxPlaylistError {
+ public void parse() throws AsxPlaylistError {
// FIXME make async using global soup session
var session = new Soup.SessionSync ();
var message = new Soup.Message ("GET",
@@ -89,15 +89,14 @@ public class Rygel.MediathekAsxPlaylist : Object {
}
}
else {
- throw new
- MediathekAsxPlaylistError.XML_ERROR (
- "Could not fetch XML");
+ throw new AsxPlaylistError.XML_ERROR (
+ "Could not fetch XML");
}
}
catch (RegexError error) { }
}
else {
- throw new MediathekAsxPlaylistError.NETWORK_ERROR (
+ throw new AsxPlaylistError.NETWORK_ERROR (
"Playlist download failed: %u (%s)",
message.status_code,
Soup.status_get_phrase (
diff --git a/src/plugins/mediathek/rygel-mediathek-plugin.vala b/src/plugins/mediathek/rygel-mediathek-plugin.vala
index 526181a..2c44eb8 100644
--- a/src/plugins/mediathek/rygel-mediathek-plugin.vala
+++ b/src/plugins/mediathek/rygel-mediathek-plugin.vala
@@ -26,13 +26,13 @@ using GUPnP;
public void module_init (PluginLoader loader) {
var plugin = new Plugin.MediaServer ("ZDFMediathek",
"ZDF Mediathek",
- typeof (Rygel.MediathekContentDir));
+ typeof (Mediathek.ContentDir));
loader.add_plugin (plugin);
}
-public class Rygel.MediathekContentDir : ContentDirectory {
+public class Rygel.Mediathek.ContentDir : ContentDirectory {
public override MediaContainer? create_root_container () {
- return MediathekRootContainer.get_instance ();
+ return RootContainer.get_instance ();
}
}
diff --git a/src/plugins/mediathek/rygel-mediathek-root-container.vala b/src/plugins/mediathek/rygel-mediathek-root-container.vala
index 3db652b..14276fe 100644
--- a/src/plugins/mediathek/rygel-mediathek-root-container.vala
+++ b/src/plugins/mediathek/rygel-mediathek-root-container.vala
@@ -23,28 +23,28 @@
using Gee;
using Soup;
-public class Rygel.MediathekRootContainer : Rygel.SimpleContainer {
+public class Rygel.Mediathek.RootContainer : Rygel.SimpleContainer {
internal SessionAsync session;
- private static MediathekRootContainer instance;
+ private static RootContainer instance;
private bool on_schedule_update () {
message("Scheduling update for all feeds....");
foreach (var container in this.children) {
- ((MediathekRssContainer) container).update ();
+ ((RssContainer) container).update ();
}
return true;
}
- public static MediathekRootContainer get_instance () {
- if (MediathekRootContainer.instance == null) {
- MediathekRootContainer.instance = new MediathekRootContainer ();
+ public static RootContainer get_instance () {
+ if (RootContainer.instance == null) {
+ RootContainer.instance = new RootContainer ();
}
return instance;
}
- private MediathekRootContainer () {
+ private RootContainer () {
base.root ("ZDF Mediathek");
this.session = new Soup.SessionAsync ();
Gee.ArrayList<int> feeds = null;
@@ -62,7 +62,7 @@ public class Rygel.MediathekRootContainer : Rygel.SimpleContainer {
}
foreach (int id in feeds) {
- this.add_child (new MediathekRssContainer (this, id));
+ this.add_child (new RssContainer (this, id));
}
GLib.Timeout.add_seconds (1800, on_schedule_update);
diff --git a/src/plugins/mediathek/rygel-mediathek-rss-container.vala b/src/plugins/mediathek/rygel-mediathek-rss-container.vala
index e72e7fb..861c96e 100644
--- a/src/plugins/mediathek/rygel-mediathek-rss-container.vala
+++ b/src/plugins/mediathek/rygel-mediathek-rss-container.vala
@@ -24,7 +24,7 @@ using Gee;
using Soup;
using Xml;
-public class Rygel.MediathekRssContainer : Rygel.SimpleContainer {
+public class Rygel.Mediathek.RssContainer : Rygel.SimpleContainer {
private uint zdf_content_id;
private Soup.Date last_modified = null;
@@ -69,13 +69,11 @@ public class Rygel.MediathekRssContainer : Rygel.SimpleContainer {
for (int i = 0; i < xpo->nodesetval->length (); i++) {
Xml.Node* node = xpo->nodesetval->item (i);
try {
- var item =
- MediathekVideoItem.create_from_xml (this,
- node);
+ var item = VideoItem.create_from_xml (this, node);
this.add_child (item);
ret = true;
}
- catch (MediathekVideoItemError error) {
+ catch (VideoItemError error) {
warning ("Error creating video item: %s",
error.message);
}
@@ -106,12 +104,11 @@ public class Rygel.MediathekRssContainer : Rygel.SimpleContainer {
last_modified.to_string(DateFormat.HTTP));
}
- ((MediathekRootContainer) this.parent).session.queue_message (
- message,
- on_feed_got);
+ ((RootContainer) this.parent).session.queue_message (message,
+ on_feed_got);
}
- public MediathekRssContainer (MediaContainer parent, uint id) {
+ public RssContainer (MediaContainer parent, uint id) {
base ("GroupId:%u".printf(id),
parent,
"ZDF Mediathek RSS feed %u".printf (id));
diff --git a/src/plugins/mediathek/rygel-mediathek-video-item.vala b/src/plugins/mediathek/rygel-mediathek-video-item.vala
index c02739d..d04b9b8 100644
--- a/src/plugins/mediathek/rygel-mediathek-video-item.vala
+++ b/src/plugins/mediathek/rygel-mediathek-video-item.vala
@@ -23,12 +23,12 @@
using GLib;
using Xml;
-public errordomain Rygel.MediathekVideoItemError {
+public errordomain Rygel.Mediathek.VideoItemError {
XML_PARSE_ERROR
}
-public class Rygel.MediathekVideoItem : Rygel.MediaItem {
- private MediathekVideoItem (MediaContainer parent, string title) {
+public class Rygel.Mediathek.VideoItem : Rygel.MediaItem {
+ private VideoItem (MediaContainer parent, string title) {
base(Checksum.compute_for_string (ChecksumType.MD5, title),
parent,
title,
@@ -42,43 +42,41 @@ public class Rygel.MediathekVideoItem : Rygel.MediaItem {
return node->ns != null && node->ns->prefix == "media";
}
- public static MediathekAsxPlaylist? handle_content (
- Xml.Node *group)
- throws MediathekVideoItemError {
- MediathekAsxPlaylist asx = null;
+ public static AsxPlaylist? handle_content (Xml.Node *group)
+ throws VideoItemError {
+ AsxPlaylist asx = null;
if (namespace_ok (group)) {
Xml.Attr* attr = group->has_prop ("url");
if (attr != null) {
var url = attr->children->content;
if (url.has_suffix (".asx")) {
try {
- asx = new MediathekAsxPlaylist (url);
+ asx = new AsxPlaylist (url);
asx.parse ();
- } catch (MediathekAsxPlaylistError error) {
+ } catch (AsxPlaylistError error) {
asx = null;
}
}
}
else {
- throw new MediathekVideoItemError.XML_PARSE_ERROR (
+ throw new VideoItemError.XML_PARSE_ERROR (
"group node has no 'url' property");
}
}
else {
- throw new MediathekVideoItemError.XML_PARSE_ERROR (
+ throw new VideoItemError.XML_PARSE_ERROR (
"invalid or no namespace");
}
return asx;
}
- public static MediathekVideoItem create_from_xml(
- MediaContainer parent,
- Xml.Node *item)
- throws MediathekVideoItemError {
+ public static VideoItem create_from_xml (MediaContainer parent,
+ Xml.Node *item)
+ throws VideoItemError {
string title = null;
- MediathekVideoItem video_item = null;
- MediathekAsxPlaylist asx = null;
+ VideoItem video_item = null;
+ AsxPlaylist asx = null;
for (Xml.Node* item_child = item->children;
item_child != null;
@@ -101,7 +99,7 @@ public class Rygel.MediathekVideoItem : Rygel.MediaItem {
else {
var msg = "Invalid or no namespace on group node";
- throw new MediathekVideoItemError.XML_PARSE_ERROR (msg);
+ throw new VideoItemError.XML_PARSE_ERROR (msg);
}
break;
default:
@@ -110,17 +108,17 @@ public class Rygel.MediathekVideoItem : Rygel.MediaItem {
}
if (title == null) {
- throw new MediathekVideoItemError.XML_PARSE_ERROR (
+ throw new VideoItemError.XML_PARSE_ERROR (
"Could not find title");
}
if (asx == null) {
- throw new MediathekVideoItemError.XML_PARSE_ERROR (
+ throw new VideoItemError.XML_PARSE_ERROR (
"Could not find URIs");
}
- video_item = new MediathekVideoItem (parent, title);
+ video_item = new VideoItem (parent, title);
foreach (string uri in asx.uris) {
video_item.add_uri (uri, null);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]