blob: 71e79975353a005de158f88f46b9a9bb266c67bd [file] [log] [blame]
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -07001// 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 Reyes63b96d72010-05-10 13:08:54 -070018#define UPDATE_ENGINE_SERVICE(obj) \
19 (G_TYPE_CHECK_INSTANCE_CAST((obj), UPDATE_ENGINE_TYPE_SERVICE, \
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070020 UpdateEngineService))
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070021#define UPDATE_ENGINE_IS_SERVICE(obj) \
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070022 (G_TYPE_CHECK_INSTANCE_TYPE((obj), UPDATE_ENGINE_TYPE_SERVICE))
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070023#define UPDATE_ENGINE_SERVICE_CLASS(klass) \
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070024 (G_TYPE_CHECK_CLASS_CAST((klass), UPDATE_ENGINE_TYPE_SERVICE, \
25 UpdateEngineService))
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070026#define UPDATE_ENGINE_IS_SERVICE_CLASS(klass) \
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070027 (G_TYPE_CHECK_CLASS_TYPE((klass), UPDATE_ENGINE_TYPE_SERVICE))
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070028#define UPDATE_ENGINE_SERVICE_GET_CLASS(obj) \
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070029 (G_TYPE_INSTANCE_GET_CLASS((obj), UPDATE_ENGINE_TYPE_SERVICE, \
30 UpdateEngineService))
31
32G_BEGIN_DECLS
33
34struct UpdateEngineService {
35 GObject parent_instance;
36
Jay Srinivasanae4697c2013-03-18 17:08:08 -070037 chromeos_update_engine::SystemState* system_state_;
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070038};
39
40struct UpdateEngineServiceClass {
41 GObjectClass parent_class;
42};
43
44UpdateEngineService* update_engine_service_new(void);
45GType update_engine_service_get_type(void);
46
47// Methods
48
Darin Petkov296889c2010-07-23 16:20:54 -070049gboolean update_engine_service_attempt_update(UpdateEngineService* self,
50 gchar* app_version,
51 gchar* omaha_url,
52 GError **error);
53
Jay Srinivasanc1ba09a2012-08-14 14:15:57 -070054gboolean update_engine_service_reset_status(UpdateEngineService* self,
55 GError **error);
56
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -070057gboolean update_engine_service_get_status(UpdateEngineService* self,
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070058 int64_t* last_checked_time,
59 double* progress,
60 gchar** current_operation,
61 gchar** new_version,
62 int64_t* new_size,
63 GError **error);
64
Jay Srinivasanae4697c2013-03-18 17:08:08 -070065gboolean update_engine_service_reboot_if_needed(UpdateEngineService* self,
66 GError **error);
67
68// TODO(jaysri): Deprecate set_track and get_track once Chrome is modified to
69// use set_channel and get_channel.
70gboolean update_engine_service_set_track(UpdateEngineService* self,
71 gchar* track,
72 GError **error);
73
Satoru Takabayashi583667b2010-10-27 13:09:57 +090074gboolean update_engine_service_get_track(UpdateEngineService* self,
75 gchar** track,
76 GError **error);
77
Jay Srinivasanae4697c2013-03-18 17:08:08 -070078// Changes the current channel of the device to the target channel. If the
79// target channel is a less stable channel than the current channel, then the
80// channel change happens immediately (at the next update check). If the
81// target channel is a more stable channel, then if is_powerwash_allowed is set
82// to true, then also the change happens immediately but with a powerwash if
83// required. Otherwise, the change takes effect eventually (when the version on
84// the target channel goes above the version number of what the device
85// currently has).
86gboolean update_engine_service_set_channel(UpdateEngineService* self,
87 gchar* target_channel,
88 bool is_powerwash_allowed,
89 GError **error);
Andrew de los Reyes63b96d72010-05-10 13:08:54 -070090
Jay Srinivasanae4697c2013-03-18 17:08:08 -070091// If get_current_channel is set to true, populates |channel| with the name of
92// the channel that the device is currently on. Otherwise, it populates it with
93// the name of the channel the device is supposed to be (in case of a pending
94// channel change).
95gboolean update_engine_service_get_channel(UpdateEngineService* self,
96 bool get_current_channel,
97 gchar** channel,
98 GError **error);
Darin Petkov8daa3242010-10-25 13:28:47 -070099
Andrew de los Reyes63b96d72010-05-10 13:08:54 -0700100gboolean update_engine_service_emit_status_update(
101 UpdateEngineService* self,
102 gint64 last_checked_time,
103 gdouble progress,
104 const gchar* current_operation,
105 const gchar* new_version,
106 gint64 new_size);
Andrew de los Reyes4e9b9f42010-04-26 15:06:43 -0700107
108G_END_DECLS
109
110#endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_DBUS_SERVICE_H__