You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by do...@apache.org on 2008/01/06 22:50:58 UTC

svn commit: r609418 - in /incubator/shindig/trunk/javascript/opensocial: ./ reference/

Author: doll
Date: Sun Jan  6 13:50:57 2008
New Revision: 609418

URL: http://svn.apache.org/viewvc?rev=609418&view=rev
Log:
Adding first version of opensocial reference code to shindig. This is simply the next version that would have been checked into the code.google.com project. It provides common code for opensocial containers to reduce the amount of new code that must be written. This code is at opensocial version 0.6.

Added:
    incubator/shindig/trunk/javascript/opensocial/
    incubator/shindig/trunk/javascript/opensocial/reference/
    incubator/shindig/trunk/javascript/opensocial/reference/activity.js   (with props)
    incubator/shindig/trunk/javascript/opensocial/reference/collection.js   (with props)
    incubator/shindig/trunk/javascript/opensocial/reference/container.js   (with props)
    incubator/shindig/trunk/javascript/opensocial/reference/datarequest.js   (with props)
    incubator/shindig/trunk/javascript/opensocial/reference/dataresponse.js   (with props)
    incubator/shindig/trunk/javascript/opensocial/reference/environment.js   (with props)
    incubator/shindig/trunk/javascript/opensocial/reference/opensocial.js   (with props)
    incubator/shindig/trunk/javascript/opensocial/reference/person.js   (with props)
    incubator/shindig/trunk/javascript/opensocial/reference/responseitem.js   (with props)
    incubator/shindig/trunk/javascript/opensocial/reference/surface.js   (with props)

Added: incubator/shindig/trunk/javascript/opensocial/reference/activity.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/opensocial/reference/activity.js?rev=609418&view=auto
==============================================================================
--- incubator/shindig/trunk/javascript/opensocial/reference/activity.js (added)
+++ incubator/shindig/trunk/javascript/opensocial/reference/activity.js Sun Jan  6 13:50:57 2008
@@ -0,0 +1,310 @@
+/**
+ * Copyright 2007 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @fileoverview Representation of an activity.
+ */
+
+
+/**
+ * @class
+ * Base interface for all activity objects.
+ *
+ * <p>
+ * <b>See also:</b>
+ * <a href="opensocial.html#newActivity">opensocial.newActivity()</a>,
+ * <a href="opensocial.html#requestCreateActivity">
+ * opensocial.requestCreateActivity()</a>
+ *
+ * @name opensocial.Activity
+ */
+
+
+/**
+ * Base interface for all activity objects.
+ *
+ * @param {opensocial.Activity.Template || String} title The title of an
+ *     activity; a template is recommended, but this field can also be a
+ *     string.
+ * @param {Map.<opensocial.Activity.Field, Object>} opt_params Any other
+ *    fields that should be set on the activity object. All of the defined
+ *    Fields are supported.
+ * @private
+ * @constructor
+ */
+opensocial.Activity = function(title, opt_params) {
+  this.fields_ = opt_params || {};
+  this.fields_[opensocial.Activity.Field.TITLE] = title;
+};
+
+
+/**
+ * @static
+ * @class
+ * All of the fields that activities can have.
+ *
+ * <p>
+ * <b>See also:</b>
+ * <a
+ * href="opensocial.Activity.html#getField">opensocial.Activity.getField()</a>
+ * </p>
+ *
+ * @name opensocial.Activity.Field
+ */
+opensocial.Activity.Field = {
+  /**
+   * A string ID
+   * that can be permanently associated with this activity.
+   * @member opensocial.Activity.Field
+   */
+  ID : 'id',
+
+  /**
+   * A string ID
+   * associated with this activity that was generated by the
+   * posting app externally.
+   * @member opensocial.Activity.Field
+   */
+  EXTERNAL_ID : 'externalId',
+
+  /**
+   * The string ID of the user who this activity is for.
+   * @member opensocial.Activity.Field
+   */
+  USER_ID : 'userId',
+
+  /**
+   * A string specifying the application that this activity is associated with.
+   * @member opensocial.Activity.Field
+   */
+  APP_ID : 'appId',
+
+  /**
+   * A string specifing the title of the stream.
+   * @member opensocial.Activity.Field
+   */
+  STREAM_TITLE : 'streamTitle',
+
+  /**
+   * A string specifying the stream's URL.
+   * @member opensocial.Activity.Field
+   */
+  STREAM_URL : 'streamUrl',
+
+  /**
+   * A string specifying the stream's source URL.
+   * @member opensocial.Activity.Field
+   */
+  STREAM_SOURCE_URL : 'streamSourceUrl',
+
+  /**
+   * A string specifying the URL for the stream's favicon.
+   * @member opensocial.Activity.Field
+   */
+  STREAM_FAVICON_URL : 'streamFaviconUrl',
+
+  /**
+   * A string specifying the title of an activity;
+   * the only field that is guaranteed
+   * to display when rendering.
+   * @member opensocial.Activity.Field
+   */
+  TITLE : 'title',
+
+  /**
+   * A string specifying the full text of an activity.
+   * @member opensocial.Activity.Field
+   */
+  BODY : 'body',
+
+  /**
+   * A string specifying the
+   * URL that represents this activity.
+   * @member opensocial.Activity.Field
+   */
+  URL : 'url',
+
+  /**
+   * Any photos, videos, or images that should be associated
+   * with the activity. Higher priority ones are higher in the list.
+   * The data has type <code>Array&lt;
+   * <a href="opensocial.Activity.MediaItem.html">MediaItem</a>&gt;</code>.
+   * @member opensocial.Activity.Field
+   */
+  MEDIA_ITEMS : 'mediaItems',
+
+  /**
+   * A string specifying the time at which this activity took place
+   * in milliseconds since the epoch.
+   * @member opensocial.Activity.Field
+   */
+  POSTED_TIME : 'postedTime',
+
+  /**
+   * A map of custom keys to values associated with this activity.
+   * @private - not supported until templates exist
+   * The data has type <code>Map&lt;String, String&gt;</code>.
+   * @member opensocial.Activity.Field
+   */
+  CUSTOM_VALUES : 'customValues'
+};
+
+
+/**
+ * Gets an ID that can be permanently associated with this activity.
+ *
+ * @return {String} The ID
+ * @member opensocial.Activity
+ */
+opensocial.Activity.prototype.getId = function() {
+  return this.getField(opensocial.Activity.Field.ID);
+};
+
+
+/**
+ * Gets the activity data that's associated with the specified key.
+ *
+ * @param {String} key The key to get data for;
+ *   see the <a href="opensocial.Activity.Field.html">Field</a> class
+ * for possible values
+ * @return {String} The data
+ * @member opensocial.Activity
+ */
+opensocial.Activity.prototype.getField = function(key) {
+  return this.fields_[key];
+};
+
+
+/**
+ * Sets data for this activity associated with the given key.
+ *
+ * @param {String} key The key to set data for
+ * @param {String} data The data to set
+ */
+opensocial.Activity.prototype.setField = function(key, data) {
+  return this.fields_[key] = data;
+};
+
+
+/**
+ * @class
+ * A media item associated with an activity.
+ * Represents images, movies, and audio.
+ * Create a <code>MediaItem</code> object using the
+ * <a href="opensocial.html#newActivityMediaItem">
+ * opensocial.newActivityMediaItem()</a> method.
+ *
+ * @name opensocial.Activity.MediaItem
+ */
+
+/**
+ * A media item associated with an activity. Represents images, movies, and
+ * audio.
+ *
+ * @param {String} mimetype The media's type
+ * @param {String} url The media's location
+ * @param {Map.<opensocial.Activity.MediaItem.Field, Object>} opt_params
+ *    Any other fields that should be set on the media item object.
+ *    All of the defined Fields are supported.
+ * @constructor
+ * @private
+ */
+opensocial.Activity.MediaItem = function(mimeType, url, opt_params) {
+  this.fields_ = opt_params || {};
+  this.fields_[opensocial.Activity.MediaItem.Field.MIME_TYPE] = mimeType;
+  this.fields_[opensocial.Activity.MediaItem.Field.URL] = url;
+};
+
+
+/**
+ * @static
+ * @class
+ * The possible types of media items.
+ *
+ * <p>
+ * <b>See also:</b>
+ * <a href="opensocial.Activity.MediaItem.Field.html">
+ * opensocial.Activity.MediaItem.Field</a>
+ * </p>
+ *
+ * @name opensocial.Activity.MediaItem.Type = {
+ */
+opensocial.Activity.MediaItem.Type = {
+  /** @member opensocial.Activity.MediaItem.Type */
+  IMAGE : 'image',
+  /** @member opensocial.Activity.MediaItem.Type */
+  VIDEO : 'video',
+  /** @member opensocial.Activity.MediaItem.Type */
+  AUDIO : 'audio'
+}
+
+
+/**
+ * @static
+ * @class
+ * All of the fields that media items have.
+ *
+ * <p>
+ * <b>See also:</b>
+ * <a href="opensocial.Activity.MediaItem.html#getField">
+ * opensocial.Activity.MediaItem.getField()</a>
+ * </p>
+ *
+ * @name opensocial.Activity.MediaItem.Field
+ */
+opensocial.Activity.MediaItem.Field = {
+  /**
+   * The type of media, specified as a
+   * <a href="opensocial.Activity.MediaItem.Type.html">
+   * <code>MediaItem.Type</code></a> object.
+   * @member opensocial.Activity.MediaItem.Field
+   */
+  TYPE : 'type',
+
+  /**
+   * The MIME type of media, specified as a String.
+   * @member opensocial.Activity.MediaItem.Field
+   */
+  MIME_TYPE : 'mimeType',
+
+  /**
+   * A string specifying the URL where the media can be found.
+   * @member opensocial.Activity.MediaItem.Field
+   */
+  URL : 'url'
+};
+
+
+/**
+ * Gets the media item data that's associated with the specified key.
+ *
+ * @param {String} key The key to get data for; see the
+ *   <a href="opensocial.Activity.MediaItem.Field.html">Field</a> class
+ *   for possible values
+ * @return {String} The data
+ */
+opensocial.Activity.MediaItem.prototype.getField = function(key) {
+  return this.fields_[key];
+};
+
+
+/**
+ * Sets data for this media item associated with the given key.
+ *
+ * @param {String} key The key to set data for
+ * @param {String} data The data to set
+ */
+opensocial.Activity.MediaItem.prototype.setField = function(key, data) {
+  return this.fields_[key] = data;
+};

