shell: Fix race loading the user name from cockpit.user

This function may be called after the the changed event has been
fired. We should update the user name when we're starting up in
case it's valid.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
base: Add a package listing API to cockpit.packages

This returns a list of all the packages, possibly expanded.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
base: Less noise when running test-packages.html test

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
shell: Implement tools menu, and dynamically add tools to it

These tools are listed in the manifest.json files. Make the terminal
such a tool.

Closes #1474
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
shell: Revert to loading packages from target host

This reverts the part of "198fd0c shell: Implement tools menu, and
dynamically add tools to it" that caused all packages to be loaded
from localhost.

Closes #1475
Reviewed-by: Stef Walter <stefw@redhat.com>
bridge: Implement an echo channel payload

And a test that uses it. This will become useful for checking of
behavior of binary channels independent of the channel implementation.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
bridge: Support for binary and base64 encoding in channels

This is mostly underlying work, and not yet exposed in cockpit.js
By passing "binary": "raw" in a channel raw data will be sent, this
is used by the resource1 channel for now.

By passing "binary": "base64" in a channel, all received data will
be assumed to be base64 encoded, and sent data will be encoded on
the way out.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
bridge: Rename 'text-stream' payload to 'stream'

Depending on whether the channel is binary or not, the stream can handle
binary data. Not just text.

Closes #1427
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
ws: Exit cockpit-ws after timeout if started via systemd

Exit cockpit-ws after a 10 minute timeout if started via systemd
and nobody has connected or is still connected.

Closes #1431
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
 * Fixed typo in documentation.
 * Removed debug output.
server: Terminal is a basic server feature and not aliased

The terminal is a basic server feature and not aliased. It was a
nice proof of concept for an alias, but now lets get it right.

Closes #1462
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
ws: Remove unused cockpit_web_service_packages() functions

These are no longer used. Cleanup and remove the code.

Closes #1463
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
base: Use the shell to determine default host if loaded into shell

When cockpit.js code is loaded into the shell, use the shell to determine
the default host rather than requiring it to be passed in all over the
place.

This lets us write future proof code. Later on when everything is migrated
we can remove this hack.

Closes #1447
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
ws: Cleaner building of control messages

Remove the dubios BUILD_INT logic when we want to add non-strings
to a control message, and just return a JsonObject from an interim
function which can be further modified. The simple string-only case
remains the same.
bridge: New resource2 payload protocol

This is something that several future enhancements need. We need to
send back a header payload before the actual data that can carry
information that affects the HTTP Headers of the response.

Closes #1464
ws: Simpler function for parsing cookies

We never need to parse all the cookies, we're simply looking
for one, so we can make this function a lot simpler.
ws: Add function for parsing header Languages

This is the Accept-Language header, unless a specific cookie is
defined, in which case that overrides it.
base: Add new cockpit.locale API for doing gettext()

This uses the conversion format from po2json in the nodejs packages
https://www.npmjs.org/package/po2json
tools: New po2json tool based on nodejs

Implement a new po2json tool based on nodejs which can define json
data as an AMD module. It also checks the plural forms for validity
before having cockpit.js parse it. Has an option to build an AMD
module out of the data.

We use locally installed nodejs modules and set them up during
autogen.sh.

Distribute the pre-processed javascript data in our tarball, so that
builders are not required to have nodejs installed. If they modify
po stuff in a tarball then they will get the standard autoconf
'missing' message.
ws: Choose appropriate translated files based on language

Use the Accept-Language and Cookie headers to choose translated files.
shell: Update the shell for the translation changes

This disables translation in the shell, but makes the dialog selector
box work correctly with the new localization infrastructure.