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
*/
private const int MAX_CHILDREN = 10;
/**
- * Cache of items found in directory
+ * Cache of children found in directory
*/
- private ArrayList<MediaObject> items;
+ private ArrayList<MediaObject> children;
/**
* Instance of GLib.File of the directory we expose
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,
} 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<Gee.List<MediaObject>> (
this,
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 {
}
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;
}
/**
base(id, parent, file.get_basename (), 0);
this.root_dir = file;
- this.items = new ArrayList<MediaObject> ();
+ this.children = new ArrayList<MediaObject> ();
this.child_count = 0;
this.results = new ArrayList<AsyncResult> ();
}
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);
}
}
}
}
- public Gee.List<MediaItem> get_children () {
+ public Gee.List<MediaObject> 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<MediaItem>;
+ return children;
}
private MediaItem? get_media_item (MediaContainer parent,
* Represents the root container.
*/
public class Rygel.MediaExportRootContainer : MediaContainer {
- private ArrayList<MediaExportContainer> children;
+ private ArrayList<MediaObject> children;
public override void get_children (uint offset,
uint max_count,
public override MediaObject? find_object_finish (AsyncResult res)
throws GLib.Error {
- MediaObject item = null;
+ MediaObject media_obj = null;
var id = ((Rygel.SimpleAsyncResult<string>) 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;
}
/**