AU: Beginnings of dbus support.

The AU will be a daemon that runs as root. Non-root will communicate
via dbus with the updater to do things such as: query status, request
forced or full updates, etc.

New files for dbus:

UpdateEngine.conf - security configuration
dbus_constants.h - common constants
dbus_service.* - The object exposed over dbus
org.chromium.UpdateEngine.service - the dbus service file
udpate_attempter.* - Refactored this out of main.cc
update_engine_client.cc - Simple command line utility to interact with
Update Engine over dbus. Whereas Update Engine runs as root, this tool
runs as non-root user.

Review URL: http://codereview.chromium.org/1733013
diff --git a/SConstruct b/SConstruct
index 5c11b6d..9598975 100644
--- a/SConstruct
+++ b/SConstruct
@@ -39,6 +39,46 @@
                         single_source = 1,
                         suffix = '.pb.cc')
 
+""" Inputs:
+        target: unused
+        source: list containing the source .xml file
+        env: the scons environment in which we are compiling
+    Outputs:
+        target: the list of targets we'll emit
+        source: the list of sources we'll process"""
+def DbusBindingsEmitter(target, source, env):
+  output = str(source[0])
+  output = output[0:output.rfind('.xml')]
+  target = [
+    output + '.dbusserver.h',
+    output + '.dbusclient.h'
+  ]
+  return target, source
+
+""" Inputs:
+        source: list of sources to process
+        target: list of targets to generate
+        env: scons environment in which we are working
+        for_signature: unused
+    Outputs: a list of commands to execute to generate the targets from
+             the sources."""
+def DbusBindingsGenerator(source, target, env, for_signature):
+  commands = []
+  for target_file in target:
+    if str(target_file).endswith('.dbusserver.h'):
+      mode_flag = '--mode=glib-server '
+    else:
+      mode_flag = '--mode=glib-client '
+    cmd = '/usr/bin/dbus-binding-tool %s --prefix=update_engine_service ' \
+          '%s > %s' % (mode_flag, str(source[0]), str(target_file))
+    commands.append(cmd)
+  return commands
+
+dbus_bindings_builder = Builder(generator = DbusBindingsGenerator,
+                                emitter = DbusBindingsEmitter,
+                                single_source = 1,
+                                suffix = 'dbusclient.h')
+
 env = Environment()
 for key in Split('CC CXX AR RANLIB LD NM'):
   value = os.environ.get(key)
@@ -54,13 +94,17 @@
     env['ENV'][key] = os.environ[key]
 
 
+    # -Wclobbered
+    # -Wempty-body
+    # -Wignored-qualifiers
+    # -Wtype-limits
 env['CCFLAGS'] = ' '.join("""-g
                              -fno-exceptions
                              -fno-strict-aliasing
                              -Wall
-                             -Werror
                              -Wclobbered
                              -Wempty-body
+                             -Werror
                              -Wignored-qualifiers
                              -Wmissing-field-initializers
                              -Wsign-compare
@@ -87,25 +131,27 @@
 env['CPPPATH'] = ['..', '../../third_party/chrome/files', '../../common']
 env['LIBPATH'] = ['../../third_party/chrome']
 env['BUILDERS']['ProtocolBuffer'] = proto_builder
+env['BUILDERS']['DbusBindings'] = dbus_bindings_builder
 
 # Fix issue with scons not passing pkg-config vars through the environment.
 for key in Split('PKG_CONFIG_LIBDIR PKG_CONFIG_PATH'):
   if os.environ.has_key(key):
     env['ENV'][key] = os.environ[key]
 
-env.ParseConfig('pkg-config --cflags --libs glib-2.0')
+env.ParseConfig('pkg-config --cflags --libs glib-2.0 dbus-1 dbus-glib-1')
 env.ProtocolBuffer('update_metadata.pb.cc', 'update_metadata.proto')
 
+env.DbusBindings('update_engine.dbusclient.h', 'update_engine.xml')
+
 if ARGUMENTS.get('debug', 0):
   env['CCFLAGS'] += ' -fprofile-arcs -ftest-coverage'
   env['LIBS'] += ['bz2', 'gcov']
 
-
-
 sources = Split("""action_processor.cc
                    bzip.cc
                    bzip_extent_writer.cc
                    cycle_breaker.cc
+                   dbus_service.cc
                    decompressing_file_writer.cc
                    delta_diff_generator.cc
                    delta_performer.cc
@@ -126,6 +172,7 @@
                    subprocess.cc
                    tarjan.cc
                    topological_sort.cc
+                   update_attempter.cc
                    update_check_action.cc
 		               update_metadata.pb.cc
 		               utils.cc""")
@@ -161,12 +208,16 @@
                             zip_unittest.cc""")
 unittest_main = ['testrunner.cc']
 
+client_main = ['update_engine_client.cc']
+
 delta_generator_main = ['generate_delta_main.cc']
 
 env.Program('update_engine', sources + main)
 unittest_cmd = env.Program('update_engine_unittests',
                            sources + unittest_sources + unittest_main)
 
+client_cmd = env.Program('update_engine_client', sources + client_main);
+
 Clean(unittest_cmd, Glob('*.gcda') + Glob('*.gcno') + Glob('*.gcov') +
                     Split('html app.info'))