mediamonkeyserver
Version:
MediaMonkey Server
77 lines (57 loc) • 1.7 kB
JavaScript
/*jslint node: true, esversion: 6 */
;
const Res = require('./object.res');
const ObjectClass = require('./object');
const FORCE_CHILDREN_COUNT=false;
const _UPNP_CLASS = ObjectClass.UPNP_CLASS+".container";
class Container extends Res {
constructor() {
super();
}
static get UPNP_CLASS() {
return _UPNP_CLASS;
}
get mimeTypes() {
if (Object.getPrototypeOf(this)!==Container.prototype) {
return super.mimeTypes;
}
return [ 'inode/directory' ];
}
get name() {
return Container.UPNP_CLASS;
}
get isContainer() { return true; }
get defaultSort() { return [ "+dc:title" ]; }
/**
*
*/
toJXML(node, attributes, request, filterCallback, callback) {
super.toJXML(node, attributes, request, filterCallback, (error, xml) => {
if (error) {
return callback(error);
}
xml._name = "container";
if (node.searchable) {
xml._attrs.searchable = true;
}
var childrenIds = node.childrenIds;
if (childrenIds!==undefined) {
// Can not filter list ! future defect ?
xml._attrs.childCount = childrenIds.length;
return callback(null, xml);
}
if (!FORCE_CHILDREN_COUNT) {
return callback(null, xml);
}
node.browseChildren( { request: request }, (error, list) => {
if (error) {
return callback(error);
}
node.service.emit("filterList", request, node, list);
xml._attrs.childCount = (list) ? list.length : 0;
callback(null, xml);
});
});
}
}
module.exports = Container;