Bug 1194049 - Part 3: support device update; r=fabrice, a=lizzard
authorLiang-Heng Chen <xeonchen@mozilla.com>
Thu, 17 Sep 2015 00:43:00 +0200
changeset 607007 16015f24e9649746c1fba687cc2880adf8c502f2
parent 607006 af3290dc0520ef3b5c318e77e08a3171dedd5258
child 607008 42df090bd2ebbc48c5d40c90901b05d708406a57
push id93006
push userjyavenard@mozilla.com
push dateThu, 15 Oct 2015 05:15:33 +0000
treeherdertry@45ea2a01301e [default view] [failures only]
reviewersfabrice, lizzard
bugs1194049
milestone43.0a2
Bug 1194049 - Part 3: support device update; r=fabrice, a=lizzard
dom/presentation/interfaces/nsITCPPresentationServer.idl
dom/presentation/provider/TCPPresentationServer.js
--- a/dom/presentation/interfaces/nsITCPPresentationServer.idl
+++ b/dom/presentation/interfaces/nsITCPPresentationServer.idl
@@ -16,17 +16,17 @@ interface nsITCPPresentationServerListen
    *          <other-error> on failure.
    */
   void onClose(in nsresult aReason);
 };
 
 /**
  * TCP presentation server which can be used by discovery services.
  */
-[scriptable, uuid(4fc57682-33d5-4793-b149-e2cc4714d70f)]
+[scriptable, uuid(fcadc9fe-f1e9-4f74-b9d3-9cd6b74afc9e)]
 interface nsITCPPresentationServer: nsISupports
 {
   /**
    * This method initializes a TCP presentation server.
    * @param   aId
    *          The unique Id for the device within the discovery scope. If aId
    *          is null, empty string or opt-out, the TCP presentation server
    *          should not work until the |id| is set appropriately.
@@ -60,16 +60,37 @@ interface nsITCPPresentationServer: nsIS
    */
   nsIPresentationDevice createTCPDevice(in AUTF8String aId,
                                         in AUTF8String aName,
                                         in AUTF8String aType,
                                         in AUTF8String aHost,
                                         in uint16_t aPort);
 
   /**
+   * Update TCPDevice for this server.
+   * @param   aId
+   *          The unique Id for the discovered device
+   * @param   aName
+   *          The human-readable name of the discovered device
+   * @param   aType
+   *          The category of the discovered device
+   * @param   aHost
+   *          The host of the provided control channel of the discovered device
+   * @param   aPort
+   *          The port of the provided control channel of the discovered device
+   * @returns The updated device
+   * @throws  NS_ERROR_INVALID_ARG if a TCPDevice with |aId| does not existed.
+   */
+  nsIPresentationDevice updateTCPDevice(in AUTF8String aId,
+                                        in AUTF8String aName,
+                                        in AUTF8String aType,
+                                        in AUTF8String aHost,
+                                        in uint16_t aPort);
+
+  /**
    * Get TCPDevice with |aID|.
    * @param   aId
    *          The unique Id for the query device
    * @returns The queried device; return |undefined|
    * @throws  NS_ERROR_INVALID_ARG if a TCPDevice with |aId| does not exist.
    */
   nsIPresentationDevice getTCPDevice(in AUTF8String aId);
 
--- a/dom/presentation/provider/TCPPresentationServer.js
+++ b/dom/presentation/provider/TCPPresentationServer.js
@@ -122,16 +122,31 @@ TCPPresentationServer.prototype = {
     this._devices.set(aId, new TCPDevice(this, {id: aId,
                                                 name: aName,
                                                 type: aType,
                                                 host: aHost,
                                                 port: aPort}));
     return this._devices.get(aId);
   },
 
+  updateTCPDevice: function(aId, aName, aType, aHost, aPort) {
+    DEBUG && log("TCPPresentationServer - updateTCPDevice with id: " + aId);
+    if (!this._devices.has(aId)) {
+      throw Cr.NS_ERROR_INVALID_ARG;
+    }
+
+    let device = this._devices.get(aId);
+    device.name = aName;
+    device.type = aType;
+    device.host = aHost;
+    device.port = aPort;
+
+    return device;
+  },
+
   getTCPDevice: function(aId) {
     DEBUG && log("TCPPresentationServer - getTCPDevice with id: " + aId);
     if (!this._devices.has(aId)) {
       throw Cr.NS_ERROR_INVALID_ARG;
     }
     return this._devices.get(aId);
   },