Propchange: incubator/shindig/trunk/javascript/opensocial/reference/activity.js
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/shindig/trunk/javascript/opensocial/reference/collection.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/opensocial/reference/collection.js?rev=609418&view=auto
==============================================================================
--- incubator/shindig/trunk/javascript/opensocial/reference/collection.js (added)
+++ incubator/shindig/trunk/javascript/opensocial/reference/collection.js Sun Jan  6 13:50:57 2008
@@ -0,0 +1,114 @@
+/**
+ * Copyright 2007 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @fileoverview Collection of multiple objects with useful accessors.
+ *
+ * May also represent subset of a larger collection (i.e. page 1 of 10), and
+ * contain information about the larger collection.
+ */
+
+
+/**
+ * @class
+ * Collection of multiple objects with useful accessors.
+ * May also represent subset of a larger collection
+ * (for example, page 1 of 10)
+ * and contain information about the larger collection.
+ *
+ * @name opensocial.Collection
+ */
+
+
+/**
+ * Create a collection.
+ *
+ * @private
+ * @constructor
+ */
+opensocial.Collection = function(array, opt_offset, opt_totalSize) {
+  this.array_ = array || [];
+  this.offset_ = opt_offset || 0;
+  this.totalSize_ = opt_totalSize || this.array_.length;
+};
+
+
+/**
+ * Finds the entry with the given ID value, or returns null if none is found.
+ * @param {String} id The ID to look for
+ * @return {Object?} The data
+ */
+opensocial.Collection.prototype.getById = function(id) {
+   // TODO(doll): A non-linear search would be better
+  for (var i = 0; i < this.size(); i++) {
+    var item = this.array_[i];
+    if (item.getId() == id) {
+      return item;
+    }
+  }
+
+  return null;
+};
+
+
+/**
+ * Gets the size of this collection,
+ * which is equal to or less than the
+ * total size of the result.
+ * @return {Number} The size of this collection
+ */
+opensocial.Collection.prototype.size = function() {
+  return this.array_.length;
+};
+
+
+/**
+ * Executes the provided function once per member of the collection,
+ * with each member in turn as the
+ * parameter to the function.
+ * @param {Function} fn The function to call with each collection entry
+ */
+opensocial.Collection.prototype.each = function(fn) {
+  for (var i = 0; i < this.size(); i++) {
+    fn(this.array_[i]);
+  }
+};
+
+
+/**
+ * Returns an array of all the objects in this collection.
+ * @return {Array.&lt;Object&gt;} The values in this collection
+ */
+opensocial.Collection.prototype.asArray = function() {
+  return this.array_;
+};
+
+
+/**
+ * Gets the total size of the larger result set
+ * that this collection belongs to.
+ * @return {Number} The total size of the result
+ */
+opensocial.Collection.prototype.getTotalSize = function() {
+  return this.totalSize_;
+};
+
+
+/**
+ * Gets the offset of this collection within a larger result set.
+ * @return {Number} The offset into the total collection
+ */
+opensocial.Collection.prototype.getOffset = function() {
+  return this.offset_;
+};

