aboutsummaryrefslogtreecommitdiffstats
path: root/data/lib/addAttachmentRow.js
blob: a2b67eeab93b39fffe87658b311ad0e6bde5c20d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// Released under the MIT/X11 license
// http://www.opensource.org/licenses/mit-license.php
"use strict";

function addAttachmentCallback(resp) {
  var newAttachID = parseInt(
      resp.params.param.value.array.data.value.int, 10);
  console.log("attachID = " + newAttachID);
  // FIXME callback.call(param, newAttachID, data.length);
}

/**
 * 
 * This has to stay in RHBugzillaPage because upstream doesn't have
 * addAttachment XML-RPC call yet.
 */
function addAttachment(data, callback, param) {
  var params = [];

  if (!constantData.passwordState.passAvailable) {
    console
        .error("addAttachment : No password, no XML-RPC calls; sorry");
    return null;
  }

  params.push(getBugNo());
  params.push({
    description : titleParsedAttachment,
    filename : "parsed-backtrace.txt",
    contenttype : "text/plain",
    data : window.btoa(data),
    nomail : true
  });

  self.postMessage(new Message("MakeXMLRPCall", {
    url : constantData.XMLRPCData[window.location.hostname].url,
    login : getLogin(),
    method : "bugzilla.addAttachment",
    params : params,
    callRPC : "AddAttachmentCallback"
  }));
  reqCounter++;
}