[rygel] core: Fix remaining warnings



commit 184ed72130e490dbd8681a04a33847af216eaf9d
Author: Jens Georg <mail jensge org>
Date:   Wed Sep 30 14:52:30 2009 +0200

    core: Fix remaining warnings

 src/rygel/rygel-media-db-container.vala |    4 +-
 src/rygel/rygel-media-db.vala           |   40 +++++++++++++-----------------
 2 files changed, 19 insertions(+), 25 deletions(-)
---
diff --git a/src/rygel/rygel-media-db-container.vala b/src/rygel/rygel-media-db-container.vala
index c041d77..a478daa 100644
--- a/src/rygel/rygel-media-db-container.vala
+++ b/src/rygel/rygel-media-db-container.vala
@@ -27,7 +27,7 @@ public class Rygel.MediaDBContainer : MediaContainer {
         int count;
         try {
             count = media_db.get_child_count (id);
-        } catch (MediaDBError e) {
+        } catch (DatabaseError e) {
             debug("Could not get child count from database: %s",
                   e.message);
             count = 0;
@@ -42,7 +42,7 @@ public class Rygel.MediaDBContainer : MediaContainer {
                                           MediaContainer container_updated) {
         try {
             this.child_count = media_db.get_child_count (this.id);
-        } catch (MediaDBError e) {
+        } catch (DatabaseError e) {
             debug("Could not get child count from database: %s",
                   e.message);
             this.child_count = 0;
diff --git a/src/rygel/rygel-media-db.vala b/src/rygel/rygel-media-db.vala
index ab62e76..63253a8 100644
--- a/src/rygel/rygel-media-db.vala
+++ b/src/rygel/rygel-media-db.vala
@@ -320,18 +320,18 @@ public class Rygel.MediaDB : Object {
     }
 
     private bool sweeper () {
-        debug ("Running sweeper");
-        var rc = db.exec (SWEEPER_STRING);
-        if (rc != Sqlite.OK) {
-            warning ("Failed to sweep database");
-            return false;
-        } else {
+        try {
+            debug ("Running sweeper");
+            db.exec (SWEEPER_STRING);
             // if there have been any objects deleted, their children
             // will have nullified parents by the trigger, so we reschedule
             // the idle sweeper
             var changes = db.changes ();
             debug ("Changes in sweeper: %d", changes);
             return changes != 0;
+        } catch (DatabaseError err) {
+            warning ("Failed to sweep database");
+            return false;
         }
     }
 
@@ -347,7 +347,7 @@ public class Rygel.MediaDB : Object {
     public signal void container_removed (string container_id);
     public signal void container_updated (string container_id);
 
-    public void remove_by_id (string id) throws MediaDBError {
+    public void remove_by_id (string id) throws DatabaseError {
         GLib.Value[] values = { id };
         this.db.exec (DELETE_BY_ID_STRING, values);
         object_removed (id);
@@ -355,7 +355,7 @@ public class Rygel.MediaDB : Object {
     }
 
 
-    public void remove_object (MediaObject obj) throws MediaDBError {
+    public void remove_object (MediaObject obj) throws DatabaseError, MediaDBError {
         this.remove_by_id (obj.id);
         if (obj is MediaItem)
             item_removed (obj.id);
@@ -477,8 +477,6 @@ public class Rygel.MediaDB : Object {
     }
 
     private void save_uris (MediaObject obj) throws Error {
-        Statement statement;
-
         foreach (var uri in obj.uris) {
             GLib.Value[] values = { obj.id, uri };
             db.exec (INSERT_URI_STRING, values);
@@ -585,7 +583,7 @@ public class Rygel.MediaDB : Object {
         return obj;
     }
 
-    public MediaItem? get_item (string item_id) throws MediaDBError {
+    public MediaItem? get_item (string item_id) throws DatabaseError, MediaDBError {
         var obj = get_object (item_id);
         if (obj != null && !(obj is MediaItem))
             throw new MediaDBError.INVALID_TYPE("Object with id %s is not a" +
@@ -594,7 +592,8 @@ public class Rygel.MediaDB : Object {
         return (MediaItem)obj;
     }
 
-    public MediaContainer? get_container (string container_id) throws MediaDBError {
+    public MediaContainer? get_container (string container_id)
+                                          throws DatabaseError, MediaDBError {
         var obj = get_object (container_id);
         if (obj != null && !(obj is MediaContainer))
             throw new MediaDBError.INVALID_TYPE("Object with id %s is not a" +
@@ -625,7 +624,7 @@ public class Rygel.MediaDB : Object {
     }
 
     public ArrayList<string> get_child_ids (string container_id)
-                                                         throws MediaDBError {
+                                                         throws DatabaseError {
         ArrayList<string> children = new ArrayList<string> (str_equal);
         GLib.Value[] values = { container_id  };
 
@@ -654,7 +653,7 @@ public class Rygel.MediaDB : Object {
     }
 
     public bool exists (string object_id, out int64 timestamp)
-                                                          throws MediaDBError {
+                                                          throws DatabaseError {
         bool exists = false;
         GLib.Value[] values = { object_id };
         int64 _timestamp = 0;
@@ -673,16 +672,11 @@ public class Rygel.MediaDB : Object {
 
     public Gee.ArrayList<MediaObject> get_children (string container_id,
                                                       long offset,
-                                                      long max_count)
-                                                      throws MediaDBError {
-        ArrayList<MediaObject> children = new ArrayList<MediaObject> ();
+                                                      long max_count) throws
+                                                      Error {
         MediaContainer parent = null;
-        try {
-            parent = (MediaContainer) get_object (container_id);
-        } catch (MediaDBError err) {
-            warning ("Could not get parent object: %s", err.message);
-            return children;
-        }
+        ArrayList<MediaObject> children = new ArrayList<MediaObject> ();
+        parent = (MediaContainer) get_object (container_id);
 
         GLib.Value[] values = { container_id,
                                 (int64) offset,



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