Propchange: incubator/shindig/trunk/javascript/opensocial/reference/collection.js
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/shindig/trunk/javascript/opensocial/reference/container.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/opensocial/reference/container.js?rev=609418&view=auto
==============================================================================
--- incubator/shindig/trunk/javascript/opensocial/reference/container.js (added)
+++ incubator/shindig/trunk/javascript/opensocial/reference/container.js Sun Jan  6 13:50:57 2008
@@ -0,0 +1,604 @@
+/**
+ * Copyright 2007 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @fileoverview Interface for containers of people functionality.
+ */
+
+
+/**
+ * Base interface for all containers.
+ *
+ * @constructor
+ * @private
+ */
+opensocial.Container = function() {
+  this.cajaEnabled_ = false;
+};
+
+
+/**
+ * The container instance.
+ *
+ * @type Container
+ * @private
+ */
+opensocial.Container.container_ = null;
+
+
+/**
+ * Set the current container object.
+ *
+ * @param {opensocial.Container} container The container
+ * @private
+ */
+opensocial.Container.setContainer = function(container) {
+  opensocial.Container.container_ = container;
+};
+
+
+/**
+ * Get the current container object.
+ *
+ * @return {opensocial.Container} container The current container
+ * @private
+ */
+opensocial.Container.get = function() {
+  return opensocial.Container.container_;
+};
+
+
+/**
+ * Gets the current environment for this gadget. You can use the environment to
+ * query things like what profile fields and surfaces are supported by this
+ * container, what parameters were passed to the current gadget and so forth.
+ *
+ * @return {opensocial.Environment} The current environment
+ *
+ * @private
+ */
+opensocial.Container.prototype.getEnvironment = function() {};
+
+
+/**
+ * Request for the container to make the specified person not a friend.
+ *
+ * Note: If this is the first activity that has been created for the user and
+ * the request is marked as HIGH priority then this call may open a user flow
+ * and navigate away from your gadget.
+ *
+ * @param {Activity} activity The activity to create. The only required field is
+ *     title.
+ * @param {CreateActivityPriority} priority The priority for this request.
+ * @param {Function} opt_callback Function to call once the request has been
+ *    processed.
+ * @private
+ */
+opensocial.Container.prototype.requestCreateActivity = function(activity,
+    priority, opt_callback) {};
+
+
+/**
+ * Returns whether the current gadget has access to the specified
+ * permission.
+ *
+ * @param {opensocial.Permission | String} permission The permission
+ * @return {Boolean} Whether the gadget has access for the permission.
+ *
+ * @private
+ */
+opensocial.Container.prototype.hasPermission = function(permission) {};
+
+
+/**
+ * Requests the user grants access to the specified permissions.
+ *
+ * @param {Array.<opensocial.Permission>} permissions The permissions to request
+ *    access to from the viewer
+ * @param {String} reason Will be displayed to the user as the reason why these
+ *    permissions are needed.
+ * @param {Function} opt_callback The function to call once the request has been
+ *    processed. This callback will either be called or the gadget will be
+ *    reloaded from scratch
+ *
+ * @private
+ */
+opensocial.Container.prototype.requestPermission = function(permissions, reason,
+    opt_callback) {};
+
+
+/**
+ * Attempts to navigate to this gadget on a different surface. If the container
+ * supports parameters will pass the optional parameters along to the gadget on
+ * the new surface.
+ *
+ * @param {opensocial.Surface} surface The surface to navigate to
+ * @param {Map.<String, String>} opt_params Params to pass to the gadget after
+ *    it has been navigated to on the surface
+ *
+ * @private
+ */
+opensocial.Container.prototype.requestNavigateTo = function(surface,
+    opt_params) {};
+
+
+/**
+ * Fetches content from the provided URL and feeds that content into the
+ * callback function.
+ * @param {String} url The URL where the content is located
+ * @param {Function} callback The function to call with the data from the URL
+ *     once it is fetched
+ * @param {Map.<opensocial.ContentRequestParameters, Object>} opt_params
+ *     Additional parameters to pass to the request
+ *
+ * @private
+ */
+opensocial.Container.prototype.makeRequest = function(url, callback,
+    opt_params) {};
+
+
+/**
+ * Calls the callback function with a dataResponse object containing the data
+ * asked for in the dataRequest object.
+ *
+ * @param {opensocial.DataRequest} dataRequest Specifies which data to get from
+ *    the server
+ * @param {Function} callback Function to call after the data is fetched
+ * @private
+ */
+opensocial.Container.prototype.requestData = function(dataRequest, callback) {};
+
+
+/**
+ * Request a profile for the specified person id.
+ * When processed, returns a Person object.
+ *
+ * @param {String} id The id of the person to fetch. Can also be standard
+ *    person IDs of VIEWER and OWNER.
+ * @param {Map.<opensocial.DataRequest.PeopleRequestFields, Object>} opt_params
+ *    Additional params to pass to the request. This request supports
+ *    PROFILE_DETAILS.
+ * @return {Object} a request object
+ * @private
+ */
+opensocial.Container.prototype.newFetchPersonRequest = function(id,
+    opt_params) {};
+
+
+/**
+ * Used to request friends from the server.
+ * When processed, returns a Collection&lt;Person&gt; object.
+ *
+ * @param {Array.<String> | String} idSpec An id, array of ids, or a group
+ *    reference used to specify which people to fetch
+ * @param {Map.<opensocial.DataRequest.PeopleRequestFields, Object>} opt_params
+ *    Additional params to pass to the request. This request supports
+ *    PROFILE_DETAILS, SORT_ORDER, FILTER, FIRST, and MAX.
+ * @return {Object} a request object
+ * @private
+ */
+opensocial.Container.prototype.newFetchPeopleRequest = function(idSpec,
+    opt_params) {};
+
+
+/**
+ * Used to request global app data.
+ * When processed, returns a Map&lt;String, String&gt; object.
+ *
+ * @param {Array.<String> | String} keys The keys you want data for. This
+ *     can be an array of key names, a single key name, or "*" to mean
+ *     "all keys".
+ * @return {Object} a request object
+ * @private
+ */
+opensocial.Container.prototype.newFetchGlobalAppDataRequest = function(
+    keys) {};
+
+
+/**
+ * Used to request instance app data.
+ * When processed, returns a Map&lt;String, String&gt; object.
+ *
+ * @param {Array.<String> | String} keys The keys you want data for. This
+ *     can be an array of key names, a single key name, or "*" to mean
+ *     "all keys".
+ * @return {Object} a request object
+ * @private
+ */
+opensocial.Container.prototype.newFetchInstanceAppDataRequest = function(
+    keys) {};
+
+
+/**
+ * Used to request an update of an app instance field from the server.
+ * When processed, does not return any data.
+ *
+ * @param {String} key The name of the key
+ * @param {String} value The value
+ * @return {Object} a request object
+ * @private
+ */
+opensocial.Container.prototype.newUpdateInstanceAppDataRequest = function(key,
+    value) {};
+
+
+/**
+ * Used to request app data for the given people.
+ * When processed, returns a Map&lt;person id, Map&lt;String, String&gt;&gt;
+ * object.
+ *
+ * @param {Array.<String> | String} idSpec An ID, array of IDs, or a group
+ *    reference; the supported keys are VIEWER, OWNER, VIEWER_FRIENDS,
+ *    OWNER_FRIENDS, or a single ID within one of those groups
+ * @param {Array.<String> | String} keys The keys you want data for. This
+ *     can be an array of key names, a single key name, or "*" to mean
+ *     "all keys".
+ * @return {Object} a request object
+ * @private
+ */
+opensocial.Container.prototype.newFetchPersonAppDataRequest = function(idSpec,
+    keys) {};
+
+
+/**
+ * Used to request an update of an app field for the given person.
+ * When processed, does not return any data.
+ *
+ * @param {String} id The id of the person to update. (Right now only the
+ *    special VIEWER id is allowed.)
+ * @param {String} key The name of the key
+ * @param {String} value The value
+ * @return {Object} a request object
+ * @private
+ */
+opensocial.Container.prototype.newUpdatePersonAppDataRequest = function(id,
+    key, value) {};
+
+
+/**
+ * Used to request an activity stream from the server.
+ *
+ * When processed, returns an object whose "activities" property is a
+ * Collection&lt;Activity&gt; object.
+ *
+ * @param {Array.<String> | String} idSpec An ID, array of IDs, or a group
+ *    reference used to specify which people's activities to fetch; the
+ *    supported keys are VIEWER, OWNER, VIEWER_FRIENDS, OWNER_FRIENDS, or
+ *    a single ID within one of those groups.
+ * @param {Map.<opensocial.DataRequest.ActivityRequestFields, Object>} opt_params
+ *    Additional params to pass to the request.
+ * @return {Object} a request object
+ * @private
+ */
+opensocial.Container.prototype.newFetchActivitiesRequest = function(idSpec,
+    opt_params) {};
+
+
+/**
+ * Creates a new collection with caja support if enabled.
+ * @return {opensocial.Collection} the collection object
+ * @private
+ */
+opensocial.Container.prototype.newCollection = function(array, opt_offset,
+    opt_totalSize) {
+  return this.wrapCollectionWithCaja_(new opensocial.Collection(array,
+      opt_offset, opt_totalSize));
+};
+
+
+/**
+ * Creates a new person with caja support if enabled.
+ * @return {opensocial.Person} the person object
+ * @private
+ */
+opensocial.Container.prototype.newPerson = function(opt_params, opt_isOwner,
+    opt_isViewer) {
+  return this.wrapPersonWithCaja_(new opensocial.Person(opt_params, opt_isOwner,
+      opt_isViewer));
+};
+
+
+/**
+ * Get an activity object used to create activities on the server
+ *
+ * @param {opensocial.Activity.Template || String} title The title of an
+ *     activity, a template is reccommended, but this field can also be a
+ *     string.
+ * @param {Map.<opensocial.Activity.Field, Object>} opt_params Any other
+ *    fields that should be set on the activity object. All of the defined
+ *    Fields are supported.
+ * @return {opensocial.Activity} the activity object
+ * @private
+ */
+opensocial.Container.prototype.newActivity = function(title,
+    opt_params) {
+  return this.wrapActivityWithCaja_(new opensocial.Activity(title, opt_params));
+};
+
+
+/**
+ * A media item associated with an activity. Represents images, movies, and
+ * audio. Used when creating activities on the server
+ *
+ * @param {String} mimeType of the media
+ * @param {String} url where the media can be found
+ * @param {Map.<opensocial.Activity.MediaItem.Field, Object>} opt_params
+ *    Any other fields that should be set on the media item object.
+ *    All of the defined Fields are supported.
+ *
+ * @return {opensocial.Activity.MediaItem} the media item object
+ * @private
+ */
+opensocial.Container.prototype.newActivityMediaItem = function(mimeType, url,
+    opt_params) {
+  return this.wrapActivityMediaItemWithCaja_(
+      new opensocial.Activity.MediaItem(mimeType, url, opt_params));
+};
+
+
+/**
+ * Creates a new response item with caja support if enabled.
+ * @return {opensocial.ResponseItem} the response item object
+ * @private
+ */
+opensocial.Container.prototype.newResponseItem = function(originalDataRequest,
+    data, opt_errorCode, opt_errorMessage) {
+  return this.wrapResponseItemWithCaja_(new opensocial.ResponseItem(
+      originalDataRequest, data, opt_errorCode, opt_errorMessage));
+};
+
+
+/**
+ * Creates a new data response with caja support if enabled.
+ * @return {opensocial.DataResponse} the data response object
+ * @private
+ */
+opensocial.Container.prototype.newDataResponse = function(responseItems,
+    opt_globalError) {
+  return this.wrapDataResponseWithCaja_(new opensocial.DataResponse(
+      responseItems, opt_globalError));
+};
+
+
+/**
+ * Get a data request object to use for sending and fetching data from the
+ * server.
+ *
+ * @return {opensocial.DataRequest} the request object
+ * @private
+ */
+opensocial.Container.prototype.newDataRequest = function() {
+  return this.wrapDataRequestWithCaja_(new opensocial.DataRequest());
+};
+
+
+/**
+ * Get a new environment object.
+ *
+ * @return {opensocial.Environment} the environment object
+ * @private
+ */
+opensocial.Container.prototype.newEnvironment = function(domain, surface,
+    supportedSurfaces, supportedFields, opt_params) {
+  return this.wrapEnvironmentWithCaja_(new opensocial.Environment(domain,
+      surface, supportedSurfaces, supportedFields, opt_params));
+};
+
+
+/**
+ * Get a new surface object.
+ *
+ * @return {opensocial.Surface} the surface object
+ * @private
+ */
+opensocial.Container.prototype.newSurface = function(name,
+    opt_isPrimaryContent) {
+  return this.wrapSurfaceWithCaja_(new opensocial.Surface(name,
+      opt_isPrimaryContent));
+};
+
+
+/**
+ * Returns true if the specified value is an array
+ * @param {Object} val Variable to test
+ * @return {boolean} Whether variable is an array
+ * @private
+ */
+opensocial.Container.isArray = function(val) {
+  return val instanceof Array;
+};
+
+
+/**
+ * Caja Support
+ */
+var caja;
+var ___;
+
+/**
+ * Enable Caja support
+ *
+ * @type Container
+ * @private
+ */
+
+// TODO(doll): As caja evolves this method should get a lot smaller
+opensocial.Container.prototype.enableCaja = function() {
+
+  ___ = window["___"];
+  caja = window["caja"];
+
+  var outers = caja.copy(___.sharedOuters);
+
+  // TODO(doll): Is this the way all containers should do this?
+  var igOnload = window["_IG_RegisterOnloadHandler"];
+  if (igOnload) {
+    outers._IG_RegisterOnloadHandler = ___.simpleFunc(igOnload);
+  }
+
+  // TODO(doll): Remove need for this
+  outers.expose = function expose(name, func) {
+    // TODO(benl): we should check that name does not contain
+    // anything except numbers and letters.
+    eval(name + ' = func;');
+  };
+
+  outers.emitHtml___ = function emitHtml(html) {
+    // TODO(doll): This only works for the sample container. Really emitHtml
+    // should be a passed in function
+    var oldHtml = document.getElementById("gadgetContent").innerHTML;
+    document.getElementById("gadgetContent").innerHTML = oldHtml + html;
+  };
+
+
+  outers.document = function() {};
+  outers.document.getElementById = function(id) {
+    // TODO(benl): namespace-ize id.
+    var element = document.getElementById(id);
+    // TODO(benl): replace innerHTML with hidden getter/setter
+    ___.allowSet(element, 'innerHTML');
+    return element;
+  };
+
+  ___.allowCall(outers.document, 'getElementById');
+
+  outers.opensocial = opensocial;
+  ___.allowCall(outers.opensocial, 'requestCreateActivity');
+  ___.allowCall(outers.opensocial, 'hasPermission');
+  ___.allowCall(outers.opensocial, 'requestPermission');
+  ___.allowCall(outers.opensocial, 'requestNavigateTo');
+  ___.allowCall(outers.opensocial, 'getEnvironment');
+  ___.allowCall(outers.opensocial, 'newDataRequest');
+  ___.allowCall(outers.opensocial, 'newActivity');
+  ___.allowCall(outers.opensocial, 'newActivityMediaItem');
+
+  var moduleHandler = ___.freeze({
+    getOuters: ___.simpleFunc(function() { return outers; }),
+    handle: ___.simpleFunc(function(newModule) { newModule(outers); })
+  });
+
+
+ this.cajaEnabled_ = true;
+  ___.setNewModuleHandler(moduleHandler);
+};
+
+
+opensocial.Container.prototype.wrapCollectionWithCaja_ = function(collection) {
+  if (this.cajaEnabled_) {
+    ___.allowCall(collection, 'getById');
+    ___.allowCall(collection, 'size');
+    ___.allowCall(collection, 'each');
+    ___.allowCall(collection, 'asArray');
+    ___.allowCall(collection, 'getTotalSize');
+    ___.allowCall(collection, 'getOffset');
+
+    // TODO(doll): Call caja method to support all array calls once it exists
+    ___.allowCall(collection.asArray(), 'push');
+    ___.allowCall(collection.asArray(), 'sort');
+  }
+  return collection;
+};
+
+
+opensocial.Container.prototype.wrapPersonWithCaja_ = function(person) {
+  if (this.cajaEnabled_) {
+    ___.allowCall(person, 'getId');
+    ___.allowCall(person, 'getDisplayName');
+    ___.allowCall(person, 'getField');
+    ___.allowCall(person, 'isViewer');
+    ___.allowCall(person, 'isOwner');
+  }
+  return person;
+};
+
+
+opensocial.Container.prototype.wrapActivityWithCaja_ = function(activity) {
+  if (this.cajaEnabled_) {
+    ___.allowCall(activity, 'getId');
+    ___.allowCall(activity, 'getField');
+  }
+  return activity;
+};
+
+
+opensocial.Container.prototype.wrapActivityMediaItemWithCaja_ = function(
+    mediaItem) {
+  if (this.cajaEnabled_) {
+    ___.allowCall(mediaItem, 'getField');
+  }
+  return mediaItem;
+};
+
+
+opensocial.Container.prototype.wrapResponseItemWithCaja_ = function(
+    responseItem) {
+  if (this.cajaEnabled_) {
+    ___.allowCall(responseItem, 'hadError');
+    ___.allowCall(responseItem, 'getError');
+    ___.allowCall(responseItem, 'getOriginalDataRequest');
+    ___.allowCall(responseItem, 'getData');
+  }
+  return responseItem;
+};
+
+
+opensocial.Container.prototype.wrapDataResponseWithCaja_ = function(
+    dataResponse) {
+  if (this.cajaEnabled_) {
+    ___.allowCall(dataResponse, 'hadError');
+    ___.allowCall(dataResponse, 'get');
+  }
+  return dataResponse;
+};
+
+
+opensocial.Container.prototype.wrapDataRequestWithCaja_ = function(request) {
+  if (this.cajaEnabled_) {
+    ___.allowCall(request, 'getRequestObjects');
+    ___.allowCall(request, 'add');
+    ___.allowCall(request, 'send');
+    ___.allowCall(request, 'newFetchPersonRequest');
+    ___.allowCall(request, 'newFetchPeopleRequest');
+    ___.allowCall(request, 'newFetchGlobalAppDataRequest');
+    ___.allowCall(request, 'newFetchInstanceAppDataRequest');
+    ___.allowCall(request, 'newUpdateInstanceAppDataRequest');
+    ___.allowCall(request, 'newFetchPersonAppDataRequest');
+    ___.allowCall(request, 'newUpdatePersonAppDataRequest');
+    ___.allowCall(request, 'newFetchActivitiesRequest');
+  }
+  return request;
+};
+
+
+opensocial.Container.prototype.wrapEnvironmentWithCaja_ = function(
+    environment) {
+  if (this.cajaEnabled_) {
+    ___.allowCall(environment, 'getDomain');
+    ___.allowCall(environment, 'getSurface');
+    ___.allowCall(environment, 'getSupportedSurfaces');
+    ___.allowCall(environment, 'getParams');
+    ___.allowCall(environment, 'supportsField');
+    ___.allowCall(environment, 'hasCapability');
+  }
+  return environment;
+};
+
+
+opensocial.Container.prototype.wrapSurfaceWithCaja_ = function(surface) {
+  if (this.cajaEnabled_) {
+    ___.allowCall(surface, 'getName');
+    ___.allowCall(surface, 'isPrimaryContent');
+  }
+  return surface;
+};

