Labs/Joey/CommunicationProtocol

From MozillaWiki
< Labs‎ | Joey
Jump to: navigation, search

Below are the Machine-to-machine communication protocols we currently use for Joey server and addon/J2ME client. If the request is successfully executed, the server returns a http header (X-joey-status) with the value of 200 with data in the response body (or, empty body if there is no data). If the server encounters an error, it returns different values for this http header as discussed below, and an empty body.


/users/login

Request:

 * rest=1
 * data[User][username]=<username>
 * data[User][password]=<password>

Success Response:

 * X-joey-status 200 with empty body

Error Joey Status Code:

 * 512 Login Error
 * 513 User not Activated

/uploads/index

Request:

 * rest=1
 * limit=<number of entries to be returned> (optional)
 * start=<limit * start is the first entry to be returned> (optional)
 * type=<type of content to be returned> (optional)
 * since=<seconds from epoch> (optional)

|type| values may be:

videos audio images text microsummaries


Success Response: The first line is always a numeric return code. A positive (or zero) integer "n" indicates the number of items in this index. The items are organized as follows (i iterates from 1 to n):

 id.i=<the id of this entry>
 title.i=<the title>
 referrer.i=<referrer URL>
 modified.i=<date, e.g., 2007-04-08 21:22:28>
 type.i=<MIME type for the transcode content at /files/view/id>
 preview.i=<Base64 encoded preview data -- always image/png>

Any item that is deleted will not contain a title, referrer, but instead look like:

 id.i=<the id of this entry>
 deleted.i=1


Error Joey Status Code:

 * 511 No Active Session

/uploads/deleteByFileID/id

Request:

 * The "id" in the URL
 * rest=1

Success Response:

 * X-joey-status 200 with empty body

Error Joey Status Code:

 * 511 No Active Session
 * 515 Not Permitted for This User
 * 514 Cannot Delete
   

/uploads/add

This one is currently uses multi-part file upload. I am thinking that we should implement this protocol on the j2me client. It is binary based and is not very complex: http://www.vivtek.com/rfc1867.html

A potential problem is that some device might require the upload to be broken into multiple pieces. But let's not worry about it now and get the most common case right first.

Request:

 * Multi-part file upload or content upload with the correct MIME type.  See:

http://viewvc.svn.mozilla.org/vc/labs/joey/trunk/addons/ff/components/mocoJoey.js?view=markup

Success Response:

 * X-joey-status 200 with empty body

Error Joey Status Code:

 * 511 No Active Session
 * 517 Out of Space for Upload
 * 518 Generic Upload Error

/files/view/id

Request:

 * The "id" in the URL

Success Response:

 * X-joey-status code 200
 * MIME type in HTTP header
 * Binary content in body

Error Joey Status Code:

 * 511 No Active Session
 * 515 Not Permitted for This User
 * 516 File Access Error

/files/view/id/preview

Request:

 * The "id" in the URL

Success Response:

 * X-joey-status code 200
 * MIME type in HTTP header
 * Binary content in body

Error Joey Status Code:

 * 511 No Active Session
 * 515 Not Permitted for This User
 * 516 File Access Error

/files/view/id/original

Request:

 * The "id" in the URL

Success Response:

 * X-joey-status code 200
 * MIME type in HTTP header
 * Binary content in body

Error Joey Status Code:

 * 511 No Active Session
 * 515 Not Permitted for This User
 * 516 File Access Error