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.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
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
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
base: Fix AMD dependency loader bug to do with circular deps

Our AMD loader would find circular dependencies when there were
none.

Closes #1469
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
base: Remove argument counting logic from AMD loader

This is optional and complicates things. Lets make it a bit simpler.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
base: Only provide default dependencies if factory is function

If there's no function involved, such as a module exporting an
object directly, then we don't need to provide default dependencies

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
base: Simpler requring of jquery in cockpit.js

Less fancy tricks, more debuggable

Closes #1470
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
Don't ignore all *.min.js files, some are actually committed
tools: Add jsmerge tool which combines javascript with newlines

Just combining javascript files can lead to syntax errors if the
files don't have consistent newlines at the end. So we force a
blank line between files using the jsmerge tool.