progress_flags |= PAKFIRE_PROGRESS_SHOW_TRANSFER_SPEED;
// Create the progress indicator
- r = pakfire_progress_create(&data.progress, pakfire, progress_flags);
+ r = pakfire_progress_create(&data.progress, pakfire, progress_flags, NULL);
if (r)
goto ERROR;
const size_t size = pakfire_filelist_total_size(filelist);
// Create the progress indicator
- r = pakfire_progress_create(&data.progress, pakfire, progress_flags);
+ r = pakfire_progress_create(&data.progress, pakfire, progress_flags, NULL);
if (r)
goto ERROR;
// Show progress when iterating over the filelist
if (flags & PAKFIRE_FILELIST_SHOW_PROGRESS) {
r = pakfire_progress_create(&progress, list->pakfire,
- PAKFIRE_PROGRESS_SHOW_PERCENTAGE|PAKFIRE_PROGRESS_SHOW_ETA);
+ PAKFIRE_PROGRESS_SHOW_PERCENTAGE|PAKFIRE_PROGRESS_SHOW_ETA, NULL);
if (r)
goto ERROR;
// Setup progress
r = pakfire_progress_create(&progress, list->pakfire,
- PAKFIRE_PROGRESS_SHOW_PERCENTAGE|PAKFIRE_PROGRESS_SHOW_ETA);
+ PAKFIRE_PROGRESS_SHOW_PERCENTAGE|PAKFIRE_PROGRESS_SHOW_ETA, NULL);
if (r)
goto ERROR;
void pakfire_progress_set_free_callback(
struct pakfire_progress* p, pakfire_progress_free_callback callback);
+struct pakfire_progress* pakfire_progress_get_parent(struct pakfire_progress* p);
unsigned long int pakfire_progress_get_value(struct pakfire_progress* p);
unsigned long int pakfire_progress_get_max_value(struct pakfire_progress* p);
const char* pakfire_progress_get_title(struct pakfire_progress* p);
#include <pakfire/pakfire.h>
int pakfire_progress_create(struct pakfire_progress** progress,
- struct pakfire* pakfire, int flags);
+ struct pakfire* pakfire, int flags, struct pakfire_progress* parent);
struct pakfire_progress* pakfire_progress_ref(struct pakfire_progress* p);
struct pakfire_progress* pakfire_progress_unref(struct pakfire_progress* p);
// Flags what to show
int flags;
+ // Parent
+ struct pakfire_progress* parent;
+
// Status
enum pakfire_progress_status {
PAKFIRE_PROGRESS_INIT = 0,
if (p->callbacks.free)
p->callbacks.free(p->pakfire, p, p->callbacks.data);
+ if (p->parent)
+ pakfire_progress_unref(p->parent);
if (p->title)
free(p->title);
pakfire_unref(p->pakfire);
}
int pakfire_progress_create(struct pakfire_progress** progress,
- struct pakfire* pakfire, int flags) {
+ struct pakfire* pakfire, int flags, struct pakfire_progress* parent) {
struct pakfire_progress* p = NULL;
int r;
// Initialize status
p->status = PAKFIRE_PROGRESS_INIT;
+ // Store a reference to the parent
+ if (parent)
+ p->parent = pakfire_progress_ref(parent);
+
// Configure some default callbacks
p->callbacks.start = pakfire_progress_default_start_callback;
int pakfire_progress_update(struct pakfire_progress* p, unsigned long int value) {
int r;
+ // Report the change to the parent progress
+ if (p->parent) {
+ r = pakfire_progress_increment(p->parent, value - p->value);
+ if (r)
+ return r;
+ }
+
// Store the new value
p->value = value;
}
// Reset values
- p->value = p->max_value = 0;
+ r = pakfire_progress_update(p, 0);
+ if (r)
+ return r;
+
+ // Reset max value
+ pakfire_progress_set_max_value(p, 0);
return 0;
}
+PAKFIRE_EXPORT struct pakfire_progress* pakfire_progress_get_parent(struct pakfire_progress* p) {
+ if (p->parent)
+ return pakfire_progress_ref(p->parent);
+
+ return NULL;
+}
+
PAKFIRE_EXPORT unsigned long int pakfire_progress_get_value(struct pakfire_progress* p) {
return p->value;
}
// Create progress indicator
r = pakfire_progress_create(&progress, repo->pakfire,
- PAKFIRE_PROGRESS_SHOW_COUNTER|PAKFIRE_PROGRESS_SHOW_ELAPSED_TIME);
+ PAKFIRE_PROGRESS_SHOW_COUNTER|PAKFIRE_PROGRESS_SHOW_ELAPSED_TIME, NULL);
if (r)
goto ERROR;