1 /* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- 2 * 3 * Copyright (C) 2009-2015 Richard Hughes <richard@hughsie.com> 4 * 5 * Licensed under the GNU Lesser General Public License Version 2.1 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21 22 #ifndef __DNF_STATE_H 23 #define __DNF_STATE_H 24 25 #include <glib-object.h> 26 #include <gio/gio.h> 27 28 #include "dnf-types.h" 29 #include "dnf-lock.h" 30 31 G_BEGIN_DECLS 32 33 #define DNF_TYPE_STATE (dnf_state_get_type ()) 34 G_DECLARE_DERIVABLE_TYPE (DnfState, dnf_state, DNF, STATE, GObject) 35 36 /** 37 * DnfStateAction: 38 * @DNF_STATE_ACTION_UNKNOWN: Unknown status 39 * @DNF_STATE_ACTION_DOWNLOAD_PACKAGES: Downloading packages 40 * @DNF_STATE_ACTION_DOWNLOAD_METADATA: Downloading metadata 41 * @DNF_STATE_ACTION_LOADING_CACHE: Loading cache 42 * @DNF_STATE_ACTION_TEST_COMMIT: Testing transaction 43 * @DNF_STATE_ACTION_REQUEST: Requesting data 44 * @DNF_STATE_ACTION_REMOVE: Removing packages 45 * @DNF_STATE_ACTION_INSTALL: Installing packages 46 * @DNF_STATE_ACTION_UPDATE: Updating packages 47 * @DNF_STATE_ACTION_CLEANUP: Cleaning packages 48 * @DNF_STATE_ACTION_OBSOLETE: Obsoleting packages 49 * @DNF_STATE_ACTION_REINSTALL: Reinstall packages 50 * @DNF_STATE_ACTION_DOWNGRADE: Downgrading packages 51 * @DNF_STATE_ACTION_QUERY: Querying for results 52 * 53 * The action enum code. 54 **/ 55 typedef enum { 56 DNF_STATE_ACTION_UNKNOWN = 0, /* Since: 0.1.0 */ 57 DNF_STATE_ACTION_DOWNLOAD_PACKAGES = 8, /* Since: 0.1.0 */ 58 DNF_STATE_ACTION_DOWNLOAD_METADATA = 20, /* Since: 0.1.0 */ 59 DNF_STATE_ACTION_LOADING_CACHE = 27, /* Since: 0.1.0 */ 60 DNF_STATE_ACTION_TEST_COMMIT = 15, /* Since: 0.1.0 */ 61 DNF_STATE_ACTION_REQUEST = 17, /* Since: 0.1.0 */ 62 DNF_STATE_ACTION_REMOVE = 6, /* Since: 0.1.0 */ 63 DNF_STATE_ACTION_INSTALL = 9, /* Since: 0.1.0 */ 64 DNF_STATE_ACTION_UPDATE = 10, /* Since: 0.1.2 */ 65 DNF_STATE_ACTION_CLEANUP = 11, /* Since: 0.1.2 */ 66 DNF_STATE_ACTION_OBSOLETE = 12, /* Since: 0.1.2 */ 67 DNF_STATE_ACTION_REINSTALL = 13, /* Since: 0.1.6 */ 68 DNF_STATE_ACTION_DOWNGRADE = 14, /* Since: 0.1.6 */ 69 DNF_STATE_ACTION_QUERY = 4, /* Since: 0.1.2 */ 70 /*< private >*/ 71 DNF_STATE_ACTION_LAST 72 } DnfStateAction; 73 74 struct _DnfStateClass 75 { 76 GObjectClass parent_class; 77 void (* percentage_changed) (DnfState *state, 78 guint value); 79 void (* allow_cancel_changed) (DnfState *state, 80 gboolean allow_cancel); 81 void (* action_changed) (DnfState *state, 82 DnfStateAction action, 83 const gchar *action_hint); 84 void (* package_progress_changed) (DnfState *state, 85 const gchar *dnf_package_get_id, 86 DnfStateAction action, 87 guint percentage); 88 /*< private >*/ 89 void (*_dnf_reserved1) (void); 90 void (*_dnf_reserved2) (void); 91 void (*_dnf_reserved3) (void); 92 void (*_dnf_reserved4) (void); 93 void (*_dnf_reserved5) (void); 94 void (*_dnf_reserved6) (void); 95 void (*_dnf_reserved7) (void); 96 void (*_dnf_reserved8) (void); 97 }; 98 99 #define dnf_state_done(state, error) dnf_state_done_real(state, error, G_STRLOC) 100 #define dnf_state_finished(state, error) dnf_state_finished_real(state, error, G_STRLOC) 101 #define dnf_state_set_number_steps(state, steps) dnf_state_set_number_steps_real(state, steps, G_STRLOC) 102 #define dnf_state_set_steps(state, error, value, args...) dnf_state_set_steps_real(state, error, G_STRLOC, value, ## args) 103 104 typedef gboolean (*DnfStateErrorHandlerCb) (const GError *error, 105 gpointer user_data); 106 107 DnfState *dnf_state_new (void); 108 109 /* getters */ 110 guint dnf_state_get_percentage (DnfState *state); 111 DnfStateAction dnf_state_get_action (DnfState *state); 112 const gchar *dnf_state_get_action_hint (DnfState *state); 113 GCancellable *dnf_state_get_cancellable (DnfState *state); 114 gboolean dnf_state_get_allow_cancel (DnfState *state); 115 guint64 dnf_state_get_speed (DnfState *state); 116 117 /* setters */ 118 void dnf_state_set_cancellable (DnfState *state, 119 GCancellable *cancellable); 120 void dnf_state_set_allow_cancel (DnfState *state, 121 gboolean allow_cancel); 122 void dnf_state_set_speed (DnfState *state, 123 guint64 speed); 124 void dnf_state_set_report_progress (DnfState *state, 125 gboolean report_progress); 126 gboolean dnf_state_set_number_steps_real (DnfState *state, 127 guint steps, 128 const gchar *strloc); 129 gboolean dnf_state_set_steps_real (DnfState *state, 130 GError **error, 131 const gchar *strloc, 132 gint value, ...); 133 gboolean dnf_state_set_percentage (DnfState *state, 134 guint percentage); 135 void dnf_state_set_package_progress (DnfState *state, 136 const gchar *dnf_package_get_id, 137 DnfStateAction action, 138 guint percentage); 139 140 /* object methods */ 141 DnfState *dnf_state_get_child (DnfState *state); 142 gboolean dnf_state_action_start (DnfState *state, 143 DnfStateAction action, 144 const gchar *action_hint); 145 gboolean dnf_state_action_stop (DnfState *state); 146 gboolean dnf_state_check (DnfState *state, 147 GError **error) 148 G_GNUC_WARN_UNUSED_RESULT; 149 gboolean dnf_state_done_real (DnfState *state, 150 GError **error, 151 const gchar *strloc) 152 G_GNUC_WARN_UNUSED_RESULT; 153 gboolean dnf_state_finished_real (DnfState *state, 154 GError **error, 155 const gchar *strloc) 156 G_GNUC_WARN_UNUSED_RESULT; 157 gboolean dnf_state_reset (DnfState *state); 158 void dnf_state_set_enable_profile (DnfState *state, 159 gboolean enable_profile); 160 #ifndef __GI_SCANNER__ 161 gboolean dnf_state_take_lock (DnfState *state, 162 DnfLockType lock_type, 163 DnfLockMode lock_mode, 164 GError **error); 165 #endif 166 gboolean dnf_state_release_locks (DnfState *state); 167 168 G_END_DECLS 169 170 #endif /* __DNF_STATE_H */ 171