[rygel] media-export: Use nested namespace
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel] media-export: Use nested namespace
- Date: Mon, 7 Jun 2010 14:26:35 +0000 (UTC)
commit 2954454345670d4bc96404ce83b79721858265d9
Author: Jens Georg <mail jensge org>
Date: Fri May 7 19:21:35 2010 +0200
media-export: Use nested namespace
Using nested namespaces instead of name prefixes reduces clutter in code
(long lines etc.) while keeping C name compatibility
.../media-export/rygel-media-export-database.vala | 6 +-
.../rygel-media-export-db-container.vala | 6 +-
.../rygel-media-export-db-object-factory.vala | 24 +++---
.../rygel-media-export-dbus-service.vala | 7 +-
.../rygel-media-export-dummy-container.vala | 2 +-
.../rygel-media-export-dynamic-container.vala | 5 +-
.../rygel-media-export-file-queue-entry.vala | 2 +-
.../media-export/rygel-media-export-harvester.vala | 16 ++--
.../media-export/rygel-media-export-item.vala | 54 +++++-----
.../rygel-media-export-media-cache.vala | 37 ++++----
.../rygel-media-export-metadata-extractor.vala | 12 +-
.../rygel-media-export-object-factory.vala | 16 ++--
.../media-export/rygel-media-export-plugin.vala | 6 +-
.../rygel-media-export-query-container.vala | 14 ++--
.../rygel-media-export-recursive-file-monitor.vala | 4 +-
.../rygel-media-export-root-container.vala | 104 ++++++++++----------
.../rygel-media-export-writable-container.vala | 12 +-
17 files changed, 159 insertions(+), 168 deletions(-)
---
diff --git a/src/plugins/media-export/rygel-media-export-database.vala b/src/plugins/media-export/rygel-media-export-database.vala
index a13f7b7..c447203 100644
--- a/src/plugins/media-export/rygel-media-export-database.vala
+++ b/src/plugins/media-export/rygel-media-export-database.vala
@@ -22,7 +22,7 @@
using Sqlite;
-public errordomain Rygel.DatabaseError {
+public errordomain Rygel.MediaExport.DatabaseError {
IO_ERROR,
SQLITE_ERROR
}
@@ -33,7 +33,7 @@ public errordomain Rygel.DatabaseError {
* It adds statement preparation based on GValue and a cancellable exec
* function.
*/
-internal class Rygel.MediaExportDatabase : Object {
+internal class Rygel.MediaExport.Database : Object {
private Sqlite.Database db;
/**
@@ -49,7 +49,7 @@ internal class Rygel.MediaExportDatabase : Object {
* @param name of the database, used to build full path
* (<cache-dir>/rygel/<name>.db)
*/
- public MediaExportDatabase (string name) throws DatabaseError {
+ public Database (string name) throws DatabaseError {
var dirname = Path.build_filename (Environment.get_user_cache_dir (),
"rygel");
DirUtils.create_with_parents (dirname, 0750);
diff --git a/src/plugins/media-export/rygel-media-export-db-container.vala b/src/plugins/media-export/rygel-media-export-db-container.vala
index 6f3758f..d725c6e 100644
--- a/src/plugins/media-export/rygel-media-export-db-container.vala
+++ b/src/plugins/media-export/rygel-media-export-db-container.vala
@@ -21,10 +21,10 @@
*/
using GUPnP;
-public class Rygel.MediaExportDBContainer : MediaContainer {
- protected MediaExportMediaCache media_db;
+public class Rygel.MediaExport.DBContainer : MediaContainer {
+ protected MediaCache media_db;
- public MediaExportDBContainer (MediaExportMediaCache media_db, string id, string title) {
+ public DBContainer (MediaCache media_db, string id, string title) {
int count;
try {
count = media_db.get_child_count (id);
diff --git a/src/plugins/media-export/rygel-media-export-db-object-factory.vala b/src/plugins/media-export/rygel-media-export-db-object-factory.vala
index ef6e81d..d0f8a6b 100644
--- a/src/plugins/media-export/rygel-media-export-db-object-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-db-object-factory.vala
@@ -32,7 +32,7 @@
* MediaDB is holding a reference to the factory; this is done to
* prevent circular references
*/
-public class Rygel.MediaExportDBObjectFactory : Object {
+public class Rygel.MediaExport.DBObjectFactory : Object {
/**
* Return a new instance of DatabaseBackedMediaContainer
*
@@ -41,11 +41,11 @@ public class Rygel.MediaExportDBObjectFactory : Object {
* @param child_count number of children in the container
*/
public virtual MediaContainer get_container (
- MediaExportMediaCache media_db,
- string id,
- string title,
- uint child_count) {
- return new MediaExportDBContainer (media_db, id, title);
+ MediaCache media_db,
+ string id,
+ string title,
+ uint child_count) {
+ return new DBContainer (media_db, id, title);
}
/**
@@ -56,11 +56,11 @@ public class Rygel.MediaExportDBObjectFactory : Object {
* @param title title of the item
* @param upnp_class upnp_class of the item
*/
- public virtual MediaItem get_item (MediaExportMediaCache media_db,
- MediaContainer parent,
- string id,
- string title,
- string upnp_class) {
- return new MediaItem (id, parent, title, upnp_class);
+ public virtual Rygel.MediaItem get_item (MediaCache media_db,
+ MediaContainer parent,
+ string id,
+ string title,
+ string upnp_class) {
+ return new Rygel.MediaItem (id, parent, title, upnp_class);
}
}
diff --git a/src/plugins/media-export/rygel-media-export-dbus-service.vala b/src/plugins/media-export/rygel-media-export-dbus-service.vala
index c93fc04..5dade8f 100644
--- a/src/plugins/media-export/rygel-media-export-dbus-service.vala
+++ b/src/plugins/media-export/rygel-media-export-dbus-service.vala
@@ -19,14 +19,13 @@
*/
[DBus (name = "org.gnome.Rygel.MediaExport1")]
-public class Rygel.MediaExportDBusService : Object {
+public class Rygel.MediaExport.DBusService : Object {
private const string RYGEL_MEDIA_EXPORT_PATH =
"/org/gnome/Rygel/MediaExport1";
- private MediaExportRootContainer root_container;
+ private RootContainer root_container;
- public MediaExportDBusService (MediaExportRootContainer root_container)
- throws GLib.Error {
+ public DBusService (RootContainer root_container) throws GLib.Error {
this.root_container = root_container;
try {
diff --git a/src/plugins/media-export/rygel-media-export-dummy-container.vala b/src/plugins/media-export/rygel-media-export-dummy-container.vala
index d69caa0..8510393 100644
--- a/src/plugins/media-export/rygel-media-export-dummy-container.vala
+++ b/src/plugins/media-export/rygel-media-export-dummy-container.vala
@@ -19,7 +19,7 @@
*/
using Gee;
-internal class Rygel.DummyContainer : NullContainer {
+internal class Rygel.MediaExport.DummyContainer : NullContainer {
public File file;
public ArrayList<string> seen_children;
diff --git a/src/plugins/media-export/rygel-media-export-dynamic-container.vala b/src/plugins/media-export/rygel-media-export-dynamic-container.vala
index 6843e15..70ddb21 100644
--- a/src/plugins/media-export/rygel-media-export-dynamic-container.vala
+++ b/src/plugins/media-export/rygel-media-export-dynamic-container.vala
@@ -19,11 +19,10 @@
*/
using Gee;
-internal class Rygel.MediaExportDynamicContainer : Rygel.MediaExportDBContainer {
+internal class Rygel.MediaExport.DynamicContainer : Rygel.MediaExport.DBContainer {
public const string ID = "DynamicContainerId";
- public MediaExportDynamicContainer (MediaExportMediaCache media_db,
- MediaContainer parent) {
+ public DynamicContainer (MediaCache media_db, MediaContainer parent) {
base (media_db, ID, "Dynamic");
this.parent = parent;
}
diff --git a/src/plugins/media-export/rygel-media-export-file-queue-entry.vala b/src/plugins/media-export/rygel-media-export-file-queue-entry.vala
index c838aab..ab6c05f 100644
--- a/src/plugins/media-export/rygel-media-export-file-queue-entry.vala
+++ b/src/plugins/media-export/rygel-media-export-file-queue-entry.vala
@@ -18,7 +18,7 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-internal class Rygel.FileQueueEntry {
+internal class Rygel.MediaExport.FileQueueEntry {
public File file;
public bool update;
diff --git a/src/plugins/media-export/rygel-media-export-harvester.vala b/src/plugins/media-export/rygel-media-export-harvester.vala
index 1523845..4aca51c 100644
--- a/src/plugins/media-export/rygel-media-export-harvester.vala
+++ b/src/plugins/media-export/rygel-media-export-harvester.vala
@@ -21,14 +21,14 @@
using GLib;
using Gee;
-public class Rygel.MediaExportHarvester : GLib.Object {
- private MediaExportMetadataExtractor extractor;
- private MediaExportMediaCache media_db;
+public class Rygel.MediaExport.Harvester : GLib.Object {
+ private MetadataExtractor extractor;
+ private MediaCache media_db;
private GLib.Queue<MediaContainer> containers;
private GLib.Queue<FileQueueEntry?> files;
private File origin;
private MediaContainer parent;
- private MediaExportRecursiveFileMonitor monitor;
+ private RecursiveFileMonitor monitor;
public Cancellable cancellable;
private const string HARVESTER_ATTRIBUTES =
FILE_ATTRIBUTE_STANDARD_NAME + "," +
@@ -37,10 +37,10 @@ public class Rygel.MediaExportHarvester : GLib.Object {
FILE_ATTRIBUTE_STANDARD_SIZE;
- public MediaExportHarvester (MediaContainer parent,
- MediaExportMediaCache media_db,
- MediaExportMetadataExtractor extractor,
- MediaExportRecursiveFileMonitor monitor) {
+ public Harvester (MediaContainer parent,
+ MediaCache media_db,
+ MetadataExtractor extractor,
+ RecursiveFileMonitor monitor) {
this.parent = parent;
this.extractor = extractor;
this.media_db = media_db;
diff --git a/src/plugins/media-export/rygel-media-export-item.vala b/src/plugins/media-export/rygel-media-export-item.vala
index 1f9b0de..a7cfd28 100644
--- a/src/plugins/media-export/rygel-media-export-item.vala
+++ b/src/plugins/media-export/rygel-media-export-item.vala
@@ -27,16 +27,14 @@ using Gst;
/**
* Represents MediaExport item.
*/
-public class Rygel.MediaExportItem : Rygel.MediaItem {
- private const string TAG_WIDTH =
- MediaExportMetadataExtractor.TAG_RYGEL_WIDTH;
- private const string TAG_HEIGHT =
- MediaExportMetadataExtractor.TAG_RYGEL_HEIGHT;
- private const string TAG_DURATION =
- MediaExportMetadataExtractor.TAG_RYGEL_DURATION;
+public class Rygel.MediaExport.MediaExportItem : Rygel.MediaItem {
+ private const string TAG_WIDTH = MetadataExtractor.TAG_RYGEL_WIDTH;
+ private const string TAG_HEIGHT = MetadataExtractor.TAG_RYGEL_HEIGHT;
+ private const string TAG_DURATION = MetadataExtractor.TAG_RYGEL_DURATION;
+
public MediaExportItem (MediaContainer parent,
- File file,
- FileInfo info) {
+ File file,
+ FileInfo info) {
string content_type = info.get_content_type ();
string item_class = null;
string id = Checksum.compute_for_string (ChecksumType.MD5,
@@ -46,15 +44,15 @@ public class Rygel.MediaExportItem : Rygel.MediaItem {
// when it's ready
if (content_type.has_prefix ("video/")) {
- item_class = MediaItem.VIDEO_CLASS;
+ item_class = Rygel.MediaItem.VIDEO_CLASS;
} else if (content_type.has_prefix ("audio/")) {
- item_class = MediaItem.AUDIO_CLASS;
+ item_class = Rygel.MediaItem.AUDIO_CLASS;
} else if (content_type.has_prefix ("image/")) {
- item_class = MediaItem.PHOTO_CLASS;
+ item_class = Rygel.MediaItem.PHOTO_CLASS;
}
if (item_class == null) {
- item_class = MediaItem.AUDIO_CLASS;
+ item_class = Rygel.MediaItem.AUDIO_CLASS;
warning (_("Failed to detect UPnP class for '%s', assuming '%s'"),
file.get_uri (),
item_class);
@@ -66,7 +64,7 @@ public class Rygel.MediaExportItem : Rygel.MediaItem {
this.add_uri (file.get_uri (), null);
}
- public static MediaItem? create_from_taglist (MediaContainer parent,
+ public static MediaExportItem? create_from_taglist (MediaContainer parent,
File file,
Gst.TagList tag_list) {
string id = Checksum.compute_for_string (ChecksumType.MD5,
@@ -82,7 +80,7 @@ public class Rygel.MediaExportItem : Rygel.MediaItem {
if (!tag_list.get_string (TAG_AUDIO_CODEC, out codec)) {
if (tag_list.get_int (TAG_WIDTH, out width) ||
tag_list.get_int (TAG_HEIGHT, out height)) {
- class_guessed = MediaItem.PHOTO_CLASS;
+ class_guessed = Rygel.MediaItem.PHOTO_CLASS;
} else {
// if it has width and height and a duration, assume
// it is a video (to capture the MPEG TS without audio
@@ -90,7 +88,7 @@ public class Rygel.MediaExportItem : Rygel.MediaItem {
int64 duration;
if (tag_list.get_int64 (TAG_DURATION,
out duration)) {
- class_guessed = MediaItem.VIDEO_CLASS;
+ class_guessed = Rygel.MediaItem.VIDEO_CLASS;
} else {
warning(_("File '%s' is of unknown format/type."),
file.get_uri ());
@@ -104,13 +102,13 @@ public class Rygel.MediaExportItem : Rygel.MediaItem {
// well
if (tag_list.get_int (TAG_WIDTH, out width) ||
tag_list.get_int (TAG_HEIGHT, out height)) {
- class_guessed = MediaItem.VIDEO_CLASS;
+ class_guessed = Rygel.MediaItem.VIDEO_CLASS;
} else {
- class_guessed = MediaItem.AUDIO_CLASS;
+ class_guessed = Rygel.MediaItem.AUDIO_CLASS;
}
}
} else {
- class_guessed = MediaItem.VIDEO_CLASS;
+ class_guessed = Rygel.MediaItem.VIDEO_CLASS;
}
} else {
// throw error. Taglist can't be empty
@@ -132,8 +130,8 @@ public class Rygel.MediaExportItem : Rygel.MediaItem {
Gst.TagList tag_list,
string upnp_class) {
string title = null;
- if (upnp_class == MediaItem.AUDIO_CLASS ||
- upnp_class == MediaItem.MUSIC_CLASS) {
+ if (upnp_class == Rygel.MediaItem.AUDIO_CLASS ||
+ upnp_class == Rygel.MediaItem.MUSIC_CLASS) {
if (!tag_list.get_string (TAG_TITLE, out title)) {
title = file.get_basename ();
@@ -146,14 +144,14 @@ public class Rygel.MediaExportItem : Rygel.MediaItem {
tag_list.get_int (TAG_WIDTH, out this.width);
tag_list.get_int (TAG_HEIGHT, out this.height);
- tag_list.get_int (MediaExportMetadataExtractor.TAG_RYGEL_DEPTH,
+ tag_list.get_int (MetadataExtractor.TAG_RYGEL_DEPTH,
out this.color_depth);
int64 duration;
- tag_list.get_int64 (MediaExportMetadataExtractor.TAG_RYGEL_DURATION,
+ tag_list.get_int64 (MetadataExtractor.TAG_RYGEL_DURATION,
out duration);
this.duration = (duration == -1) ? -1 : (long) (duration / 1000000000);
- tag_list.get_int (MediaExportMetadataExtractor.TAG_RYGEL_CHANNELS,
+ tag_list.get_int (MetadataExtractor.TAG_RYGEL_CHANNELS,
out this.n_audio_channels);
tag_list.get_string (TAG_ARTIST, out this.author);
@@ -164,17 +162,17 @@ public class Rygel.MediaExportItem : Rygel.MediaItem {
this.track_number = (int) tmp;
tag_list.get_uint (TAG_BITRATE, out tmp);
this.bitrate = (int) tmp / 8;
- tag_list.get_int (MediaExportMetadataExtractor.TAG_RYGEL_RATE,
+ tag_list.get_int (MetadataExtractor.TAG_RYGEL_RATE,
out this.sample_freq);
int64 size;
- tag_list.get_int64 (MediaExportMetadataExtractor.TAG_RYGEL_SIZE,
+ tag_list.get_int64 (MetadataExtractor.TAG_RYGEL_SIZE,
out size);
this.size = (long) size;
uint64 mtime;
- tag_list.get_uint64 (MediaExportMetadataExtractor.TAG_RYGEL_MTIME,
+ tag_list.get_uint64 (MetadataExtractor.TAG_RYGEL_MTIME,
out mtime);
this.modified = (int64) mtime;
@@ -189,7 +187,7 @@ public class Rygel.MediaExportItem : Rygel.MediaItem {
}
- tag_list.get_string (MediaExportMetadataExtractor.TAG_RYGEL_MIME,
+ tag_list.get_string (MetadataExtractor.TAG_RYGEL_MIME,
out this.mime_type);
this.add_uri (file.get_uri (), null);
diff --git a/src/plugins/media-export/rygel-media-export-media-cache.vala b/src/plugins/media-export/rygel-media-export-media-cache.vala
index 41e5b06..d698353 100644
--- a/src/plugins/media-export/rygel-media-export-media-cache.vala
+++ b/src/plugins/media-export/rygel-media-export-media-cache.vala
@@ -42,9 +42,9 @@ public enum Rygel.MediaDBObjectType {
*
* MediaExportDB is a sqlite3 backed persistent storage of media objects
*/
-public class Rygel.MediaExportMediaCache : Object {
- private MediaExportDatabase db;
- private MediaExportDBObjectFactory factory;
+public class Rygel.MediaExport.MediaCache : Object {
+ private Database db;
+ private DBObjectFactory factory;
private const string schema_version = "5";
private const string CREATE_META_DATA_TABLE_STRING =
"CREATE TABLE meta_data (size INTEGER NOT NULL, " +
@@ -85,7 +85,7 @@ public class Rygel.MediaExportMediaCache : Object {
"INSERT INTO object_type (id, desc) VALUES (0, 'Container'); " +
"INSERT INTO object_type (id, desc) VALUES (1, 'Item'); " +
"INSERT INTO schema_info (version) VALUES ('" +
- MediaExportMediaCache.schema_version + "'); ";
+ MediaCache.schema_version + "'); ";
private const string CREATE_CLOSURE_TABLE =
"CREATE TABLE closure (ancestor TEXT, descendant TEXT, depth INTEGER)";
@@ -279,7 +279,7 @@ public class Rygel.MediaExportMediaCache : Object {
}
}
- public void save_item (MediaItem item) throws Error {
+ public void save_item (Rygel.MediaItem item) throws Error {
try {
db.begin ();
save_metadata (item);
@@ -303,7 +303,7 @@ public class Rygel.MediaExportMediaCache : Object {
db.begin ();
remove_uris (object);
if (object is MediaItem) {
- save_metadata (object as MediaItem);
+ save_metadata (object as Rygel.MediaItem);
}
update_object_internal (object);
save_uris (object);
@@ -328,7 +328,7 @@ public class Rygel.MediaExportMediaCache : Object {
GLib.Value[] values = { object_id };
MediaObject parent = null;
- MediaExportDatabase.RowCallback cb = (statement) => {
+ Database.RowCallback cb = (statement) => {
var parent_container = parent as MediaContainer;
var object = get_object_from_statement (parent_container,
statement.column_text (18),
@@ -413,7 +413,7 @@ public class Rygel.MediaExportMediaCache : Object {
GLib.Value[] values = { container_id,
(int64) offset,
(int64) max_count };
- MediaExportDatabase.RowCallback callback = (statement) => {
+ Database.RowCallback callback = (statement) => {
var child_id = statement.column_text (17);
children.add (get_object_from_statement (parent,
child_id,
@@ -482,7 +482,7 @@ public class Rygel.MediaExportMediaCache : Object {
debug ("Parameters to bind: %u", args.n_values);
- MediaExportDatabase.RowCallback callback = (statement) => {
+ Database.RowCallback callback = (statement) => {
var child_id = statement.column_text (17);
var parent_id = statement.column_text (18);
try {
@@ -514,21 +514,20 @@ public class Rygel.MediaExportMediaCache : Object {
return children;
}
- public MediaExportMediaCache (string name) throws Error {
+ public MediaCache (string name) throws Error {
this.open_db (name);
- this.factory = new MediaExportDBObjectFactory ();
+ this.factory = new DBObjectFactory ();
}
- public MediaExportMediaCache.with_factory (
- string name,
- MediaExportDBObjectFactory factory)
- throws Error {
+ public MediaCache.with_factory (string name,
+ DBObjectFactory factory)
+ throws Error {
this.open_db (name);
this.factory = factory;
}
private void open_db (string name) throws Error {
- this.db = new MediaExportDatabase (name);
+ this.db = new Database (name);
int old_version = -1;
try {
@@ -720,7 +719,7 @@ public class Rygel.MediaExportMediaCache : Object {
this.db.exec (DELETE_URI_STRING, values);
}
- private void save_metadata (MediaItem item) throws Error {
+ private void save_metadata (Rygel.MediaItem item) throws Error {
GLib.Value[] values = { item.size,
item.mime_type,
item.width,
@@ -749,7 +748,7 @@ public class Rygel.MediaExportMediaCache : Object {
}
if (item.parent == null) {
- parent = MediaExportDatabase null ();
+ parent = Database null ();
} else {
parent = item.parent.id;
}
@@ -1036,7 +1035,7 @@ public class Rygel.MediaExportMediaCache : Object {
args.append (v);
var data = new ArrayList<string> ();
- MediaExportDatabase.RowCallback callback = (statement) => {
+ Database.RowCallback callback = (statement) => {
data.add (statement.column_text (0));
return true;
diff --git a/src/plugins/media-export/rygel-media-export-metadata-extractor.vala b/src/plugins/media-export/rygel-media-export-metadata-extractor.vala
index 13b7512..85a0846 100644
--- a/src/plugins/media-export/rygel-media-export-metadata-extractor.vala
+++ b/src/plugins/media-export/rygel-media-export-metadata-extractor.vala
@@ -40,7 +40,7 @@ private enum Gst.StreamType {
* uri property, it will extact the metadata for you and emit signal
* metadata_available for each key/value pair extracted.
*/
-public class Rygel.MediaExportMetadataExtractor: GLib.Object {
+public class Rygel.MediaExport.MetadataExtractor: GLib.Object {
public const string TAG_RYGEL_SIZE = "rygel-size";
public const string TAG_RYGEL_DURATION = "rygel-duration";
public const string TAG_RYGEL_MIME = "rygel-mime";
@@ -104,8 +104,8 @@ public class Rygel.MediaExportMetadataExtractor: GLib.Object {
bus.message["error"] += this.error_cb;
}
- public static MediaExportMetadataExtractor? create() {
- if (MediaExportMetadataExtractor.factory == null) {
+ public static MetadataExtractor? create() {
+ if (factory == null) {
debug ("Checking for gstreamer element 'playbin'...");
var factory = ElementFactory.find("playbin2");
if (factory != null) {
@@ -122,13 +122,13 @@ public class Rygel.MediaExportMetadataExtractor: GLib.Object {
return null;
}
}
- MediaExportMetadataExtractor.factory = factory;
+ MetadataExtractor.factory = factory;
}
- return new MediaExportMetadataExtractor ();
+ return new MetadataExtractor ();
}
- MediaExportMetadataExtractor () {
+ private MetadataExtractor () {
this.register_custom_tag (TAG_RYGEL_SIZE, typeof (int64));
this.register_custom_tag (TAG_RYGEL_DURATION, typeof (int64));
this.register_custom_tag (TAG_RYGEL_MIME, typeof (string));
diff --git a/src/plugins/media-export/rygel-media-export-object-factory.vala b/src/plugins/media-export/rygel-media-export-object-factory.vala
index 6bd89bb..9eb236a 100644
--- a/src/plugins/media-export/rygel-media-export-object-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-object-factory.vala
@@ -20,16 +20,16 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-internal class Rygel.MediaExportObjectFactory : MediaExportDBObjectFactory {
+internal class Rygel.MediaExport.ObjectFactory : DBObjectFactory {
public override MediaContainer get_container (
- MediaExportMediaCache media_db,
- string id,
- string title,
- uint child_count) {
- if (id.has_prefix (MediaExportQueryContainer.PREFIX)) {
- return new MediaExportQueryContainer (media_db, id, title);
+ MediaCache media_db,
+ string id,
+ string title,
+ uint child_count) {
+ if (id.has_prefix (QueryContainer.PREFIX)) {
+ return new QueryContainer (media_db, id, title);
} else {
- return new MediaExportWritableContainer (media_db, id, title);
+ return new WritableContainer (media_db, id, title);
}
}
}
diff --git a/src/plugins/media-export/rygel-media-export-plugin.vala b/src/plugins/media-export/rygel-media-export-plugin.vala
index db27d5d..5a9d0a8 100644
--- a/src/plugins/media-export/rygel-media-export-plugin.vala
+++ b/src/plugins/media-export/rygel-media-export-plugin.vala
@@ -31,12 +31,12 @@ using GLib;
public void module_init (PluginLoader loader) {
var plugin = new Plugin.MediaServer ("MediaExport",
_("@REALNAME@'s media"),
- typeof (Rygel.MediaExportContentDir));
+ typeof (Rygel.MediaExport.ContentDir));
loader.add_plugin (plugin);
}
-public class Rygel.MediaExportContentDir : ContentDirectory {
+public class Rygel.MediaExport.ContentDir : ContentDirectory {
public override MediaContainer? create_root_container () {
- return MediaExportRootContainer.get_instance ();
+ return RootContainer.get_instance ();
}
}
diff --git a/src/plugins/media-export/rygel-media-export-query-container.vala b/src/plugins/media-export/rygel-media-export-query-container.vala
index 2476efc..3a14a7a 100644
--- a/src/plugins/media-export/rygel-media-export-query-container.vala
+++ b/src/plugins/media-export/rygel-media-export-query-container.vala
@@ -21,7 +21,7 @@
using Gee;
using GUPnP;
-internal class Rygel.MediaExportQueryContainer : Rygel.MediaExportDBContainer {
+internal class Rygel.MediaExport.QueryContainer : DBContainer {
public static const string PREFIX = "virtual-container:";
private string attribute;
private SearchExpression expression;
@@ -66,9 +66,9 @@ internal class Rygel.MediaExportQueryContainer : Rygel.MediaExportDBContainer {
return true;
}
- public MediaExportQueryContainer (MediaExportMediaCache media_db,
- string id,
- string name = "") {
+ public QueryContainer (MediaCache media_db,
+ string id,
+ string name = "") {
// parse the id
// Following the schema:
// virtual-folder:<class>,? -> get all of that class (eg. Albums)
@@ -213,9 +213,9 @@ internal class Rygel.MediaExportQueryContainer : Rygel.MediaExportDBContainer {
// contain '%' chars which will makes sprintf crash
new_id = this.pattern.replace ("%s", new_id);
register_id (ref new_id);
- var container = new MediaExportQueryContainer (this.media_db,
- new_id,
- meta_data);
+ var container = new QueryContainer (this.media_db,
+ new_id,
+ meta_data);
children.add (container);
}
}
diff --git a/src/plugins/media-export/rygel-media-export-recursive-file-monitor.vala b/src/plugins/media-export/rygel-media-export-recursive-file-monitor.vala
index 447b943..28d290a 100644
--- a/src/plugins/media-export/rygel-media-export-recursive-file-monitor.vala
+++ b/src/plugins/media-export/rygel-media-export-recursive-file-monitor.vala
@@ -22,11 +22,11 @@
using Gee;
using Rygel;
-public class Rygel.MediaExportRecursiveFileMonitor : Object {
+public class Rygel.MediaExport.RecursiveFileMonitor : Object {
private Cancellable cancellable;
HashMap<File, FileMonitor> monitors;
- public MediaExportRecursiveFileMonitor (Cancellable? cancellable) {
+ public RecursiveFileMonitor (Cancellable? cancellable) {
this.cancellable = cancellable;
this.monitors = new HashMap<File, FileMonitor> (GLib.file_hash,
GLib.file_equal);
diff --git a/src/plugins/media-export/rygel-media-export-root-container.vala b/src/plugins/media-export/rygel-media-export-root-container.vala
index e997124..d123e63 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -24,13 +24,13 @@ using GUPnP;
/**
* Represents the root container.
*/
-public class Rygel.MediaExportRootContainer : Rygel.MediaExportDBContainer {
- private MediaExportMetadataExtractor extractor;
- private HashMap<File, MediaExportHarvester> harvester;
- private MediaExportRecursiveFileMonitor monitor;
- private MediaExportDBusService service;
- private MediaExportDynamicContainer dynamic_elements;
- private Gee.List<MediaExportHarvester> harvester_trash;
+public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
+ private MetadataExtractor extractor;
+ private HashMap<File, Harvester> harvester;
+ private RecursiveFileMonitor monitor;
+ private DBusService service;
+ private DynamicContainer dynamic_elements;
+ private Gee.List<Harvester> harvester_trash;
private static MediaContainer instance = null;
@@ -68,17 +68,16 @@ public class Rygel.MediaExportRootContainer : Rygel.MediaExportDBContainer {
}
public static MediaContainer get_instance() {
- if (MediaExportRootContainer.instance == null) {
+ if (RootContainer.instance == null) {
try {
- MediaExportRootContainer.instance =
- new MediaExportRootContainer ();
+ RootContainer.instance = new RootContainer ();
} catch (Error error) {
warning(_("Failed to create instance of database"));
- MediaExportRootContainer.instance = new NullContainer ();
+ RootContainer.instance = new NullContainer ();
}
}
- return MediaExportRootContainer.instance;
+ return RootContainer.instance;
}
public void add_uri (string uri) {
@@ -98,26 +97,26 @@ public class Rygel.MediaExportRootContainer : Rygel.MediaExportDBContainer {
}
}
- private MediaExportQueryContainer? search_to_virtual_container (
+ private QueryContainer? search_to_virtual_container (
RelationalExpression expression) {
if (expression.operand1 == "upnp:class" &&
expression.op == SearchCriteriaOp.EQ) {
switch (expression.operand2) {
case "object.container.album.musicAlbum":
string id = "virtual-container:upnp:album,?";
- MediaExportQueryContainer.register_id (ref id);
+ QueryContainer.register_id (ref id);
- return new MediaExportQueryContainer (this.media_db,
- id,
- _("Albums"));
+ return new QueryContainer (this.media_db,
+ id,
+ _("Albums"));
case "object.container.person.musicArtist":
string id = "virtual-container:dc:creator,?,upnp:album,?";
- MediaExportQueryContainer.register_id (ref id);
+ QueryContainer.register_id (ref id);
- return new MediaExportQueryContainer (this.media_db,
- id,
- _("Artists"));
+ return new QueryContainer (this.media_db,
+ id,
+ _("Artists"));
default:
return null;
}
@@ -165,7 +164,7 @@ public class Rygel.MediaExportRootContainer : Rygel.MediaExportDBContainer {
SearchExpression expression,
out MediaContainer container) {
RelationalExpression virtual_expression = null;
- MediaExportQueryContainer query_container;
+ QueryContainer query_container;
if (!(expression is LogicalExpression)) {
return false;
@@ -196,19 +195,19 @@ public class Rygel.MediaExportRootContainer : Rygel.MediaExportDBContainer {
}
var last_argument = query_container.plaintext_id.replace (
- MediaExportQueryContainer.PREFIX,
+ QueryContainer.PREFIX,
"");
var escaped_detail = Uri.escape_string (virtual_expression.operand2,
"",
true);
- var new_id = "%s%s,%s,%s".printf (MediaExportQueryContainer.PREFIX,
+ var new_id = "%s%s,%s,%s".printf (QueryContainer.PREFIX,
virtual_expression.operand1,
escaped_detail,
last_argument);
- MediaExportQueryContainer.register_id (ref new_id);
- container = new MediaExportQueryContainer (this.media_db, new_id);
+ QueryContainer.register_id (ref new_id);
+ container = new QueryContainer (this.media_db, new_id);
return true;
}
@@ -226,9 +225,8 @@ public class Rygel.MediaExportRootContainer : Rygel.MediaExportDBContainer {
string upnp_class = null;
if (is_find_object (expression, out id) &&
- id.has_prefix (MediaExportQueryContainer.PREFIX)) {
- query_container = new MediaExportQueryContainer (this.media_db,
- id);
+ id.has_prefix (QueryContainer.PREFIX)) {
+ query_container = new QueryContainer (this.media_db, id);
query_container.parent = this;
list = new ArrayList<MediaObject> ();
@@ -282,29 +280,27 @@ public class Rygel.MediaExportRootContainer : Rygel.MediaExportDBContainer {
/**
* Create a new root container.
*/
- private MediaExportRootContainer () throws Error {
- var object_factory = new MediaExportObjectFactory ();
- var db = new MediaExportMediaCache.with_factory ("media-export",
- object_factory);
+ private RootContainer () throws Error {
+ var object_factory = new ObjectFactory ();
+ var db = new MediaCache.with_factory ("media-export", object_factory);
base (db, "0", "MediaExportRoot");
- this.extractor = MediaExportMetadataExtractor.create ();
+ this.extractor = MetadataExtractor.create ();
- this.harvester = new HashMap<File, MediaExportHarvester> (file_hash,
- file_equal);
- this.harvester_trash = new ArrayList<MediaExportHarvester> ();
+ this.harvester = new HashMap<File, Harvester> (file_hash, file_equal);
+ this.harvester_trash = new ArrayList<Harvester> ();
- this.monitor = new MediaExportRecursiveFileMonitor (null);
+ this.monitor = new RecursiveFileMonitor (null);
this.monitor.changed.connect (this.on_file_changed);
try {
- this.service = new MediaExportDBusService (this);
+ this.service = new DBusService (this);
} catch (Error err) {
warning (_("Failed to create MediaExport DBus service: %s"),
err.message);
}
- this.dynamic_elements = new MediaExportDynamicContainer (db, this);
+ this.dynamic_elements = new DynamicContainer (db, this);
try {
int64 timestamp;
@@ -342,15 +338,15 @@ public class Rygel.MediaExportRootContainer : Rygel.MediaExportDBContainer {
"virtual-folders");
foreach (var container in virtual_containers) {
var info = container.split ("=");
- var id = MediaExportQueryContainer.PREFIX + info[1];
- if (!MediaExportQueryContainer.validate_virtual_id (id)) {
+ var id = QueryContainer.PREFIX + info[1];
+ if (!QueryContainer.validate_virtual_id (id)) {
warning (_("%s is not a valid virtual ID"), id);
continue;
}
- MediaExportQueryContainer.register_id (ref id);
+ QueryContainer.register_id (ref id);
- var virtual_container = new MediaExportQueryContainer (
+ var virtual_container = new QueryContainer (
this.media_db,
id,
info[0]);
@@ -367,7 +363,7 @@ public class Rygel.MediaExportRootContainer : Rygel.MediaExportDBContainer {
}
foreach (var id in ids) {
- if (id == MediaExportDynamicContainer.ID) {
+ if (id == DynamicContainer.ID) {
continue;
}
@@ -382,15 +378,15 @@ public class Rygel.MediaExportRootContainer : Rygel.MediaExportDBContainer {
this.updated ();
}
- private void on_file_harvested (MediaExportHarvester harvester,
- File file) {
+ private void on_file_harvested (Harvester harvester,
+ File file) {
message (_("'%s' harvested"), file.get_uri ());
this.harvester.remove (file);
}
- private void on_remove_cancelled_harvester (MediaExportHarvester harvester,
- File file) {
+ private void on_remove_cancelled_harvester (Harvester harvester,
+ File file) {
this.harvester_trash.remove (harvester);
}
@@ -410,10 +406,10 @@ public class Rygel.MediaExportRootContainer : Rygel.MediaExportDBContainer {
this.harvester_trash.add (harvester);
}
- var harvester = new MediaExportHarvester (parent,
- this.media_db,
- this.extractor,
- this.monitor);
+ var harvester = new Harvester (parent,
+ this.media_db,
+ this.extractor,
+ this.monitor);
harvester.harvested.connect (this.on_file_harvested);
this.harvester[file] = harvester;
harvester.harvest (file);
@@ -437,7 +433,7 @@ public class Rygel.MediaExportRootContainer : Rygel.MediaExportDBContainer {
assert (parent_container != null);
this.harvest (file, parent_container);
- } catch (Rygel.DatabaseError error) {
+ } catch (DatabaseError error) {
warning (_("Error fetching object '%s' from database: %s"),
id,
error.message);
diff --git a/src/plugins/media-export/rygel-media-export-writable-container.vala b/src/plugins/media-export/rygel-media-export-writable-container.vala
index 8658402..8544b71 100644
--- a/src/plugins/media-export/rygel-media-export-writable-container.vala
+++ b/src/plugins/media-export/rygel-media-export-writable-container.vala
@@ -22,15 +22,15 @@
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
-internal class Rygel.MediaExportWritableContainer : MediaExportDBContainer {
- public MediaExportWritableContainer (MediaExportMediaCache media_db,
- string id,
- string title) {
+internal class Rygel.MediaExport.WritableContainer : DBContainer {
+ public WritableContainer (MediaCache media_db,
+ string id,
+ string title) {
base (media_db, id, title);
}
- public override async void add_item (MediaItem item,
- Cancellable? cancellable)
+ public override async void add_item (Rygel.MediaItem item,
+ Cancellable? cancellable)
throws Error {
yield base.add_item (item, cancellable);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]