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 | #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_DBUS_SERVICE_H__ |
| 6 | #define CHROMEOS_PLATFORM_UPDATE_ENGINE_DBUS_SERVICE_H__ |
| 7 | |
| 8 | #include <inttypes.h> |
| 9 | #include <dbus/dbus-glib.h> |
| 10 | #include <dbus/dbus-glib-bindings.h> |
| 11 | #include <dbus/dbus-glib-lowlevel.h> |
| 12 | #include <glib-object.h> |
| 13 | |
| 14 | #include "update_engine/update_attempter.h" |
| 15 | |
| 16 | // Type macros: |
| 17 | #define UPDATE_ENGINE_TYPE_SERVICE (update_engine_service_get_type()) |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 18 | #define UPDATE_ENGINE_SERVICE(obj) \ |
| 19 | (G_TYPE_CHECK_INSTANCE_CAST((obj), UPDATE_ENGINE_TYPE_SERVICE, \ |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 20 | UpdateEngineService)) |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 21 | #define UPDATE_ENGINE_IS_SERVICE(obj) \ |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 22 | (G_TYPE_CHECK_INSTANCE_TYPE((obj), UPDATE_ENGINE_TYPE_SERVICE)) |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 23 | #define UPDATE_ENGINE_SERVICE_CLASS(klass) \ |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 24 | (G_TYPE_CHECK_CLASS_CAST((klass), UPDATE_ENGINE_TYPE_SERVICE, \ |
| 25 | UpdateEngineService)) |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 26 | #define UPDATE_ENGINE_IS_SERVICE_CLASS(klass) \ |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 27 | (G_TYPE_CHECK_CLASS_TYPE((klass), UPDATE_ENGINE_TYPE_SERVICE)) |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 28 | #define UPDATE_ENGINE_SERVICE_GET_CLASS(obj) \ |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 29 | (G_TYPE_INSTANCE_GET_CLASS((obj), UPDATE_ENGINE_TYPE_SERVICE, \ |
| 30 | UpdateEngineService)) |
| 31 | |
| 32 | G_BEGIN_DECLS |
| 33 | |
| 34 | struct UpdateEngineService { |
| 35 | GObject parent_instance; |
| 36 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 37 | chromeos_update_engine::SystemState* system_state_; |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 38 | }; |
| 39 | |
| 40 | struct UpdateEngineServiceClass { |
| 41 | GObjectClass parent_class; |
| 42 | }; |
| 43 | |
| 44 | UpdateEngineService* update_engine_service_new(void); |
| 45 | GType update_engine_service_get_type(void); |
| 46 | |
| 47 | // Methods |
| 48 | |
Darin Petkov | 296889c | 2010-07-23 16:20:54 -0700 | [diff] [blame] | 49 | gboolean update_engine_service_attempt_update(UpdateEngineService* self, |
| 50 | gchar* app_version, |
| 51 | gchar* omaha_url, |
| 52 | GError **error); |
| 53 | |
Chris Sosa | d317e40 | 2013-06-12 13:47:09 -0700 | [diff] [blame] | 54 | gboolean update_engine_service_attempt_rollback(UpdateEngineService* self, |
| 55 | bool powerwash, |
| 56 | GError **error); |
| 57 | |
Jay Srinivasan | c1ba09a | 2012-08-14 14:15:57 -0700 | [diff] [blame] | 58 | gboolean update_engine_service_reset_status(UpdateEngineService* self, |
| 59 | GError **error); |
| 60 | |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 61 | gboolean update_engine_service_get_status(UpdateEngineService* self, |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 62 | int64_t* last_checked_time, |
| 63 | double* progress, |
| 64 | gchar** current_operation, |
| 65 | gchar** new_version, |
| 66 | int64_t* new_size, |
| 67 | GError **error); |
| 68 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 69 | gboolean update_engine_service_reboot_if_needed(UpdateEngineService* self, |
| 70 | GError **error); |
| 71 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 72 | // Changes the current channel of the device to the target channel. If the |
| 73 | // target channel is a less stable channel than the current channel, then the |
| 74 | // channel change happens immediately (at the next update check). If the |
| 75 | // target channel is a more stable channel, then if is_powerwash_allowed is set |
| 76 | // to true, then also the change happens immediately but with a powerwash if |
| 77 | // required. Otherwise, the change takes effect eventually (when the version on |
| 78 | // the target channel goes above the version number of what the device |
| 79 | // currently has). |
| 80 | gboolean update_engine_service_set_channel(UpdateEngineService* self, |
| 81 | gchar* target_channel, |
| 82 | bool is_powerwash_allowed, |
| 83 | GError **error); |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 84 | |
Jay Srinivasan | ae4697c | 2013-03-18 17:08:08 -0700 | [diff] [blame] | 85 | // If get_current_channel is set to true, populates |channel| with the name of |
| 86 | // the channel that the device is currently on. Otherwise, it populates it with |
| 87 | // the name of the channel the device is supposed to be (in case of a pending |
| 88 | // channel change). |
| 89 | gboolean update_engine_service_get_channel(UpdateEngineService* self, |
| 90 | bool get_current_channel, |
| 91 | gchar** channel, |
| 92 | GError **error); |
Darin Petkov | 8daa324 | 2010-10-25 13:28:47 -0700 | [diff] [blame] | 93 | |
Alex Deymo | 5fdf776 | 2013-07-17 20:01:40 -0700 | [diff] [blame] | 94 | // Enables or disables the sharing and consuming updates over P2P feature |
| 95 | // according to the |enabled| argument passed. |
| 96 | gboolean update_engine_service_set_p2p_update_permission( |
| 97 | UpdateEngineService* self, |
| 98 | gboolean enabled, |
| 99 | GError **error); |
| 100 | |
| 101 | // Returns in |enabled| the current value for the P2P enabled setting. This |
| 102 | // involves both sharing and consuming updates over P2P. |
| 103 | gboolean update_engine_service_get_p2p_update_permission( |
| 104 | UpdateEngineService* self, |
| 105 | gboolean* enabled, |
| 106 | GError **error); |
| 107 | |
Alex Deymo | f4867c4 | 2013-06-28 14:41:39 -0700 | [diff] [blame] | 108 | // If there's no device policy installed, sets the update over cellular networks |
| 109 | // permission to the |allowed| value. Otherwise, this method returns with an |
| 110 | // error since this setting is overridden by the applied policy. |
| 111 | gboolean update_engine_service_set_update_over_cellular_permission( |
| 112 | UpdateEngineService* self, |
| 113 | bool allowed, |
| 114 | GError **error); |
| 115 | |
| 116 | // Returns the current value of the update over cellular network setting, either |
| 117 | // forced by the device policy if the device is enrolled or the current user |
| 118 | // preference otherwise. |
| 119 | gboolean update_engine_service_get_update_over_cellular_permission( |
| 120 | UpdateEngineService* self, |
| 121 | bool* allowed, |
| 122 | GError **error); |
| 123 | |
Andrew de los Reyes | 63b96d7 | 2010-05-10 13:08:54 -0700 | [diff] [blame] | 124 | gboolean update_engine_service_emit_status_update( |
| 125 | UpdateEngineService* self, |
| 126 | gint64 last_checked_time, |
| 127 | gdouble progress, |
| 128 | const gchar* current_operation, |
| 129 | const gchar* new_version, |
| 130 | gint64 new_size); |
Andrew de los Reyes | 4e9b9f4 | 2010-04-26 15:06:43 -0700 | [diff] [blame] | 131 | |
| 132 | G_END_DECLS |
| 133 | |
| 134 | #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DBUS_SERVICE_H__ |