Author: chabotc
Date: Mon Jun  9 14:18:39 2008
New Revision: 665894

URL: http://svn.apache.org/viewvc?rev=665894&view=rev
Log:
SHINDIG-368 add support for RequestSendMessage()

Added:
    
incubator/shindig/trunk/php/src/socialdata/samplecontainer/BasicMessagesService.php
Modified:
    incubator/shindig/trunk/features/opensocial-current/jsoncontainer.js
    incubator/shindig/trunk/features/opensocial-reference/message.js
    
incubator/shindig/trunk/php/src/socialdata/samplecontainer/OpenSocialDataHandler.php

Modified: incubator/shindig/trunk/features/opensocial-current/jsoncontainer.js
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-current/jsoncontainer.js?rev=665894&r1=665893&r2=665894&view=diff
==============================================================================
--- incubator/shindig/trunk/features/opensocial-current/jsoncontainer.js 
(original)
+++ incubator/shindig/trunk/features/opensocial-current/jsoncontainer.js Mon 
Jun  9 14:18:39 2008
@@ -55,6 +55,16 @@
   });
 };
 
+JsonContainer.prototype.requestSendMessage = function(recipients, message, 
opt_callback) {
+  opt_callback = opt_callback || {};
+
+  var req = opensocial.newDataRequest();
+  req.add(this.newRequestSendMessageRequest(recipients, message), 'key');
+  req.send(function(response) {
+    opt_callback(response.get('key'));
+  });
+};
+
 JsonContainer.prototype.createJson = function(requestObjects) {
   var jsonObjects = [];
   for (var i = 0; i < requestObjects.length; i++) {
@@ -174,6 +184,12 @@
     'activity' : activity});
 };
 
+JsonContainer.prototype.newRequestSendMessageRequest = function(idSpec,
+    message) {
+  return new RequestItem({'type' : 'SEND_MESSAGE', 'idSpec' : idSpec,
+    'message' : message});
+};
+
 RequestItem = function(jsonParams, processData) {
   this.jsonParams = jsonParams;
   this.processData = processData ||

Modified: incubator/shindig/trunk/features/opensocial-reference/message.js
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/features/opensocial-reference/message.js?rev=665894&r1=665893&r2=665894&view=diff
==============================================================================
--- incubator/shindig/trunk/features/opensocial-reference/message.js (original)
+++ incubator/shindig/trunk/features/opensocial-reference/message.js Mon Jun  9 
14:18:39 2008
@@ -84,7 +84,21 @@
    * sanitized by the container.
    * @member opensocial.Message.Field
    */
-  BODY : 'body'
+  BODY : 'body',
+
+  /**
+   * The title of the message as a message template. Specifies the
+   * message ID to use in the gadget xml.
+   * @member opensocial.Message.Field
+   */
+  TITLE_ID : 'titleId',
+
+  /**
+   * The main text of the message as a message template. Specifies the
+   * message ID to use in the gadget xml.
+   * @member opensocial.Message.Field
+   */
+  BODY_ID : 'bodyId'
 };
 
 
@@ -131,10 +145,14 @@
  * @param {String} key The key to get data for;
  *   see the <a href="opensocial.Message.Field.html">Field</a> class
  * for possible values
+ * @param {Map.&lt;opensocial.DataRequest.DataRequestFields, Object&gt;}
+ *  opt_params Additional
+ *    <a href="opensocial.DataRequest.DataRequestFields.html">params</a>
+ *    to pass to the request.
  * @return {String} The data
  * @member opensocial.Message
  */
-opensocial.Message.prototype.getField = function(key) {
+opensocial.Message.prototype.getField = function(key, opt_params) {
   return gadgets.util.escape(this.fields_[key]);
 };
 

Added: 
incubator/shindig/trunk/php/src/socialdata/samplecontainer/BasicMessagesService.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/samplecontainer/BasicMessagesService.php?rev=665894&view=auto
==============================================================================
--- 
incubator/shindig/trunk/php/src/socialdata/samplecontainer/BasicMessagesService.php
 (added)
+++ 
incubator/shindig/trunk/php/src/socialdata/samplecontainer/BasicMessagesService.php
 Mon Jun  9 14:18:39 2008
@@ -0,0 +1,27 @@
+<?php
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations under the License.
+ */
+
+class BasicMessagesService {
+
+       public function createMessage($personId, $message, $token)
+       {
+               
+               return new ResponseItem(null, NOT_IMPLEMENTED);
+       }
+}

Modified: 
incubator/shindig/trunk/php/src/socialdata/samplecontainer/OpenSocialDataHandler.php
URL: 
http://svn.apache.org/viewvc/incubator/shindig/trunk/php/src/socialdata/samplecontainer/OpenSocialDataHandler.php?rev=665894&r1=665893&r2=665894&view=diff
==============================================================================
--- 
incubator/shindig/trunk/php/src/socialdata/samplecontainer/OpenSocialDataHandler.php
 (original)
+++ 
incubator/shindig/trunk/php/src/socialdata/samplecontainer/OpenSocialDataHandler.php
 Mon Jun  9 14:18:39 2008
@@ -22,16 +22,18 @@
  * This will expand to be more sophisticated as time goes on.
  */
 class OpenSocialDataHandler extends GadgetDataHandler {
-       private $handles = array('FETCH_PEOPLE', 'FETCH_PERSON_APP_DATA', 
'UPDATE_PERSON_APP_DATA', 'FETCH_ACTIVITIES', 'CREATE_ACTIVITY');
+       private $handles = array('FETCH_PEOPLE', 'FETCH_PERSON_APP_DATA', 
'UPDATE_PERSON_APP_DATA', 'FETCH_ACTIVITIES', 'CREATE_ACTIVITY', 
'SEND_MESSAGE');
        private $peopleHandler;
        private $dataHandler;
        private $activitiesHandler;
+       private $messagesHandler;
        
        public function __construct()
        {
                $this->peopleHandler = new BasicPeopleService();
                $this->dataHandler = new BasicDataService();
                $this->activitiesHandler = new BasicActivitiesService();
+               $this->messagesHandler = new BasicMessagesService();
        }
        
        public function shouldHandle($requestType)
@@ -89,6 +91,11 @@
                                        
                                        case 'CREATE_ACTIVITY' :
                                                break;
+                                               
+                                       case 'SEND_MESSAGE' :
+                                               $message = $params["message"];
+                                               $response = 
$this->messagesHandler->sendMessage($peopleIds, $message, $request->getToken());
+                                               break;
                                }
                        } else {
                                $response = new ResponseItem(BAD_REQUEST, 
"Invalid people id's");


Reply via email to