Propchange: incubator/shindig/trunk/javascript/opensocial/reference/container.js
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/shindig/trunk/javascript/opensocial/reference/datarequest.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/opensocial/reference/datarequest.js?rev=609418&view=auto
==============================================================================
--- incubator/shindig/trunk/javascript/opensocial/reference/datarequest.js (added)
+++ incubator/shindig/trunk/javascript/opensocial/reference/datarequest.js Sun Jan  6 13:50:57 2008
@@ -0,0 +1,503 @@
+/**
+ * Copyright 2007 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @fileoverview Object used to request social information from the container.
+ * This includes data for friends, profiles, app data, and activities.
+ *
+ * All apps that require access to people information should send a dataRequest
+ * in order to receieve a dataResponse
+ */
+
+
+/**
+ * @class
+ * <p>
+ * Creates an item to request social information from the container.
+ * This includes data for friends, profiles, app data, and activities.
+ * All apps that require access to people information
+ * should send a DataRequest.
+ * </p>
+ *
+ * <p>
+ * Here's an example of creating, initializing, sending, and handling
+ * the results of a data request:
+ * </p>
+ *
+ * <pre>function requestMe() {
+  var req = opensocial.newDataRequest();
+  req.add(req.newFetchPersonRequest(
+            opensocial.DataRequest.PersonId.VIEWER),
+          "viewer");
+  req.send(handleRequestMe);
+};
+
+function handleRequestMe(data) {
+  var viewer = data.get("viewer");
+  if (viewer.hadError()) {
+    <em>//Handle error using viewer.getError()...</em>
+    return;
+  }
+
+  <em>//No error. Do something with viewer.getData()...</em>
+}
+</pre>
+ * <p>
+ * <b>See also:</b>
+ * <a href="opensocial.html#newDataRequest"><code>
+ * opensocial.newDataRequest()</code></a>
+ * </p>
+ *
+ * @name opensocial.DataRequest
+ */
+
+/**
+ * Do not create a DataRequest directly, instead use
+ * opensocial.createDataRequest();
+ *
+ * @private
+ * @constructor
+ */
+opensocial.DataRequest = function() {
+  this.requestObjects_ = [];
+};
+
+
+/**
+ * {Array.<{key: string, request:opensocial.DataRequest.BaseDataRequest}>}
+ *    requestObjects An array of
+ *    data requests that the container should fetch data for
+ * @private
+ */
+opensocial.DataRequest.prototype.requestObjects_ = null;
+
+
+/**
+ * Get the requested objects
+ *
+ * @return {Array.<{key:String, request:BaseDataRequest}>}
+ *    requestObjects An array of data requests that the container should fetch
+ *    data for
+ * @private
+ */
+opensocial.DataRequest.prototype.getRequestObjects = function() {
+  return this.requestObjects_;
+};
+
+
+/**
+ * Adds an item to fetch (get) or update (set) data from the server.
+ * A single DataRequest object can have multiple items.
+ * As a rule, each item is executed in the order it was added,
+ * starting with the item that was added first.
+ * However, items that can't collide might be executed in parallel.
+ *
+ * @param {Object} request Specifies which data to fetch or update
+ * @param {String} opt_key A key to map the generated response data to
+ */
+opensocial.DataRequest.prototype.add = function(request, opt_key) {
+  return this.requestObjects_.push({'key': opt_key, 'request': request});
+};
+
+
+/**
+ * Sends a data request to the server in order to get a data response.
+ * Although the server may optimize these requests,
+ * they will always be executed 
+ * as though they were serial.
+ *
+ * @param {Function} opt_callback The function to call with the
+ *   <a href="opensocial.DataResponse.html">data response</a>
+ *    generated by the server
+ */
+opensocial.DataRequest.prototype.send = function(opt_callback) {
+  var callback = opt_callback || function(){};
+  opensocial.Container.get().requestData(this, callback);
+};
+
+
+/**
+ * @static
+ * @class
+ * Constant person IDs available when fetching person information.
+ *
+ * @name opensocial.DataRequest.PersonId
+ */
+opensocial.DataRequest.PersonId = {
+ /**
+  * @member opensocial.DataRequest.PersonId
+  */
+  OWNER : 'OWNER',
+ /**
+  * @member opensocial.DataRequest.PersonId
+  */
+  VIEWER : 'VIEWER'
+};
+
+
+/**
+ * @static
+ * @class
+ * Groups available when fetching person information.
+ *
+ * @name opensocial.DataRequest.Group
+ */
+opensocial.DataRequest.Group = {
+ /**
+  * @member opensocial.DataRequest.Group
+  */
+  OWNER_FRIENDS : 'OWNER_FRIENDS',
+ /**
+  * @member opensocial.DataRequest.Group
+  */
+  VIEWER_FRIENDS : 'VIEWER_FRIENDS'
+};
+
+
+/**
+ * @static
+ * @class
+ * The sort orders available for ordering person objects.
+ *
+ * @name opensocial.DataRequest.SortOrder
+ */
+opensocial.DataRequest.SortOrder = {
+  /**
+   * When used will sort people by the container's definition of top friends.
+   * @member opensocial.DataRequest.SortOrder
+   */
+  TOP_FRIENDS : 'topFriends',
+  /**
+   * When used will sort people alphabetically by the name field.
+   *
+   * @member opensocial.DataRequest.SortOrder
+   */
+  NAME : 'name'
+};
+
+
+/**
+ * @static
+ * @class
+ * The filters available for limiting person requests.
+ *
+ * @name opensocial.DataRequest.FilterType
+ */
+opensocial.DataRequest.FilterType = {
+  /**
+   * Retrieves all friends.
+   *
+   * @member opensocial.DataRequest.FilterType
+   */
+  ALL : 'all',
+  /**
+   * Retrieves all friends with any data for this application.
+   *
+   * @member opensocial.DataRequest.FilterType
+   */
+  HAS_APP : 'hasApp'
+};
+
+
+/**
+ * @static
+ * @class
+ * @name opensocial.DataRequest.PeopleRequestFields
+ */
+opensocial.DataRequest.PeopleRequestFields = {
+  /**
+   * An array of
+   * <a href="opensocial.Person.Field.html">
+   * <code>opensocial.Person.Field</code></a>
+   * specifying what profile data to fetch
+   * for each of the person objects. The server will always include
+   * ID, NAME, and THUMBNAIL_URL.
+   *
+   * @member opensocial.DataRequest.PeopleRequestFields
+   */
+  PROFILE_DETAILS : 'profileDetail',
+
+  /**
+   * A sort order for the people objects; defaults to TOP_FRIENDS.
+   * Possible values are defined by
+   * <a href="opensocial.DataRequest.SortOrder.html">SortOrder</a>.
+   *
+   * @member opensocial.DataRequest.PeopleRequestFields
+   */
+  SORT_ORDER : 'sortOrder',
+
+  /**
+   * How to filter the people objects; defaults to ALL.
+   * Possible values are defined by
+   * <a href="opensocial.DataRequest.FilterType.html">FilterType</a>.
+   *
+   * @member opensocial.DataRequest.PeopleRequestFields
+   */
+  FILTER : 'filter',
+
+  /**
+   * When paginating, the index of the first item to fetch.
+   * Specified as a <code>Number</code>.
+   *
+   * @member opensocial.DataRequest.PeopleRequestFields
+   */
+  FIRST : 'first',
+
+  /**
+   * The maximum number of items to fetch; defaults to 20. If set to a larger
+   * number, a container may honor the request, or may limit the number to a
+   * container-specified limit of at least 20.
+   * Specified as a <code>Number</code>.
+   *
+   * @member opensocial.DataRequest.PeopleRequestFields
+   */
+  MAX : 'max'
+};
+
+
+/**
+ * If the named param does not exist sets it to the default value.
+ *
+ * @param {Map} params Parameter map.
+ * @param {String} name of the param to check
+ * @param {Object} defaultValue The value to set if the param does not exist.
+ * @private
+ */
+opensocial.DataRequest.prototype.addDefaultParam = function(params, name,
+    defaultValue) {
+  params[name] = params[name] || defaultValue;
+};
+
+
+/**
+ * Adds the default profile fields to the desired array.
+ *
+ * @param {Map} params Parameter map.
+ * @private
+ */
+opensocial.DataRequest.prototype.addDefaultProfileFields = function(params) {
+  var fields = opensocial.DataRequest.PeopleRequestFields;
+  var profileFields = params[fields.PROFILE_DETAILS] || [];
+  params[fields.PROFILE_DETAILS] = profileFields.concat(
+      [opensocial.Person.Field.ID, opensocial.Person.Field.NAME,
+       opensocial.Person.Field.THUMBNAIL_URL]);
+};
+
+
+/**
+ * Returns the keys object as an array.
+ *
+ * @param {Object} keys
+ * @private
+ */
+opensocial.DataRequest.prototype.asArray = function(keys) {
+  if (opensocial.Container.isArray(keys)) {
+    return keys;
+  } else {
+    return [keys];
+  }
+};
+
+
+/**
+ * Creates an item to request a profile for the specified person ID.
+ * When processed, returns a
+ * <a href="opensocial.Person.html"><code>Person</code></a> object.
+ *
+ * @param {String} id The ID of the person to fetch; can be the standard
+ *    <a href="opensocial.DataRequest.PersonId.html">person ID</a>
+ *    of VIEWER or OWNER
+ * @param {Map.&lt;opensocial.DataRequest.PeopleRequestFields, Object&gt;}
+ *  opt_params
+ *    Additional
+ *    <a href="opensocial.DataRequest.PeopleRequestFields.html">parameters</a>
+ *    to pass to the request; this request supports PROFILE_DETAILS
+ * @return {Object} A request object
+ */
+opensocial.DataRequest.prototype.newFetchPersonRequest = function(id,
+    opt_params) {
+  opt_params = opt_params || {};
+  var fields = opensocial.DataRequest.PeopleRequestFields;
+
+  this.addDefaultProfileFields(opt_params);
+
+  return opensocial.Container.get().newFetchPersonRequest(id, opt_params);
+};
+
+
+/**
+ * Creates an item to request friends from the server.
+ * When processed, returns a <a href="opensocial.Collection.html">Collection</a>
+ * &lt;<a href="opensocial.Person.html">Person</a>&gt; object.
+ *
+ * @param {Array.&lt;String&gt; | String} idSpec An ID, array of IDs, or a group
+ *    reference used to specify which people to fetch; the supported keys are
+ *    VIEWER, OWNER, VIEWER_FRIENDS, OWNER_FRIENDS, or a single ID within one
+ *    of those groups.
+ * @param {Map.&lt;opensocial.DataRequest.PeopleRequestFields, Object&gt;}
+ *  opt_params
+ *    Additional
+ *    <a href="opensocial.DataRequest.PeopleRequestFields.html">params</a>
+ *    to pass to the request
+ * @return {Object} A request object
+ */
+opensocial.DataRequest.prototype.newFetchPeopleRequest = function(idSpec,
+    opt_params) {
+  opt_params = opt_params || {};
+  var fields = opensocial.DataRequest.PeopleRequestFields;
+
+  this.addDefaultProfileFields(opt_params);
+
+  this.addDefaultParam(opt_params, fields.SORT_ORDER,
+      opensocial.DataRequest.SortOrder.TOP_FRIENDS);
+
+  this.addDefaultParam(opt_params, fields.FILTER,
+      opensocial.DataRequest.FilterType.ALL);
+
+  this.addDefaultParam(opt_params, fields.FIRST, 0);
+
+  this.addDefaultParam(opt_params, fields.MAX, 20);
+
+  return opensocial.Container.get().newFetchPeopleRequest(idSpec, opt_params);
+};
+
+
+/**
+ * Creates an item to request global app data.
+ * When processed, returns a Map&lt;String, String&gt; object.
+ *
+ * @param {Array.&lt;String&gt; | String} keys The keys you want data for; this
+ *     can be an array of key names, a single key name, or "*" to mean
+ *     "all keys"
+ * @return {Object} A request object
+ */
+opensocial.DataRequest.prototype.newFetchGlobalAppDataRequest = function(keys) {
+  return opensocial.Container.get().newFetchGlobalAppDataRequest(
+      this.asArray(keys));
+};
+
+
+/**
+ * Creates an item to request instance app data.
+ * When processed, returns a Map&lt;String, String&gt; object.
+ *
+ * @param {Array.&lt;String&gt; | String} keys The keys you want data for; this
+ *     can be an array of key names, a single key name, or "*" to mean
+ *     "all keys"
+ * @return {Object} A request object
+ */
+opensocial.DataRequest.prototype.newFetchInstanceAppDataRequest =
+    function(keys) {
+  return opensocial.Container.get().newFetchInstanceAppDataRequest(
+      this.asArray(keys));
+};
+
+
+/**
+ * Creates an item to request an update of an app instance field from the
+ * server. When processed, does not return any data.
+ *
+ * @param {String} key The name of the key. This may only contain alphanumeric
+ *     (A-Za-z0-9) characters, underscore(_), dot(.) or dash(-).
+ * @param {String} value The value
+ * @return {Object} A request object
+ */
+opensocial.DataRequest.prototype.newUpdateInstanceAppDataRequest = function(key,
+    value) {
+  return opensocial.Container.get().newUpdateInstanceAppDataRequest(key, value);
+};
+
+
+/**
+ * Creates an item to request app data for the given people.
+ * When processed, returns a Map&lt;
+ * <a href="opensocial.DataRequest.PersonId.html">PersonId</a>,
+ * Map&lt;String,
+ * String&gt;&gt; object.
+ *
+ * @param {Array.&lt;String&gt; | String} idSpec An ID, array of IDs, or a group
+ *    reference; the supported keys are VIEWER, OWNER, VIEWER_FRIENDS,
+ *    OWNER_FRIENDS, or a single ID within one of those groups
+ * @param {Array.&lt;String&gt; | String} keys The keys you want data for; this
+ *     can be an array of key names, a single key name, or "*" to mean
+ *     "all keys"
+ * @return {Object} A request object
+ */
+opensocial.DataRequest.prototype.newFetchPersonAppDataRequest = function(idSpec,
+    keys) {
+  return opensocial.Container.get().newFetchPersonAppDataRequest(idSpec,
+      this.asArray(keys));
+};
+
+
+/**
+ * Creates an item to request an update of an app field for the given person.
+ * When processed, does not return any data.
+ *
+ * @param {String} id The ID of the person to update; only the
+ *     special <code>VIEWER</code> ID is currently allowed.
+ * @param {String} key The name of the key. This may only contain alphanumeric
+ *     (A-Za-z0-9) characters, underscore(_), dot(.) or dash(-).
+ * @param {String} value The value
+ * @return {Object} A request object
+ */
+opensocial.DataRequest.prototype.newUpdatePersonAppDataRequest = function(id,
+    key, value) {
+  return opensocial.Container.get().newUpdatePersonAppDataRequest(id, key,
+      value);
+};
+
+
+/**
+ * @static
+ * @class
+ * Used by
+ * <a href="opensocial.DataRequest.html#newFetchActivitiesRequest">
+ * <code>DataRequest.newFetchActivitiesRequest()</code></a>.
+ * @name opensocial.DataRequest.ActivityRequestFields
+ */
+opensocial.DataRequest.ActivityRequestFields = {
+  /**
+   * {String} If provided will filter all activities by this app Id.
+   * @private - at the moment you can only request activities for your own app
+   */
+  APP_ID : 'appId'
+};
+
+
+/**
+ * Creates an item to request an activity stream from the server.
+ *
+ * <p>
+ * When processed, returns an object whose "activities" property is a
+ * Collection&lt;Activity&gt; object.
+ * </p>
+ *
+ * @param {Array.&lt;String&gt; | String} idSpec An ID, array of IDs, or a group
+ *    reference used to specify which people's activities to fetch; the
+ *    supported keys are VIEWER, OWNER, VIEWER_FRIENDS, OWNER_FRIENDS, or
+ *    a single ID within one of those groups.
+ * @param {Map.&lt;opensocial.DataRequest.ActivityRequestFields, Object&gt;}
+ *  opt_params
+ *    Additional
+ *    <a href="opensocial.DataRequest.ActivityRequestFields.html">parameters</a>
+ *    to pass to the request
+ * @return {Object} A request object
+ */
+opensocial.DataRequest.prototype.newFetchActivitiesRequest = function(idSpec,
+    opt_params) {
+  opt_params = opt_params || {};
+  return opensocial.Container.get().newFetchActivitiesRequest(idSpec,
+      opt_params);
+};

