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/dbus_service.cc b/dbus_service.cc
new file mode 100644
index 0000000..8dc239f
--- /dev/null
+++ b/dbus_service.cc
@@ -0,0 +1,51 @@
+// Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "update_engine/dbus_service.h"
+#include <string>
+#include "base/logging.h"
+
+using std::string;
+
+G_DEFINE_TYPE(UpdateEngineService, update_engine_service, G_TYPE_OBJECT)
+
+static void update_engine_service_finalize(GObject* object) {
+ G_OBJECT_CLASS(update_engine_service_parent_class)->finalize(object);
+}
+
+static void update_engine_service_class_init(UpdateEngineServiceClass* klass) {
+ GObjectClass *object_class;
+ object_class = G_OBJECT_CLASS(klass);
+ object_class->finalize = update_engine_service_finalize;
+}
+
+static void update_engine_service_init(UpdateEngineService* object) {
+}
+
+UpdateEngineService* update_engine_service_new(void) {
+ return reinterpret_cast<UpdateEngineService*>(
+ g_object_new(UPDATE_ENGINE_TYPE_SERVICE, NULL));
+}
+
+gboolean update_engine_service_get_status(UpdateEngineService* self,
+ int64_t* last_checked_time,
+ double* progress,
+ gchar** current_operation,
+ gchar** new_version,
+ int64_t* new_size,
+ GError **error) {
+ string current_op;
+ string new_version_str;
+
+ CHECK(self->update_attempter_->GetStatus(last_checked_time,
+ progress,
+ ¤t_op,
+ &new_version_str,
+ new_size));
+
+ *current_operation = strdup(current_op.c_str());
+ *new_version = strdup(new_version_str.c_str());
+ return TRUE;
+}
+