[rygel/wip/update-object] media-export: Allow updating of items via UPnP



commit c7d36149cea83f0aa2af42c13c9c377723e484df
Author: Jens Georg <jensg openismus com>
Date:   Tue Oct 23 23:11:48 2012 +0200

    media-export: Allow updating of items via UPnP

 src/plugins/media-export/Makefile.am               |    2 +
 .../rygel-media-export-music-item.vala             |    9 ++++-
 .../rygel-media-export-object-factory.vala         |    8 ++--
 .../rygel-media-export-photo-item.vala             |   37 ++++++++++++++++++++
 .../rygel-media-export-root-container.vala         |    4 +-
 .../rygel-media-export-video-item.vala             |   37 ++++++++++++++++++++
 .../rygel-media-export-writable-db-container.vala  |    8 ++--
 7 files changed, 94 insertions(+), 11 deletions(-)
---
diff --git a/src/plugins/media-export/Makefile.am b/src/plugins/media-export/Makefile.am
index 36d0b7f..3294d1f 100644
--- a/src/plugins/media-export/Makefile.am
+++ b/src/plugins/media-export/Makefile.am
@@ -37,6 +37,8 @@ librygel_media_export_la_SOURCES = \
 	rygel-media-export-object-factory.vala \
 	rygel-media-export-writable-db-container.vala \
 	rygel-media-export-music-item.vala \
+	rygel-media-export-video-item.vala \
+	rygel-media-export-photo-item.vala \
 	rygel-media-export-collate.c
 
 librygel_media_export_la_VALAFLAGS = \
diff --git a/src/plugins/media-export/rygel-media-export-music-item.vala b/src/plugins/media-export/rygel-media-export-music-item.vala
index 27f9db8..4d27b9a 100644
--- a/src/plugins/media-export/rygel-media-export-music-item.vala
+++ b/src/plugins/media-export/rygel-media-export-music-item.vala
@@ -24,7 +24,8 @@
  * Own MusicItem class to provide disc number inside music item for sorting
  * and metadata extraction.
  */
-internal class Rygel.MediaExport.MusicItem : Rygel.MusicItem {
+internal class Rygel.MediaExport.MusicItem : Rygel.MusicItem,
+                                             Rygel.UpdatableObject {
     public int disc;
 
     public MusicItem (string         id,
@@ -33,4 +34,10 @@ internal class Rygel.MediaExport.MusicItem : Rygel.MusicItem {
                       string         upnp_class = Rygel.MusicItem.UPNP_CLASS) {
         base (id, parent, title, upnp_class);
     }
+
+    public async void commit () throws Error {
+        var cache = MediaCache.get_default ();
+        cache.save_item (this);
+    }
+
 }
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 7a5b59b..5be14bd 100644
--- a/src/plugins/media-export/rygel-media-export-object-factory.vala
+++ b/src/plugins/media-export/rygel-media-export-object-factory.vala
@@ -77,12 +77,12 @@ internal class Rygel.MediaExport.ObjectFactory : Object {
                                        string         upnp_class) {
         switch (upnp_class) {
             case Rygel.MusicItem.UPNP_CLASS:
-            case AudioItem.UPNP_CLASS:
+            case Rygel.AudioItem.UPNP_CLASS:
                 return new MusicItem (id, parent, title);
-            case VideoItem.UPNP_CLASS:
+            case Rygel.VideoItem.UPNP_CLASS:
                 return new VideoItem (id, parent, title);
-            case PhotoItem.UPNP_CLASS:
-            case ImageItem.UPNP_CLASS:
+            case Rygel.PhotoItem.UPNP_CLASS:
+            case Rygel.ImageItem.UPNP_CLASS:
                 return new PhotoItem (id, parent, title);
             default:
                 assert_not_reached ();
diff --git a/src/plugins/media-export/rygel-media-export-photo-item.vala b/src/plugins/media-export/rygel-media-export-photo-item.vala
new file mode 100644
index 0000000..d6e938f
--- /dev/null
+++ b/src/plugins/media-export/rygel-media-export-photo-item.vala
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * Author: Jens Georg <jensg openismus 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.
+ */
+
+internal class Rygel.MediaExport.PhotoItem : Rygel.PhotoItem,
+                                             Rygel.UpdatableObject {
+    public PhotoItem (string         id,
+                      MediaContainer parent,
+                      string         title,
+                      string         upnp_class = Rygel.PhotoItem.UPNP_CLASS) {
+        base (id, parent, title, upnp_class);
+    }
+
+    public async void commit () throws Error {
+        var cache = MediaCache.get_default ();
+        cache.save_item (this);
+    }
+
+}
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 235d3e7..e39e2c1 100644
--- a/src/plugins/media-export/rygel-media-export-root-container.vala
+++ b/src/plugins/media-export/rygel-media-export-root-container.vala
@@ -423,9 +423,9 @@ public class Rygel.MediaExport.RootContainer : Rygel.MediaExport.DBContainer {
                                                    Rygel.MusicItem.UPNP_CLASS,
                                                    virtual_folders_music);
             this.add_virtual_containers_for_class (_("Pictures"),
-                                                   PhotoItem.UPNP_CLASS);
+                                                   Rygel.PhotoItem.UPNP_CLASS);
             this.add_virtual_containers_for_class (_("Videos"),
-                                                   VideoItem.UPNP_CLASS);
+                                                   Rygel.VideoItem.UPNP_CLASS);
         } catch (Error error) {};
     }
 
diff --git a/src/plugins/media-export/rygel-media-export-video-item.vala b/src/plugins/media-export/rygel-media-export-video-item.vala
new file mode 100644
index 0000000..e22213d
--- /dev/null
+++ b/src/plugins/media-export/rygel-media-export-video-item.vala
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2012 Intel Corporation.
+ *
+ * Author: Jens Georg <jensg openismus 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.
+ */
+
+internal class Rygel.MediaExport.VideoItem : Rygel.VideoItem,
+                                             Rygel.UpdatableObject {
+    public VideoItem (string         id,
+                      MediaContainer parent,
+                      string         title,
+                      string         upnp_class = Rygel.VideoItem.UPNP_CLASS) {
+        base (id, parent, title, upnp_class);
+    }
+
+    public async void commit () throws Error {
+        var cache = MediaCache.get_default ();
+        cache.save_item (this);
+    }
+
+}
diff --git a/src/plugins/media-export/rygel-media-export-writable-db-container.vala b/src/plugins/media-export/rygel-media-export-writable-db-container.vala
index b4db6dc..f3c3073 100644
--- a/src/plugins/media-export/rygel-media-export-writable-db-container.vala
+++ b/src/plugins/media-export/rygel-media-export-writable-db-container.vala
@@ -29,10 +29,10 @@ internal class Rygel.MediaExport.WritableDbContainer : DBContainer,
         base (media_db, id, title);
 
         this.create_classes = new ArrayList<string> ();
-        this.create_classes.add (ImageItem.UPNP_CLASS);
-        this.create_classes.add (PhotoItem.UPNP_CLASS);
-        this.create_classes.add (VideoItem.UPNP_CLASS);
-        this.create_classes.add (AudioItem.UPNP_CLASS);
+        this.create_classes.add (Rygel.ImageItem.UPNP_CLASS);
+        this.create_classes.add (Rygel.PhotoItem.UPNP_CLASS);
+        this.create_classes.add (Rygel.VideoItem.UPNP_CLASS);
+        this.create_classes.add (Rygel.AudioItem.UPNP_CLASS);
         this.create_classes.add (Rygel.MusicItem.UPNP_CLASS);
     }
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]