Propchange: incubator/shindig/trunk/javascript/opensocial/reference/datarequest.js
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/shindig/trunk/javascript/opensocial/reference/dataresponse.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/opensocial/reference/dataresponse.js?rev=609418&view=auto
==============================================================================
--- incubator/shindig/trunk/javascript/opensocial/reference/dataresponse.js (added)
+++ incubator/shindig/trunk/javascript/opensocial/reference/dataresponse.js Sun Jan  6 13:50:57 2008
@@ -0,0 +1,76 @@
+/**
+ * Copyright 2007 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @fileoverview DataResponse containing information about
+ * friends, contacts, profile, app data, and activities.
+ *
+ * Whenever a dataRequest is sent to the server it will return a dataResponse
+ * object. Values from the server will be mapped to the requested keys specified
+ * in the dataRequest.
+ */
+
+
+/**
+ * @class
+ * This object contains the requested server data mapped to the requested keys.
+ *
+ * <p>
+ * <b>See also:</b>
+ * <a href="opensocial.DataRequest.html">DataRequest</a>
+ * </p>
+ *
+ * @name opensocial.DataResponse
+ */
+
+/**
+ * Construct the data response.
+ * This object contains the requested server data mapped to the requested keys.
+ *
+ * @param {Map.<String, ResponseItem>} responseItems Key/value map of data
+ *    response information
+ * @param {Boolean} opt_globalError Optional field indicating whether there were
+ *    any errors generating this data response
+ *
+ * @private
+ * @constructor
+ */
+opensocial.DataResponse = function(responseItems, opt_globalError) {
+  this.responseItems_ = responseItems;
+  this.globalError_ = opt_globalError;
+};
+
+
+/**
+ * Returns true if there was an error in fetching this data from the server.
+ *
+ * @return {Boolean} True if there was an error; otherwise, false
+ * @member opensocial.DataResponse
+ */
+opensocial.DataResponse.prototype.hadError = function() {
+  return !!this.globalError_;
+};
+
+
+/**
+ * Gets the ResponseItem for the requested field.
+ *
+ * @return {opensocial.ResponseItem} The requested
+ *    <a href="opensocial.ResponseItem.html">response</a> calculated by the
+ *    server
+ * @member opensocial.DataResponse
+ */
+opensocial.DataResponse.prototype.get = function(key) {
+  return this.responseItems_[key];
+};

