/* Copyright 2009 Palm, Inc.  All rights reserved. */

Photos.Model.LocalAlbums = Class.create(Photos.Model.Albums, {
	newThumbsModel: function(item) {
		return new Photos.Model.LocalThumbs(
						item.albumID, item.albumName);
	},

	request: function(filter, offset, limit, done) {
		Photos.Service.listAlbums(
			offset, limit, filter, this.translate.bind(this, done),
			this.controller);
	},

	translate: function(done, response) {
		if (!response || !response.returnValue) {
			done([], 0);
			return;
		}

		for (var i = 0, len = response.albums.length; i < len; i++) {
			var album = response.albums[i];
			switch (album.albumPath) {
			case "/media/internal/screencaptures":
				album.albumName = $L("Screen captures");
				break;
			case "/media/internal/Messaging":
				album.albumName = $L("Messaging");
				break;
			case "/media/internal/wallpapers":
				album.albumName = $L("Wallpapers");
				break;
			case "/media/internal/downloads":
				album.albumName = $L("Downloads");
				break;
			}
		}
		done(response.albums, parseInt(response.albumsTotal, 10));
	}
});

