rygel r588 - trunk/src/plugins/tracker



Author: zeeshanak
Date: Sat Feb 14 15:30:50 2009
New Revision: 588
URL: http://svn.gnome.org/viewvc/rygel?rev=588&view=rev

Log:
Put TrackerSearchResult in separate file.

Added:
   trunk/src/plugins/tracker/rygel-tracker-search-result.vala
Modified:
   trunk/src/plugins/tracker/Makefile.am
   trunk/src/plugins/tracker/rygel-tracker-container.vala

Modified: trunk/src/plugins/tracker/Makefile.am
==============================================================================
--- trunk/src/plugins/tracker/Makefile.am	(original)
+++ trunk/src/plugins/tracker/Makefile.am	Sat Feb 14 15:30:50 2009
@@ -22,6 +22,8 @@
 		rygel-tracker-music-container.c \
 		rygel-tracker-image-container.h \
 		rygel-tracker-image-container.c \
+		rygel-tracker-search-result.h \
+		rygel-tracker-search-result.c \
 		rygel-tracker-item.h \
 		rygel-tracker-item.c \
 		rygel-tracker-video-item.h \
@@ -51,6 +53,9 @@
 				    rygel-tracker-image-container.h \
 				    rygel-tracker-image-container.c \
 				    rygel-tracker-image-container.vala \
+				    rygel-tracker-search-result.h \
+				    rygel-tracker-search-result.c \
+				    rygel-tracker-search-result.vala \
                                     rygel-tracker-item.h \
                                     rygel-tracker-item.c \
                                     rygel-tracker-item.vala \

Modified: trunk/src/plugins/tracker/rygel-tracker-container.vala
==============================================================================
--- trunk/src/plugins/tracker/rygel-tracker-container.vala	(original)
+++ trunk/src/plugins/tracker/rygel-tracker-container.vala	Sat Feb 14 15:30:50 2009
@@ -221,85 +221,3 @@
                                                       string[] metadata);
 }
 
-public class Rygel.TrackerSearchResult : GLib.Object, GLib.AsyncResult {
-    protected GLib.Object source_object;
-    protected AsyncReadyCallback callback;
-
-    public Gee.List<MediaObject> data;
-    public GLib.Error error;
-
-    public TrackerSearchResult (TrackerContainer   container,
-                                AsyncReadyCallback callback) {
-        this.source_object = container;
-        this.callback = callback;
-
-        this.data = new ArrayList<MediaObject> ();
-    }
-
-    public void ready (string[][] search_result, GLib.Error error) {
-        if (error != null) {
-            this.error = error;
-
-            this.complete ();
-        }
-
-        TrackerContainer container = (TrackerContainer) this.source_object;
-
-        /* Iterate through all items */
-        for (uint i = 0; i < search_result.length; i++) {
-            string child_path = search_result[i][0];
-            string[] metadata = this.slice_strv_tail (search_result[i], 2);
-
-            var item = container.fetch_item_by_path (child_path, metadata);
-            this.data.add (item);
-        }
-
-        this.complete ();
-    }
-
-    /**
-     * Chops the tail of a string array.
-     *
-     * param strv the string to chop the tail of.
-     * param index index of the first element in the tail.
-     *
-     * FIXME: Stop using it once vala supports array[N:M] syntax.
-     */
-    private string[] slice_strv_tail (string[] strv, int index) {
-        var strv_length = this.get_strv_length (strv);
-        string[] slice = new string[strv_length - index];
-
-        for (int i = 0; i < slice.length; i++) {
-            slice[i] = strv[i + index];
-        }
-
-        return slice;
-    }
-
-    /**
-     * Gets the length of a null-terminated string array
-     *
-     * param strv the string to compute length of
-     *
-     * FIXME: Temporary hack, don't use once bug#571322 is fixed
-     */
-    private int get_strv_length (string[] strv) {
-        int i = 0;
-
-        for (i = 0; strv[i] != null; i++);
-
-        return i + 1;
-    }
-
-    public unowned GLib.Object get_source_object () {
-        return this.source_object;
-    }
-
-    public void* get_user_data () {
-        return null;
-    }
-
-    public void complete () {
-        this.callback (this.source_object, this);
-    }
-}

Added: trunk/src/plugins/tracker/rygel-tracker-search-result.vala
==============================================================================
--- (empty file)
+++ trunk/src/plugins/tracker/rygel-tracker-search-result.vala	Sat Feb 14 15:30:50 2009
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2009 Nokia Corporation, all rights reserved.
+ *
+ * Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
+ *
+ * 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.
+ */
+
+using Rygel;
+using Gee;
+
+/**
+ * Handles Tracker Search.Query method results.
+ *
+ * FIXME: This should inherit from Rygel.SimpleAsyncResult once bug#567319 is
+ *        fixed.
+ */
+public class Rygel.TrackerSearchResult : GLib.Object, GLib.AsyncResult {
+    protected GLib.Object source_object;
+    protected AsyncReadyCallback callback;
+
+    public Gee.List<MediaObject> data;
+    public GLib.Error error;
+
+    public TrackerSearchResult (TrackerContainer   container,
+                                AsyncReadyCallback callback) {
+        this.source_object = container;
+        this.callback = callback;
+
+        this.data = new ArrayList<MediaObject> ();
+    }
+
+    public void ready (string[][] search_result, GLib.Error error) {
+        if (error != null) {
+            this.error = error;
+
+            this.complete ();
+        }
+
+        TrackerContainer container = (TrackerContainer) this.source_object;
+
+        /* Iterate through all items */
+        for (uint i = 0; i < search_result.length; i++) {
+            string child_path = search_result[i][0];
+            string[] metadata = this.slice_strv_tail (search_result[i], 2);
+
+            var item = container.fetch_item_by_path (child_path, metadata);
+            this.data.add (item);
+        }
+
+        this.complete ();
+    }
+
+    /**
+     * Chops the tail of a string array.
+     *
+     * param strv the string to chop the tail of.
+     * param index index of the first element in the tail.
+     *
+     * FIXME: Stop using it once vala supports array[N:M] syntax.
+     */
+    private string[] slice_strv_tail (string[] strv, int index) {
+        var strv_length = this.get_strv_length (strv);
+        string[] slice = new string[strv_length - index];
+
+        for (int i = 0; i < slice.length; i++) {
+            slice[i] = strv[i + index];
+        }
+
+        return slice;
+    }
+
+    /**
+     * Gets the length of a null-terminated string array
+     *
+     * param strv the string to compute length of
+     *
+     * FIXME: Temporary hack, don't use once bug#571322 is fixed
+     */
+    private int get_strv_length (string[] strv) {
+        int i = 0;
+
+        for (i = 0; strv[i] != null; i++);
+
+        return i + 1;
+    }
+
+    public unowned GLib.Object get_source_object () {
+        return this.source_object;
+    }
+
+    public void* get_user_data () {
+        return null;
+    }
+
+    public void complete () {
+        this.callback (this.source_object, this);
+    }
+}
+



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