Propchange: incubator/shindig/trunk/javascript/opensocial/reference/dataresponse.js
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/shindig/trunk/javascript/opensocial/reference/environment.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/opensocial/reference/environment.js?rev=609418&view=auto
==============================================================================
--- incubator/shindig/trunk/javascript/opensocial/reference/environment.js (added)
+++ incubator/shindig/trunk/javascript/opensocial/reference/environment.js Sun Jan  6 13:50:57 2008
@@ -0,0 +1,165 @@
+/**
+ * Copyright 2007 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @fileoverview Representation of a environment.
+ */
+
+
+/**
+ * @class
+ * Represents the current environment for a gadget.
+ *
+ * <p>
+ * <b>See also:</b>
+ * <a href="opensocial.html#getEnvironment">opensocial.getEnvironment()</a>,
+ *
+ * @name opensocial.Environment
+ */
+
+
+/**
+ * Base interface for all environment objects.
+ *
+ * @param {String} domain The current domain
+ * @param {opensocial.Surface} surface The current surface
+ * @param {Array.&lt;Surface&gt;} supportedSurfaces
+ *    The surfaces supported by this container
+ * @param {Map.&lt;String, Map.&lt;String, Boolean&gt;&gt;} supportedFields
+ *    The fields supported by this container
+ * @param {Map.&lt;String, String&gt;} opt_params
+ *    The params this gadget has access to
+ *
+ * @private
+ * @constructor
+ */
+opensocial.Environment = function(domain, surface, supportedSurfaces,
+    supportedFields, opt_params) {
+  this.domain = domain;
+  this.surface = surface;
+  this.supportedSurfaces = supportedSurfaces;
+  this.supportedFields = supportedFields;
+  this.params = opt_params || {};
+};
+
+
+/**
+ * Returns the current domain &mdash;
+ * for example, "orkut.com" or "myspace.com".
+ *
+ * @return {String} The domain
+ */
+opensocial.Environment.prototype.getDomain = function() {
+  return this.domain;
+};
+
+
+/**
+ * Returns the current surface.
+ *
+ * @return {opensocial.Surface}
+ *    The current <a href="opensocial.Surface.html">surface</a>
+ */
+opensocial.Environment.prototype.getSurface = function() {
+  return this.surface;
+};
+
+
+/**
+ * Returns an array of all the supported surfaces.
+ *
+ * @return {Array.&lt;opensocial.Surface&gt;}
+ *    All supported <a href="opensocial.Surface.html">surfaces</a>
+ */
+opensocial.Environment.prototype.getSupportedSurfaces = function() {
+  return this.supportedSurfaces;
+};
+
+
+/**
+ * Returns the parameters passed into this gadget.
+ *
+ * @return {Map.&lt;String, String&gt;} The parameter map
+ */
+opensocial.Environment.prototype.getParams = function() {
+  return this.params;
+};
+
+
+/**
+ * @static
+ * @class
+ *
+ * The types of objects in this container.
+ * 
+ * <p>
+ * <b>See also:</b>
+ * <a href="opensocial.Environment.html#supportsField">
+ * <code>Environment.supportsField()</code></a>
+ *
+ * @name opensocial.Environment.ObjectType
+ */
+opensocial.Environment.ObjectType = {
+  /**
+   * @member opensocial.Environment.ObjectType
+   */
+  PERSON : 'person',
+  /**
+   * @member opensocial.Environment.ObjectType
+   */
+  ACTIVITY : 'activity',
+  /**
+   * @member opensocial.Environment.ObjectType
+   */
+  ACTIVITY_MEDIA_ITEM : 'activityMediaItem'
+};
+
+
+/**
+ * Returns true if the specified field is supported in this container on the
+ * given object type.
+ *
+ * @param {opensocial.Environment.ObjectType} objectType
+ *    The <a href="opensocial.Environment.ObjectType.html">object type</a>
+ *    to check for the field
+ * @param {String} fieldName The name of the field to check for
+ * @return {Boolean} True if the field is supported on the specified object type
+ */
+opensocial.Environment.prototype.supportsField = function(objectType,
+    fieldName) {
+  var supportedObjectFields = this.supportedFields[objectType] || [];
+  return !!supportedObjectFields[fieldName];
+};
+
+
+/**
+ * Returns true if the specified function is supported in this container.
+ *
+ * @param {String} functionName The function name
+ * @return {Boolean} True if this container supports the function
+ */
+opensocial.Environment.prototype.hasCapability = function(functionName) {
+  var splitNames = functionName.split(".");
+  var parentObject = window;
+
+  for (var i = 0; i < splitNames.length; i++) {
+    var childObject = parentObject[splitNames[i]];
+    if (!childObject) {
+      return false;
+    } else {
+      parentObject = childObject;
+    }
+  }
+  return true;
+};

