From: Zeeshan Ali (Khattak) Date: Thu, 4 Jun 2009 16:02:24 +0000 (+0300) Subject: media-export: Use generic types/names X-Git-Tag: RYGEL_0_4~378 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=15e9c3403613dc4f3624268d5858cecdee64d207;p=profile%2Fivi%2Frygel.git media-export: Use generic types/names --- diff --git a/src/plugins/media-export/rygel-media-export-container.vala b/src/plugins/media-export/rygel-media-export-container.vala index cdd2d17..29cf885 100644 --- a/src/plugins/media-export/rygel-media-export-container.vala +++ b/src/plugins/media-export/rygel-media-export-container.vala @@ -23,8 +23,7 @@ using GLib; using Rygel; /** - * MediaContainer which exposes the contents of a directory - * as items. + * MediaContainer which exposes the contents of a directory. * * The folder contents will be queried on demand and cached afterwards */ @@ -36,9 +35,9 @@ public class Rygel.MediaExportContainer : MediaContainer { private const int MAX_CHILDREN = 10; /** - * Cache of items found in directory + * Cache of children found in directory */ - private ArrayList items; + private ArrayList children; /** * Instance of GLib.File of the directory we expose @@ -53,7 +52,7 @@ public class Rygel.MediaExportContainer : MediaContainer { Cancellable? cancellable, AsyncReadyCallback callback) { // if the cache is empty, fill it - if (this.items.size == 0) { + if (this.children.size == 0) { var res = new MediaExportDirectorySearchResult (this, offset, max_count, @@ -72,7 +71,7 @@ public class Rygel.MediaExportContainer : MediaContainer { } else { uint stop = offset + max_count; stop = stop.clamp (0, this.child_count); - var children = this.items.slice ((int) offset, (int) stop); + var children = this.children.slice ((int) offset, (int) stop); var res = new SimpleAsyncResult> ( this, @@ -88,11 +87,11 @@ public class Rygel.MediaExportContainer : MediaContainer { if (res is MediaExportDirectorySearchResult) { var dsr = (MediaExportDirectorySearchResult) res; - foreach (var item in dsr.data) { - this.items.add (item); + foreach (var media_obj in dsr.data) { + this.children.add (media_obj); } - this.child_count = this.items.size; + this.child_count = this.children.size; this.results.remove (res); return dsr.get_children (); } else { @@ -119,31 +118,31 @@ public class Rygel.MediaExportContainer : MediaContainer { } public MediaObject? find_object_sync (string id) { - MediaObject item = null; + MediaObject media_obj = null; - // check if the searched item is in our cache - foreach (var tmp in this.items) { + // check if the searched object is in our cache + foreach (var tmp in this.children) { if (id == tmp.id) { - item = tmp; + media_obj = tmp; break; } } // if not found, do a depth-first search on the child // folders - if (item == null) { - foreach (var tmp in this.items) { + if (media_obj == null) { + foreach (var tmp in this.children) { if (tmp is MediaExportContainer) { var folder = (MediaExportContainer) tmp; - item = folder.find_object_sync (id); - if (item != null) { + media_obj = folder.find_object_sync (id); + if (media_obj != null) { break; } } } } - return item; + return media_obj; } /** @@ -159,7 +158,7 @@ public class Rygel.MediaExportContainer : MediaContainer { base(id, parent, file.get_basename (), 0); this.root_dir = file; - this.items = new ArrayList (); + this.children = new ArrayList (); this.child_count = 0; this.results = new ArrayList (); } diff --git a/src/plugins/media-export/rygel-media-export-directory-search-result.vala b/src/plugins/media-export/rygel-media-export-directory-search-result.vala index 1a1674b..18e1602 100644 --- a/src/plugins/media-export/rygel-media-export-directory-search-result.vala +++ b/src/plugins/media-export/rygel-media-export-directory-search-result.vala @@ -60,20 +60,21 @@ public class Rygel.MediaExportDirectorySearchResult : if (list != null) { foreach (FileInfo file_info in list) { var f = file.get_child (file_info.get_name ()); - MediaObject item = null; + MediaObject media_obj = null; if (file_info.get_file_type () == FileType.DIRECTORY) { - item = new Rygel.MediaExportContainer ( + media_obj = new Rygel.MediaExportContainer ( (MediaContainer) source_object, f); } else { - item = get_media_item ((MediaContainer) source_object, + media_obj = get_media_item ( + (MediaContainer) source_object, f, file_info); } - if (item != null) { - data.add (item); + if (media_obj != null) { + data.add (media_obj); } } @@ -107,12 +108,12 @@ public class Rygel.MediaExportDirectorySearchResult : } } - public Gee.List get_children () { + public Gee.List get_children () { uint stop = offset + max_count; stop = stop.clamp (0, data.size); var children = data.slice ((int) offset, (int) stop); - return children as Gee.List; + return children; } private MediaItem? get_media_item (MediaContainer parent, 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 23aaaf9..705f6be 100644 --- a/src/plugins/media-export/rygel-media-export-root-container.vala +++ b/src/plugins/media-export/rygel-media-export-root-container.vala @@ -27,7 +27,7 @@ using GConf; * Represents the root container. */ public class Rygel.MediaExportRootContainer : MediaContainer { - private ArrayList children; + private ArrayList children; public override void get_children (uint offset, uint max_count, @@ -62,29 +62,29 @@ public class Rygel.MediaExportRootContainer : MediaContainer { public override MediaObject? find_object_finish (AsyncResult res) throws GLib.Error { - MediaObject item = null; + MediaObject media_obj = null; var id = ((Rygel.SimpleAsyncResult) res).data; foreach (var tmp in this.children) { if (id == tmp.id) { - item = tmp; + media_obj = tmp; break; } } - if (item == null) { + if (media_obj == null) { foreach (var tmp in this.children) { if (tmp is MediaExportContainer) { var folder = (MediaExportContainer) tmp; - item = folder.find_object_sync (id); - if (item != null) { + media_obj = folder.find_object_sync (id); + if (media_obj != null) { break; } } } } - return item; + return media_obj; } /**