Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame^] | 1 | // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "update_engine/dbus_service.h" |
| 6 | #include <string> |
| 7 | #include "base/logging.h" |
| 8 | |
| 9 | using std::string; |
| 10 | |
| 11 | G_DEFINE_TYPE(UpdateEngineService, update_engine_service, G_TYPE_OBJECT) |
| 12 | |
| 13 | static void update_engine_service_finalize(GObject* object) { |
| 14 | G_OBJECT_CLASS(update_engine_service_parent_class)->finalize(object); |
| 15 | } |
| 16 | |
| 17 | static void update_engine_service_class_init(UpdateEngineServiceClass* klass) { |
| 18 | GObjectClass *object_class; |
| 19 | object_class = G_OBJECT_CLASS(klass); |
| 20 | object_class->finalize = update_engine_service_finalize; |
| 21 | } |
| 22 | |
| 23 | static void update_engine_service_init(UpdateEngineService* object) { |
| 24 | } |
| 25 | |
| 26 | UpdateEngineService* update_engine_service_new(void) { |
| 27 | return reinterpret_cast<UpdateEngineService*>( |
| 28 | g_object_new(UPDATE_ENGINE_TYPE_SERVICE, NULL)); |
| 29 | } |
| 30 | |
| 31 | gboolean update_engine_service_get_status(UpdateEngineService* self, |
| 32 | int64_t* last_checked_time, |
| 33 | double* progress, |
| 34 | gchar** current_operation, |
| 35 | gchar** new_version, |
| 36 | int64_t* new_size, |
| 37 | GError **error) { |
| 38 | string current_op; |
| 39 | string new_version_str; |
| 40 | |
| 41 | CHECK(self->update_attempter_->GetStatus(last_checked_time, |
| 42 | progress, |
| 43 | ¤t_op, |
| 44 | &new_version_str, |
| 45 | new_size)); |
| 46 | |
| 47 | *current_operation = strdup(current_op.c_str()); |
| 48 | *new_version = strdup(new_version_str.c_str()); |
| 49 | return TRUE; |
| 50 | } |
| 51 | |