Propchange: incubator/shindig/trunk/javascript/opensocial/reference/environment.js
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/shindig/trunk/javascript/opensocial/reference/opensocial.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/opensocial/reference/opensocial.js?rev=609418&view=auto
==============================================================================
--- incubator/shindig/trunk/javascript/opensocial/reference/opensocial.js (added)
+++ incubator/shindig/trunk/javascript/opensocial/reference/opensocial.js Sun Jan  6 13:50:57 2008
@@ -0,0 +1,410 @@
+/**
+ * Copyright 2007 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @fileoverview Browser environment for interacting with people.
+ */
+
+
+/**
+ * @static
+ * @class
+ * Namespace for top-level people functions.
+ *
+ * @name opensocial
+ */
+
+/**
+ * Namespace for top level people functions.
+ *
+ * @private
+ * @constructor (note: a constructor for JsDoc purposes)
+ */
+var opensocial = function() {};
+
+
+/**
+ * Takes an activity and tries to create it,
+ * without waiting for the operation to complete.
+ * Optionally calls a function when the operation completes.
+ * <p>
+ * <b>See also:</b>
+ * <a href="#newActivity">newActivity()</a>
+ * </p>
+ *
+ * <p class="note">
+ * <b>Note:</b>
+ * If this is the first activity that has been created for the user and
+ * the request is marked as HIGH priority then this call may open a user flow
+ * and navigate away from your gadget.
+ *
+ * @param {opensocial.Activity} activity The <a href="opensocial.Activity.html">
+ *    activity</a> to create
+ * @param {opensocial.CreateActivityPriority} priority The
+ *    <a href="opensocial.CreateActivityPriority.html">priority</a> for this
+ *    request
+ * @param {Function} opt_callback The function to call once the request has been
+ *    processed. This callback will either be called or the gadget will be
+ *    reloaded from scratch
+ *
+ * @member opensocial
+ */
+opensocial.requestCreateActivity = function(activity, priority, opt_callback) {
+ opensocial.Container.get().requestCreateActivity(activity, priority,
+     opt_callback);
+};
+
+
+/**
+ * @static
+ * @class
+ * The priorities a create activity request can have.
+ * <p><b>See also:</b>
+ * <a href="opensocial.html#requestCreateActivity">
+ * opensocial.requestCreateActivity()</a>
+ * </p>
+ *
+ * @name opensocial.CreateActivityPriority
+ */
+opensocial.CreateActivityPriority = {
+  /**
+   * If the activity is of high importance, it will be created even if this
+   * requires asking the user for permission. This may cause the container to
+   * open a user flow which may navigate away from your gagdet.
+   *
+   * @member opensocial.CreateActivityPriority
+   */
+  HIGH : 'HIGH',
+
+  /**
+   * If the activity is of low importance, it will not be created if the
+   * user has not given permission for the current app to create activities.
+   * With this priority, the requestCreateActivity call will never open a user
+   * flow.
+   *
+   * @member opensocial.CreateActivityPriority
+   */
+  LOW : 'LOW'
+};
+
+
+/**
+ * Returns true if the current gadget has access to the specified
+ * permission.
+ *
+ * @param {opensocial.Permission} permission
+ *    The <a href="opensocial.Permission.html">permission</a>
+ * @return {Boolean}
+ *    True if the gadget has access for the permission; false if it doesn't
+ *
+ * @member opensocial
+ */
+opensocial.hasPermission = function(permission) {
+  return opensocial.Container.get().hasPermission(permission);
+};
+
+
+/**
+ * Requests the user to grant access to the specified permissions.
+ *
+ * @param {Array.&lt;opensocial.Permission&gt;} permissions
+ *    The <a href="opensocial.Permission.html">permissions</a> to request
+ *    from the viewer
+ * @param {String} reason Displayed to the user as the reason why these
+ *    permissions are needed
+ * @param {Function} opt_callback The function to call once the request has been
+ *    processed; either this callback will be called or the gadget will be
+ *    reloaded from scratch
+ *
+ * @member opensocial
+ */
+opensocial.requestPermission = function(permissions, reason, opt_callback) {
+  opensocial.Container.get().requestPermission(permissions, reason,
+      opt_callback);
+};
+
+
+/**
+ * @static
+ * @class
+ *
+ * The permissions an app can ask for.
+ *
+ * <p>
+ * <b>See also:</b>
+ * <a href="opensocial.html#hasPermission">
+ * <code>opensocial.hasPermission()</code></a>,
+ * <a href="opensocial.html#requestPermission">
+ * <code>opensocial.requestPermission()</code></a>
+ *
+ * @name opensocial.Permission
+ */
+opensocial.Permission = {
+  /**
+   * Access to the viewer person object
+   *
+   * @member opensocial.Permission
+   */
+  VIEWER : 'viewer'
+};
+
+
+/**
+ * Attempts to navigate to this gadget on a different surface. If the container
+ * supports parameters will pass the optional parameters along to the gadget on
+ * the new surface.
+ *
+ * @param {opensocial.Surface} surface The surface to navigate to
+ * @param {Map.&lt;String, String&gt;} opt_params
+ *    Params to pass to the gadget after it
+ *    has been navigated to on the surface
+ *
+ * @member opensocial
+ */
+/* TODO(doll): Do we want a real Surface object here? or just the name? */
+opensocial.requestNavigateTo = function(surface, opt_params) {
+  return opensocial.Container.get().requestNavigateTo(surface, opt_params);
+};
+
+
+/**
+ * Gets the current environment for this gadget. You can use the environment to
+ * make queries such as what profile fields and surfaces are supported by this
+ * container, what parameters were passed to the current gadget, and so on.
+ *
+ * @return {opensocial.Environment}
+ *    The current <a href="opensocial.Environment.html">environment</a>
+ *
+ * @member opensocial
+ */
+opensocial.getEnvironment = function() {
+  return opensocial.Container.get().getEnvironment();
+};
+
+
+/**
+ * Fetches content from the provided URL and feeds that content into the
+ * callback function.
+ * @param {String} url The URL where the content is located
+ * @param {Function} callback The function to call with the data from the URL
+ *     once it is fetched
+ * @param {Map.&lt;opensocial.ContentRequestParameters, Object&gt;} opt_params
+ *     Additional
+ *     <a href="opensocial.ContentRequestParameters.html">parameters</a>
+ *     to pass to the request
+ *
+ * @member opensocial
+ */
+opensocial.makeRequest = function(url, callback, opt_params) {
+  opensocial.Container.get().makeRequest(url, callback, opt_params);
+};
+
+
+/**
+ * TODO(doll): Rename authentication to authorization, also add headers param
+ *
+ * @static
+ * @class
+ * Used by the
+ * <a href="opensocial.html#makeRequest">
+ * <code>opensocial.makeRequest()</code></a> method.
+ * @name opensocial.ContentRequestParameters
+ */
+opensocial.ContentRequestParameters = {
+  /**
+   * The method to use when fetching content from the URL;
+   * defaults to <code>MethodType.GET</a></code>.
+   * Specified as a 
+   * <a href="opensocial.ContentRequestParameters.MethodType.html">MethodType</a>.
+   *
+   * @member opensocial.ContentRequestParameters
+   */
+  METHOD : 'method',
+
+  /**
+   * The type of content that lives at the URL;
+   * defaults to <code>ContentType.HTML</code>.
+   * Specified as a
+   * <a href="opensocial.ContentRequestParameters.ContentType.html">
+   * ContentType</a>.
+   *
+   * @member opensocial.ContentRequestParameters
+   */
+  CONTENT_TYPE : 'contentType',
+
+  /**
+   * The type of authentication to use when fetching the content;
+   * defaults to <code>AuthenticationType.NONE</code>.
+   * Specified as an
+   * <a href="opensocial.ContentRequestParameters.AuthenticationType.html">
+   * AuthenticationType</a>.
+   *
+   * @member opensocial.ContentRequestParameters
+   */
+  AUTHENTICATION : 'authentication',
+
+  /**
+   * If the content is a feed, the number of entries to fetch;
+   * defaults to 3.
+   * Specified as a <code>Number</code>.
+   *
+   * @member opensocial.ContentRequestParameters
+   */
+  NUM_ENTRIES : 'numEntries',
+
+  /**
+   * If the content is a feed, whether to fetch summaries for that feed;
+   * defaults to false.
+   * Specified as a <code>Boolean</code>.
+   *
+   * @member opensocial.ContentRequestParameters
+   */
+  GET_SUMMARIES : 'getSummaries'
+};
+
+
+/**
+ * @static
+ * @class
+ * Used by
+ * <a href="opensocial.ContentRequestParameters.html">
+ * ContentRequestParameters</a>.
+ * @name opensocial.ContentRequestParameters.MethodType
+ */
+opensocial.ContentRequestParameters.MethodType = {
+  /** @member opensocial.ContentRequestParameters.MethodType */
+  GET : 'get',
+
+  /** @member opensocial.ContentRequestParameters.MethodType */
+  POST : 'post'
+};
+
+
+/**
+ * @static
+ * @class
+ * Used by
+ * <a href="opensocial.ContentRequestParameters.html">
+ * ContentRequestParameters</a>.
+ * @name opensocial.ContentRequestParameters.ContentType
+ */
+opensocial.ContentRequestParameters.ContentType = {
+  /**
+   * Returns text.
+   * @member opensocial.ContentRequestParameters.ContentType
+   */
+  HTML : 'html',
+
+  /**
+   * Returns a dom object.
+   * @member opensocial.ContentRequestParameters.ContentType
+   */
+  XML : 'xml',
+
+  /**
+   * Returns a json object.
+   * @member opensocial.ContentRequestParameters.ContentType
+   */
+   FEED : 'feed'
+};
+
+
+/**
+ * @static
+ * @class
+ * Used by
+ * <a href="opensocial.ContentRequestParameters.html">
+ * ContentRequestParameters</a>.
+ * @name opensocial.ContentRequestParameters.AuthenticationType
+ */
+opensocial.ContentRequestParameters.AuthenticationType = {
+  /** @member opensocial.ContentRequestParameters.AuthenticationType */
+  NONE : 'none',
+
+  /** @member opensocial.ContentRequestParameters.AuthenticationType */
+  SIGNED : 'signed',
+
+  /** @member opensocial.ContentRequestParameters.AuthenticationType */
+  AUTHENTICATED : 'authenticated'
+};
+
+
+/**
+ * Creates a data request object to use for sending and fetching data from the
+ * server.
+ *
+ * @return {opensocial.DataRequest} The
+ *    <a href="opensocial.DataRequest.html">request</a> object
+ * @member opensocial
+ */
+opensocial.newDataRequest = function() {
+  return opensocial.Container.get().newDataRequest();
+};
+
+
+/**
+ * Creates an activity object,
+ * which represents an activity on the server.
+ * <p>
+ * <b>See also:</b>
+ * <a href="#requestCreateActivity">requestCreateActivity()</a>,
+ * </p>
+ *
+ * @param {String} title The title of an activity
+ * @param {Map.&lt;opensocial.Activity.Field, Object&gt;} opt_params Any other
+ *    fields that should be set on the activity object; all of the defined
+ *    <a href="opensocial.Activity.Field.html">Field</a>s are supported
+ * @return {opensocial.Activity} The new
+ *    <a href="opensocial.Activity.html">activity</a> object
+ * @member opensocial
+ */
+opensocial.newActivity = function(title, opt_params) {
+  return opensocial.Container.get().newActivity(title, opt_params);
+};
+
+
+/**
+ * Creates a media item associated with an activity.
+ * Represents images, movies, and audio.
+ * Used when creating activities on the server.
+ *
+ * @param {String} mimeType
+ *    <a href="opensocial.Activity.MediaItem.Type.html">MIME type</a> of the
+ *    media
+ * @param {String} url Where the media can be found
+ * @param {Map.&lt;opensocial.Activity.MediaItem.Field, Object&gt;} opt_params
+ *    Any other fields that should be set on the media item object;
+ *    all of the defined
+ *    <a href="opensocial.Activity.MediaItem.Field.html">Field</a>s
+ *    are supported
+ *
+ * @return {opensocial.Activity.MediaItem} The new
+ *    <a href="opensocial.Activity.MediaItem.html">media item</a> object
+ * @member opensocial
+ */
+opensocial.newActivityMediaItem = function(mimeType, url, opt_params) {
+  return opensocial.Container.get().newActivityMediaItem(mimeType,
+      url, opt_params);
+};
+
+
+// TODO(doll): Util function - pull up the gadgets inherits in shindig so that
+// opensocial and gadgets use the same one
+Function.prototype.inherits = function(parentCtor) {
+  function tempCtor() {};
+  tempCtor.prototype = parentCtor.prototype;
+  this.superClass_ = parentCtor.prototype;
+  this.prototype = new tempCtor();
+  this.prototype.constructor = this;
+};

