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

Photos.Model.FacebookUserSummary = Class.create(Photos.Model.Summary, {
	initialize: function($super, userID, userName) {
		$super();
		this.uid = userID || "";
		this.name = userName || "";
	},

	getTitle: function() {
		return $L("#{name}'s photos").interpolate({name: this.name});
	},

	getHeadline: function() {
		return $L("Photos of #{name}").interpolate({name: this.name});
	},

	getHeadlineImages: function() {
		return [];
	},

	getHighlightTitle: function() {
		return $L("Recently updated");
	},

	getMoreText: function() {
		return $L("All #{name}'s albums").interpolate({
			name: this.name
		});
	},

	requestHighlights: function(done) {
		function translate(response) {
			Mojo.Log.error("Got response: " + Object.toJSON(response));
			for (var i = 0, len = response.albums.length;
								i < len; i++) {
				var album = response.albums[i];
				album.albumID = album.aid;
				album.albumName = album.name;
				album.albumIcon = album.icon;
				album.albumCount = album.count;
			}
			Mojo.Log.error("Sending off: " + Object.toJSON(response.albums));
			done(response.albums);
		}

		this.controller.serviceRequest(
			'palm://com.palm.photo.facebook', {
				method: "getContactAlbums",
				onSuccess: translate.bind(this),
				parameters: {
					cid: this.uid
				}
		});
	},

	getThumbsModel: function(item) {
		// otherwise we have the owner of the album, and
		// we're checking out photos of that person.
		return new Photos.Model.FacebookThumbs(
			"facebook", item.aid, item.name,
			this.uid, this.name);
	},

	headline: function(callback) {
		callback('thumbs', {
			model: new Photos.Model.FacebookThumbs(
				"facebook", this.uid, this.getHeadline())
		});
	},

	more: function(callback) {
		callback('albums', {
			model: new Photos.Model.FacebookAlbums(
				"facebook", this.uid)
		});
	}
});

