Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / chrome / browser / resources / cryptotoken / llgnubby.js
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 /**
6  * @fileoverview Interface for representing a low-level gnubby device.
7  */
8 'use strict';
9
10 /**
11  * Low level gnubby 'driver'. One per physical USB device.
12  * @interface
13  */
14 function llGnubby() {}
15
16 // Commands of the USB interface.
17 /** Echo data through local processor only */
18 llGnubby.CMD_PING = 0x81;
19 /** Perform reset action and read ATR string */
20 llGnubby.CMD_ATR = 0x82;
21 /** Send raw APDU */
22 llGnubby.CMD_APDU = 0x83;
23 /** Send lock channel command */
24 llGnubby.CMD_LOCK = 0x84;
25 /** Obtain system information record */
26 llGnubby.CMD_SYSINFO = 0x85;
27 /** Control prompt flashing */
28 llGnubby.CMD_PROMPT = 0x87;
29 /** Send device identification wink */
30 llGnubby.CMD_WINK = 0x88;
31 /** USB test */
32 llGnubby.CMD_USB_TEST = 0xb9;
33 /** Device Firmware Upgrade */
34 llGnubby.CMD_DFU = 0xba;
35 /** Protocol resync command */
36 llGnubby.CMD_SYNC = 0xbc;
37 /** Error response */
38 llGnubby.CMD_ERROR = 0xbf;
39
40 // Low-level error codes.
41 /** No error */
42 llGnubby.OK = 0;
43 /** Invalid command */
44 llGnubby.INVALID_CMD = 1;
45 /** Invalid parameter */
46 llGnubby.INVALID_PAR = 2;
47 /** Invalid message length */
48 llGnubby.INVALID_LEN = 3;
49 /** Invalid message sequencing */
50 llGnubby.INVALID_SEQ = 4;
51 /** Message has timed out */
52 llGnubby.TIMEOUT = 5;
53 /** CHannel is busy */
54 llGnubby.BUSY = 6;
55 /** Access denied */
56 llGnubby.ACCESS_DENIED = 7;
57 /** Device is gone */
58 llGnubby.GONE = 8;
59 /** Verification error */
60 llGnubby.VERIFY_ERROR = 9;
61 /** Command requires channel lock */
62 llGnubby.LOCK_REQUIRED = 10;
63 /** Sync error */
64 llGnubby.SYNC_FAIL = 11;
65 /** Other unspecified error */
66 llGnubby.OTHER = 127;
67
68 // Remote helper errors.
69 /** Not a remote helper */
70 llGnubby.NOTREMOTE = 263;
71 /** Could not reach remote endpoint */
72 llGnubby.COULDNOTDIAL = 264;
73
74 // chrome.usb-related errors.
75 /** No device */
76 llGnubby.NODEVICE = 512;
77 /** Permission denied */
78 llGnubby.NOPERMISSION = 666;
79
80 /** Destroys this low-level device instance. */
81 llGnubby.prototype.destroy = function() {};
82
83 /**
84  * Register a client for this gnubby.
85  * @param {*} who The client.
86  */
87 llGnubby.prototype.registerClient = function(who) {};
88
89 /**
90  * De-register a client.
91  * @param {*} who The client.
92  * @return {number} The number of remaining listeners for this device, or -1
93  *     if this had no clients to start with.
94  */
95 llGnubby.prototype.deregisterClient = function(who) {};
96
97 /**
98  * @param {*} who The client.
99  * @return {boolean} Whether this device has who as a client.
100  */
101 llGnubby.prototype.hasClient = function(who) {};
102
103 /**
104  * Queue command to be sent.
105  * If queue was empty, initiate the write.
106  * @param {number} cid The client's channel ID.
107  * @param {number} cmd The command to send.
108  * @param {ArrayBuffer} data Command data
109  */
110 llGnubby.prototype.queueCommand = function(cid, cmd, data) {};