1 /*
  2  * Licensed to the Apache Software Foundation (ASF) under one
  3  * or more contributor license agreements.  See the NOTICE file
  4  * distributed with this work for additional information
  5  * regarding copyright ownership.  The ASF licenses this file
  6  * to you under the Apache License, Version 2.0 (the
  7  * "License"); you may not use this file except in compliance
  8  * with the License.  You may obtain a copy of the License at
  9  *
 10  *     http://www.apache.org/licenses/LICENSE-2.0
 11  *
 12  * Unless required by applicable law or agreed to in writing,
 13  * software distributed under the License is distributed on an
 14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  * KIND, either express or implied.  See the License for the
 16  * specific language governing permissions and limitations
 17  * under the License.
 18  */
 19 
 20 /**
 21  * @class
 22  * Representation of an activity.
 23  *
 24  * <p>Activities are rendered with a title and an optional activity body.</p>
 25  *
 26  * <p>You may set the title and body directly as strings when calling
 27  * opensocial.createActivity.</p>
 28  *
 29  * <p>However, it is usually beneficial to create activities using
 30  * Activity Templates for the title and body. Activity Templates support:</p>
 31  * <ul>
 32  *   <li>Internationalization</li>
 33  *   <li>Replacement variables in the message</li>
 34  *   <li>Activity Summaries, which are message variations used to summarize
 35  *     repeated activities that share something in common.</li>
 36  * </ul>
 37  *
 38  * <p>Activity Templates are defined as messages in the gadget specification.
 39  * To define messages, you create and reference message bundle XML files for
 40  * each locale you support.</p>
 41  *
 42  * <p>Example module spec in gadget XML:
 43  * <pre>
 44  * <ModulePrefs title="ListenToThis">
 45  *   <Locale messages="http://www.listentostuff.com/messages.xml"/>
 46  *   <Locale lang="de" messages="http://www.listentostuff.com/messages-DE.xml"/>
 47  * </ModulePrefs>
 48  * </pre>
 49  * </p>
 50  *
 51  * <p>Example message bundle:
 52  * <pre>
 53  * <messagebundle>
 54  *  <msg name="LISTEN_TO_THIS_SONG">
 55  *     ${Subject.DisplayName} told ${Owner.DisplayName} to
 56  *     listen to a song!
 57  *  </msg>
 58  * </messagebundle>
 59  * </pre>
 60  * </p>
 61  *
 62  * <p>You can set custom key/value string pairs when posting an activity.
 63  * These values will be used for variable substitution in the templates.</p>
 64  * <p>Example JS call:
 65  * <pre>
 66  *   var owner = ...;
 67  *   var viewer = ...;
 68  *   var activity = opensocial.newActivity('LISTEN_TO_THIS_SONG',
 69  *    {Song: 'Do That There - (Young Einstein hoo-hoo mix)',
 70  *     Artist: 'Lyrics Born', Subject: viewer, Owner: owner})
 71  * </pre>
 72  * </p>
 73  *
 74  * <p> Associated message:
 75  * <pre>
 76  * <msg name="LISTEN_TO_THIS_SONG">
 77  *     ${Subject.DisplayName} told ${Owner.DisplayName} to listen
 78  *     to ${Song} by ${Artist}
 79  * </msg>
 80  * </pre>
 81  * </p>
 82  *
 83  * <p>People can also be set as values in key/value pairs when posting
 84  * an activity. You can then reference the following fields on a person:</p>
 85  * <ul>
 86  *  <li>${Person.DisplayName} The person's name</li>
 87  *  <li>${Person.Id} The user ID of the person</li>
 88  *  <li>${Person.ProfileUrl} The profile URL of the person</li>
 89  *  <li>${Person} This will show the display name, but containers may optionally
 90  *     provide special formatting, such as showing the name as a link</li>
 91  * </ul>
 92  *
 93  * <p>Users will have many activities in their activity streams, and containers
 94  * will not show every activity that is visible to a user. To help display
 95  * large numbers of activities, containers will summarize a list of activities
 96  * from a given source to a single entry.</p>
 97  *
 98  * <p>You can provide Activity Summaries to customize the text shown when
 99  * multiple activities are summarized. If no customization is provided, a
100  * container may ignore your activities altogether or provide default text
101  * such as "Bob changed his status message + 20 other events like this."</p>
102  * <ul>
103  *  <li>Activity Summaries will always summarize around a specific key in a
104  *   key/value pair. This is so that the summary can say something concrete
105  *   (this is clearer in the example below).</li>
106  *  <li>Other variables will have synthetic "Count" variables created with
107  *   the total number of items summarized.</li>
108  *  <li>Message ID of the summary is the message ID of the main template + ":" +
109  *   the data key</li>
110  * </ul>
111  *
112  * <p>Example summaries:
113  * <pre>
114  * <messagebundle>
115  *   <msg name="LISTEN_TO_THIS_SONG:Artist">
116  *     ${Subject.Count} of your friends have suggested listening to songs
117  *     by ${Artist}!
118  *   </msg>
119  *   <msg name="LISTEN_TO_THIS_SONG:Song">
120  *     ${Subject.Count} of your friends have suggested listening to ${Song}
121  *   !</msg>
122  *   <msg name="LISTEN_TO_THIS_SONG:Subject">
123  *    ${Subject.DisplayName} has recommended ${Song.Count} songs to you.
124  *   </msg>
125  * </messagebundle>
126  * </pre></p>
127  *
128  * <p>Activity Templates may only have the following HTML tags: <b>,
129  * <i>, <a>, <span>. The container also has the option
130  * to strip out these tags when rendering the activity.</p>
131  *
132  * <p>
133  * <b>See also:</b>
134  * <a href="opensocial.html#newActivity">opensocial.newActivity()</a>,
135  * <a href="opensocial.html#requestCreateActivity">
136  * opensocial.requestCreateActivity()</a>
137  *
138  * @name opensocial.Activity
139  */
140 
141 
142 /**
143  * Base interface for all activity objects.
144  *
145  * Private, see opensocial.createActivity() for usage.
146  *
147  * @param {Map.<opensocial.Activity.Field, Object>} params
148  *    Parameters defining the activity.
149  * @private
150  * @constructor
151  */
152 opensocial.Activity = function(params) {
153     this.fields_ = params || {};
154 };
155 
156 
157 /**
158  * @static
159  * @class
160  * All of the fields that activities can have.
161  *
162  * <p>It is only required to set one of TITLE_ID or TITLE. In addition, if you
163  * are using any variables in your title or title template,
164  * you must set TEMPLATE_PARAMS.</p>
165  *
166  * <p>Other possible fields to set are: URL, MEDIA_ITEMS, BODY_ID, BODY,
167  * EXTERNAL_ID, PRIORITY, STREAM_TITLE, STREAM_URL, STREAM_SOURCE_URL,
168  * and STREAM_FAVICON_URL.</p>
169  *
170  * <p>Containers are only required to use TITLE_ID or TITLE, they may ignore
171  * additional parameters.</p>
172  *
173  * <p>
174  * <b>See also:</b>
175  * <a
176  * href="opensocial.Activity.html#getField">opensocial.Activity.getField()</a>
177  * </p>
178  *
179  * @name opensocial.Activity.Field
180  */
181 opensocial.Activity.Field = {
182   /**
183    * <p>A string specifying the title template message ID in the gadget
184    *   spec.</p>
185    *
186    * <p>The title is the primary text of an activity.</p>
187    *
188    * <p>Titles may only have the following HTML tags: <b> <i>,
189    * <a>, <span>.
190    * The container may ignore this formatting when rendering the activity.</p>
191    *
192    * @member opensocial.Activity.Field
193    */
194   TITLE_ID : 'titleId',
195 
196   /**
197    * <p>A string specifying the primary text of an activity.</p>
198    *
199    * <p>Titles may only have the following HTML tags: <b> <i>,
200    * <a>, <span>.
201    * The container may ignore this formatting when rendering the activity.</p>
202    *
203    * @member opensocial.Activity.Field
204    */
205   TITLE : 'title',
206 
207   /**
208    * <p>A map of custom keys to values associated with this activity.
209    * These will be used for evaluation in templates.</p>
210    *
211    * <p>The data has type <code>Map<String, Object></code>. The
212    * object may be either a String or an opensocial.Person.</p>
213    *
214    * <p>When passing in a person with key PersonKey, can use the following
215    * replacement variables in the template:</p>
216    * <ul>
217    *  <li>PersonKey.DisplayName - Display name for the person</li>
218    *  <li>PersonKey.ProfileUrl. URL of the person's profile</li>
219    *  <li>PersonKey.Id -  The ID of the person</li>
220    *  <li>PersonKey - Container may replace with DisplayName, but may also
221    *     optionally link to the user.</li>
222    * </ul>
223    *
224    * @member opensocial.Activity.Field
225    */
226   TEMPLATE_PARAMS : 'templateParams',
227 
228   /**
229    * A string specifying the
230    * URL that represents this activity.
231    * @member opensocial.Activity.Field
232    */
233   URL : 'url',
234 
235   /**
236    * Any photos, videos, or images that should be associated
237    * with the activity. Higher priority ones are higher in the list.
238    * The data has type <code>Array<
239    * <a href="opensocial.MediaItem.html">MediaItem</a>></code>.
240    * @member opensocial.Activity.Field
241    */
242   MEDIA_ITEMS : 'mediaItems',
243 
244   /**
245    * <p>A string specifying the body template message ID in the gadget spec.</p>
246    *
247    * <p>The body is an optional expanded version of an activity.</p>
248    *
249    * <p>Bodies may only have the following HTML tags: <b> <i>,
250    * <a>, <span>.
251    * The container may ignore this formatting when rendering the activity.</p>
252    *
253    * @member opensocial.Activity.Field
254    */
255   BODY_ID : 'bodyId',
256 
257   /**
258    * <p>A string specifying an optional expanded version of an activity.</p>
259    *
260    * <p>Bodies may only have the following HTML tags: <b> <i>,
261    * <a>, <span>.
262    * The container may ignore this formatting when rendering the activity.</p>
263    *
264    * @member opensocial.Activity.Field
265    */
266   BODY : 'body',
267 
268   /**
269    * An optional string ID generated by the posting application.
270    * @member opensocial.Activity.Field
271    */
272   EXTERNAL_ID : 'externalId',
273 
274   /**
275    * A string specifing the title of the stream.
276    * @member opensocial.Activity.Field
277    */
278   STREAM_TITLE : 'streamTitle',
279 
280   /**
281    * A string specifying the stream's URL.
282    * @member opensocial.Activity.Field
283    */
284   STREAM_URL : 'streamUrl',
285 
286   /**
287    * A string specifying the stream's source URL.
288    * @member opensocial.Activity.Field
289    */
290   STREAM_SOURCE_URL : 'streamSourceUrl',
291 
292   /**
293    * A string specifying the URL for the stream's favicon.
294    * @member opensocial.Activity.Field
295    */
296   STREAM_FAVICON_URL : 'streamFaviconUrl',
297 
298   /**
299    * A number between 0 and 1 representing the relative priority of
300    * this activity in relation to other activities from the same source
301    * @member opensocial.Activity.Field
302    */
303   PRIORITY : 'priority',
304 
305   /**
306    * A string ID that is permanently associated with this activity.
307    * This value can not be set.
308    * @member opensocial.Activity.Field
309    */
310   ID : 'id',
311 
312   /**
313    * The string ID of the user who this activity is for.
314    * This value can not be set.
315    * @member opensocial.Activity.Field
316    */
317   USER_ID : 'userId',
318 
319   /**
320    * A string specifying the application that this activity is associated with.
321    * This value can not be set.
322    * @member opensocial.Activity.Field
323    */
324   APP_ID : 'appId',
325 
326   /**
327    * A string specifying the time at which this activity took place
328    * in milliseconds since the epoch.
329    * This value can not be set.
330    * @member opensocial.Activity.Field
331    */
332   POSTED_TIME : 'postedTime'
333 };
334 
335 
336 /**
337  * Gets an ID that can be permanently associated with this activity.
338  *
339  * @return {String} The ID
340  * @member opensocial.Activity
341  */
342 opensocial.Activity.prototype.getId = function() {
343   return this.getField(opensocial.Activity.Field.ID);
344 };
345 
346 
347 /**
348  * Gets the activity data that's associated with the specified key.
349  *
350  * @param {String} key The key to get data for;
351  *   see the <a href="opensocial.Activity.Field.html">Field</a> class
352  * for possible values
353  * @param {Map.<opensocial.DataRequest.DataRequestFields, Object>}
354  *  opt_params Additional
355  *    <a href="opensocial.DataRequest.DataRequestFields.html">params</a>
356  *    to pass to the request.
357  * @return {String} The data
358  * @member opensocial.Activity
359  */
360 opensocial.Activity.prototype.getField = function(key, opt_params) {
361   return opensocial.Container.getField(this.fields_, key, opt_params);
362 };
363 
364 
365 /**
366  * Sets data for this activity associated with the given key.
367  *
368  * @param {String} key The key to set data for
369  * @param {String} data The data to set
370  */
371 opensocial.Activity.prototype.setField = function(key, data) {
372   return this.fields_[key] = data;
373 };/*
374  * Licensed to the Apache Software Foundation (ASF) under one
375  * or more contributor license agreements.  See the NOTICE file
376  * distributed with this work for additional information
377  * regarding copyright ownership.  The ASF licenses this file
378  * to you under the Apache License, Version 2.0 (the
379  * "License"); you may not use this file except in compliance
380  * with the License.  You may obtain a copy of the License at
381  *
382  *     http://www.apache.org/licenses/LICENSE-2.0
383  *
384  * Unless required by applicable law or agreed to in writing,
385  * software distributed under the License is distributed on an
386  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
387  * KIND, either express or implied.  See the License for the
388  * specific language governing permissions and limitations
389  * under the License.
390  */
391 
392 /**
393  * @fileoverview Representation of an address.
394  */
395 
396 
397 /**
398  * @class
399  * Base interface for all address objects.
400  *
401  * @name opensocial.Address
402  */
403 
404 
405 /**
406  * Base interface for all address objects.
407  *
408  * @private
409  * @constructor
410  */
411 opensocial.Address = function(opt_params) {
412   this.fields_ = opt_params || {};
413 };
414 
415 
416 /**
417  * @static
418  * @class
419  * All of the fields that an address has. These are the supported keys for the
420  * <a href="opensocial.Address.html#getField">Address.getField()</a> method.
421  *
422  * @name opensocial.Address.Field
423  */
424 opensocial.Address.Field = {
425   /**
426    * The address type or label. Examples: work, my favorite store, my house, etc
427    * Specified as a String.
428    *
429    * @member opensocial.Address.Field
430    */
431   TYPE : 'type',
432 
433   /**
434    * If the container does not have structured addresses in its data store,
435    * this field will return the unstructured address that the user entered. Use
436    * opensocial.getEnvironment().supportsField to see which fields are
437    * supported. Specified as a String.
438    *
439    * @member opensocial.Address.Field
440    */
441   UNSTRUCTURED_ADDRESS : 'unstructuredAddress',
442 
443   /**
444    * The po box of the address if there is one. Specified as a String.
445    *
446    * @member opensocial.Address.Field
447    */
448   PO_BOX : 'poBox',
449 
450   /**
451    * The street address. Specified as a String.
452    *
453    * @member opensocial.Address.Field
454    */
455   STREET_ADDRESS : 'streetAddress',
456 
457   /**
458    * The extended street address. Specified as a String.
459    *
460    * @member opensocial.Address.Field
461    */
462   EXTENDED_ADDRESS : 'extendedAddress',
463 
464   /**
465    * The region. Specified as a String.
466    *
467    * @member opensocial.Address.Field
468    */
469   REGION : 'region',
470 
471   /**
472    * The locality. Specified as a String.
473    *
474    * @member opensocial.Address.Field
475    */
476   LOCALITY : 'locality',
477 
478   /**
479    * The postal code. Specified as a String.
480    *
481    * @member opensocial.Address.Field
482    */
483   POSTAL_CODE : 'postalCode',
484 
485   /**
486    * The country. Specified as a String.
487    *
488    * @member opensocial.Address.Field
489    */
490   COUNTRY : 'country',
491 
492   /**
493    * The latitude. Specified as a Number.
494    *
495    * @member opensocial.Address.Field
496    */
497   LATITUDE : 'latitude',
498 
499   /**
500    * The longitude. Specified as a Number.
501    *
502    * @member opensocial.Address.Field
503    */
504   LONGITUDE : 'longitude'
505 };
506 
507 
508 /**
509  * Gets data for this body type that is associated with the specified key.
510  *
511  * @param {String} key The key to get data for;
512  *    keys are defined in <a href="opensocial.Address.Field.html"><code>
513  *    Address.Field</code></a>
514  * @param {Map.<opensocial.DataRequest.DataRequestFields, Object>}
515  *  opt_params Additional
516  *    <a href="opensocial.DataRequest.DataRequestFields.html">params</a>
517  *    to pass to the request
518  * @return {String} The data
519  */
520 opensocial.Address.prototype.getField = function(key, opt_params) {
521   return opensocial.Container.getField(this.fields_, key, opt_params);
522 };
523 /*
524  * Licensed to the Apache Software Foundation (ASF) under one
525  * or more contributor license agreements.  See the NOTICE file
526  * distributed with this work for additional information
527  * regarding copyright ownership.  The ASF licenses this file
528  * to you under the Apache License, Version 2.0 (the
529  * "License"); you may not use this file except in compliance
530  * with the License.  You may obtain a copy of the License at
531  *
532  *     http://www.apache.org/licenses/LICENSE-2.0
533  *
534  * Unless required by applicable law or agreed to in writing,
535  * software distributed under the License is distributed on an
536  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
537  * KIND, either express or implied.  See the License for the
538  * specific language governing permissions and limitations
539  * under the License.
540  */
541 
542 /**
543  * @fileoverview Representation of a body type.
544  */
545 
546 
547 /**
548  * @class
549  * Base interface for all body type objects.
550  *
551  * @name opensocial.BodyType
552  */
553 
554 
555 /**
556  * Base interface for all body type objects.
557  *
558  * @private
559  * @constructor
560  */
561 opensocial.BodyType = function(opt_params) {
562   this.fields_ = opt_params || {};
563 };
564 
565 
566 /**
567  * @static
568  * @class
569  * All of the fields that a body type has. These are the supported keys for the
570  * <a href="opensocial.BodyType.html#getField">BodyType.getField()</a>
571  * method.
572  *
573  * @name opensocial.BodyType.Field
574  */
575 opensocial.BodyType.Field = {
576   /**
577    * The build of the person's body, specified as a string.
578    * Not supported by all containers.
579    * @member opensocial.BodyType.Field
580    */
581   BUILD : 'build',
582 
583   /**
584    * The height of the person in meters, specified as a number.
585    * Not supported by all containers.
586    * @member opensocial.BodyType.Field
587    */
588   HEIGHT : 'height',
589 
590   /**
591    * The weight of the person in kilograms, specified as a number.
592    * Not supported by all containers.
593    * @member opensocial.BodyType.Field
594    */
595   WEIGHT : 'weight',
596 
597   /**
598    * The eye color of the person, specified as a string.
599    * Not supported by all containers.
600    * @member opensocial.BodyType.Field
601    */
602   EYE_COLOR : 'eyeColor',
603 
604   /**
605    * The hair color of the person, specified as a string.
606    * Not supported by all containers.
607    * @member opensocial.BodyType.Field
608    */
609   HAIR_COLOR : 'hairColor'
610 };
611 
612 
613 /**
614  * Gets data for this body type that is associated with the specified key.
615  *
616  * @param {String} key The key to get data for;
617  *    keys are defined in <a href="opensocial.BodyType.Field.html"><code>
618  *    BodyType.Field</code></a>
619  * @param {Map.<opensocial.DataRequest.DataRequestFields, Object>}
620  *  opt_params Additional
621  *    <a href="opensocial.DataRequest.DataRequestFields.html">params</a>
622  *    to pass to the request.
623  * @return {String} The data
624  */
625 opensocial.BodyType.prototype.getField = function(key, opt_params) {
626   return opensocial.Container.getField(this.fields_, key, opt_params);
627 };
628 /*
629  * Licensed to the Apache Software Foundation (ASF) under one
630  * or more contributor license agreements.  See the NOTICE file
631  * distributed with this work for additional information
632  * regarding copyright ownership.  The ASF licenses this file
633  * to you under the Apache License, Version 2.0 (the
634  * "License"); you may not use this file except in compliance
635  * with the License.  You may obtain a copy of the License at
636  *
637  *     http://www.apache.org/licenses/LICENSE-2.0
638  *
639  * Unless required by applicable law or agreed to in writing,
640  * software distributed under the License is distributed on an
641  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
642  * KIND, either express or implied.  See the License for the
643  * specific language governing permissions and limitations
644  * under the License.
645  */
646 
647 /**
648  * @fileoverview Collection of multiple objects with useful accessors.
649  *
650  * May also represent subset of a larger collection (i.e. page 1 of 10), and
651  * contain information about the larger collection.
652  */
653 
654 
655 /**
656  * @class
657  * Collection of multiple objects with useful accessors.
658  * May also represent subset of a larger collection
659  * (for example, page 1 of 10)
660  * and contain information about the larger collection.
661  *
662  * @name opensocial.Collection
663  */
664 
665 
666 /**
667  * Create a collection.
668  *
669  * @private
670  * @constructor
671  */
672 opensocial.Collection = function(array, opt_offset, opt_totalSize) {
673   this.array_ = array || [];
674   this.offset_ = opt_offset || 0;
675   this.totalSize_ = opt_totalSize || this.array_.length;
676 };
677 
678 
679 /**
680  * Finds the entry with the given ID value, or returns null if none is found.
681  * @param {String} id The ID to look for
682  * @return {Object?} The data
683  */
684 opensocial.Collection.prototype.getById = function(id) {
685    // TODO(doll): A non-linear search would be better
686   for (var i = 0; i < this.size(); i++) {
687     var item = this.array_[i];
688     if (item.getId() == id) {
689       return item;
690     }
691   }
692 
693   return null;
694 };
695 
696 
697 /**
698  * Gets the size of this collection,
699  * which is equal to or less than the
700  * total size of the result.
701  * @return {Number} The size of this collection
702  */
703 opensocial.Collection.prototype.size = function() {
704   return this.array_.length;
705 };
706 
707 
708 /**
709  * Executes the provided function once per member of the collection,
710  * with each member in turn as the
711  * parameter to the function.
712  * @param {Function} fn The function to call with each collection entry
713  */
714 opensocial.Collection.prototype.each = function(fn) {
715   for (var i = 0; i < this.size(); i++) {
716     fn(this.array_[i]);
717   }
718 };
719 
720 
721 /**
722  * Returns an array of all the objects in this collection.
723  * @return {Array.<Object>} The values in this collection
724  */
725 opensocial.Collection.prototype.asArray = function() {
726   return this.array_;
727 };
728 
729 
730 /**
731  * Gets the total size of the larger result set
732  * that this collection belongs to.
733  * @return {Number} The total size of the result
734  */
735 opensocial.Collection.prototype.getTotalSize = function() {
736   return this.totalSize_;
737 };
738 
739 
740 /**
741  * Gets the offset of this collection within a larger result set.
742  * @return {Number} The offset into the total collection
743  */
744 opensocial.Collection.prototype.getOffset = function() {
745   return this.offset_;
746 };
747 /*
748  * Licensed to the Apache Software Foundation (ASF) under one
749  * or more contributor license agreements.  See the NOTICE file
750  * distributed with this work for additional information
751  * regarding copyright ownership.  The ASF licenses this file
752  * to you under the Apache License, Version 2.0 (the
753  * "License"); you may not use this file except in compliance
754  * with the License.  You may obtain a copy of the License at
755  *
756  *     http://www.apache.org/licenses/LICENSE-2.0
757  *
758  * Unless required by applicable law or agreed to in writing,
759  * software distributed under the License is distributed on an
760  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
761  * KIND, either express or implied.  See the License for the
762  * specific language governing permissions and limitations
763  * under the License.
764  */
765 
766 /**
767  * @fileoverview Interface for containers of people functionality.
768  */
769 
770 
771 /**
772  * Base interface for all containers.
773  *
774  * @constructor
775  * @private
776  */
777 opensocial.Container = function() {};
778 
779 
780 /**
781  * The container instance.
782  *
783  * @type Container
784  * @private
785  */
786 opensocial.Container.container_ = null;
787 
788 
789 /**
790  * Set the current container object.
791  *
792  * @param {opensocial.Container} container The container
793  * @private
794  */
795 opensocial.Container.setContainer = function(container) {
796   opensocial.Container.container_ = container;
797 };
798 
799 
800 /**
801  * Get the current container object.
802  *
803  * @return {opensocial.Container} container The current container
804  * @private
805  */
806 opensocial.Container.get = function() {
807   return opensocial.Container.container_;
808 };
809 
810 
811 /**
812  * Gets the current environment for this gadget. You can use the environment to
813  * query things like what profile fields and surfaces are supported by this
814  * container, what parameters were passed to the current gadget and so forth.
815  *
816  * @return {opensocial.Environment} The current environment
817  *
818  * @private
819  */
820 opensocial.Container.prototype.getEnvironment = function() {};
821 
822 /**
823  * Requests the container to send a specific message to the specified users. If
824  * the container does not support this method the callback will be called with a
825  * opensocial.ResponseItem. The response item will have its error code set to
826  * NOT_IMPLEMENTED.
827  *
828  * @param {Array.<String> | String} recipients An ID, array of IDs, or a
829  *     group reference; the supported keys are VIEWER, OWNER, VIEWER_FRIENDS,
830  *    OWNER_FRIENDS, or a single ID within one of those groups
831  * @param {opensocial.Message} message The message to send to the specified
832  *     users.
833  * @param {Function} opt_callback The function to call once the request has been
834  *    processed; either this callback will be called or the gadget will be
835  *    reloaded from scratch. This function will be passed one parameter, an
836  *    opensocial.ResponseItem. The error code will be set to reflect whether
837  *    there were any problems with the request. If there was no error, the
838  *    message was sent. If there was an error, you can use the response item's
839  *    getErrorCode method to determine how to proceed. The data on the response
840  *    item will not be set.
841  *
842  * @member opensocial
843  * @private
844  */
845 opensocial.Container.prototype.requestSendMessage = function(recipients,
846     message, opt_callback, opt_params) {
847   if (opt_callback) {
848     window.setTimeout(function() {
849       opt_callback(new opensocial.ResponseItem(
850           null, null, opensocial.ResponseItem.Error.NOT_IMPLEMENTED, null));
851     }, 0);
852   }
853 };
854 
855 
856 /**
857  * Requests the container to share this gadget with the specified users. If the
858  * container does not support this method the callback will be called with a
859  * opensocial.ResponseItem. The response item will have its error code set to
860  * NOT_IMPLEMENTED.
861  *
862  * @param {Array.<String> | String} recipients An ID, array of IDs, or a
863  *     group reference; the supported keys are VIEWER, OWNER, VIEWER_FRIENDS,
864  *    OWNER_FRIENDS, or a single ID within one of those groups
865  * @param {opensocial.Message} reason The reason the user wants the gadget to
866  *     share itself. This reason can be used by the container when prompting the
867  *     user for permission to share the app. It may also be ignored.
868  * @param {Function} opt_callback The function to call once the request has been
869  *    processed; either this callback will be called or the gadget will be
870  *    reloaded from scratch. This function will be passed one parameter, an
871  *    opensocial.ResponseItem. The error code will be set to reflect whether
872  *    there were any problems with the request. If there was no error, the
873  *    sharing request was sent. If there was an error, you can use the response
874  *    item's getErrorCode method to determine how to proceed. The data on the
875  *    response item will not be set.
876  *
877  * @member opensocial
878  * @private
879  */
880 opensocial.Container.prototype.requestShareApp = function(recipients, reason,
881     opt_callback, opt_params) {
882   if (opt_callback) {
883     window.setTimeout(function() {
884       opt_callback(new opensocial.ResponseItem(
885           null, null, opensocial.ResponseItem.Error.NOT_IMPLEMENTED, null));
886     }, 0);
887   }
888 };
889 
890 
891 /**
892  * Request for the container to make the specified person not a friend.
893  *
894  * Note: If this is the first activity that has been created for the user and
895  * the request is marked as HIGH priority then this call may open a user flow
896  * and navigate away from your gadget.
897  *
898  * @param {Activity} activity The activity to create. The only required field is
899  *     title.
900  * @param {CreateActivityPriority} priority The priority for this request.
901  * @param {Function} opt_callback Function to call once the request has been
902  *    processed.
903  * @private
904  */
905 opensocial.Container.prototype.requestCreateActivity = function(activity,
906     priority, opt_callback) {
907   if (opt_callback) {
908     window.setTimeout(function() {
909       opt_callback(new opensocial.ResponseItem(
910           null, null, opensocial.ResponseItem.Error.NOT_IMPLEMENTED, null));
911     }, 0);
912   }
913 };
914 
915 
916 /**
917  * Returns whether the current gadget has access to the specified
918  * permission.
919  *
920  * @param {opensocial.Permission | String} permission The permission
921  * @return {Boolean} Whether the gadget has access for the permission.
922  *
923  * @private
924  */
925 opensocial.Container.prototype.hasPermission = function(permission) {
926   return false;
927 };
928 
929 
930 /**
931  * Requests the user grants access to the specified permissions.
932  *
933  * @param {Array.<opensocial.Permission>} permissions The permissions to request
934  *    access to from the viewer
935  * @param {String} reason Will be displayed to the user as the reason why these
936  *    permissions are needed.
937  * @param {Function} opt_callback The function to call once the request has been
938  *    processed. This callback will either be called or the gadget will be
939  *    reloaded from scratch
940  *
941  * @private
942  */
943 opensocial.Container.prototype.requestPermission = function(permissions, reason,
944     opt_callback) {
945   if (opt_callback) {
946     window.setTimeout(function () {
947       opt_callback(new opensocial.ResponseItem(
948           null, null, opensocial.ResponseItem.Error.NOT_IMPLEMENTED, null));
949     }, 0);
950   }
951 };
952 
953 
954 /**
955  * Calls the callback function with a dataResponse object containing the data
956  * asked for in the dataRequest object.
957  *
958  * @param {opensocial.DataRequest} dataRequest Specifies which data to get from
959  *    the server
960  * @param {Function} callback Function to call after the data is fetched
961  * @private
962  */
963 opensocial.Container.prototype.requestData = function(dataRequest, callback) {};
964 
965 
966 /**
967  * Request a profile for the specified person id.
968  * When processed, returns a Person object.
969  *
970  * @param {String} id The id of the person to fetch. Can also be standard
971  *    person IDs of VIEWER and OWNER.
972  * @param {Map.<opensocial.DataRequest.PeopleRequestFields, Object>} opt_params
973  *    Additional params to pass to the request. This request supports
974  *    PROFILE_DETAILS.
975  * @return {Object} a request object
976  * @private
977  */
978 opensocial.Container.prototype.newFetchPersonRequest = function(id,
979     opt_params) {};
980 
981 
982 /**
983  * Used to request friends from the server.
984  * When processed, returns a Collection<Person> object.
985  *
986  * @param {opensocial.IdSpec} idSpec An IdSpec used to specify which people to
987  *     fetch. See also <a href="opensocial.IdSpec.html">IdSpec</a>.
988  * @param {Map.<opensocial.DataRequest.PeopleRequestFields, Object>} opt_params
989  *    Additional params to pass to the request. This request supports
990  *    PROFILE_DETAILS, SORT_ORDER, FILTER, FILTER_OPTIONS, FIRST, and MAX.
991  * @return {Object} a request object
992  * @private
993  */
994 opensocial.Container.prototype.newFetchPeopleRequest = function(idSpec,
995     opt_params) {};
996 
997 
998 /**
999  * Used to request app data for the given people.
1000  * When processed, returns a Map<person id, Map<String, String>>
1001  * object.TODO: All of the data values returned will be valid json.
1002  *
1003  * @param {opensocial.IdSpec} idSpec An IdSpec used to specify which people to
1004  *     fetch. See also <a href="opensocial.IdSpec.html">IdSpec</a>.
1005  * @param {Array.<String> | String} keys The keys you want data for. This
1006  *     can be an array of key names, a single key name, or "*" to mean
1007  *     "all keys".
1008  * @param {Map.<opensocial.DataRequest.DataRequestFields, Object>}
1009  *  opt_params Additional
1010  *    <a href="opensocial.DataRequest.DataRequestFields.html">params</a>
1011  *    to pass to the request
1012  * @return {Object} a request object
1013  * @private
1014  */
1015 opensocial.Container.prototype.newFetchPersonAppDataRequest = function(idSpec,
1016     keys, opt_params) {};
1017 
1018 
1019 /**
1020  * Used to request an update of an app field for the given person.
1021  * When processed, does not return any data.
1022  *
1023  * @param {String} id The id of the person to update. (Right now only the
1024  *    special VIEWER id is allowed.)
1025  * @param {String} key The name of the key
1026  * @param {String} value The value
1027  * @return {Object} a request object
1028  * @private
1029  */
1030 opensocial.Container.prototype.newUpdatePersonAppDataRequest = function(id,
1031     key, value) {};
1032 
1033 
1034 /**
1035  * Deletes the given keys from the datastore for the given person.
1036  * When processed, does not return any data.
1037  *
1038  * @param {String} id The ID of the person to update; only the
1039  *     special <code>VIEWER</code> ID is currently allowed.
1040  * @param {Array.<String> | String} keys The keys you want to delete from
1041  *     the datastore; this can be an array of key names, a single key name,
1042  *     or "*" to mean "all keys"
1043  * @return {Object} A request object
1044  * @private
1045  */
1046 opensocial.Container.prototype.newRemovePersonAppDataRequest = function(id,
1047     keys) {};
1048 
1049 
1050 /**
1051  * Used to request an activity stream from the server.
1052  *
1053  * When processed, returns a Collection<Activity>.
1054  *
1055  * @param {opensocial.IdSpec} idSpec An IdSpec used to specify which people to
1056  *     fetch. See also <a href="opensocial.IdSpec.html">IdSpec</a>.
1057  * @param {Map.<opensocial.DataRequest.ActivityRequestFields, Object>} opt_params
1058  *    Additional params to pass to the request.
1059  * @return {Object} a request object
1060  * @private
1061  */
1062 opensocial.Container.prototype.newFetchActivitiesRequest = function(idSpec,
1063     opt_params) {};
1064 
1065 
1066 /**
1067  * Creates a new collection with caja support if enabled.
1068  * @return {opensocial.Collection} the collection object
1069  * @private
1070  */
1071 opensocial.Container.prototype.newCollection = function(array, opt_offset,
1072     opt_totalSize) {
1073   return new opensocial.Collection(array, opt_offset, opt_totalSize);
1074 };
1075 
1076 
1077 /**
1078  * Creates a new person with caja support if enabled.
1079  * @return {opensocial.Person} the person object
1080  * @private
1081  */
1082 opensocial.Container.prototype.newPerson = function(opt_params, opt_isOwner,
1083     opt_isViewer) {
1084   return new opensocial.Person(opt_params, opt_isOwner, opt_isViewer);
1085 };
1086 
1087 
1088 /**
1089  * Get an activity object used to create activities on the server
1090  *
1091  * @param {opensocial.Activity.Template || String} title The title of an
1092  *     activity, a template is reccommended, but this field can also be a
1093  *     string.
1094  * @param {Map.<opensocial.Activity.Field, Object>} opt_params Any other
1095  *    fields that should be set on the activity object. All of the defined
1096  *    Fields are supported.
1097  * @return {opensocial.Activity} the activity object
1098  * @private
1099  */
1100 opensocial.Container.prototype.newActivity = function(opt_params) {
1101   return new opensocial.Activity(opt_params);
1102 };
1103 
1104 
1105 /**
1106  * Creates a media item. Represents images, movies, and audio.
1107  * Used when creating activities on the server.
1108  *
1109  * @param {String} mimeType of the media
1110  * @param {String} url where the media can be found
1111  * @param {Map.<opensocial.MediaItem.Field, Object>} opt_params
1112  *    Any other fields that should be set on the media item object.
1113  *    All of the defined Fields are supported.
1114  *
1115  * @return {opensocial.MediaItem} the media item object
1116  * @private
1117  */
1118 opensocial.Container.prototype.newMediaItem = function(mimeType, url,
1119     opt_params) {
1120   return new opensocial.MediaItem(mimeType, url, opt_params);
1121 };
1122 
1123 
1124 /**
1125  * Creates a media item associated with an activity.
1126  * Represents images, movies, and audio.
1127  * Used when creating activities on the server.
1128  *
1129  * @param {String} body The main text of the message.
1130  * @param {Map.<opensocial.Message.Field, Object>} opt_params
1131  *    Any other fields that should be set on the message object;
1132  *    all of the defined
1133  *    <a href="opensocial.Message.Field.html">Field</a>s
1134  *    are supported
1135  *
1136  * @return {opensocial.Message} The new
1137  *    <a href="opensocial.Message.html">message</a> object
1138  * @private
1139  */
1140 opensocial.Container.prototype.newMessage = function(body, opt_params) {
1141   return new opensocial.Message(body, opt_params);
1142 };
1143 
1144 
1145 /**
1146  * Creates an IdSpec object.
1147  *
1148  * @param {Map.<opensocial.IdSpec.Field, Object>} parameters
1149  *    Parameters defining the id spec.
1150  * @return {opensocial.IdSpec} The new
1151  *     <a href="opensocial.IdSpec.html">IdSpec</a> object
1152  * @private
1153  */
1154 opensocial.Container.prototype.newIdSpec = function(params) {
1155   return new opensocial.IdSpec(params);
1156 };
1157 
1158 
1159 /**
1160  * Creates a NavigationParameters object.
1161  *
1162  * @param {Map.<opensocial.NavigationParameters.Field, Object>} parameters
1163  *     Parameters defining the navigation
1164  * @return {opensocial.NavigationParameters} The new
1165  *     <a href="opensocial.NavigationParameters.html">NavigationParameters</a>
1166  *     object
1167  * @private
1168  */
1169 opensocial.Container.prototype.newNavigationParameters = function(params) {
1170   return new opensocial.NavigationParameters(params);
1171 };
1172 
1173 
1174 /**
1175  * Creates a new response item with caja support if enabled.
1176  * @return {opensocial.ResponseItem} the response item object
1177  * @private
1178  */
1179 opensocial.Container.prototype.newResponseItem = function(originalDataRequest,
1180     data, opt_errorCode, opt_errorMessage) {
1181   return new opensocial.ResponseItem(originalDataRequest, data, opt_errorCode,
1182       opt_errorMessage);
1183 };
1184 
1185 
1186 /**
1187  * Creates a new data response with caja support if enabled.
1188  * @return {opensocial.DataResponse} the data response object
1189  * @private
1190  */
1191 opensocial.Container.prototype.newDataResponse = function(responseItems,
1192     opt_globalError) {
1193   return new opensocial.DataResponse(responseItems, opt_globalError);
1194 };
1195 
1196 
1197 /**
1198  * Get a data request object to use for sending and fetching data from the
1199  * server.
1200  *
1201  * @return {opensocial.DataRequest} the request object
1202  * @private
1203  */
1204 opensocial.Container.prototype.newDataRequest = function() {
1205   return new opensocial.DataRequest();
1206 };
1207 
1208 
1209 /**
1210  * Get a new environment object.
1211  *
1212  * @return {opensocial.Environment} the environment object
1213  * @private
1214  */
1215 opensocial.Container.prototype.newEnvironment = function(domain,
1216     supportedFields) {
1217   return new opensocial.Environment(domain, supportedFields);
1218 };
1219 
1220 
1221 /**
1222  * Returns true if the specified value is an array
1223  * @param {Object} val Variable to test
1224  * @return {boolean} Whether variable is an array
1225  * @private
1226  */
1227 opensocial.Container.isArray = function(val) {
1228   return val instanceof Array;
1229 };
1230 
1231 
1232 /**
1233  * Returns the value corresponding to the key in the fields map. Escapes
1234  * the value appropriately.
1235  * @param {Map<String, Object>} fields All of the values mapped by key.
1236  * @param {String} key The key to get data for.
1237  * @param {Map.<opensocial.DataRequest.DataRequestFields, Object>}
1238  *  opt_params Additional
1239  *    <a href="opensocial.DataRequest.DataRequestFields.html">params</a>
1240  *    to pass to the request.
1241  * @return {String} The data
1242  * @private
1243  */
1244 opensocial.Container.getField = function(fields, key, opt_params) {
1245   var value = fields[key];
1246   return opensocial.Container.escape(value, opt_params, false);
1247 };
1248 
1249 opensocial.Container.escape = function(value, opt_params, opt_escapeObjects) {
1250   if (opt_params && opt_params['escapeType'] == 'none') {
1251     return value;
1252   } else {
1253     return gadgets.util.escape(value, opt_escapeObjects);
1254   }
1255 };
1256 
1257 
1258 /**
1259  * Caja Support.  See features/caja/*.js
1260  */
1261 var cajita;
1262 var ___;
1263 var attachDocumentStub;
1264 // See features/caja/domita.js for uriCallback's contract.
1265 var uriCallback = {
1266   rewrite: function rewrite(uri, mimeTypes) {
1267     uri = String(uri);
1268     // By default, only allow references to anchors.
1269     if (/^#/.test(uri)) {
1270       return '#' + encodeURIComponent(decodeURIComponent(uri.substring(1)));
1271     // and files on the same host
1272     } else if (/^\/(?:[^\/][^?#]*)?$/) {
1273       return encodeURI(decodeURI(uri));
1274     }
1275     // This callback can be replaced with one that passes the URL through
1276     // a proxy that checks the mimetype.
1277     return null;
1278   }
1279 };
1280 
1281 /**
1282  * Enable Caja support
1283  *
1284  * @type Container
1285  * @private
1286  */
1287 
1288 // TODO(doll): As caja evolves this method should get a lot smaller
1289 opensocial.Container.prototype.enableCaja = function() {
1290 
1291   ___ = window["___"];
1292   cajita = window["cajita"];
1293   valijaMaker = window["valijaMaker"];
1294   attachDocumentStub = window["attachDocumentStub"];
1295 
1296   var imports = ___.copy(___.sharedImports);
1297   imports.outers = imports;
1298   imports.console = console;
1299   imports.$v = ___.asSimpleFunc(valijaMaker)(imports);
1300   ___.getNewModuleHandler().setImports(imports);
1301 
1302   
1303   attachDocumentStub('-g___', uriCallback, imports);
1304   var gadgetRoot = document.createElement('div');
1305   gadgetRoot.className = 'g___';
1306   imports.htmlEmitter___ = new HtmlEmitter(gadgetRoot);
1307   document.body.appendChild(gadgetRoot);
1308 
1309   // Add the opensocial APIs and mark them callable and readable.
1310   imports.gadgets = gadgets;
1311   imports.opensocial = opensocial;
1312   // The below described the opensocial reference APIs.
1313   // A prefix of "c_" specifies a class, "m_" a method, "f_" a field,
1314   // and "s_" a static member.
1315   // Derived from http://code.google.com/apis/opensocial/docs/0.8/reference/ .
1316   var opensocialSchema = {
1317     c_gadgets: {
1318       c_MiniMessage: {
1319         m_createDismissibleMessage: 0,
1320         m_createStaticMessage: 0,
1321         m_createTimerMessage: 0,
1322         m_dismissMessage: 0
1323       },
1324       c_Prefs: {
1325         m_getArray: 0,
1326         m_getBool: 0,
1327         m_getCountry: 0,
1328         m_getFloat: 0,
1329         m_getInt: 0,
1330         m_getLang: 0,
1331         m_getMsg: 0,
1332         m_getString: 0,
1333         m_set: 0,
1334         m_setArray: 0
1335       },
1336       c_Tab: {
1337         m_getCallback: 0,
1338         m_getContentContainer: 0,
1339         m_getIndex: 0,
1340         m_getName: 0,
1341         m_getNameContainer: 0
1342       },
1343       c_TabSet: {
1344         m_addTab: 0,
1345         m_alignTabs: 0,
1346         m_displayTabs: 0,
1347         m_getHeaderContainer: 0,
1348         m_getSelectedTab: 0,
1349         m_getTabs: 0,
1350         m_removeTab: 0,
1351         m_setSelectedTab: 0,
1352         m_swapTabs: 0
1353       },
1354       c_flash: {
1355         s_embedCachedFlash: 0,
1356         s_embedFlash: 0,
1357         s_getMajorVersion: 0
1358       },
1359       c_io: {
1360         c_AuthorizationType: {
1361           s_NONE: 0,
1362           s_OAUTH: 0,
1363           s_SIGNED: 0
1364         },
1365         c_ContentType: {
1366           s_DOM: 0,
1367           s_FEED: 0,
1368           s_JSON: 0,
1369           s_TEXT: 0
1370         },
1371         c_MethodType: {
1372           s_DELETE: 0,
1373           s_GET: 0,
1374           s_HEAD: 0,
1375           s_POST: 0,
1376           s_PUT: 0
1377         },
1378         c_ProxyUrlRequestParameters: {
1379           s_REFRESH_INTERVAL: 0
1380         },
1381         c_RequestParameters: {
1382           s_AUTHORIZATION: 0,
1383           s_CONTENT_TYPE: 0,
1384           s_GET_SUMMARIES: 0,
1385           s_HEADERS: 0,
1386           s_METHOD: 0,
1387           s_NUM_ENTRIES: 0,
1388           s_POST_DATA: 0
1389         },
1390         s_encodeValues: 0,
1391         s_getProxyUrl: 0,
1392         s_makeRequest: 0
1393       },
1394       c_json: {
1395         s_parse: 0,
1396         s_stringify: 0
1397       },
1398       c_pubsub: {
1399         s_publish: 0,
1400         s_subscribe: 0,
1401         s_unsubscribe: 0
1402       },
1403       c_rpc: {
1404         s_call: 0,
1405         s_register: 0,
1406         s_registerDefault: 0,
1407         s_unregister: 0,
1408         s_unregisterDefault: 0
1409       },
1410       c_skins: {
1411         c_Property: {
1412           s_ANCHOR_COLOR: 0,
1413           s_BG_COLOR: 0,
1414           s_BG_IMAGE: 0,
1415           s_FONT_COLOR: 0
1416         },
1417         s_getProperty: 0
1418       },
1419       c_util: {
1420         s_escapeString: 0,
1421         s_getFeatureParameters: 0,
1422         s_hasFeature: 0,
1423         s_registerOnLoadHandler: 0,
1424         s_unescapeString: 0
1425       },
1426       c_views: {
1427         c_View: {
1428           m_bind: 0,
1429           m_getUrlTemplate: 0,
1430           m_isOnlyVisibleGadget: 0
1431         },
1432         c_ViewType: {
1433           s_CANVAS: 0,
1434           s_HOME: 0,
1435           s_PREVIEW: 0,
1436           s_PROFILE: 0
1437         },
1438         s_bind: 0,
1439         s_getCurrentView: 0,
1440         s_getParams: 0,
1441         s_requestNavigateTo: 0
1442       },
1443       c_window: {
1444         s_adjustHeight: 0,
1445         s_getViewportDimensions: 0,
1446         s_setTitle: 0
1447       }
1448     },
1449     c_opensocial: {
1450       c_Activity: {
1451         c_Field: {
1452           s_APP_ID: 0,
1453           s_BODY: 0,
1454           s_BODY_ID: 0,
1455           s_EXTERNAL_ID: 0,
1456           s_ID: 0,
1457           s_MEDIA_ITEMS: 0,
1458           s_POSTED_TIME: 0,
1459           s_PRIORITY: 0,
1460           s_STREAM_FAVICON_URL: 0,
1461           s_STREAM_SOURCE_URL: 0,
1462           s_STREAM_TITLE: 0,
1463           s_STREAM_URL: 0,
1464           s_TEMPLATE_PARAMS: 0,
1465           s_TITLE: 0,
1466           s_TITLE_ID: 0,
1467           s_URL: 0,
1468           s_USER_ID: 0
1469         },
1470         m_getField: 0,
1471         m_getId: 0,
1472         m_setField: 0
1473       },
1474       c_Address: {
1475         c_Field: {
1476           s_COUNTRY: 0,
1477           s_EXTENDED_ADDRESS: 0,
1478           s_LATITUDE: 0,
1479           s_LOCALITY: 0,
1480           s_LONGITUDE: 0,
1481           s_POSTAL_CODE: 0,
1482           s_PO_BOX: 0,
1483           s_REGION: 0,
1484           s_STREET_ADDRESS: 0,
1485           s_TYPE: 0,
1486           s_UNSTRUCTURED_ADDRESS: 0
1487         },
1488         m_getField: 0
1489       },
1490       c_BodyType: {
1491         c_Field: {
1492           s_BUILD: 0,
1493           s_EYE_COLOR: 0,
1494           s_HAIR_COLOR: 0,
1495           s_HEIGHT: 0,
1496           s_WEIGHT: 0
1497         },
1498         m_getField: 0
1499       },
1500       c_Collection: {
1501         m_asArray: 0,
1502         m_each: 0,
1503         m_getById: 0,
1504         m_getOffset: 0,
1505         m_getTotalSize: 0,
1506         m_size: 0
1507       },
1508       c_CreateActivityPriority: {
1509         s_HIGH: 0,
1510         s_LOW: 0
1511       },
1512       c_DataRequest: {
1513         c_DataRequestFields: {
1514           s_ESCAPE_TYPE: 0
1515         },
1516         c_FilterType: {
1517           s_ALL: 0,
1518           s_HAS_APP: 0,
1519           s_TOP_FRIENDS: 0
1520         },
1521         c_PeopleRequestFields: {
1522           s_FILTER: 0,
1523           s_FILTER_OPTIONS: 0,
1524           s_FIRST: 0,
1525           s_MAX: 0,
1526           s_PROFILE_DETAILS: 0,
1527           s_SORT_ORDER: 0
1528         },
1529         c_SortOrder: {
1530           s_NAME: 0,
1531           s_TOP_FRIENDS: 0
1532         },
1533         m_add: 0,
1534         m_newFetchActivitiesRequest: 0,
1535         m_newFetchPeopleRequest: 0,
1536         m_newFetchPersonAppDataRequest: 0,
1537         m_newFetchPersonRequest: 0,
1538         m_newRemovePersonAppDataRequest: 0,
1539         m_newUpdatePersonAppDataRequest: 0,
1540         m_send: 0
1541       },
1542       c_DataResponse: {
1543         m_get: 0,
1544         m_getErrorMessage: 0,
1545         m_hadError: 0
1546       },
1547       c_Email: {
1548         c_Field: {
1549           s_ADDRESS: 0,
1550           s_TYPE: 0
1551         },
1552         m_getField: 0
1553       },
1554       c_Enum: {
1555         c_Drinker: {
1556           s_HEAVILY: 0,
1557           s_NO: 0,
1558           s_OCCASIONALLY: 0,
1559           s_QUIT: 0,
1560           s_QUITTING: 0,
1561           s_REGULARLY: 0,
1562           s_SOCIALLY: 0,
1563           s_YES: 0
1564         },
1565         c_Gender: {
1566           s_FEMALE: 0,
1567           s_MALE: 0
1568         },
1569         c_LookingFor: {
1570           s_ACTIVITY_PARTNERS: 0,
1571           s_DATING: 0,
1572           s_FRIENDS: 0,
1573           s_NETWORKING: 0,
1574           s_RANDOM: 0,
1575           s_RELATIONSHIP: 0
1576         },
1577         c_Presence: {
1578           s_AWAY: 0,
1579           s_CHAT: 0,
1580           s_DND: 0,
1581           s_OFFLINE: 0,
1582           s_ONLINE: 0,
1583           s_XA: 0
1584         },
1585         c_Smoker: {
1586           s_HEAVILY: 0,
1587           s_NO: 0,
1588           s_OCCASIONALLY: 0,
1589           s_QUIT: 0,
1590           s_QUITTING: 0,
1591           s_REGULARLY: 0,
1592           s_SOCIALLY: 0,
1593           s_YES: 0
1594         },
1595         m_getDisplayValue: 0,
1596         m_getKey: 0
1597       },
1598       c_Environment: {
1599         c_ObjectType: {
1600           s_ACTIVITY: 0,
1601           s_ACTIVITY_MEDIA_ITEM: 0,
1602           s_ADDRESS: 0,
1603           s_BODY_TYPE: 0,
1604           s_EMAIL: 0,
1605           s_FILTER_TYPE: 0,
1606           s_MESSAGE: 0,
1607           s_MESSAGE_TYPE: 0,
1608           s_NAME: 0,
1609           s_ORGANIZATION: 0,
1610           s_PERSON: 0,
1611           s_PHONE: 0,
1612           s_SORT_ORDER: 0,
1613           s_URL: 0
1614         },
1615         m_getDomain: 0,
1616         m_supportsField: 0
1617       },
1618       c_EscapeType: {
1619         s_HTML_ESCAPE: 0,
1620         s_NONE: 0
1621       },
1622       c_IdSpec: {
1623         c_Field: {
1624           s_GROUP_ID: 0,
1625           s_NETWORK_DISTANCE: 0,
1626           s_USER_ID: 0
1627         },
1628         c_PersonId: {
1629           s_OWNER: 0,
1630           s_VIEWER: 0
1631         },
1632         m_getField: 0,
1633         m_setField: 0
1634       },
1635       c_MediaItem: {
1636         c_Field: {
1637           s_MIME_TYPE: 0,
1638           s_TYPE: 0,
1639           s_URL: 0
1640         },
1641         c_Type: {
1642           s_AUDIO: 0,
1643           s_IMAGE: 0,
1644           s_VIDEO: 0
1645         },
1646         m_getField: 0,
1647         m_setField: 0
1648       },
1649       c_Message: {
1650         c_Field: {
1651           s_BODY: 0,
1652           s_BODY_ID: 0,
1653           s_TITLE: 0,
1654           s_TITLE_ID: 0,
1655           s_TYPE: 0
1656         },
1657         c_Type: {
1658           s_EMAIL: 0,
1659           s_NOTIFICATION: 0,
1660           s_PRIVATE_MESSAGE: 0,
1661           s_PUBLIC_MESSAGE: 0
1662         },
1663         m_getField: 0,
1664         m_setField: 0
1665       },
1666       c_Name: {
1667         c_Field: {
1668           s_ADDITIONAL_NAME: 0,
1669           s_FAMILY_NAME: 0,
1670           s_GIVEN_NAME: 0,
1671           s_HONORIFIC_PREFIX: 0,
1672           s_HONORIFIC_SUFFIX: 0,
1673           s_UNSTRUCTURED: 0
1674         },
1675         m_getField: 0
1676       },
1677       c_NavigationParameters: {
1678         c_DestinationType: {
1679           s_RECIPIENT_DESTINATION: 0,
1680           s_VIEWER_DESTINATION: 0
1681         },
1682         c_Field: {
1683           s_OWNER: 0,
1684           s_PARAMETERS: 0,
1685           s_VIEW: 0
1686         },
1687         m_getField: 0,
1688         m_setField: 0
1689       },
1690       c_Organization: {
1691         c_Field: {
1692           s_ADDRESS: 0,
1693           s_DESCRIPTION: 0,
1694           s_END_DATE: 0,
1695           s_FIELD: 0,
1696           s_NAME: 0,
1697           s_SALARY: 0,
1698           s_START_DATE: 0,
1699           s_SUB_FIELD: 0,
1700           s_TITLE: 0,
1701           s_WEBPAGE: 0
1702         },
1703         m_getField: 0
1704       },
1705       c_Permission: {
1706         s_VIEWER: 0
1707       },
1708       c_Person: {
1709         c_Field: {
1710           s_ABOUT_ME: 0,
1711           s_ACTIVITIES: 0,
1712           s_ADDRESSES: 0,
1713           s_AGE: 0,
1714           s_BODY_TYPE: 0,
1715           s_BOOKS: 0,
1716           s_CARS: 0,
1717           s_CHILDREN: 0,
1718           s_CURRENT_LOCATION: 0,
1719           s_DATE_OF_BIRTH: 0,
1720           s_DRINKER: 0,
1721           s_EMAILS: 0,
1722           s_ETHNICITY: 0,
1723           s_FASHION: 0,
1724           s_FOOD: 0,
1725           s_GENDER: 0,
1726           s_HAPPIEST_WHEN: 0,
1727           s_HAS_APP: 0,
1728           s_HEROES: 0,
1729           s_HUMOR: 0,
1730           s_ID: 0,
1731           s_INTERESTS: 0,
1732           s_JOBS: 0,
1733           s_JOB_INTERESTS: 0,
1734           s_LANGUAGES_SPOKEN: 0,
1735           s_LIVING_ARRANGEMENT: 0,
1736           s_LOOKING_FOR: 0,
1737           s_MOVIES: 0,
1738           s_MUSIC: 0,
1739           s_NAME: 0,
1740           s_NETWORK_PRESENCE: 0,
1741           s_NICKNAME: 0,
1742           s_PETS: 0,
1743           s_PHONE_NUMBERS: 0,
1744           s_POLITICAL_VIEWS: 0,
1745           s_PROFILE_SONG: 0,
1746           s_PROFILE_URL: 0,
1747           s_PROFILE_VIDEO: 0,
1748           s_QUOTES: 0,
1749           s_RELATIONSHIP_STATUS: 0,
1750           s_RELIGION: 0,
1751           s_ROMANCE: 0,
1752           s_SCARED_OF: 0,
1753           s_SCHOOLS: 0,
1754           s_SEXUAL_ORIENTATION: 0,
1755           s_SMOKER: 0,
1756           s_SPORTS: 0,
1757           s_STATUS: 0,
1758           s_TAGS: 0,
1759           s_THUMBNAIL_URL: 0,
1760           s_TIME_ZONE: 0,
1761           s_TURN_OFFS: 0,
1762           s_TURN_ONS: 0,
1763           s_TV_SHOWS: 0,
1764           s_URLS: 0
1765         },
1766         m_getDisplayName: 0,
1767         m_getField: 0,
1768         m_getId: 0,
1769         m_isOwner: 0,
1770         m_isViewer: 0
1771       },
1772       c_Phone: {
1773         c_Field: {
1774           s_NUMBER: 0,
1775           s_TYPE: 0
1776         },
1777         m_getField: 0
1778       },
1779       c_ResponseItem: {
1780         c_Error: {
1781           s_BAD_REQUEST: 0,
1782           s_FORBIDDEN: 0,
1783           s_INTERNAL_ERROR: 0,
1784           s_LIMIT_EXCEEDED: 0,
1785           s_NOT_IMPLEMENTED: 0,
1786           s_UNAUTHORIZED: 0
1787         },
1788         m_getData: 0,
1789         m_getErrorCode: 0,
1790         m_getErrorMessage: 0,
1791         m_getOriginalDataRequest: 0,
1792         m_hadError: 0
1793       },
1794       c_Url: {
1795         c_Field: {
1796           s_ADDRESS: 0,
1797           s_LINK_TEXT: 0,
1798           s_TYPE: 0
1799         },
1800         m_getField: 0
1801       },
1802       s_getEnvironment: 0,
1803       s_hasPermission: 0,
1804       s_newActivity: 0,
1805       s_newDataRequest: 0,
1806       s_newIdSpec: 0,
1807       s_newMediaItem: 0,
1808       s_newMessage: 0,
1809       s_newNavigationParameters: 0,
1810       s_requestCreateActivity: 0,
1811       s_requestPermission: 0,
1812       s_requestSendMessage: 0,
1813       s_requestShareApp: 0
1814     }
1815   };
1816   function whitelist(schema, obj) {
1817     if (!obj) { return; }  // Occurs for optional features
1818     for (var k in schema) {
1819       if (schema.hasOwnProperty(k)) {
1820         var m = k.match(/^([mcs])_(\w+)$/);
1821         var type = m[1], name = m[2];
1822         switch (type) {
1823           case 'c':
1824             ___.allowRead(obj, name);
1825             whitelist(schema[k], obj[name]);
1826             break;
1827           case 'm':
1828             ___.allowCall(obj.prototype, name);
1829             break;
1830           case 'f':
1831             ___.allowRead(obj.prototype, name);
1832             break;
1833           case 's':
1834             if ('function' === typeof obj[name]) {
1835               ___.allowCall(obj, name);
1836             } else {
1837               ___.allowRead(obj, name);
1838             }
1839             break;
1840         }
1841       }
1842     }
1843   }
1844   whitelist(opensocialSchema, window);
1845 };
1846 /*
1847  * Licensed to the Apache Software Foundation (ASF) under one
1848  * or more contributor license agreements.  See the NOTICE file
1849  * distributed with this work for additional information
1850  * regarding copyright ownership.  The ASF licenses this file
1851  * to you under the Apache License, Version 2.0 (the
1852  * "License"); you may not use this file except in compliance
1853  * with the License.  You may obtain a copy of the License at
1854  *
1855  *     http://www.apache.org/licenses/LICENSE-2.0
1856  *
1857  * Unless required by applicable law or agreed to in writing,
1858  * software distributed under the License is distributed on an
1859  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1860  * KIND, either express or implied.  See the License for the
1861  * specific language governing permissions and limitations
1862  * under the License.
1863  */
1864 
1865 /**
1866  * @fileoverview Object used to request social information from the container.
1867  * This includes data for friends, profiles, app data, and activities.
1868  *
1869  * All apps that require access to people information should send a dataRequest
1870  * in order to receieve a dataResponse
1871  */
1872 
1873 
1874 /**
1875  * @class
1876  * <p>
1877  * Used to request social information from the container.
1878  * This includes data for friends, profiles, app data, and activities.
1879  * All apps that require access to people information
1880  * should send a DataRequest.
1881  * </p>
1882  *
1883  * <p>
1884  * Here's an example of creating, initializing, sending, and handling
1885  * the results of a data request:
1886  * </p>
1887  *
1888  * <pre>function requestMe() {
1889   var req = opensocial.newDataRequest();
1890   req.add(req.newFetchPersonRequest(
1891             opensocial.DataRequest.PersonId.VIEWER),
1892           "viewer");
1893   req.send(handleRequestMe);
1894 };
1895 
1896 function handleRequestMe(data) {
1897   var viewer = data.get("viewer");
1898   if (viewer.hadError()) {
1899     <em>//Handle error using viewer.getError()...</em>
1900     return;
1901   }
1902 
1903   <em>//No error. Do something with viewer.getData()...</em>
1904 }
1905 </pre>
1906  * <p>
1907  * <b>See also:</b>
1908  * <a href="opensocial.html#newDataRequest"><code>
1909  * opensocial.newDataRequest()</code></a>
1910  * </p>
1911  *
1912  * @name opensocial.DataRequest
1913  */
1914 
1915 /**
1916  * Do not create a DataRequest directly, instead use
1917  * opensocial.createDataRequest();
1918  *
1919  * @private
1920  * @constructor
1921  */
1922 opensocial.DataRequest = function() {
1923   this.requestObjects_ = [];
1924 };
1925 
1926 
1927 /**
1928  * {Array.<{key: string, request:opensocial.DataRequest.BaseDataRequest}>}
1929  *    requestObjects An array of
1930  *    data requests that the container should fetch data for
1931  * @private
1932  */
1933 opensocial.DataRequest.prototype.requestObjects_ = null;
1934 
1935 
1936 /**
1937  * Get the requested objects
1938  *
1939  * @return {Array.<{key:String, request:BaseDataRequest}>}
1940  *    requestObjects An array of data requests that the container should fetch
1941  *    data for
1942  * @private
1943  */
1944 opensocial.DataRequest.prototype.getRequestObjects = function() {
1945   return this.requestObjects_;
1946 };
1947 
1948 
1949 /**
1950  * Adds an item to fetch (get) or update (set) data from the server.
1951  * A single DataRequest object can have multiple items.
1952  * As a rule, each item is executed in the order it was added,
1953  * starting with the item that was added first.
1954  * However, items that can't collide might be executed in parallel.
1955  *
1956  * @param {Object} request Specifies which data to fetch or update
1957  * @param {String} opt_key A key to map the generated response data to
1958  */
1959 opensocial.DataRequest.prototype.add = function(request, opt_key) {
1960   return this.requestObjects_.push({'key': opt_key, 'request': request});
1961 };
1962 
1963 
1964 /**
1965  * Sends a data request to the server in order to get a data response.
1966  * Although the server may optimize these requests,
1967  * they will always be executed
1968  * as though they were serial.
1969  *
1970  * @param {Function} opt_callback The function to call with the
1971  *   <a href="opensocial.DataResponse.html">data response</a>
1972  *    generated by the server
1973  */
1974 opensocial.DataRequest.prototype.send = function(opt_callback) {
1975   var callback = opt_callback || function(){};
1976   opensocial.Container.get().requestData(this, callback);
1977 };
1978 
1979 
1980 /**
1981  * @static
1982  * @class
1983  * The sort orders available for ordering person objects.
1984  *
1985  * @name opensocial.DataRequest.SortOrder
1986  */
1987 opensocial.DataRequest.SortOrder = {
1988   /**
1989    * When used will sort people by the container's definition of top friends.
1990    * @member opensocial.DataRequest.SortOrder
1991    */
1992   TOP_FRIENDS : 'topFriends',
1993   /**
1994    * When used will sort people alphabetically by the name field.
1995    *
1996    * @member opensocial.DataRequest.SortOrder
1997    */
1998   NAME : 'name'
1999 };
2000 
2001 
2002 /**
2003  * @static
2004  * @class
2005  * The filters available for limiting person requests.
2006  *
2007  * @name opensocial.DataRequest.FilterType
2008  */
2009 opensocial.DataRequest.FilterType = {
2010   /**
2011    * Retrieves all friends.
2012    *
2013    * @member opensocial.DataRequest.FilterType
2014    */
2015   ALL : 'all',
2016   /**
2017    * Retrieves all friends with any data for this application.
2018    *
2019    * @member opensocial.DataRequest.FilterType
2020    */
2021   HAS_APP : 'hasApp',
2022   /**
2023    * Retrieves only the user's top friends.
2024    *
2025    * @member opensocial.DataRequest.FilterType
2026    */
2027   TOP_FRIENDS : 'topFriends',
2028   /**
2029    * Will filter the people requested by checking if they are friends with
2030    * the given <a href="opensocial.IdSpec.html">idSpec</a>. Expects a
2031    *    filterOptions parameter to be passed with the following fields defined:
2032    *  - idSpec The <a href="opensocial.IdSpec.html">idSpec</a> that each person
2033    *        must be friends with.
2034   */
2035   IS_FRIENDS_WITH: 'isFriendsWith'
2036 };
2037 
2038 
2039 /**
2040  * @static
2041  * @class
2042  * @name opensocial.DataRequest.PeopleRequestFields
2043  */
2044 opensocial.DataRequest.PeopleRequestFields = {
2045   /**
2046    * An array of
2047    * <a href="opensocial.Person.Field.html">
2048    * <code>opensocial.Person.Field</code></a>
2049    * specifying what profile data to fetch
2050    * for each of the person objects. The server will always include
2051    * ID, NAME, and THUMBNAIL_URL.
2052    *
2053    * @member opensocial.DataRequest.PeopleRequestFields
2054    */
2055   PROFILE_DETAILS : 'profileDetail',
2056 
2057   /**
2058    * A sort order for the people objects; defaults to TOP_FRIENDS.
2059    * Possible values are defined by
2060    * <a href="opensocial.DataRequest.SortOrder.html">SortOrder</a>.
2061    *
2062    * @member opensocial.DataRequest.PeopleRequestFields
2063    */
2064   SORT_ORDER : 'sortOrder',
2065 
2066   /**
2067    * How to filter the people objects; defaults to ALL.
2068    * Possible values are defined by
2069    * <a href="opensocial.DataRequest.FilterType.html">FilterType</a>.
2070    *
2071    * @member opensocial.DataRequest.PeopleRequestFields
2072    */
2073   FILTER : 'filter',
2074 
2075   /**
2076    * Additional options to be passed into the filter,
2077    * specified as a Map<String, Object>.
2078    *
2079    * @member opensocial.DataRequest.PeopleRequestFields
2080    */
2081   FILTER_OPTIONS: 'filterOptions',
2082 
2083   /**
2084    * When paginating, the index of the first item to fetch.
2085    * Specified as a <code>Number</code>.
2086    *
2087    * @member opensocial.DataRequest.PeopleRequestFields
2088    */
2089   FIRST : 'first',
2090 
2091   /**
2092    * The maximum number of items to fetch; defaults to 20. If set to a larger
2093    * number, a container may honor the request, or may limit the number to a
2094    * container-specified limit of at least 20.
2095    * Specified as a <code>Number</code>.
2096    *
2097    * @member opensocial.DataRequest.PeopleRequestFields
2098    */
2099   MAX : 'max'
2100 };
2101 
2102 
2103 /**
2104  * If the named param does not exist sets it to the default value.
2105  *
2106  * @param {Map} params Parameter map.
2107  * @param {String} name of the param to check
2108  * @param {Object} defaultValue The value to set if the param does not exist.
2109  * @private
2110  */
2111 opensocial.DataRequest.prototype.addDefaultParam = function(params, name,
2112     defaultValue) {
2113   params[name] = params[name] || defaultValue;
2114 };
2115 
2116 
2117 /**
2118  * Adds the default profile fields to the desired array.
2119  *
2120  * @param {Map} params Parameter map.
2121  * @private
2122  */
2123 opensocial.DataRequest.prototype.addDefaultProfileFields = function(params) {
2124   var fields = opensocial.DataRequest.PeopleRequestFields;
2125   var profileFields = params[fields.PROFILE_DETAILS] || [];
2126   params[fields.PROFILE_DETAILS] = profileFields.concat(
2127       [opensocial.Person.Field.ID, opensocial.Person.Field.NAME,
2128        opensocial.Person.Field.THUMBNAIL_URL]);
2129 };
2130 
2131 
2132 /**
2133  * Returns the keys object as an array.
2134  *
2135  * @param {Object} keys
2136  * @private
2137  */
2138 opensocial.DataRequest.prototype.asArray = function(keys) {
2139   if (opensocial.Container.isArray(keys)) {
2140     return keys;
2141   } else {
2142     return [keys];
2143   }
2144 };
2145 
2146 
2147 /**
2148  * Creates an item to request a profile for the specified person ID.
2149  * When processed, returns a
2150  * <a href="opensocial.Person.html"><code>Person</code></a> object.
2151  *
2152  * @param {String} id The ID of the person to fetch; can be the standard
2153  *    <a href="opensocial.IdSpec.PersonId.html">person ID</a>
2154  *    of VIEWER or OWNER
2155  * @param {Map.<opensocial.DataRequest.PeopleRequestFields, Object>}
2156  *  opt_params
2157  *    Additional
2158  *    <a href="opensocial.DataRequest.PeopleRequestFields.html">parameters</a>
2159  *    to pass to the request; this request supports PROFILE_DETAILS
2160  * @return {Object} A request object
2161  */
2162 opensocial.DataRequest.prototype.newFetchPersonRequest = function(id,
2163     opt_params) {
2164   opt_params = opt_params || {};
2165   this.addDefaultProfileFields(opt_params);
2166 
2167   return opensocial.Container.get().newFetchPersonRequest(id, opt_params);
2168 };
2169 
2170 
2171 /**
2172  * Creates an item to request friends from the server.
2173  * When processed, returns a <a href="opensocial.Collection.html">Collection</a>
2174  * <<a href="opensocial.Person.html">Person</a>> object.
2175  *
2176  * @param {opensocial.IdSpec} idSpec An IdSpec used to specify
2177  *    which people to fetch. See also <a href="opensocial.IdSpec.html">IdSpec</a>.
2178  * @param {Map.<opensocial.DataRequest.PeopleRequestFields, Object>}
2179  *  opt_params
2180  *    Additional
2181  *    <a href="opensocial.DataRequest.PeopleRequestFields.html">params</a>
2182  *    to pass to the request
2183  * @return {Object} A request object
2184  */
2185 opensocial.DataRequest.prototype.newFetchPeopleRequest = function(idSpec,
2186     opt_params) {
2187   opt_params = opt_params || {};
2188   var fields = opensocial.DataRequest.PeopleRequestFields;
2189 
2190   this.addDefaultProfileFields(opt_params);
2191 
2192   this.addDefaultParam(opt_params, fields.SORT_ORDER,
2193       opensocial.DataRequest.SortOrder.TOP_FRIENDS);
2194 
2195   this.addDefaultParam(opt_params, fields.FILTER,
2196       opensocial.DataRequest.FilterType.ALL);
2197 
2198   this.addDefaultParam(opt_params, fields.FIRST, 0);
2199 
2200   this.addDefaultParam(opt_params, fields.MAX, 20);
2201 
2202   return opensocial.Container.get().newFetchPeopleRequest(idSpec, opt_params);
2203 };
2204 
2205 
2206 /**
2207  * @static
2208  * @class
2209  * @name opensocial.DataRequest.DataRequestFields
2210  */
2211 opensocial.DataRequest.DataRequestFields = {
2212   /**
2213    * How to escape person data returned from the server; defaults to HTML_ESCAPE.
2214    * Possible values are defined by
2215    * <a href="opensocial.EscapeType.html">EscapeType</a>.
2216    *
2217    * @member opensocial.DataRequest.DataRequestFields
2218    */
2219   ESCAPE_TYPE : 'escapeType'
2220 };
2221 
2222 
2223 /**
2224  * Creates an item to request app data for the given people.
2225  * When processed, returns a Map<
2226  * <a href="opensocial.DataRequest.PersonId.html">PersonId</a>,
2227  * Map<String, String>> object.
2228  * All of the data values returned will be valid json.
2229  *
2230  * @param {opensocial.IdSpec} idSpec An IdSpec used to specify which people to
2231  *     fetch. See also <a href="opensocial.IdSpec.html">IdSpec</a>.
2232  * @param {Array.<String> | String} keys The keys you want data for; this
2233  *     can be an array of key names, a single key name, or "*" to mean
2234  *     "all keys"
2235  * @param {Map.<opensocial.DataRequest.DataRequestFields, Object>}
2236  *  opt_params Additional
2237  *    <a href="opensocial.DataRequest.DataRequestFields.html">params</a>
2238  *    to pass to the request
2239  * @return {Object} A request object
2240  */
2241 opensocial.DataRequest.prototype.newFetchPersonAppDataRequest = function(idSpec,
2242     keys, opt_params) {
2243   return opensocial.Container.get().newFetchPersonAppDataRequest(idSpec,
2244       this.asArray(keys), opt_params);
2245 };
2246 
2247 
2248 /**
2249  * Creates an item to request an update of an app field for the given person.
2250  * When processed, does not return any data.
2251  *
2252  * @param {String} id The ID of the person to update; only the
2253  *     special <code>VIEWER</code> ID is currently allowed.
2254  * @param {String} key The name of the key. This may only contain alphanumeric
2255  *     (A-Za-z0-9) characters, underscore(_), dot(.) or dash(-).
2256  * @param {String} value The value, must be valid json
2257  * @return {Object} A request object
2258  */
2259 opensocial.DataRequest.prototype.newUpdatePersonAppDataRequest = function(id,
2260     key, value) {
2261   return opensocial.Container.get().newUpdatePersonAppDataRequest(id, key,
2262       value);
2263 };
2264 
2265 
2266 /**
2267  * Deletes the given keys from the datastore for the given person.
2268  * When processed, does not return any data.
2269  *
2270  * @param {String} id The ID of the person to update; only the
2271  *     special <code>VIEWER</code> ID is currently allowed.
2272  * @param {Array.<String> | String} keys The keys you want to delete from
2273  *     the datastore; this can be an array of key names, a single key name,
2274  *     or "*" to mean "all keys"
2275  * @return {Object} A request object
2276  */
2277 opensocial.DataRequest.prototype.newRemovePersonAppDataRequest = function(id,
2278     keys) {
2279   return opensocial.Container.get().newRemovePersonAppDataRequest(id, keys);
2280 };
2281 
2282 
2283 /**
2284  * @static
2285  * @class
2286  * Used by
2287  * <a href="opensocial.DataRequest.html#newFetchActivitiesRequest">
2288  * <code>DataRequest.newFetchActivitiesRequest()</code></a>.
2289  * @name opensocial.DataRequest.ActivityRequestFields
2290  * @private
2291  */
2292 opensocial.DataRequest.ActivityRequestFields = {
2293   /**
2294    * {String} If provided will filter all activities by this app Id.
2295    * @private - at the moment you can only request activities for your own app
2296    */
2297   APP_ID : 'appId'
2298 };
2299 
2300 
2301 /**
2302  * Creates an item to request an activity stream from the server.
2303  *
2304  * <p>
2305  * When processed, returns a Collection<Activity>.
2306  * </p>
2307  *
2308  * @param {opensocial.IdSpec} idSpec An IdSpec used to specify which people to
2309  *     fetch. See also <a href="opensocial.IdSpec.html">IdSpec</a>.
2310  * @param {Map.<opensocial.DataRequest.ActivityRequestFields, Object>}
2311  *  opt_params
2312  *    Additional parameters
2313  *    to pass to the request; not currently used
2314  * @return {Object} A request object
2315  */
2316 opensocial.DataRequest.prototype.newFetchActivitiesRequest = function(idSpec,
2317     opt_params) {
2318   opt_params = opt_params || {};
2319   return opensocial.Container.get().newFetchActivitiesRequest(idSpec,
2320       opt_params);
2321 };
2322 /*
2323  * Licensed to the Apache Software Foundation (ASF) under one
2324  * or more contributor license agreements.  See the NOTICE file
2325  * distributed with this work for additional information
2326  * regarding copyright ownership.  The ASF licenses this file
2327  * to you under the Apache License, Version 2.0 (the
2328  * "License"); you may not use this file except in compliance
2329  * with the License.  You may obtain a copy of the License at
2330  *
2331  *     http://www.apache.org/licenses/LICENSE-2.0
2332  *
2333  * Unless required by applicable law or agreed to in writing,
2334  * software distributed under the License is distributed on an
2335  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2336  * KIND, either express or implied.  See the License for the
2337  * specific language governing permissions and limitations
2338  * under the License.
2339  */
2340 
2341 /**
2342  * @fileoverview DataResponse containing information about
2343  * friends, contacts, profile, app data, and activities.
2344  *
2345  * Whenever a dataRequest is sent to the server it will return a dataResponse
2346  * object. Values from the server will be mapped to the requested keys specified
2347  * in the dataRequest.
2348  */
2349 
2350 
2351 /**
2352  * @class
2353  * This object contains the requested server data mapped to the requested keys.
2354  *
2355  * <p>
2356  * <b>See also:</b>
2357  * <a href="opensocial.DataRequest.html">DataRequest</a>
2358  * </p>
2359  *
2360  * @name opensocial.DataResponse
2361  */
2362 
2363 /**
2364  * Construct the data response.
2365  * This object contains the requested server data mapped to the requested keys.
2366  *
2367  * @param {Map.<String, ResponseItem>} responseItems Key/value map of data
2368  *    response information
2369  * @param {Boolean} opt_globalError Optional field indicating whether there were
2370  *    any errors generating this data response
2371  *
2372  * @private
2373  * @constructor
2374  */
2375 opensocial.DataResponse = function(responseItems, opt_globalError,
2376     opt_errorMessage) {
2377   this.responseItems_ = responseItems;
2378   this.globalError_ = opt_globalError;
2379   this.errorMessage_ = opt_errorMessage;
2380 };
2381 
2382 
2383 /**
2384  * Returns true if there was an error in fetching this data from the server.
2385  *
2386  * @return {Boolean} True if there was an error; otherwise, false
2387  * @member opensocial.DataResponse
2388  */
2389 opensocial.DataResponse.prototype.hadError = function() {
2390   return !!this.globalError_;
2391 };
2392 
2393 
2394 /**
2395  * If the entire request had a batch level error, returns the error message.
2396  *
2397  * @return {String} A human-readable description of the error that occurred.
2398  */
2399 opensocial.DataResponse.prototype.getErrorMessage = function() {
2400   return this.errorMessage_;
2401 };
2402 
2403 
2404 /**
2405  * Gets the ResponseItem for the requested field.
2406  *
2407  * @return {opensocial.ResponseItem} The requested
2408  *    <a href="opensocial.ResponseItem.html">response</a> calculated by the
2409  *    server
2410  * @member opensocial.DataResponse
2411  */
2412 opensocial.DataResponse.prototype.get = function(key) {
2413   return this.responseItems_[key];
2414 };
2415 /*
2416  * Licensed to the Apache Software Foundation (ASF) under one
2417  * or more contributor license agreements.  See the NOTICE file
2418  * distributed with this work for additional information
2419  * regarding copyright ownership.  The ASF licenses this file
2420  * to you under the Apache License, Version 2.0 (the
2421  * "License"); you may not use this file except in compliance
2422  * with the License.  You may obtain a copy of the License at
2423  *
2424  *     http://www.apache.org/licenses/LICENSE-2.0
2425  *
2426  * Unless required by applicable law or agreed to in writing,
2427  * software distributed under the License is distributed on an
2428  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2429  * KIND, either express or implied.  See the License for the
2430  * specific language governing permissions and limitations
2431  * under the License.
2432  */
2433 
2434 /**
2435  * @fileoverview Representation of an email.
2436  */
2437 
2438 
2439 /**
2440  * @class
2441  * Base interface for all email objects.
2442  *
2443  * @name opensocial.Email
2444  */
2445 
2446 
2447 /**
2448  * Base interface for all email objects.
2449  *
2450  * @private
2451  * @constructor
2452  */
2453 opensocial.Email = function(opt_params) {
2454   this.fields_ = opt_params || {};
2455 };
2456 
2457 
2458 /**
2459  * @static
2460  * @class
2461  * All of the fields that an email has. These are the supported keys for the
2462  * <a href="opensocial.Email.html#getField">Email.getField()</a> method.
2463  *
2464  * @name opensocial.Email.Field
2465  */
2466 opensocial.Email.Field = {
2467   /**
2468    * The email type or label, specified as a String.
2469    * Examples: work, my favorite store, my house, etc.
2470    *
2471    * @member opensocial.Email.Field
2472    */
2473   TYPE : 'type',
2474 
2475   /**
2476    * The email address, specified as a String.
2477    *
2478    * @member opensocial.Email.Field
2479    */
2480   ADDRESS : 'address'
2481 };
2482 
2483 
2484 /**
2485  * Gets data for this body type that is associated with the specified key.
2486  *
2487  * @param {String} key The key to get data for;
2488  *    keys are defined in <a href="opensocial.Email.Field.html"><code>
2489  *    Email.Field</code></a>
2490  * @param {Map.<opensocial.DataRequest.DataRequestFields, Object>}
2491  *  opt_params Additional
2492  *    <a href="opensocial.DataRequest.DataRequestFields.html">params</a>
2493  *    to pass to the request.
2494  * @return {String} The data
2495  */
2496 opensocial.Email.prototype.getField = function(key, opt_params) {
2497   return opensocial.Container.getField(this.fields_, key, opt_params);
2498 };
2499 /*
2500  * Licensed to the Apache Software Foundation (ASF) under one
2501  * or more contributor license agreements.  See the NOTICE file
2502  * distributed with this work for additional information
2503  * regarding copyright ownership.  The ASF licenses this file
2504  * to you under the Apache License, Version 2.0 (the
2505  * "License"); you may not use this file except in compliance
2506  * with the License.  You may obtain a copy of the License at
2507  *
2508  *     http://www.apache.org/licenses/LICENSE-2.0
2509  *
2510  * Unless required by applicable law or agreed to in writing,
2511  * software distributed under the License is distributed on an
2512  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2513  * KIND, either express or implied.  See the License for the
2514  * specific language governing permissions and limitations
2515  * under the License.
2516  */
2517 
2518 /**
2519  * @fileoverview Representation of an enum.
2520  */
2521 
2522 
2523 /**
2524  * @class
2525  * Base interface for all enum objects.
2526  * This class allows containers to use constants for fields that are usually
2527  * have a common set of values.
2528  * There are two main ways to use this class.
2529  *
2530  * <p>
2531  * If your gadget just wants to display how much of a smoker someone is,
2532  * it can simply use:
2533  * </p>
2534  *
2535  * <pre>html = "This person smokes: " + person.getField('smoker').getValue();</pre>
2536  *
2537  * <p>
2538  * This value field will be correctly set up by the container. This is a place
2539  * where the container can even localize the value for the gadget so that it
2540  * always shows the right thing.
2541  * </p>
2542  *
2543  * <p>
2544  * If your gadget wants to have some logic around the smoker
2545  * field it can use:
2546  * </p>
2547  *
2548  * <pre>if (person.getField('smoker').getKey() != "NO") { //gadget logic here }</pre>
2549  *
2550  * <p class="note">
2551  * <b>Note:</b>
2552  * The key may be null if the person's smoker field cannot be coerced
2553  * into one of the standard enum types.
2554  * The value, on the other hand, is never null.
2555  * </p>
2556  *
2557  * @name opensocial.Enum
2558  */
2559 
2560 
2561 /**
2562  * Base interface for all enum objects.
2563  *
2564  * @private
2565  * @constructor
2566  */
2567 opensocial.Enum = function(key, displayValue) {
2568   this.key = key;
2569   this.displayValue = displayValue;
2570 };
2571 
2572 
2573 /**
2574  * Use this for logic within your gadget. If they key is null then the value
2575  * does not fit in the defined enums.
2576  *
2577  * @return {String} The enum's key. This should be one of the defined enums
2578  *     below.
2579  */
2580 opensocial.Enum.prototype.getKey = function() {
2581   return gadgets.util.escape(this.key);
2582 };
2583 
2584 
2585 /**
2586  * The value of this enum. This will be a user displayable string. If the
2587  * container supports localization, the string will be localized.
2588  *
2589  * @return {String} The enum's value.
2590  */
2591 opensocial.Enum.prototype.getDisplayValue = function() {
2592   return gadgets.util.escape(this.displayValue);
2593 };
2594 
2595 
2596 /**
2597  * @static
2598  * @class
2599  * The enum keys used by the smoker field.
2600  * <p><b>See also:</b>
2601  * <a href="opensocial.Person.Field.html">
2602  * opensocial.Person.Field.Smoker</a>
2603  * </p>
2604  *
2605  * @name opensocial.Enum.Smoker
2606  */
2607 opensocial.Enum.Smoker = {
2608   /** @member opensocial.Enum.Smoker */
2609   NO : 'NO',
2610   /** @member opensocial.Enum.Smoker */
2611   YES : 'YES',
2612   /** @member opensocial.Enum.Smoker */
2613   SOCIALLY : 'SOCIALLY',
2614   /** @member opensocial.Enum.Smoker */
2615   OCCASIONALLY : 'OCCASIONALLY',
2616   /** @member opensocial.Enum.Smoker */
2617   REGULARLY : 'REGULARLY',
2618   /** @member opensocial.Enum.Smoker */
2619   HEAVILY : 'HEAVILY',
2620   /** @member opensocial.Enum.Smoker */
2621   QUITTING : 'QUITTING',
2622   /** @member opensocial.Enum.Smoker */
2623   QUIT : 'QUIT'
2624 };
2625 
2626 
2627 /**
2628  * @static
2629  * @class
2630  * The enum keys used by the drinker field.
2631  * <p><b>See also:</b>
2632  * <a href="opensocial.Person.Field.html">
2633  * opensocial.Person.Field.Drinker</a>
2634  * </p>
2635  *
2636  * @name opensocial.Enum.Drinker
2637  */
2638 opensocial.Enum.Drinker = {
2639   /** @member opensocial.Enum.Drinker */
2640   NO : 'NO',
2641   /** @member opensocial.Enum.Drinker */
2642   YES : 'YES',
2643   /** @member opensocial.Enum.Drinker */
2644   SOCIALLY : 'SOCIALLY',
2645   /** @member opensocial.Enum.Drinker */
2646   OCCASIONALLY : 'OCCASIONALLY',
2647   /** @member opensocial.Enum.Drinker */
2648   REGULARLY : 'REGULARLY',
2649   /** @member opensocial.Enum.Drinker */
2650   HEAVILY : 'HEAVILY',
2651   /** @member opensocial.Enum.Drinker */
2652   QUITTING : 'QUITTING',
2653   /** @member opensocial.Enum.Drinker */
2654   QUIT : 'QUIT'
2655 };
2656 
2657 
2658 /**
2659  * @static
2660  * @class
2661  * The enum keys used by the gender field.
2662  * <p><b>See also:</b>
2663  * <a href="opensocial.Person.Field.html">
2664  * opensocial.Person.Field.Gender</a>
2665  * </p>
2666  *
2667  * @name opensocial.Enum.Gender
2668  */
2669 opensocial.Enum.Gender = {
2670   /** @member opensocial.Enum.Gender */
2671   MALE : 'MALE',
2672   /** @member opensocial.Enum.Gender */
2673   FEMALE : 'FEMALE'
2674 };
2675 
2676 
2677 /**
2678  * @static
2679  * @class
2680  * The enum keys used by the lookingFor field.
2681  * <p><b>See also:</b>
2682  * <a href="opensocial.Person.Field.html">
2683  * opensocial.Person.Field.LookingFor</a>
2684  * </p>
2685  *
2686  * @name opensocial.Enum.LookingFor
2687  */
2688 opensocial.Enum.LookingFor = {
2689   /** @member opensocial.Enum.LookingFor */
2690   DATING : 'DATING',
2691   /** @member opensocial.Enum.LookingFor */
2692   FRIENDS : 'FRIENDS',
2693   /** @member opensocial.Enum.LookingFor */
2694   RELATIONSHIP : 'RELATIONSHIP',
2695   /** @member opensocial.Enum.LookingFor */
2696   NETWORKING : 'NETWORKING',
2697   /** @member opensocial.Enum.LookingFor */
2698   ACTIVITY_PARTNERS : 'ACTIVITY_PARTNERS',
2699   /** @member opensocial.Enum.LookingFor */
2700   RANDOM : 'RANDOM'
2701 };
2702 
2703 
2704 /**
2705  * @static
2706  * @class
2707  * The enum keys used by the networkPresence field.
2708  * <p><b>See also:</b>
2709  * <a href="opensocial.Person.Field.html">
2710  * opensocial.Person.Field.NetworkPresence</a>
2711  * </p>
2712  *
2713  * @name opensocial.Enum.Presence
2714  */
2715 opensocial.Enum.Presence = {
2716   /** @member opensocial.Enum.Presence */
2717   AWAY : 'AWAY',
2718   /** @member opensocial.Enum.Presence */
2719   CHAT : 'CHAT',
2720   /** @member opensocial.Enum.Presence */
2721   DND : 'DND',
2722   /** @member opensocial.Enum.Presence */
2723   OFFLINE : 'OFFLINE',
2724   /** @member opensocial.Enum.Presence */
2725   ONLINE : 'ONLINE',
2726   /** @member opensocial.Enum.Presence */
2727   XA : 'XA'
2728 };
2729 /*
2730  * Licensed to the Apache Software Foundation (ASF) under one
2731  * or more contributor license agreements.  See the NOTICE file
2732  * distributed with this work for additional information
2733  * regarding copyright ownership.  The ASF licenses this file
2734  * to you under the Apache License, Version 2.0 (the
2735  * "License"); you may not use this file except in compliance
2736  * with the License.  You may obtain a copy of the License at
2737  *
2738  *     http://www.apache.org/licenses/LICENSE-2.0
2739  *
2740  * Unless required by applicable law or agreed to in writing,
2741  * software distributed under the License is distributed on an
2742  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2743  * KIND, either express or implied.  See the License for the
2744  * specific language governing permissions and limitations
2745  * under the License.
2746  */
2747 
2748 /**
2749  * @fileoverview Representation of a environment.
2750  */
2751 
2752 
2753 /**
2754  * @class
2755  * Represents the current environment for a gadget.
2756  *
2757  * <p>
2758  * <b>See also:</b>
2759  * <a href="opensocial.html#getEnvironment">opensocial.getEnvironment()</a>,
2760  *
2761  * @name opensocial.Environment
2762  */
2763 
2764 
2765 /**
2766  * Base interface for all environment objects.
2767  *
2768  * @param {String} domain The current domain
2769  * @param {Map.<String, Map.<String, Boolean>>} supportedFields
2770  *    The fields supported by this container
2771  *
2772  * @private
2773  * @constructor
2774  */
2775 opensocial.Environment = function(domain, supportedFields) {
2776   this.domain = domain;
2777   this.supportedFields = supportedFields;
2778 };
2779 
2780 
2781 /**
2782  * Returns the current domain —
2783  * for example, "orkut.com" or "myspace.com".
2784  *
2785  * @return {String} The domain
2786  */
2787 opensocial.Environment.prototype.getDomain = function() {
2788   return this.domain;
2789 };
2790 
2791 
2792 /**
2793  * @static
2794  * @class
2795  *
2796  * The types of objects in this container.
2797  *
2798  * <p>
2799  * <b>See also:</b>
2800  * <a href="opensocial.Environment.html#supportsField">
2801  * <code>Environment.supportsField()</code></a>
2802  *
2803  * @name opensocial.Environment.ObjectType
2804  */
2805 opensocial.Environment.ObjectType = {
2806   /**
2807    * @member opensocial.Environment.ObjectType
2808    */
2809   PERSON : 'person',
2810   /**
2811    * @member opensocial.Environment.ObjectType
2812    */
2813   ADDRESS : 'address',
2814   /**
2815    * @member opensocial.Environment.ObjectType
2816    */
2817   BODY_TYPE : 'bodyType',
2818   /**
2819    * @member opensocial.Environment.ObjectType
2820    */
2821   EMAIL : 'email',
2822   /**
2823    * @member opensocial.Environment.ObjectType
2824    */
2825   NAME : 'name',
2826   /**
2827    * @member opensocial.Environment.ObjectType
2828    */
2829   ORGANIZATION : 'organization',
2830   /**
2831    * @member opensocial.Environment.ObjectType
2832    */
2833   PHONE : 'phone',
2834   /**
2835    * @member opensocial.Environment.ObjectType
2836    */
2837   URL : 'url',
2838   /**
2839    * @member opensocial.Environment.ObjectType
2840    */
2841   ACTIVITY : 'activity',
2842   /**
2843    * @member opensocial.Environment.ObjectType
2844    */
2845   MEDIA_ITEM : 'mediaItem',
2846   /**
2847    * @member opensocial.Environment.ObjectType
2848    */
2849   MESSAGE : 'message',
2850   /**
2851    * @member opensocial.Environment.ObjectType
2852    */
2853   MESSAGE_TYPE : 'messageType',
2854   /**
2855    * @member opensocial.Environment.ObjectType
2856    */
2857   SORT_ORDER : 'sortOrder',
2858   /**
2859    * @member opensocial.Environment.ObjectType
2860    */
2861   FILTER_TYPE : 'filterType'
2862 };
2863 
2864 
2865 /**
2866  * Returns true if the specified field is supported in this container on the
2867  * given object type.
2868  *
2869  * @param {opensocial.Environment.ObjectType} objectType
2870  *    The <a href="opensocial.Environment.ObjectType.html">object type</a>
2871  *    to check for the field
2872  * @param {String} fieldName The name of the field to check for
2873  * @return {Boolean} True if the field is supported on the specified object type
2874  */
2875 opensocial.Environment.prototype.supportsField = function(objectType,
2876     fieldName) {
2877   var supportedObjectFields = this.supportedFields[objectType] || [];
2878   return !!supportedObjectFields[fieldName];
2879 };/*
2880  * Licensed to the Apache Software Foundation (ASF) under one
2881  * or more contributor license agreements.  See the NOTICE file
2882  * distributed with this work for additional information
2883  * regarding copyright ownership.  The ASF licenses this file
2884  * to you under the Apache License, Version 2.0 (the
2885  * "License"); you may not use this file except in compliance
2886  * with the License.  You may obtain a copy of the License at
2887  *
2888  *     http://www.apache.org/licenses/LICENSE-2.0
2889  *
2890  * Unless required by applicable law or agreed to in writing,
2891  * software distributed under the License is distributed on an
2892  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
2893  * KIND, either express or implied.  See the License for the
2894  * specific language governing permissions and limitations
2895  * under the License.
2896  */
2897 
2898 /**
2899  * @fileoverview Representation of an group of people ids.
2900  */
2901 
2902 
2903 /**
2904  * @class
2905  * Base interface for all id spec objects.
2906  *
2907  * @name opensocial.IdSpec
2908  */
2909 
2910 
2911 /**
2912  * Base interface for all id spec objects. Use this class when specifying which
2913  * people you want to fetch.
2914  *
2915  * For example, opensocial.newIdSpec({userId : 'VIEWER', groupId : 'FRIENDS'})
2916  *                means you are looking for all of the viewer's friends.
2917  * For example, opensocial.newIdSpec({userId : 'VIEWER',
2918  *                                    groupId : 'FRIENDS', networkDistance : 2})
2919  *                means you are looking for all of the viewer's friends of friends.
2920  * For example, opensocial.newIdSpec({userId : 'OWNER'})
2921  *                means you are looking for the owner.
2922  *
2923  * Private, see opensocial.newIdSpec() for usage.
2924  *
2925  * @private
2926  * @constructor
2927  */
2928 opensocial.IdSpec = function(opt_params) {
2929   this.fields_ = opt_params || {};
2930 };
2931 
2932 
2933 /**
2934  * @static
2935  * @class
2936  * All of the fields that id specs can have.
2937  *
2938  * <p>
2939  * <b>See also:</b>
2940  * <a
2941  * href="opensocial.IdSpec.html#getField">opensocial.IdSpec.getField()</a>
2942  * </p>
2943  *
2944  * @name opensocial.IdSpec.Field
2945  */
2946 opensocial.IdSpec.Field = {
2947   /**
2948    * A string or an array of strings representing the user id. Can be
2949    * one of the opensocial.IdSpec.PersonId values.
2950    * @member opensocial.IdSpec.Field
2951    */
2952   USER_ID : 'userId',
2953 
2954   /**
2955    * A string representing the group id or one of the
2956    * opensocial.IdSpec.GroupId values. Defaults to SELF.
2957    * @member opensocial.IdSpec.Field
2958    */
2959   GROUP_ID : 'groupId',
2960 
2961   /**
2962    * An optional numeric parameter, used to specify how many "hops"
2963    * are allowed between two people still considered part of the
2964    * same group.
2965    * Defaults to 1 (they must be the same person or
2966    * directly be connected by the group).
2967    *
2968    * Not all containers will support networkDistances greater than 1.
2969    *
2970    * @member opensocial.IdSpec.Field
2971    */
2972   NETWORK_DISTANCE : 'networkDistance'
2973 };
2974 
2975 
2976 /**
2977  * @static
2978  * @class
2979  * Constant person IDs available when fetching person information.
2980  *
2981  * @name opensocial.IdSpec.PersonId
2982  */
2983 opensocial.IdSpec.PersonId = {
2984  /**
2985   * @member opensocial.IdSpec.PersonId
2986   */
2987   OWNER : 'OWNER',
2988  /**
2989   * @member opensocial.IdSpec.PersonId
2990   */
2991   VIEWER : 'VIEWER'
2992 };
2993 
2994 
2995  /**
2996  * @static
2997  * @class
2998  * Constant group IDs available when fetching collections of people.
2999  *
3000  * @name opensocial.IdSpec.GroupId
3001  */
3002 opensocial.IdSpec.GroupId = {
3003  /**
3004   * @member opensocial.IdSpec.GroupId
3005   */
3006   SELF : 'SELF',
3007  /**
3008   * @member opensocial.IdSpec.GroupId
3009   */
3010   FRIENDS : 'FRIENDS',
3011  /**
3012   * @member opensocial.IdSpec.GroupId
3013   */
3014   ALL : 'ALL'
3015 };
3016 
3017 
3018 /**
3019  * Gets the id spec's data that's associated with the specified key.
3020  *
3021  * @param {String} key The key to get data for;
3022  *   see the <a href="opensocial.IdSpec.Field.html">Field</a> class
3023  * for possible values
3024  * @param {Map.<opensocial.DataRequest.DataRequestFields, Object>}
3025  *  opt_params Additional
3026  *    <a href="opensocial.DataRequest.DataRequestFields.html">params</a>
3027  *    to pass to the request.
3028  * @return {String} The data
3029  * @member opensocial.IdSpec
3030  */
3031 opensocial.IdSpec.prototype.getField = function(key, opt_params) {
3032   return opensocial.Container.getField(this.fields_, key, opt_params);
3033 };
3034 
3035 
3036 /**
3037  * Sets data for this id spec associated with the given key.
3038  *
3039  * @param {String} key The key to set data for
3040  * @param {String} data The data to set
3041  */
3042 opensocial.IdSpec.prototype.setField = function(key, data) {
3043   return this.fields_[key] = data;
3044 };
3045 /*
3046  * Licensed to the Apache Software Foundation (ASF) under one
3047  * or more contributor license agreements.  See the NOTICE file
3048  * distributed with this work for additional information
3049  * regarding copyright ownership.  The ASF licenses this file
3050  * to you under the Apache License, Version 2.0 (the
3051  * "License"); you may not use this file except in compliance
3052  * with the License.  You may obtain a copy of the License at
3053  *
3054  *     http://www.apache.org/licenses/LICENSE-2.0
3055  *
3056  * Unless required by applicable law or agreed to in writing,
3057  * software distributed under the License is distributed on an
3058  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
3059  * KIND, either express or implied.  See the License for the
3060  * specific language governing permissions and limitations
3061  * under the License.
3062  */
3063 
3064 /**
3065  * @class
3066  * Represents images, movies, and audio.
3067  * Create a <code>MediaItem</code> object using the
3068  * <a href="opensocial.html#newMediaItem">
3069  * opensocial.newMediaItem()</a> method.
3070  *
3071  * @name opensocial.MediaItem
3072  */
3073 
3074 /**
3075  * Represents images, movies, and audio.
3076  *
3077  * @param {String} mimeType The media's type
3078  * @param {String} url The media's location
3079  * @param {Map.<opensocial.MediaItem.Field, Object>} opt_params
3080  *    Any other fields that should be set on the media item object.
3081  *    All of the defined Fields are supported.
3082  * @constructor
3083  * @private
3084  */
3085 opensocial.MediaItem = function(mimeType, url, opt_params) {
3086   this.fields_ = opt_params || {};
3087   this.fields_[opensocial.MediaItem.Field.MIME_TYPE] = mimeType;
3088   this.fields_[opensocial.MediaItem.Field.URL] = url;
3089 };
3090 
3091 
3092 /**
3093  * @static
3094  * @class
3095  * The possible types of media items.
3096  *
3097  * <p>
3098  * <b>See also:</b>
3099  * <a href="opensocial.MediaItem.Field.html">
3100  * opensocial.MediaItem.Field</a>
3101  * </p>
3102  *
3103  * @name opensocial.MediaItem.Type
3104  */
3105 opensocial.MediaItem.Type = {
3106   /** @member opensocial.MediaItem.Type */
3107   IMAGE : 'image',
3108   /** @member opensocial.MediaItem.Type */
3109   VIDEO : 'video',
3110   /** @member opensocial.MediaItem.Type */
3111   AUDIO : 'audio'
3112 }
3113 
3114 
3115 /**
3116  * @static
3117  * @class
3118  * All of the fields that media items have.
3119  *
3120  * <p>
3121  * <b>See also:</b>
3122  * <a href="opensocial.MediaItem.html#getField">
3123  * opensocial.MediaItem.getField()</a>
3124  * </p>
3125  *
3126  * @name opensocial.MediaItem.Field
3127  */
3128 opensocial.MediaItem.Field = {
3129   /**
3130    * The type of media, specified as a
3131    * <a href="opensocial.MediaItem.Type.html">
3132    * <code>MediaItem.Type</code></a> object.
3133    * @member opensocial.MediaItem.Field
3134    */
3135   TYPE : 'type',
3136 
3137   /**
3138    * The MIME type of media, specified as a String.
3139    * @member opensocial.MediaItem.Field
3140    */
3141   MIME_TYPE : 'mimeType',
3142 
3143   /**
3144    * A string specifying the URL where the media can be found.
3145    * @member opensocial.MediaItem.Field
3146    */
3147   URL : 'url'
3148 };
3149 
3150 
3151 /**
3152  * Gets the media item data that's associated with the specified key.
3153  *
3154  * @param {String} key The key to get data for; see the
3155  *   <a href="opensocial.MediaItem.Field.html">Field</a> class
3156  *   for possible values
3157  * @return {String} The data
3158  */
3159 opensocial.MediaItem.prototype.getField = function(key, opt_params) {
3160   return opensocial.Container.getField(this.fields_, key, opt_params);
3161 };
3162 
3163 
3164 /**
3165  * Sets data for this media item associated with the given key.
3166  *
3167  * @param {String} key The key to set data for
3168  * @param {String} data The data to set
3169  */
3170 opensocial.MediaItem.prototype.setField = function(key, data) {
3171   return this.fields_[key] = data;
3172 };
3173 /*
3174  * Licensed to the Apache Software Foundation (ASF) under one
3175  * or more contributor license agreements.  See the NOTICE file
3176  * distributed with this work for additional information
3177  * regarding copyright ownership.  The ASF licenses this file
3178  * to you under the Apache License, Version 2.0 (the
3179  * "License"); you may not use this file except in compliance
3180  * with the License.  You may obtain a copy of the License at
3181  *
3182  *     http://www.apache.org/licenses/LICENSE-2.0
3183  *
3184  * Unless required by applicable law or agreed to in writing,
3185  * software distributed under the License is distributed on an
3186  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
3187  * KIND, either express or implied.  See the License for the
3188  * specific language governing permissions and limitations
3189  * under the License.
3190  */
3191 
3192 /**
3193  * @fileoverview Representation of a message.
3194  */
3195 
3196 
3197 /**
3198  * @class
3199  * Base interface for all message objects.
3200  *
3201  * <p>
3202  * <b>See also:</b>
3203  * <a href="opensocial.html#newMessage">opensocial.newMessage()</a>,
3204  * <a href="opensocial.html#requestSendMessage">
3205  * opensocial.requestSendMessage()</a>
3206  *
3207  * @name opensocial.Message
3208  */
3209 
3210 
3211 /**
3212  * Base interface for all message objects.
3213  *
3214  * @param {String} body The main text of the message.
3215  * @param {Map.<opensocial.Message.Field, Object>} opt_params Any other
3216  *    fields that should be set on the message object. All of the defined
3217  *    Fields are supported.
3218  * @private
3219  * @constructor
3220  */
3221 opensocial.Message = function(body, opt_params) {
3222   this.fields_ = opt_params || {};
3223   this.fields_[opensocial.Message.Field.BODY] = body;
3224 };
3225 
3226 
3227 /**
3228  * @static
3229  * @class
3230  * All of the fields that messages can have.
3231  *
3232  * <p>
3233  * <b>See also:</b>
3234  * <a
3235  * href="opensocial.Message.html#getField">opensocial.Message.getField()</a>
3236  * </p>
3237  *
3238  * @name opensocial.Message.Field
3239  */
3240 opensocial.Message.Field = {
3241   /**
3242    * The title of the message, specified as an opensocial.Message.Type.
3243    * @member opensocial.Message.Field
3244    */
3245   TYPE : 'type',
3246 
3247   /**
3248    * The title of the message. HTML attributes are allowed and are
3249    * sanitized by the container.
3250    * @member opensocial.Message.Field
3251    */
3252   TITLE : 'title',
3253 
3254   /**
3255    * The main text of the message. HTML attributes are allowed and are
3256    * sanitized by the container.
3257    * @member opensocial.Message.Field
3258    */
3259   BODY : 'body',
3260 
3261   /**
3262    * The title of the message as a message template. Specifies the
3263    * message ID to use in the gadget xml.
3264    * @member opensocial.Message.Field
3265    */
3266   TITLE_ID : 'titleId',
3267 
3268   /**
3269    * The main text of the message as a message template. Specifies the
3270    * message ID to use in the gadget xml.
3271    * @member opensocial.Message.Field
3272    */
3273   BODY_ID : 'bodyId'
3274 };
3275 
3276 
3277 /**
3278  * @static
3279  * @class
3280  * The types of messages that can be sent.
3281  *
3282  * @name opensocial.Message.Type
3283  */
3284 opensocial.Message.Type = {
3285   /**
3286    * An email.
3287    *
3288    * @member opensocial.Message.Type
3289    */
3290   EMAIL : 'email',
3291 
3292   /**
3293    * A short private message.
3294    *
3295    * @member opensocial.Message.Type
3296    */
3297   NOTIFICATION : 'notification',
3298 
3299   /**
3300    * A message to a specific user that can be seen only by that user.
3301    *
3302    * @member opensocial.Message.Type
3303    */
3304   PRIVATE_MESSAGE : 'privateMessage',
3305 
3306   /**
3307    * A message to a specific user that can be seen by more than that user.
3308    * @member opensocial.Message.Type
3309    */
3310   PUBLIC_MESSAGE : 'publicMessage'
3311 };
3312 
3313 
3314 /**
3315  * Gets the message data that's associated with the specified key.
3316  *
3317  * @param {String} key The key to get data for;
3318  *   see the <a href="opensocial.Message.Field.html">Field</a> class
3319  * for possible values
3320  * @param {Map.<opensocial.DataRequest.DataRequestFields, Object>}
3321  *  opt_params Additional
3322  *    <a href="opensocial.DataRequest.DataRequestFields.html">params</a>
3323  *    to pass to the request.
3324  * @return {String} The data
3325  * @member opensocial.Message
3326  */
3327 opensocial.Message.prototype.getField = function(key, opt_params) {
3328   return opensocial.Container.getField(this.fields_, key, opt_params);
3329 };
3330 
3331 
3332 /**
3333  * Sets data for this message associated with the given key.
3334  *
3335  * @param {String} key The key to set data for
3336  * @param {String} data The data to set
3337  */
3338 opensocial.Message.prototype.setField = function(key, data) {
3339   return this.fields_[key] = data;
3340 };
3341 /*
3342  * Licensed to the Apache Software Foundation (ASF) under one
3343  * or more contributor license agreements.  See the NOTICE file
3344  * distributed with this work for additional information
3345  * regarding copyright ownership.  The ASF licenses this file
3346  * to you under the Apache License, Version 2.0 (the
3347  * "License"); you may not use this file except in compliance
3348  * with the License.  You may obtain a copy of the License at
3349  *
3350  *     http://www.apache.org/licenses/LICENSE-2.0
3351  *
3352  * Unless required by applicable law or agreed to in writing,
3353  * software distributed under the License is distributed on an
3354  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
3355  * KIND, either express or implied.  See the License for the
3356  * specific language governing permissions and limitations
3357  * under the License.
3358  */
3359 
3360 /**
3361  * @fileoverview Representation of an name.
3362  */
3363 
3364 
3365 /**
3366  * @class
3367  * Base interface for all name objects.
3368  *
3369  * @name opensocial.Name
3370  */
3371 
3372 
3373 /**
3374  * Base interface for all name objects.
3375  *
3376  * @private
3377  * @constructor
3378  */
3379 opensocial.Name = function(opt_params) {
3380   this.fields_ = opt_params || {};
3381 };
3382 
3383 
3384 /**
3385  * @static
3386  * @class
3387  * All of the fields that a name has. These are the supported keys for the
3388  * <a href="opensocial.Name.html#getField">Name.getField()</a> method.
3389  *
3390  * @name opensocial.Name.Field
3391  */
3392 opensocial.Name.Field = {
3393   /**
3394    * The family name. Specified as a String.
3395    *
3396    * @member opensocial.Name.Field
3397    */
3398   FAMILY_NAME : 'familyName',
3399 
3400   /**
3401    * The given name. Specified as a String.
3402    *
3403    * @member opensocial.Name.Field
3404    */
3405   GIVEN_NAME : 'givenName',
3406 
3407   /**
3408    * The additional name. Specified as a String.
3409    *
3410    * @member opensocial.Name.Field
3411    */
3412   ADDITIONAL_NAME : 'additionalName',
3413 
3414   /**
3415    * The honorific prefix. Specified as a String.
3416    *
3417    * @member opensocial.Name.Field
3418    */
3419   HONORIFIC_PREFIX : 'honorificPrefix',
3420 
3421   /**
3422    * The honorific suffix. Specified as a String.
3423    *
3424    * @member opensocial.Name.Field
3425    */
3426   HONORIFIC_SUFFIX : 'honorificSuffix',
3427 
3428   /**
3429    * The unstructured name. Specified as a String.
3430    *
3431    * @member opensocial.Name.Field
3432    */
3433   UNSTRUCTURED : 'unstructured'
3434 };
3435 
3436 
3437 /**
3438  * Gets data for this name that is associated with the specified key.
3439  *
3440  * @param {String} key The key to get data for;
3441  *    keys are defined in <a href="opensocial.Name.Field.html"><code>
3442  *    Name.Field</code></a>
3443  * @param {Map.<opensocial.DataRequest.DataRequestFields, Object>}
3444  *  opt_params Additional
3445  *    <a href="opensocial.DataRequest.DataRequestFields.html">params</a>
3446  *    to pass to the request.
3447  * @return {String} The data
3448  */
3449 opensocial.Name.prototype.getField = function(key, opt_params) {
3450   return opensocial.Container.getField(this.fields_, key, opt_params);
3451 };
3452 /*
3453  * Licensed to the Apache Software Foundation (ASF) under one
3454  * or more contributor license agreements.  See the NOTICE file
3455  * distributed with this work for additional information
3456  * regarding copyright ownership.  The ASF licenses this file
3457  * to you under the Apache License, Version 2.0 (the
3458  * "License"); you may not use this file except in compliance
3459  * with the License.  You may obtain a copy of the License at
3460  *
3461  *     http://www.apache.org/licenses/LICENSE-2.0
3462  *
3463  * Unless required by applicable law or agreed to in writing,
3464  * software distributed under the License is distributed on an
3465  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
3466  * KIND, either express or implied.  See the License for the
3467  * specific language governing permissions and limitations
3468  * under the License.
3469  */
3470 
3471 /**
3472  * @fileoverview Representation of navigation parameters for RequestShareApp.
3473  */
3474 
3475 
3476 /**
3477  * @class
3478  * Parameters used by RequestShareApp to instruct the container on where to go
3479  * after the request is made.
3480  *
3481  *  It could be used, for example, to specify where viewers get routed
3482  *  in one of two cases:
3483  * 1) After a user gets a shareApp invitation or receives a message a gadget
3484  *     developer should be able to send that user to a context sensitive place.
3485  * 2) After a viewer actually shares an app with someone else the gadget
3486  *     developer should be able to redirect the viewer to a context sensitive
3487  *     place.
3488  *
3489  *
3490  * @name opensocial.NavigationParameters
3491  */
3492 
3493 
3494 /**
3495  * Use this class to hold navigation parameters for RequestShareApp.
3496  *
3497  * For example, opensocial.newNavigationParameters({view : 'preview',
3498  *                                                  owner: 'xx',
3499  *                                                  parameters: {}).
3500  *
3501  * Private, see <a href="opensocial.html#newNavigationParameters">
3502  *              opensocial.newNavigationParameters()</a> for usage.
3503  *
3504  * @private
3505  * @constructor
3506  */
3507 opensocial.NavigationParameters = function(opt_params) {
3508   this.fields_ = opt_params || {};
3509 };
3510 
3511 
3512 /**
3513  * @static
3514  * @class
3515  * All of the fields that NavigationParameters can have.
3516  *
3517  * <p>
3518  * <b>See also:</b>
3519  * <a
3520  * href="opensocial.NavigationParameters.html#getField">
3521  *         opensocial.NavigationParameters.getField()</a>
3522  * </p>
3523  *
3524  * @name opensocial.NavigationParameters.Field
3525  */
3526 opensocial.NavigationParameters.Field = {
3527   /**
3528    * The <a href="gadgets.views.View.html">View</a> to navigate to.
3529    *
3530    * @member opensocial.NavigationParameters.Field
3531    */
3532   VIEW : 'view',
3533 
3534   /**
3535    * A string representing the owner id.
3536    *
3537    * @member opensocial.NavigationParameters.Field
3538    */
3539   OWNER : 'owner',
3540 
3541   /**
3542    * An optional list of parameters passed to the gadget once the new view,
3543    * with the new owner, has been loaded.
3544    *
3545    *
3546    * @member opensocial.NavigationParameters.Field
3547    */
3548   PARAMETERS : 'parameters'
3549 };
3550 
3551 
3552 /**
3553  * Gets the NavigationParameters' data that's associated with the specified key.
3554  *
3555  * @param {String} key The key to get data for;
3556  *     see the <a href="opensocial.NavigationParameters.Field.html">Field</a>
3557  *     class for possible values
3558  * @param {Map.<opensocial.DataRequest.DataRequestFields, Object>}
3559  *     opt_params Additional
3560  *     <a href="opensocial.DataRequest.DataRequestFields.html">params</a>
3561  *     to pass to the request.
3562  * @return {String} The data
3563  * @member opensocial.NavigationParameters
3564  */
3565 opensocial.NavigationParameters.prototype.getField = function(key, opt_params) {
3566   return opensocial.Container.getField(this.fields_, key, opt_params);
3567 };
3568 
3569 
3570 /**
3571  * Sets data for this NavigationParameters associated with the given key.
3572  *
3573  * @param {String} key The key to set data for
3574  * @param {Object} data The data to set
3575  */
3576 opensocial.NavigationParameters.prototype.setField = function(key, data) {
3577   return this.fields_[key] = data;
3578 };
3579 
3580 
3581 /**
3582  * @static
3583  * @class
3584  *
3585  * The destinations available for navigation in
3586  * <a href="opensocial.html#requestShareApp">requestShareApp</a>
3587  * and <a href="opensocial.html#requestSendMessage">requestSendMessage</a>.
3588  *
3589  * @name opensocial.NavigationParameters.DestinationType
3590  */
3591 opensocial.NavigationParameters.DestinationType = {
3592   /** @member opensocial.NavigationParameters.DestinationType */
3593   VIEWER_DESTINATION : "viewerDestination",
3594 
3595   /** @member opensocial.NavigationParameters.DestinationType  */
3596   RECIPIENT_DESTINATION : "recipientDestination"
3597 };
3598 /*
3599  * Licensed to the Apache Software Foundation (ASF) under one
3600  * or more contributor license agreements.  See the NOTICE file
3601  * distributed with this work for additional information
3602  * regarding copyright ownership.  The ASF licenses this file
3603  * to you under the Apache License, Version 2.0 (the
3604  * "License"); you may not use this file except in compliance
3605  * with the License.  You may obtain a copy of the License at
3606  *
3607  *     http://www.apache.org/licenses/LICENSE-2.0
3608  *
3609  * Unless required by applicable law or agreed to in writing,
3610  * software distributed under the License is distributed on an
3611  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
3612  * KIND, either express or implied.  See the License for the
3613  * specific language governing permissions and limitations
3614  * under the License.
3615  */
3616 
3617 /**
3618  * @fileoverview Browser environment for interacting with people.
3619  */
3620 
3621 
3622 /**
3623  * @static
3624  * @class
3625  * Namespace for top-level people functions.
3626  *
3627  * @name opensocial
3628  */
3629 
3630 /**
3631  * Namespace for top level people functions.
3632  *
3633  * @private
3634  * @constructor (note: a constructor for JsDoc purposes)
3635  */
3636 var opensocial = function() {};
3637 
3638 
3639 /**
3640  * Requests the container to send a specific message to the specified users.
3641  *
3642  * <p>
3643  * The callback function is passed one parameter, an
3644  *    opensocial.ResponseItem. The error code will be set to reflect whether
3645  *    there were any problems with the request. If there was no error, the
3646  *    message was sent. If there was an error, you can use the response item's
3647  *    getErrorCode method to determine how to proceed. The data on the response
3648  *    item will not be set.
3649  * </p>
3650  *
3651  * <p>
3652  * If the container does not support this method
3653  * the callback will be called with an
3654  * opensocial.ResponseItem that has an error code of
3655  * NOT_IMPLEMENTED.
3656  * </p>
3657  *
3658  * @param {Array.<String> | String} recipients An ID, array of IDs, or a
3659  *     group reference; the supported keys are VIEWER, OWNER, VIEWER_FRIENDS,
3660  *    OWNER_FRIENDS, or a single ID within one of those groups
3661  * @param {opensocial.Message} message The message to send to the specified
3662  *     users
3663  * @param {Function} opt_callback The function to call once the request has been
3664  *    processed; either this callback will be called or the gadget will be
3665  *    reloaded from scratch
3666  * @param {opensocial.NavigationParameters} opt_params The optional parameters
3667  *     indicating where to send a user when a request is made, or when a request is
3668  *     accepted; options are of type
3669  *     <a href="opensocial.NavigationParameters.DestinationType.html">
3670  *     NavigationParameters.DestinationType</a>
3671  *
3672  * @member opensocial
3673  */
3674 opensocial.requestSendMessage = function(recipients, message, opt_callback,
3675     opt_params) {
3676   opensocial.Container.get().requestSendMessage(recipients, message,
3677       opt_callback, opt_params);
3678 };
3679 
3680 
3681 /**
3682  * Requests the container to share this gadget with the specified users.
3683  *
3684  * <p>
3685  * The callback function is passed one parameter, an
3686  *    opensocial.ResponseItem. The error code will be set to reflect whether
3687  *    there were any problems with the request. If there was no error, the
3688  *    sharing request was sent. If there was an error, you can use the response
3689  *    item's getErrorCode method to determine how to proceed. The data on the
3690  *    response item will not be set.
3691  * </p>
3692  *
3693  * <p>
3694  * If the
3695  * container does not support this method the callback will be called with a
3696  * opensocial.ResponseItem. The response item will have its error code set to
3697  * NOT_IMPLEMENTED.
3698  * </p>
3699  *
3700  * @param {Array.<String> | String} recipients An ID, array of IDs, or a
3701  *     group reference; the supported keys are VIEWER, OWNER, VIEWER_FRIENDS,
3702  *    OWNER_FRIENDS, or a single ID within one of those groups
3703  * @param {opensocial.Message} reason The reason the user wants the gadget to
3704  *     share itself. This reason can be used by the container when prompting the
3705  *     user for permission to share the app. It may also be ignored.
3706  * @param {Function} opt_callback The function to call once the request has been
3707  *    processed; either this callback will be called or the gadget will be
3708  *    reloaded from scratch
3709  * @param {opensocial.NavigationParameters} opt_params The optional parameters
3710  *     indicating where to send a user when a request is made, or when a request is
3711  *     accepted; options are of type
3712  *     <a href="opensocial.NavigationParameters.DestinationType.html">
3713  *     NavigationParameters.DestinationType</a>
3714  *
3715  * @member opensocial
3716  */
3717 opensocial.requestShareApp = function(recipients, reason, opt_callback,
3718     opt_params) {
3719   opensocial.Container.get().requestShareApp(recipients, reason, opt_callback,
3720       opt_params);
3721 };
3722 
3723 
3724 /**
3725  * Takes an activity and tries to create it,
3726  * without waiting for the operation to complete.
3727  * Optionally calls a function when the operation completes.
3728  * <p>
3729  * <b>See also:</b>
3730  * <a href="#newActivity">newActivity()</a>
3731  * </p>
3732  *
3733  * <p class="note">
3734  * <b>Note:</b>
3735  * If this is the first activity that has been created for the user and
3736  * the request is marked as HIGH priority then this call may open a user flow
3737  * and navigate away from your gadget.
3738  *
3739  * <p>
3740  * This callback will either be called or the gadget will be
3741  *    reloaded from scratch. This function will be passed one parameter, an
3742  *    opensocial.ResponseItem. The error code will be set to reflect whether
3743  *    there were any problems with the request. If there was no error, the
3744  *    activity was created. If there was an error, you can use the response
3745  *    item's getErrorCode method to determine how to proceed. The data on the
3746  *    response item will not be set.
3747  * </p>
3748  *
3749  * <p>
3750  * If the container does not support this method the callback will be called
3751  * with a opensocial.ResponseItem. The response item will have its error code
3752  * set to NOT_IMPLEMENTED.
3753  * </p>
3754  *
3755  * @param {opensocial.Activity} activity The <a href="opensocial.Activity.html">
3756  *    activity</a> to create
3757  * @param {opensocial.CreateActivityPriority} priority The
3758  *    <a href="opensocial.CreateActivityPriority.html">priority</a> for this
3759  *    request
3760  * @param {Function} opt_callback The function to call once the request has been
3761  *    processed.
3762  *
3763  * @member opensocial
3764  */
3765 opensocial.requestCreateActivity = function(activity, priority, opt_callback) {
3766   if (!activity || (!activity.getField(opensocial.Activity.Field.TITLE)
3767       && !activity.getField(opensocial.Activity.Field.TITLE_ID))) {
3768     if (opt_callback) {
3769       opt_callback(new opensocial.ResponseItem(null, null,
3770           opensocial.ResponseItem.Error.BAD_REQUEST,
3771           "You must pass in an activity with a title or title id."));
3772     }
3773     return;
3774   }
3775 
3776  opensocial.Container.get().requestCreateActivity(activity, priority,
3777      opt_callback);
3778 };
3779 
3780 
3781 /**
3782  * @static
3783  * @class
3784  * The priorities a create activity request can have.
3785  * <p><b>See also:</b>
3786  * <a href="opensocial.html#requestCreateActivity">
3787  * opensocial.requestCreateActivity()</a>
3788  * </p>
3789  *
3790  * @name opensocial.CreateActivityPriority
3791  */
3792 opensocial.CreateActivityPriority = {
3793   /**
3794    * If the activity is of high importance, it will be created even if this
3795    * requires asking the user for permission. This may cause the container to
3796    * open a user flow which may navigate away from your gagdet.
3797    *
3798    * @member opensocial.CreateActivityPriority
3799    */
3800   HIGH : 'HIGH',
3801 
3802   /**
3803    * If the activity is of low importance, it will not be created if the
3804    * user has not given permission for the current app to create activities.
3805    * With this priority, the requestCreateActivity call will never open a user
3806    * flow.
3807    *
3808    * @member opensocial.CreateActivityPriority
3809    */
3810   LOW : 'LOW'
3811 };
3812 
3813 /*
3814 *  Returns the ContainerURLTemplate. 
3815 *  @return {string}
3816 */
3817 opensocial.getContainerUrlTemplate = function()
3818 {
3819     return opensocial.getEnvironment().currentApplication.getField(MyOpenSpace.Application.Field.CANVAS_URL) + "?appId={name}";
3820 };
3821 
3822 /**
3823  * Returns true if the current gadget has access to the specified
3824  * permission. If the gadget calls opensocial.requestPermission and permissions
3825  * are granted then this function must return true on all subsequent calls.
3826  *
3827  * @param {opensocial.Permission} permission
3828  *    The <a href="opensocial.Permission.html">permission</a>
3829  * @return {Boolean}
3830  *    True if the gadget has access for the permission; false if it doesn't
3831  *
3832  * @member opensocial
3833  */
3834 opensocial.hasPermission = function(permission) {
3835   return opensocial.Container.get().hasPermission(permission);
3836 };
3837 
3838 
3839 /**
3840  * Requests the user to grant access to the specified permissions. If the
3841  * container does not support this method the callback will be called with a
3842  * opensocial.ResponseItem. The response item will have its error code set to
3843  * NOT_IMPLEMENTED.
3844  *
3845  * @param {Array.<opensocial.Permission>} permissions
3846  *    The <a href="opensocial.Permission.html">permissions</a> to request
3847  *    from the viewer
3848  * @param {String} reason Displayed to the user as the reason why these
3849  *    permissions are needed
3850  * @param {Function} opt_callback The function to call once the request has been
3851  *    processed; either this callback will be called or the gadget will be
3852  *    reloaded from scratch. This function will be passed one parameter, an
3853  *    opensocial.ResponseItem. The error code will be set to reflect whether
3854  *    there were any problems with the request. If there was no error, all
3855  *    permissions were granted. If there was an error, you can use
3856  *    opensocial.hasPermission to check which permissions are still denied. The
3857  *    data on the response item will be set. It will be an array of the
3858  *    opensocial.Permissions that were granted.
3859  *
3860  * @member opensocial
3861  */
3862 opensocial.requestPermission = function(permissions, reason, opt_callback) {
3863   opensocial.Container.get().requestPermission(permissions, reason,
3864       opt_callback);
3865 };
3866 
3867 
3868 /**
3869  * @static
3870  * @class
3871  *
3872  * The permissions an app can ask for.
3873  *
3874  * <p>
3875  * <b>See also:</b>
3876  * <a href="opensocial.html#hasPermission">
3877  * <code>opensocial.hasPermission()</code></a>,
3878  * <a href="opensocial.html#requestPermission">
3879  * <code>opensocial.requestPermission()</code></a>
3880  *
3881  * @name opensocial.Permission
3882  */
3883 opensocial.Permission = {
3884   /**
3885    * Access to the viewer person object
3886    *
3887    * @member opensocial.Permission
3888    */
3889   VIEWER : 'viewer'
3890 };
3891 
3892 
3893 /**
3894  * Gets the current environment for this gadget. You can use the environment to
3895  * make queries such as what profile fields and surfaces are supported by this
3896  * container, what parameters were passed to the current gadget, and so on.
3897  *
3898  * @return {opensocial.Environment}
3899  *    The current <a href="opensocial.Environment.html">environment</a>
3900  *
3901  * @member opensocial
3902  */
3903 opensocial.getEnvironment = function() {
3904   return opensocial.Container.get().getEnvironment();
3905 };
3906 
3907 
3908 /**
3909  * Creates a data request object to use for sending and fetching data from the
3910  * server.
3911  *
3912  * @return {opensocial.DataRequest} The
3913  *    <a href="opensocial.DataRequest.html">request</a> object
3914  * @member opensocial
3915  */
3916 opensocial.newDataRequest = function() {
3917   return opensocial.Container.get().newDataRequest();
3918 };
3919 
3920 
3921 /**
3922  * Creates an activity object,
3923  * which represents an activity on the server.
3924  * <p>
3925  * <b>See also:</b>
3926  * <a href="#requestCreateActivity">requestCreateActivity()</a>,
3927  * </p>
3928  *
3929  * <p>It is only required to set one of TITLE_ID or TITLE. In addition, if you
3930  * are using any variables in your title or title template,
3931  * you must set TEMPLATE_PARAMS.</p>
3932  *
3933  * <p>Other possible fields to set are: URL, MEDIA_ITEMS, BODY_ID, BODY,
3934  * EXTERNAL_ID, PRIORITY, STREAM_TITLE, STREAM_URL, STREAM_SOURCE_URL,
3935  * and STREAM_FAVICON_URL.</p>
3936  *
3937  * <p>Containers are only required to use TITLE_ID or TITLE, and may choose to
3938  * ignore additional parameters.</p>
3939  *
3940  * <p>See <a href="opensocial.Activity.Field.html">Field</a>s are supported for
3941  * more details.</p>
3942  *
3943  * @param {Map.<opensocial.Activity.Field, Object>} params
3944  *    Parameters defining the activity.
3945  * @return {opensocial.Activity} The new
3946  *    <a href="opensocial.Activity.html">activity</a> object
3947  * @member opensocial
3948  */
3949 opensocial.newActivity = function(params) {
3950   return opensocial.Container.get().newActivity(params);
3951 };
3952 
3953 
3954 /**
3955  * Creates a media item.
3956  * Represents images, movies, and audio.
3957  * Used when creating activities on the server.
3958  *
3959  * @param {String} mimeType
3960  *    <a href="opensocial.MediaItem.Type.html">MIME type</a> of the
3961  *    media
3962  * @param {String} url Where the media can be found
3963  * @param {Map.<opensocial.MediaItem.Field, Object>} opt_params
3964  *    Any other fields that should be set on the media item object;
3965  *    all of the defined
3966  *    <a href="opensocial.MediaItem.Field.html">Field</a>s
3967  *    are supported
3968  *
3969  * @return {opensocial.MediaItem} The new
3970  *    <a href="opensocial.MediaItem.html">media item</a> object
3971  * @member opensocial
3972  */
3973 opensocial.newMediaItem = function(mimeType, url, opt_params) {
3974   return opensocial.Container.get().newMediaItem(mimeType, url, opt_params);
3975 };
3976 
3977 
3978 /**
3979  * Creates a media item associated with an activity.
3980  * Represents images, movies, and audio.
3981  * Used when creating activities on the server.
3982  *
3983  * @param {String} body The main text of the message.
3984  * @param {Map.<opensocial.Message.Field, Object>} opt_params
3985  *    Any other fields that should be set on the message object;
3986  *    all of the defined
3987  *    <a href="opensocial.Message.Field.html">Field</a>s
3988  *    are supported
3989  *
3990  * @return {opensocial.Message} The new
3991  *    <a href="opensocial.Message.html">message</a> object
3992  * @member opensocial
3993  */
3994 opensocial.newMessage = function(body, opt_params) {
3995   return opensocial.Container.get().newMessage(body, opt_params);
3996 };
3997 
3998 
3999 /**
4000  * @static
4001  * @class
4002  * The types of escaping that can be applied to person data or fields.
4003  *
4004  * @name opensocial.EscapeType
4005  */
4006 opensocial.EscapeType = {
4007   /**
4008    * When used will HTML-escape the data.
4009    * @member opensocial.EscapeType
4010    */
4011   HTML_ESCAPE : 'htmlEscape',
4012   /**
4013    * When used will not escape the data.
4014    *
4015    * @member opensocial.EscapeType
4016    */
4017   NONE : 'none'
4018 };
4019 
4020 
4021 /**
4022  * Creates an IdSpec object.
4023  *
4024  * @param {Map.<opensocial.IdSpec.Field, Object>} parameters
4025  *    Parameters defining the id spec.
4026  * @return {opensocial.IdSpec} The new
4027  *     <a href="opensocial.IdSpec.html">IdSpec</a> object
4028  * @member opensocial
4029  */
4030 opensocial.newIdSpec = function(params) {
4031   return opensocial.Container.get().newIdSpec(params);
4032 };
4033 
4034 
4035 /**
4036  * Creates a NavigationParameters object.
4037  * <p>
4038  * <b>See also:</b>
4039  * <a href="#requestShareApp">requestShareApp()</a>
4040  * </p>
4041  *
4042  *
4043  * @param {Map.<opensocial.NavigationParameters.Field, Object>} parameters
4044  *     Parameters defining the navigation
4045  * @return {opensocial.NavigationParameters} The new
4046  *     <a href="opensocial.NavigationParameters.html">NavigationParameters</a>
4047  *     object
4048  * @member opensocial
4049  */
4050 opensocial.newNavigationParameters = function(params) {
4051   return opensocial.Container.get().newNavigationParameters(params);
4052 };
4053 
4054 
4055 // TODO(doll): Util function - pull up the gadgets inherits in shindig so that
4056 // opensocial and gadgets use the same one
4057 /** @private */
4058 Function.prototype.inherits = function(parentCtor) {
4059   function tempCtor() {};
4060 
4061   tempCtor.prototype = parentCtor.prototype;
4062   this.superClass_ = parentCtor.prototype;
4063   this.prototype = new tempCtor();
4064   this.prototype.constructor = this;
4065 };
4066 /*
4067  * Licensed to the Apache Software Foundation (ASF) under one
4068  * or more contributor license agreements.  See the NOTICE file
4069  * distributed with this work for additional information
4070  * regarding copyright ownership.  The ASF licenses this file
4071  * to you under the Apache License, Version 2.0 (the
4072  * "License"); you may not use this file except in compliance
4073  * with the License.  You may obtain a copy of the License at
4074  *
4075  *     http://www.apache.org/licenses/LICENSE-2.0
4076  *
4077  * Unless required by applicable law or agreed to in writing,
4078  * software distributed under the License is distributed on an
4079  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4080  * KIND, either express or implied.  See the License for the
4081  * specific language governing permissions and limitations
4082  * under the License.
4083  */
4084 
4085 /**
4086  * @fileoverview Representation of a organization.
4087  */
4088 
4089 
4090 /**
4091  * @class
4092  * Base interface for all organization objects.
4093  *
4094  * @name opensocial.Organization
4095  */
4096 
4097 
4098 /**
4099  * Base interface for all organization objects.
4100  *
4101  * @private
4102  * @constructor
4103  */
4104 opensocial.Organization = function(opt_params) {
4105   this.fields_ = opt_params || {};
4106 };
4107 
4108 
4109 /**
4110  * @static
4111  * @class
4112  * All of the fields that a organization has. These are the supported keys for
4113  * the <a href="opensocial.Organization.html#getField">
4114  * Organization.getField()</a> method.
4115  *
4116  * @name opensocial.Organization.Field
4117  */
4118 opensocial.Organization.Field = {
4119   /**
4120    * The name of the organization. For example, could be a school name or a job
4121    * company. Specified as a string.
4122    * Not supported by all containers.
4123    * @member opensocial.Organization.Field
4124    */
4125   NAME : 'name',
4126 
4127   /**
4128    * The title or role the person has in the organization, specified as a
4129    * string. This could be graduate student, or software engineer.
4130    * Not supported by all containers.
4131    * @member opensocial.Organization.Field
4132    */
4133   TITLE : 'title',
4134 
4135   /**
4136    * A description or notes about the person's work in the organization,
4137    * specified as a string. This could be the courses taken by a student, or a
4138    * more detailed description about a Organization role.
4139    * Not supported by all containers.
4140    * @member opensocial.Organization.Field
4141    */
4142   DESCRIPTION : 'description',
4143 
4144   /**
4145    * The field the organization is in, specified as a string. This could be the
4146    * degree pursued if the organization is a school.
4147    * Not supported by all containers.
4148    * @member opensocial.Organization.Field
4149    */
4150   FIELD : 'field',
4151 
4152   /**
4153    * The subfield the Organization is in, specified as a string.
4154    * Not supported by all containers.
4155    * @member opensocial.Organization.Field
4156    */
4157   SUB_FIELD : 'subField',
4158 
4159   /**
4160    * The date the person started at the organization, specified as a Date.
4161    * Not supported by all containers.
4162    * @member opensocial.Organization.Field
4163    */
4164   START_DATE : 'startDate',
4165 
4166   /**
4167    * The date the person stopped at the organization, specified as a Date.
4168    * A null date indicates that the person is still involved with the
4169    * organization.
4170    * Not supported by all containers.
4171    * @member opensocial.Organization.Field
4172    */
4173   END_DATE : 'endDate',
4174 
4175  /**
4176    * The salary the person receieves from the organization, specified as a
4177    * string.
4178    * Not supported by all containers.
4179    * @member opensocial.Organization.Field
4180    */
4181   SALARY : 'salary',
4182 
4183  /**
4184    * The address of the organization, specified as an opensocial.Address.
4185    * Not supported by all containers.
4186    * @member opensocial.Organization.Field
4187    */
4188   ADDRESS : 'address',
4189 
4190  /**
4191    * A webpage related to the organization, specified as a string.
4192    * Not supported by all containers.
4193    * @member opensocial.Organization.Field
4194    */
4195   WEBPAGE : 'webpage'
4196 };
4197 
4198 
4199 /**
4200  * Gets data for this body type that is associated with the specified key.
4201  *
4202  * @param {String} key The key to get data for;
4203  *    keys are defined in <a href="opensocial.Organization.Field.html"><code>
4204  *    Organization.Field</code></a>
4205  * @param {Map.<opensocial.DataRequest.DataRequestFields, Object>}
4206  *  opt_params Additional
4207  *    <a href="opensocial.DataRequest.DataRequestFields.html">params</a>
4208  *    to pass to the request
4209  * @return {String} The data
4210  */
4211 opensocial.Organization.prototype.getField = function(key, opt_params) {
4212   return opensocial.Container.getField(this.fields_, key, opt_params);
4213 };
4214 /*
4215  * Licensed to the Apache Software Foundation (ASF) under one
4216  * or more contributor license agreements.  See the NOTICE file
4217  * distributed with this work for additional information
4218  * regarding copyright ownership.  The ASF licenses this file
4219  * to you under the Apache License, Version 2.0 (the
4220  * "License"); you may not use this file except in compliance
4221  * with the License.  You may obtain a copy of the License at
4222  *
4223  *     http://www.apache.org/licenses/LICENSE-2.0
4224  *
4225  * Unless required by applicable law or agreed to in writing,
4226  * software distributed under the License is distributed on an
4227  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4228  * KIND, either express or implied.  See the License for the
4229  * specific language governing permissions and limitations
4230  * under the License.
4231  */
4232 
4233 /**
4234  * @fileoverview Representation of a person.
4235  */
4236 
4237 
4238 /**
4239  * @class
4240  * Base interface for all person objects.
4241  *
4242  * @name opensocial.Person
4243  */
4244 
4245 
4246 /**
4247  * Base interface for all person objects.
4248  *
4249  * @private
4250  * @constructor
4251  */
4252 opensocial.Person = function(opt_params, opt_isOwner, opt_isViewer) {
4253   this.fields_ = opt_params || {};
4254   this.isOwner_ = opt_isOwner;
4255   this.isViewer_ = opt_isViewer;
4256 };
4257 
4258 
4259 /**
4260  * @static
4261  * @class
4262  * All of the fields that a person has. These are the supported keys for the
4263  * <a href="opensocial.Person.html#getField">Person.getField()</a> method.
4264  *
4265  * @name opensocial.Person.Field
4266  */
4267 opensocial.Person.Field = {
4268   /**
4269    * A string ID that can be permanently associated with this person.
4270    * @member opensocial.Person.Field
4271    */
4272   ID : 'id',
4273 
4274   /**
4275    * A opensocial.Name object containing the person's name.
4276    * @member opensocial.Person.Field
4277    */
4278   NAME : 'name',
4279 
4280   /**
4281    * A String representing the person's nickname.
4282    * @member opensocial.Person.Field
4283    */
4284   NICKNAME : 'nickname',
4285 
4286   /**
4287    * Person's photo thumbnail URL, specified as a string.
4288    * This URL must be fully qualified. Relative URLs will not work in gadgets.
4289    * @member opensocial.Person.Field
4290    */
4291   THUMBNAIL_URL : 'thumbnailUrl',
4292 
4293   /**
4294    * Person's profile URL, specified as a string.
4295    * This URL must be fully qualified. Relative URLs will not work in gadgets.
4296    * Container support for this field is OPTIONAL.
4297    * @member opensocial.Person.Field
4298    */
4299   PROFILE_URL : 'profileUrl',
4300 
4301   /**
4302    * Person's current location, specified as an
4303    * <a href="opensocial.Address.html">Address</a>.
4304    * Container support for this field is OPTIONAL.
4305    * @member opensocial.Person.Field
4306    */
4307   CURRENT_LOCATION : 'currentLocation',
4308 
4309   /**
4310    * Addresses associated with the person, specified as an Array of
4311    * <a href="opensocial.Address.html">Address</a>es.
4312    * Container support for this field is OPTIONAL.
4313    * @member opensocial.Person.Field
4314    */
4315   ADDRESSES : 'addresses',
4316 
4317   /**
4318    * Emails associated with the person, specified as an Array of
4319    * <a href="opensocial.Email.html">Email</a>s.
4320    * Container support for this field is OPTIONAL.
4321    * @member opensocial.Person.Field
4322    */
4323   EMAILS : 'emails',
4324 
4325   /**
4326    * Phone numbers associated with the person, specified as an Array of
4327    * <a href="opensocial.Phone.html">Phone</a>s.
4328    * Container support for this field is OPTIONAL.
4329    * @member opensocial.Person.Field
4330    */
4331   PHONE_NUMBERS : 'phoneNumbers',
4332 
4333   /**
4334    * A general statement about the person, specified as a string.
4335    * Container support for this field is OPTIONAL.
4336    *
4337    * @member opensocial.Person.Field
4338    */
4339   ABOUT_ME : 'aboutMe',
4340 
4341   /**
4342    * Person's status, headline or shoutout, specified as a string.
4343    * Container support for this field is OPTIONAL.
4344    *
4345    * @member opensocial.Person.Field
4346    */
4347   STATUS : 'status',
4348 
4349   /**
4350    * Person's profile song, specified as an opensocial.Url.
4351    * Container support for this field is OPTIONAL.
4352    *
4353    * @member opensocial.Person.Field
4354    */
4355   PROFILE_SONG : 'profileSong',
4356 
4357   /**
4358    * Person's profile video, specified as an opensocial.Url.
4359    * Container support for this field is OPTIONAL.
4360    *
4361    * @member opensocial.Person.Field
4362    */
4363   PROFILE_VIDEO : 'profileVideo',
4364 
4365   /**
4366    * Person's gender, specified as an opensocial.Enum with the enum's
4367    * key referencing opensocial.Enum.Gender.
4368    * Container support for this field is OPTIONAL.
4369    *
4370    * @member opensocial.Person.Field
4371    */
4372   GENDER : 'gender',
4373 
4374   /**
4375    * Person's sexual orientation, specified as a string.
4376    * Container support for this field is OPTIONAL.
4377    * @member opensocial.Person.Field
4378    */
4379   SEXUAL_ORIENTATION : 'sexualOrientation',
4380 
4381   /**
4382    * Person's relationship status, specified as a string.
4383    * Container support for this field is OPTIONAL.
4384    * @member opensocial.Person.Field
4385    */
4386   RELATIONSHIP_STATUS : 'relationshipStatus',
4387 
4388   /**
4389    * Person's age, specified as a number.
4390    * Container support for this field is OPTIONAL.
4391    * @member opensocial.Person.Field
4392    */
4393   AGE : 'age',
4394 
4395   /**
4396    * Person's date of birth, specified as a Date object.
4397    * Container support for this field is OPTIONAL.
4398    * @member opensocial.Person.Field
4399    */
4400   DATE_OF_BIRTH : 'dateOfBirth',
4401 
4402   /**
4403    * Person's body characteristics, specified as an opensocial.BodyType.
4404    * Container support for this field is OPTIONAL.
4405    * @member opensocial.Person.Field
4406    */
4407   BODY_TYPE : 'bodyType',
4408 
4409   /**
4410    * Person's ethnicity, specified as a string.
4411    * Container support for this field is OPTIONAL.
4412    * @member opensocial.Person.Field
4413    */
4414   ETHNICITY : 'ethnicity',
4415 
4416   /**
4417    * Person's smoking status, specified as an opensocial.Enum with the enum's
4418    * key referencing opensocial.Enum.Smoker.
4419    * Container support for this field is OPTIONAL.
4420    *
4421    * @member opensocial.Person.Field
4422    */
4423   SMOKER : 'smoker',
4424 
4425   /**
4426    * Person's drinking status, specified as an opensocial.Enum with the enum's
4427    * key referencing opensocial.Enum.Drinker.
4428    * Container support for this field is OPTIONAL.
4429    *
4430    * @member opensocial.Person.Field
4431    */
4432   DRINKER : 'drinker',
4433 
4434   /**
4435    * Description of the person's children, specified as a string.
4436    * Container support for this field is OPTIONAL.
4437    * @member opensocial.Person.Field
4438    */
4439   CHILDREN : 'children',
4440 
4441   /**
4442    * Description of the person's pets, specified as a string.
4443    * Container support for this field is OPTIONAL.
4444    * @member opensocial.Person.Field
4445    */
4446   PETS : 'pets',
4447 
4448   /**
4449    * Description of the person's living arrangement, specified as a string.
4450    * Container support for this field is OPTIONAL.
4451    * @member opensocial.Person.Field
4452    */
4453   LIVING_ARRANGEMENT : 'livingArrangement',
4454 
4455   /**
4456    * Person's time zone, specified as the difference in minutes between
4457    * Greenwich Mean Time (GMT) and the user's local time. See
4458    * Date.getTimezoneOffset() in javascript for more details on this format.
4459    * Container support for this field is OPTIONAL.
4460    * @member opensocial.Person.Field
4461    */
4462   TIME_ZONE : 'timeZone',
4463 
4464   /**
4465    * List of the languages that the person speaks as ISO 639-1 codes,
4466    * specified as an Array of strings.
4467    * Container support for this field is OPTIONAL.
4468    * @member opensocial.Person.Field
4469    */
4470   LANGUAGES_SPOKEN : 'languagesSpoken',
4471 
4472   /**
4473    * Jobs the person has held, specified as an Array of
4474    * <a href="opensocial.Organization.html">Organization</a>s.
4475    * Container support for this field is OPTIONAL.
4476    *
4477    * @member opensocial.Person.Field
4478    */
4479   JOBS : 'jobs',
4480 
4481   /**
4482    * Person's favorite jobs, or job interests and skills, specified as a string.
4483    * Container support for this field is OPTIONAL.
4484    *
4485    * @member opensocial.Person.Field
4486    */
4487   JOB_INTERESTS : 'jobInterests',
4488 
4489   /**
4490    * Schools the person has attended, specified as an Array of
4491    * <a href="opensocial.Organization.html">Organization</a>s.
4492    * Container support for this field is OPTIONAL.
4493    *
4494    * @member opensocial.Person.Field
4495    */
4496   SCHOOLS : 'schools',
4497 
4498   /**
4499    * Person's interests, hobbies or passions, specified as an Array of strings.
4500    * Container support for this field is OPTIONAL.
4501    *
4502    * @member opensocial.Person.Field
4503    */
4504   INTERESTS : 'interests',
4505 
4506   /**
4507    * URLs related to the person, their webpages, or feeds. Specified as an
4508    * Array of opensocial.Url.
4509    * Container support for this field is OPTIONAL.
4510    *
4511    * @member opensocial.Person.Field
4512    */
4513   URLS : 'urls',
4514 
4515   /**
4516    * Person's favorite music, specified as an Array of strings.
4517    * Container support for this field is OPTIONAL.
4518    *
4519    * @member opensocial.Person.Field
4520    */
4521   MUSIC : 'music',
4522 
4523   /**
4524    * Person's favorite movies, specified as an Array of strings.
4525    * Container support for this field is OPTIONAL.
4526    *
4527    * @member opensocial.Person.Field
4528    */
4529   MOVIES : 'movies',
4530 
4531   /**
4532    * Person's favorite TV shows, specified as an Array of strings.
4533    * Container support for this field is OPTIONAL.
4534    *
4535    * @member opensocial.Person.Field
4536    */
4537   TV_SHOWS : 'tvShows',
4538 
4539   /**
4540    * Person's favorite books, specified as an Array of strings.
4541    * Container support for this field is OPTIONAL.
4542    *
4543    * @member opensocial.Person.Field
4544    */
4545   BOOKS : 'books',
4546 
4547   /**
4548    * Person's favorite activities, specified as an Array of strings.
4549    * Container support for this field is OPTIONAL.
4550    *
4551    * @member opensocial.Person.Field
4552    */
4553   ACTIVITIES : 'activities',
4554 
4555   /**
4556    * Person's favorite sports, specified as an Array of strings.
4557    * Container support for this field is OPTIONAL.
4558    *
4559    * @member opensocial.Person.Field
4560    */
4561   SPORTS : 'sports',
4562 
4563   /**
4564    * Person's favorite heroes, specified as an Array of strings.
4565    * Container support for this field is OPTIONAL.
4566    *
4567    * @member opensocial.Person.Field
4568    */
4569   HEROES : 'heroes',
4570 
4571   /**
4572    * Person's favorite quotes, specified as an Array of strings.
4573    * Container support for this field is OPTIONAL.
4574    *
4575    * @member opensocial.Person.Field
4576    */
4577   QUOTES : 'quotes',
4578 
4579   /**
4580    * Person's favorite cars, specified as an Array of strings.
4581    * Container support for this field is OPTIONAL.
4582    *
4583    * @member opensocial.Person.Field
4584    */
4585   CARS : 'cars',
4586 
4587   /**
4588    * Person's favorite food, specified as an Array of strings.
4589    * Container support for this field is OPTIONAL.
4590    *
4591    * @member opensocial.Person.Field
4592    */
4593   FOOD : 'food',
4594 
4595   /**
4596    * Person's turn ons, specified as an Array of strings.
4597    * Container support for this field is OPTIONAL.
4598    *
4599    * @member opensocial.Person.Field
4600    */
4601   TURN_ONS : 'turnOns',
4602 
4603   /**
4604    * Person's turn offs, specified as an Array of strings.
4605    * Container support for this field is OPTIONAL.
4606    *
4607    * @member opensocial.Person.Field
4608    */
4609   TURN_OFFS : 'turnOffs',
4610 
4611   /**
4612    * Arbitrary tags about the person, specified as an Array of strings.
4613    * Container support for this field is OPTIONAL.
4614    *
4615    * @member opensocial.Person.Field
4616    */
4617   TAGS : 'tags',
4618 
4619   /**
4620    * Person's comments about romance, specified as a string.
4621    * Container support for this field is OPTIONAL.
4622    *
4623    * @member opensocial.Person.Field
4624    */
4625   ROMANCE : 'romance',
4626 
4627   /**
4628    * What the person is scared of, specified as a string.
4629    * Container support for this field is OPTIONAL.
4630    *
4631    * @member opensocial.Person.Field
4632    */
4633   SCARED_OF : 'scaredOf',
4634 
4635   /**
4636    * Describes when the person is happiest, specified as a string.
4637    * Container support for this field is OPTIONAL.
4638    *
4639    * @member opensocial.Person.Field
4640    */
4641   HAPPIEST_WHEN : 'happiestWhen',
4642 
4643   /**
4644    * Person's thoughts on fashion, specified as a string.
4645    * Container support for this field is OPTIONAL.
4646    *
4647    * @member opensocial.Person.Field
4648    */
4649   FASHION : 'fashion',
4650 
4651   /**
4652    * Person's thoughts on humor, specified as a string.
4653    * Container support for this field is OPTIONAL.
4654    *
4655    * @member opensocial.Person.Field
4656    */
4657   HUMOR : 'humor',
4658 
4659   /**
4660    * Person's statement about who or what they are looking for, or what they are
4661    * interested in meeting people for. Specified as an Array of opensocial.Enum
4662    * with the enum's key referencing opensocial.Enum.LookingFor.
4663    * Container support for this field is OPTIONAL.
4664    *
4665    * @member opensocial.Person.Field
4666    */
4667   LOOKING_FOR : 'lookingFor',
4668 
4669   /**
4670    * Person's relgion or religious views, specified as a string.
4671    * Container support for this field is OPTIONAL.
4672    *
4673    * @member opensocial.Person.Field
4674    */
4675   RELIGION : 'religion',
4676 
4677   /**
4678    * Person's political views, specified as a string.
4679    * Container support for this field is OPTIONAL.
4680    *
4681    * @member opensocial.Person.Field
4682    */
4683   POLITICAL_VIEWS : 'politicalViews',
4684 
4685   /**
4686    * A boolean indicating whether the person has used the current app.
4687    * Container support for this field is OPTIONAL.
4688    *
4689    * @member opensocial.Person.Field
4690    */
4691   HAS_APP : 'hasApp',
4692 
4693   /**
4694    * Person's current network status. Specified as an Enum with the enum's
4695    * key referencing opensocial.Enum.Presence.
4696    * Container support for this field is OPTIONAL.
4697    *
4698    * @member opensocial.Person.Field
4699    */
4700   NETWORK_PRESENCE : 'networkPresence'
4701 };
4702 
4703 
4704 /**
4705  * Gets an ID that can be permanently associated with this person.
4706  *
4707  * @return {String} The ID
4708  */
4709 opensocial.Person.prototype.getId = function() {
4710   return this.getField(opensocial.Person.Field.ID);
4711 };
4712 
4713 
4714 var ORDERED_NAME_FIELDS_ = [
4715     opensocial.Name.Field.HONORIFIC_PREFIX,
4716     opensocial.Name.Field.GIVEN_NAME,
4717     opensocial.Name.Field.FAMILY_NAME,
4718     opensocial.Name.Field.HONORIFIC_SUFFIX,
4719     opensocial.Name.Field.ADDITIONAL_NAME];
4720 
4721 /**
4722  * Gets a text display name for this person; guaranteed to return
4723  * a useful string.
4724  *
4725  * @return {String} The display name
4726  */
4727 opensocial.Person.prototype.getDisplayName = function() {
4728   var name = this.getField(opensocial.Person.Field.NAME);
4729   if (name) {
4730     // Try unstructured field first
4731     var unstructured = name.getField(opensocial.Name.Field.UNSTRUCTURED);
4732     if (unstructured) {
4733       return unstructured;
4734     }
4735 
4736     // Next try to construct the name from the individual components
4737     var fullName = '';
4738     for (var i = 0; i < ORDERED_NAME_FIELDS_.length; i++) {
4739       var nameValue = name.getField(ORDERED_NAME_FIELDS_[i]);
4740       if (nameValue) {
4741         fullName += nameValue + ' ';
4742       }
4743     }
4744     return fullName.replace(/^\s+|\s+$/g, '') ;
4745   }
4746 
4747   // Finally, try the nickname field
4748   return this.getField(opensocial.Person.Field.NICKNAME);
4749 };
4750 
4751 
4752 /**
4753  * Gets data for this person that is associated with the specified key.
4754  *
4755  * @param {String} key The key to get data for;
4756  *    keys are defined in <a href="opensocial.Person.Field.html"><code>
4757  *    Person.Field</code></a>
4758  * @param {Map.<opensocial.DataRequest.DataRequestFields, Object>}
4759  *  opt_params Additional
4760  *    <a href="opensocial.DataRequest.DataRequestFields.html">params</a>
4761  *    to pass to the request.
4762  * @return {String} The data
4763  */
4764 opensocial.Person.prototype.getField = function(key, opt_params) {
4765   return opensocial.Container.getField(this.fields_, key, opt_params);
4766 };
4767 
4768 
4769 /**
4770  * Returns true if this person object represents the currently logged in user.
4771  *
4772  * @return {Boolean} True if this is the currently logged in user;
4773  *   otherwise, false
4774  */
4775 opensocial.Person.prototype.isViewer = function() {
4776   return !!this.isViewer_;
4777 };
4778 
4779 
4780 /**
4781  * Returns true if this person object represents the owner of the current page.
4782  *
4783  * @return {Boolean} True if this is the owner of the page;
4784  *   otherwise, false
4785  */
4786 opensocial.Person.prototype.isOwner = function() {
4787   return !!this.isOwner_;
4788 };
4789 /*
4790  * Licensed to the Apache Software Foundation (ASF) under one
4791  * or more contributor license agreements.  See the NOTICE file
4792  * distributed with this work for additional information
4793  * regarding copyright ownership.  The ASF licenses this file
4794  * to you under the Apache License, Version 2.0 (the
4795  * "License"); you may not use this file except in compliance
4796  * with the License.  You may obtain a copy of the License at
4797  *
4798  *     http://www.apache.org/licenses/LICENSE-2.0
4799  *
4800  * Unless required by applicable law or agreed to in writing,
4801  * software distributed under the License is distributed on an
4802  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4803  * KIND, either express or implied.  See the License for the
4804  * specific language governing permissions and limitations
4805  * under the License.
4806  */
4807 
4808 /**
4809  * @fileoverview Representation of an phone number.
4810  */
4811 
4812 
4813 /**
4814  * @class
4815  * Base interface for all phone objects.
4816  *
4817  * @name opensocial.Phone
4818  */
4819 
4820 
4821 /**
4822  * Base interface for all phone objects.
4823  *
4824  * @private
4825  * @constructor
4826  */
4827 opensocial.Phone = function(opt_params) {
4828   this.fields_ = opt_params || {};
4829 };
4830 
4831 
4832 /**
4833  * @static
4834  * @class
4835  * All of the fields that a phone has. These are the supported keys for the
4836  * <a href="opensocial.Phone.html#getField">Phone.getField()</a> method.
4837  *
4838  * @name opensocial.Phone.Field
4839  */
4840 opensocial.Phone.Field = {
4841   /**
4842    * The phone number type or label, specified as a String.
4843    * Examples: work, my favorite store, my house, etc.
4844    *
4845    * @member opensocial.Phone.Field
4846    */
4847   TYPE : 'type',
4848 
4849   /**
4850    * The phone number, specified as a String.
4851    *
4852    * @member opensocial.Phone.Field
4853    */
4854   NUMBER : 'number'
4855 };
4856 
4857 
4858 /**
4859  * Gets data for this phone that is associated with the specified key.
4860  *
4861  * @param {String} key The key to get data for;
4862  *    keys are defined in <a href="opensocial.Phone.Field.html"><code>
4863  *    Phone.Field</code></a>
4864  * @param {Map.<opensocial.DataRequest.DataRequestFields, Object>}
4865  *  opt_params Additional
4866  *    <a href="opensocial.DataRequest.DataRequestFields.html">params</a>
4867  *    to pass to the request.
4868  * @return {String} The data
4869  */
4870 opensocial.Phone.prototype.getField = function(key, opt_params) {
4871   return opensocial.Container.getField(this.fields_, key, opt_params);
4872 };
4873 /*
4874  * Licensed to the Apache Software Foundation (ASF) under one
4875  * or more contributor license agreements.  See the NOTICE file
4876  * distributed with this work for additional information
4877  * regarding copyright ownership.  The ASF licenses this file
4878  * to you under the Apache License, Version 2.0 (the
4879  * "License"); you may not use this file except in compliance
4880  * with the License.  You may obtain a copy of the License at
4881  *
4882  *     http://www.apache.org/licenses/LICENSE-2.0
4883  *
4884  * Unless required by applicable law or agreed to in writing,
4885  * software distributed under the License is distributed on an
4886  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
4887  * KIND, either express or implied.  See the License for the
4888  * specific language governing permissions and limitations
4889  * under the License.
4890  */
4891 
4892 /**
4893  * @fileoverview ResponseItem containing information about a specific response
4894  * from the server.
4895  */
4896 
4897 
4898 /**
4899  * @class
4900  * Represents a response that was generated
4901  * by processing a data request item on the server.
4902  *
4903  * @name opensocial.ResponseItem
4904  */
4905 
4906 
4907 /**
4908  * Represents a response that was generated by processing a data request item
4909  * on the server.
4910  *
4911  * @private
4912  * @constructor
4913  */
4914 opensocial.ResponseItem = function(originalDataRequest, data,
4915     opt_errorCode, opt_errorMessage) {
4916   this.originalDataRequest_ = originalDataRequest;
4917   this.data_ = data;
4918   this.errorCode_ = opt_errorCode;
4919   this.errorMessage_ = opt_errorMessage;
4920 };
4921 
4922 
4923 /**
4924  * Returns true if there was an error in fetching this data from the server.
4925  *
4926  * @return {Boolean} True if there was an error; otherwise, false
4927  */
4928 opensocial.ResponseItem.prototype.hadError = function() {
4929   return !!this.errorCode_;
4930 };
4931 
4932 
4933 /**
4934  * @static
4935  * @class
4936  *
4937  * Error codes that a response item can return.
4938  *
4939  * @name opensocial.ResponseItem.Error
4940  */
4941 opensocial.ResponseItem.Error = {
4942   /**
4943    * This container does not support the request that was made.
4944    *
4945    * @member opensocial.ResponseItem.Error
4946    */
4947   NOT_IMPLEMENTED : 'notImplemented',
4948 
4949   /**
4950    * The gadget does not have access to the requested data.
4951    * To get access, use
4952    * <a href="opensocial.html#requestPermission">
4953    * opensocial.requestPermission()</a>.
4954    *
4955    * @member opensocial.ResponseItem.Error
4956    */
4957   UNAUTHORIZED : 'unauthorized',
4958 
4959   /**
4960    * The gadget can never have access to the requested data.
4961    *
4962    * @member opensocial.ResponseItem.Error
4963    */
4964   FORBIDDEN : 'forbidden',
4965 
4966    /**
4967    * The request was invalid. Example: 'max' was -1.
4968    *
4969    * @member opensocial.ResponseItem.Error
4970    */
4971   BAD_REQUEST : 'badRequest',
4972 
4973   /**
4974    * The request encountered an unexpected condition that
4975    * prevented it from fulfilling the request.
4976    *
4977    * @member opensocial.ResponseItem.Error
4978    */
4979   INTERNAL_ERROR : 'internalError',
4980 
4981   /**
4982    * The gadget exceeded a quota on the request. Example quotas include a
4983    * max number of calls per day, calls per user per day, calls within a
4984    * certain time period and so forth.
4985    *
4986    * @member opensocial.ResponseItem.Error
4987    */
4988   LIMIT_EXCEEDED : 'limitExceeded'
4989 };
4990 
4991 
4992 /**
4993  * If the request had an error, returns the error code.
4994  * The error code can be container-specific
4995  * or one of the values defined by
4996  * <a href="opensocial.ResponseItem.Error.html"><code>Error</code></a>.
4997  *
4998  * @return {String} The error code, or null if no error occurred
4999  */
5000 opensocial.ResponseItem.prototype.getErrorCode = function() {
5001   return this.errorCode_;
5002 };
5003 
5004 
5005 /**
5006  * If the request had an error, returns the error message.
5007  *
5008  * @return {String} A human-readable description of the error that occurred;
5009  *    can be null, even if an error occurred
5010  */
5011 opensocial.ResponseItem.prototype.getErrorMessage = function() {
5012   return this.errorMessage_;
5013 };
5014 
5015 
5016 /**
5017  * Returns the original data request.
5018  *
5019  * @return {opensocial.DataRequest} The data request used to fetch this data
5020  *    response
5021  */
5022 opensocial.ResponseItem.prototype.getOriginalDataRequest = function() {
5023   return this.originalDataRequest_;
5024 };
5025 
5026 
5027 /**
5028  * Gets the response data.
5029  *
5030  * @return {Object} The requested value calculated by the server; the type of
5031  *    this value is defined by the type of request that was made
5032  */
5033 opensocial.ResponseItem.prototype.getData = function() {
5034   return this.data_;
5035 };
5036 /*
5037  * Licensed to the Apache Software Foundation (ASF) under one
5038  * or more contributor license agreements.  See the NOTICE file
5039  * distributed with this work for additional information
5040  * regarding copyright ownership.  The ASF licenses this file
5041  * to you under the Apache License, Version 2.0 (the
5042  * "License"); you may not use this file except in compliance
5043  * with the License.  You may obtain a copy of the License at
5044  *
5045  *     http://www.apache.org/licenses/LICENSE-2.0
5046  *
5047  * Unless required by applicable law or agreed to in writing,
5048  * software distributed under the License is distributed on an
5049  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
5050  * KIND, either express or implied.  See the License for the
5051  * specific language governing permissions and limitations
5052  * under the License.
5053  */
5054 
5055 /**
5056  * @fileoverview Representation of an url.
5057  */
5058 
5059 
5060 /**
5061  * @class
5062  * Base interface for all URL objects.
5063  *
5064  * @name opensocial.Url
5065  */
5066 
5067 
5068 /**
5069  * Base interface for all url objects.
5070  *
5071  * @private
5072  * @constructor
5073  */
5074 opensocial.Url = function(opt_params) {
5075   this.fields_ = opt_params || {};
5076 };
5077 
5078 
5079 /**
5080  * @static
5081  * @class
5082  * All of the fields that a url has. These are the supported keys for the
5083  * <a href="opensocial.Url.html#getField">Url.getField()</a> method.
5084  *
5085  * @name opensocial.Url.Field
5086  */
5087 opensocial.Url.Field = {
5088   /**
5089    * The url number type or label. Examples: work, blog feed,
5090    * website, etc Specified as a String.
5091    *
5092    * @member opensocial.Url.Field
5093    */
5094   TYPE : 'type',
5095 
5096   /**
5097    * The text of the link. Specified as a String.
5098    *
5099    * @member opensocial.Url.Field
5100    */
5101   LINK_TEXT : 'linkText',
5102 
5103   /**
5104    * The address the url points to. Specified as a String.
5105    *
5106    * @member opensocial.Url.Field
5107    */
5108   ADDRESS : 'address'
5109 };
5110 
5111 
5112 /**
5113  * Gets data for this URL that is associated with the specified key.
5114  *
5115  * @param {String} key The key to get data for;
5116  *    keys are defined in <a href="opensocial.Url.Field.html"><code>
5117  *    Url.Field</code></a>
5118  * @param {Map.<opensocial.DataRequest.DataRequestFields, Object>}
5119  *  opt_params Additional
5120  *    <a href="opensocial.DataRequest.DataRequestFields.html">params</a>
5121  *    to pass to the request.
5122  * @return {String} The data
5123  */
5124 opensocial.Url.prototype.getField = function(key, opt_params) {
5125   return opensocial.Container.getField(this.fields_, key, opt_params);
5126 };
5127