Makefile.am: Rework how we use GLIB_VERSION_MAX_ALLOWED

GLIB_VERSION_MAX_ALLOWED unless us to quickly see if we've used
any GLib APIs that are not supported by our target GLib version.

However gdbus-codegen is really broken in this regard and use
of GLIB_VERSION_MAX_ALLOWED where the version is less than 2.38
generates code which crashes. See this bug:

https://bugzilla.gnome.org/show_bug.cgi?id=710133

So we post-process the gdbus-codegen generated files to remove
the GLIB_VERSION_MAX_ALLOWED define when compiling those files.

Reviewed-by: Patrick Uiterwijk <puiterwijk@redhat.com>
Makefile.am: Cleaner use of CPPFLAGS and CFLAGS

Use AM_CPPFLAGS for our project global settings and individual
xxx_CFLAGS variables for the various components.

Reviewed-by: Patrick Uiterwijk <puiterwijk@redhat.com>
Makefile.am: Remove unused WARN_CFLAGS variable usage

Reviewed-by: Patrick Uiterwijk <puiterwijk@redhat.com>
Makefile.am: Put agent in its own directory and cleanup

Since we're going to be putting more into the agent, move
it to its own source directory.

Moved some common code into src/cockpit to be used
by both cockpit-agent and cockpit-ws.

While doing this, I did a bit of housekeeping in the
make files. This helps with code coverage by not building
lots of stuff multiple times.

Sorry that there's a bit mixed together here, but due to
time constraints I haven't split it all out into
separate patches.

Closed #250

Reviewed-by: Patrick Uiterwijk <puiterwijk@redhat.com>
js-lint: $ signs are allowed in variable names, include them

Reviewed-by: Patrick Uiterwijk <puiterwijk@redhat.com>
js-lint: Support jQuery as a global identifier

Closes #253

Reviewed-by: Patrick Uiterwijk <puiterwijk@redhat.com>
cockpit: Split CockpitPipe out of CockpitFdTransport

In later commits we need to use the queuing and writing to a file
descriptor functionality that's inside of CockpitFdTransport.

Split CockpitFdTransport into CockpitPipe (which contains the base
queeing and writing to a file descriptor and optionally tracking
a subprocess) and CockpitPipeTransport which contains the
CockpitTransport logic.

Renamed to use the naming 'pipe' as it's clearer what this is.
Similar to a unix pipe or pipe(), talking to file descriptors.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
agent: Add a new CockpitChannel class

This class is the base class for channel server (ie: agent)
implementations.

Turn dbus-server.c into CockpitDBusJson which derives from
CockpitChannel.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
Tests: It's not always channel 0 anymore...
agent: Add CockpitTextStream with 'text-stream' payload type

CockpitTextStream is a channel of payload type 'text-stream'
that transfers raw textual data.

 * Only UTF-8 data is supported. There may be another binary
   stream in the future, but that's not here.
 * Only supports connecting to a unix socket for now, might
   get other connection types in the future implemented in
   the same class.

Fixes #257
Closes #262
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
Tests: Ignore more journal messages.
Tests: Ignore one more journal message.
web: Implement a basic REST JSON client

Here's a basic REST JSON client that uses 'text-stream' channels.
It only supports GET requests so far.

We introduce a new namespace for Cockpit called $cockpit. This allows
us to start organizing our code into such a namespace, and getting
ready for foreign code in the same javascript context.

We use jQuery Deferreds as the model for async processing, as this
provides a reliable mechanism for connecting handlers, reporting
failures, progress, etc..

See rest.js near the top for documentation on how to use the REST
JSON client.

Fixes #258
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
web: Add POST support to REST client

Added $cockpit.rest(xxx).post(yyy) method to rest.js and tests
This sends the params as application/json.

If query string params are desired, these can be included on the
@path argument.

Fixes #259
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
web: Implement REST DELETE method

And add some tests for it. 'delete' is a reserved word in javascript
so the method is called .del()

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
web: Add support for REST streaming of responses

This is where the response contains mulitple JSON snippets and
we want to see them as they get pushed from the server.

This is Docker style as in /events in their API.

Strictly speaking this could break if a channel message ending
does not line up with the end of the JSON. However for the time
being this should work.

Also add some tests of receiving data split into multiple
channel messages.

Fixes #254
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
web: Define a new RestError class and expose HTTP errors correctly

REST uses specific errors for specific conditions, so expose them
for callers to access.

In addition we map some errors to our Cockpit style string problem
codes.

Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>
Prettified readme and hacking with markdown

Signed-off-by: Stef Walter <stefw@redhat.com>

Closes #221
Makefile.am: Fix race when calling gdbus-codegen

gdbus-codegen generates multiple files, which is annoying. This causes
make to call it more than once at the same time, when doing parallel
jobs.

Force make to call gdbus-codegen for only the generated .c files, and
expect that the corresponding .h file will be generated in the process.

Closes #274

Reviewed-by: Stephen Gallagher <sgallagh@redhat.com>
agent: Return problems for CockpitTextStream open failures

For the cases where the socket file is not found, return "not-found"
and when permission denied, return "not-authorized".

Fixes #266
Closes #270
Reviewed-by: Marius Vollmer <marius.vollmer@redhat.com>