Propchange: incubator/shindig/trunk/javascript/opensocial/reference/opensocial.js
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/shindig/trunk/javascript/opensocial/reference/person.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/opensocial/reference/person.js?rev=609418&view=auto
==============================================================================
--- incubator/shindig/trunk/javascript/opensocial/reference/person.js (added)
+++ incubator/shindig/trunk/javascript/opensocial/reference/person.js Sun Jan  6 13:50:57 2008
@@ -0,0 +1,144 @@
+/**
+ * Copyright 2007 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @fileoverview Representation of a person.
+ */
+
+
+/**
+ * @class
+ * Base interface for all person objects.
+ *
+ * @name opensocial.Person
+ */
+
+
+/**
+ * Base interface for all person objects.
+ *
+ * @private
+ * @constructor
+ */
+opensocial.Person = function(opt_params, opt_isOwner, opt_isViewer) {
+  this.fields_ = opt_params || {};
+  this.isOwner_ = opt_isOwner;
+  this.isViewer_ = opt_isViewer;
+};
+
+
+/**
+ * @static
+ * @class
+ * All of the fields that a person has. These are the supported keys for the
+ * <a href="opensocial.Person.html#getField">Person.getField()</a> method.
+ *
+ * @name opensocial.Person.Field
+ */
+/* TODO(doll): This is not the complete set of fields yet. */
+opensocial.Person.Field = {
+  /**
+   * A string ID that can be permanently associated with this person.
+   * @member opensocial.Person.Field
+   */
+  ID : 'id',
+
+  /**
+   * A string containing the person's name.
+   * @member opensocial.Person.Field
+   */
+  NAME : 'name',
+
+  /**
+   * Person's photo thumbnail URL, specified as a string.
+   * @member opensocial.Person.Field
+   */
+  THUMBNAIL_URL : 'thumbnailUrl',
+
+  /**
+   * Person's profile URL, specified as a string.
+   * @member opensocial.Person.Field
+   */
+  PROFILE_URL : 'profileUrl',
+
+  /**
+   * Person's age, specified as a number. Not supported by all containers.
+   * @member opensocial.Person.Field
+   */
+  AGE : 'age',
+
+ /**
+   * Person's gender, specified as a string. Not supported by all containers.
+   * @member opensocial.Person.Field
+   */
+  GENDER : 'gender'
+
+  // TODO(doll): Add the rest of the profile fields here
+};
+
+
+/**
+ * Gets an ID that can be permanently associated with this person.
+ *
+ * @return {String} The ID
+ */
+opensocial.Person.prototype.getId = function() {
+  return this.getField(opensocial.Person.Field.ID);
+};
+
+
+/**
+ * Gets a text display name for this person; guaranteed to return
+ * a useful string.
+ *
+ * @return {String} The display name
+ */
+opensocial.Person.prototype.getDisplayName = function() {
+  return this.getField(opensocial.Person.Field.NAME);
+};
+
+
+/**
+ * Gets data for this person that is associated with the specified key.
+ *
+ * @param {String} key The key to get data for;
+ *    keys are defined in <a href="opensocial.Person.Field.html"><code>
+ *    Person.Field</code></a>
+ * @return {String} The data
+ */
+opensocial.Person.prototype.getField = function(key) {
+  return this.fields_[key];
+};
+
+
+/**
+ * Returns true if this person object represents the currently logged in user.
+ *
+ * @return {Boolean} True if this is the currently logged in user;
+ *   otherwise, false
+ */
+opensocial.Person.prototype.isViewer = function() {
+  return !!this.isViewer_;
+};
+
+
+/**
+ * Returns true if this person object represents the owner of the current page.
+ *
+ * @return {Boolean} True if this is the owner of the page;
+ *   otherwise, false
+ */
+opensocial.Person.prototype.isOwner = function() {
+  return !!this.isOwner_;
+};

Propchange: incubator/shindig/trunk/javascript/opensocial/reference/person.js
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/shindig/trunk/javascript/opensocial/reference/responseitem.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/opensocial/reference/responseitem.js?rev=609418&view=auto
==============================================================================
--- incubator/shindig/trunk/javascript/opensocial/reference/responseitem.js (added)
+++ incubator/shindig/trunk/javascript/opensocial/reference/responseitem.js Sun Jan  6 13:50:57 2008
@@ -0,0 +1,149 @@
+/**
+ * Copyright 2007 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @fileoverview ResponseItem containing information about a specific response
+ * from the server.
+ */
+
+
+/**
+ * @class
+ * Represents a response that was generated
+ * by processing a data request item on the server.
+ *
+ * @name opensocial.ResponseItem
+ */
+
+
+/**
+ * Represents a response that was generated by processing a data request item
+ * on the server.
+ *
+ * @private
+ * @constructor
+ */
+opensocial.ResponseItem = function(originalDataRequest, data,
+    opt_errorCode, opt_errorMessage) {
+  this.originalDataRequest_ = originalDataRequest;
+  this.data_ = data;
+  this.errorCode_ = opt_errorCode;
+  this.errorMessage_ = opt_errorMessage;
+};
+
+
+/**
+ * Returns true if there was an error in fetching this data from the server.
+ *
+ * @return {Boolean} True if there was an error; otherwise, false
+ */
+opensocial.ResponseItem.prototype.hadError = function() {
+  return !!this.errorCode_;
+};
+
+
+/**
+ * @static
+ * @class
+ *
+ * Error codes that a response item can return.
+ *
+ * @name opensocial.ResponseItem.Error
+ */
+opensocial.ResponseItem.Error = {
+  /**
+   * This container does not support the request that was made.
+   *
+   * @member opensocial.ResponseItem.Error
+   */
+  NOT_IMPLEMENTED : 'notImplemented',
+
+  /**
+   * The gadget does not have access to the requested data.
+   * To get access, use 
+   * <a href="opensocial.html#requestPermission">
+   * opensocial.requestPermission()</a>.
+   *
+   * @member opensocial.ResponseItem.Error
+   */
+  UNAUTHORIZED : 'unauthorized',
+
+  /**
+   * The gadget can never have access to the requested data.
+   *
+   * @member opensocial.ResponseItem.Error
+   */
+  FORBIDDEN : 'forbidden',
+
+   /**
+   * The request was invalid. Example: 'max' was -1.
+   *
+   * @member opensocial.ResponseItem.Error
+   */
+  BAD_REQUEST : 'badRequest',
+
+  /**
+   * The request encountered an unexpected condition that
+   * prevented it from fulfilling the request.
+   *
+   * @member opensocial.ResponseItem.Error
+   */
+  INTERNAL_ERROR : 'internalError'
+};
+
+
+/**
+ * If the request had an error, returns the error code.
+ * The error code can be container-specific 
+ * or one of the values defined by
+ * <a href="opensocial.ResponseItem.Error.html"><code>Error</code></a>.
+ *
+ * @return {String} The error code, or null if no error occurred
+ */
+opensocial.ResponseItem.prototype.getErrorCode = function() {
+  return this.errorCode_;
+};
+
+
+/**
+ * If the request had an error, returns the error message.
+ *
+ * @return {String} A human-readable description of the error that occurred;
+ *    can be null, even if an error occurred
+ */
+opensocial.ResponseItem.prototype.getErrorMessage = function() {
+  return this.errorMessage_;
+};
+
+
+/**
+ * Returns the original data request.
+ *
+ * @return {opensocial.DataRequest} The data request used to fetch this data
+ *    response
+ */
+opensocial.ResponseItem.prototype.getOriginalDataRequest = function() {
+  return this.originalDataRequest_;
+};
+
+
+/**
+ * Gets the response data.
+ *
+ * @return {Object} The requested value calculated by the server; the type of
+ *    this value is defined by the type of request that was made
+ */
+opensocial.ResponseItem.prototype.getData = function() {
+  return this.data_;
+};

Propchange: incubator/shindig/trunk/javascript/opensocial/reference/responseitem.js
------------------------------------------------------------------------------
    svn:executable = *

Added: incubator/shindig/trunk/javascript/opensocial/reference/surface.js
URL: http://svn.apache.org/viewvc/incubator/shindig/trunk/javascript/opensocial/reference/surface.js?rev=609418&view=auto
==============================================================================
--- incubator/shindig/trunk/javascript/opensocial/reference/surface.js (added)
+++ incubator/shindig/trunk/javascript/opensocial/reference/surface.js Sun Jan  6 13:50:57 2008
@@ -0,0 +1,60 @@
+/**
+ * Copyright 2007 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * @fileoverview Representation of a surface.
+ */
+
+
+/**
+ * @class
+ * Base interface for all surface objects.
+ *
+ * @name opensocial.Surface
+ */
+
+
+/**
+ * Base interface for all surface objects.
+ *
+ * @private
+ * @constructor
+ */
+opensocial.Surface = function(name, opt_isPrimaryContent) {
+  this.name = name;
+  this.isPrimaryContentValue = !!opt_isPrimaryContent;
+};
+
+
+/**
+ * Returns the name of this surface.
+ *
+ * @return {String} The surface name
+ */
+opensocial.Surface.prototype.getName = function() {
+  // TODO(doll): Should we doc these names as enums?
+  return this.name;
+};
+
+
+/**
+ * Returns true if the gadget is the primary content on this surface.
+ * On a canvas page
+ * this is most likely true; on a profile page, it is most likely false.
+ *
+ * @return {boolean} True if the gadget is the primary content; otherwise, false
+ */
+opensocial.Surface.prototype.isPrimaryContent = function() {
+  return this.isPrimaryContentValue;
+};

Propchange: incubator/shindig/trunk/javascript/opensocial/reference/surface.js
------------------------------------------------------------------------------
    svn:executable = *