OLD | NEW |
1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "update_engine/dbus_service.h" | 5 #include "update_engine/dbus_service.h" |
6 #include <string> | 6 #include <string> |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "update_engine/marshal.glibmarshal.h" | 8 #include "update_engine/marshal.glibmarshal.h" |
9 | 9 |
10 using std::string; | 10 using std::string; |
11 | 11 |
12 G_DEFINE_TYPE(UpdateEngineService, update_engine_service, G_TYPE_OBJECT) | 12 G_DEFINE_TYPE(UpdateEngineService, update_engine_service, G_TYPE_OBJECT) |
13 | 13 |
14 static void update_engine_service_finalize(GObject* object) { | 14 static void update_engine_service_finalize(GObject* object) { |
15 G_OBJECT_CLASS(update_engine_service_parent_class)->finalize(object); | 15 G_OBJECT_CLASS(update_engine_service_parent_class)->finalize(object); |
16 } | 16 } |
17 | 17 |
18 static guint status_update_signal = 0; | 18 static guint status_update_signal = 0; |
19 | 19 |
20 static void update_engine_service_class_init(UpdateEngineServiceClass* klass) { | 20 static void update_engine_service_class_init(UpdateEngineServiceClass* klass) { |
21 GObjectClass *object_class; | 21 GObjectClass *object_class; |
22 object_class = G_OBJECT_CLASS(klass); | 22 object_class = G_OBJECT_CLASS(klass); |
23 object_class->finalize = update_engine_service_finalize; | 23 object_class->finalize = update_engine_service_finalize; |
24 | 24 |
25 status_update_signal = g_signal_new( | 25 status_update_signal = g_signal_new( |
26 "status_update", | 26 "status_update", |
27 G_OBJECT_CLASS_TYPE(klass), | 27 G_OBJECT_CLASS_TYPE(klass), |
28 G_SIGNAL_RUN_LAST, | 28 G_SIGNAL_RUN_LAST, |
29 0, // 0 == no class method associated | 29 0, // 0 == no class method associated |
30 NULL, // Accumulator | 30 NULL, // Accumulator |
31 NULL, // Accumulator data | 31 NULL, // Accumulator data |
32 update_engine_VOID__INT64_DOUBLE_STRING_STRING_INT64, | 32 update_engine_VOID__INT64_DOUBLE_STRING_STRING_INT64, |
33 G_TYPE_NONE, // Return type | 33 G_TYPE_NONE, // Return type |
34 5, // param count: | 34 5, // param count: |
(...skipping 14 matching lines...) Expand all Loading... |
49 | 49 |
50 gboolean update_engine_service_get_status(UpdateEngineService* self, | 50 gboolean update_engine_service_get_status(UpdateEngineService* self, |
51 int64_t* last_checked_time, | 51 int64_t* last_checked_time, |
52 double* progress, | 52 double* progress, |
53 gchar** current_operation, | 53 gchar** current_operation, |
54 gchar** new_version, | 54 gchar** new_version, |
55 int64_t* new_size, | 55 int64_t* new_size, |
56 GError **error) { | 56 GError **error) { |
57 string current_op; | 57 string current_op; |
58 string new_version_str; | 58 string new_version_str; |
59 | 59 |
60 CHECK(self->update_attempter_->GetStatus(last_checked_time, | 60 CHECK(self->update_attempter_->GetStatus(last_checked_time, |
61 progress, | 61 progress, |
62 ¤t_op, | 62 ¤t_op, |
63 &new_version_str, | 63 &new_version_str, |
64 new_size)); | 64 new_size)); |
65 | 65 |
66 *current_operation = strdup(current_op.c_str()); | 66 *current_operation = strdup(current_op.c_str()); |
67 *new_version = strdup(new_version_str.c_str()); | 67 *new_version = strdup(new_version_str.c_str()); |
68 return TRUE; | 68 return TRUE; |
69 } | 69 } |
70 | 70 |
71 gboolean update_engine_service_check_for_update(UpdateEngineService* self, | 71 gboolean update_engine_service_attempt_update(UpdateEngineService* self, |
72 GError **error) { | 72 gchar* app_version, |
73 self->update_attempter_->CheckForUpdate(); | 73 gchar* omaha_url, |
| 74 GError **error) { |
| 75 const string update_app_version = app_version ? app_version : ""; |
| 76 const string update_omaha_url = omaha_url ? omaha_url : ""; |
| 77 LOG(INFO) << "Attempt update: app_version=\"" << update_app_version << "\" " |
| 78 << "omaha_url=\"" << update_omaha_url << "\""; |
| 79 self->update_attempter_->CheckForUpdate(app_version, omaha_url); |
74 return TRUE; | 80 return TRUE; |
75 } | 81 } |
76 | 82 |
| 83 gboolean update_engine_service_check_for_update(UpdateEngineService* self, |
| 84 GError **error) { |
| 85 self->update_attempter_->CheckForUpdate("", ""); |
| 86 return TRUE; |
| 87 } |
| 88 |
77 gboolean update_engine_service_emit_status_update( | 89 gboolean update_engine_service_emit_status_update( |
78 UpdateEngineService* self, | 90 UpdateEngineService* self, |
79 gint64 last_checked_time, | 91 gint64 last_checked_time, |
80 gdouble progress, | 92 gdouble progress, |
81 const gchar* current_operation, | 93 const gchar* current_operation, |
82 const gchar* new_version, | 94 const gchar* new_version, |
83 gint64 new_size) { | 95 gint64 new_size) { |
84 g_signal_emit(self, | 96 g_signal_emit(self, |
85 status_update_signal, | 97 status_update_signal, |
86 0, | 98 0, |
87 last_checked_time, | 99 last_checked_time, |
88 progress, | 100 progress, |
89 current_operation, | 101 current_operation, |
90 new_version, | 102 new_version, |
91 new_size); | 103 new_size); |
92 return TRUE; | 104 return TRUE; |
93 } | 105 } |
OLD | NEW |