[Aptitude-svn-commit] r4332 - in branches/aptitude-0.3/aptitude: .
src
Daniel Burrows
dburrows at costa.debian.org
Thu Sep 29 21:40:14 UTC 2005
Author: dburrows
Date: Thu Sep 29 21:40:11 2005
New Revision: 4332
Modified:
branches/aptitude-0.3/aptitude/ChangeLog
branches/aptitude-0.3/aptitude/src/ui.cc
Log:
Hook up the new objects in interactive mode.
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Thu Sep 29 21:40:11 2005
@@ -1,5 +1,10 @@
2005-09-29 Daniel Burrows <dburrows at debian.org>
+ * src/ui.cc:
+
+ First cut at using the download_manager code instead of the old
+ download code.
+
* src/download_thread.cc, src/download_thread.h:
Accept download managers instead of acquire objects as the
Modified: branches/aptitude-0.3/aptitude/src/ui.cc
==============================================================================
--- branches/aptitude-0.3/aptitude/src/ui.cc (original)
+++ branches/aptitude-0.3/aptitude/src/ui.cc Thu Sep 29 21:40:11 2005
@@ -84,6 +84,8 @@
#include <generic/apt/apt_undo_group.h>
#include <generic/apt/aptitude_resolver_universe.h>
#include <generic/apt/config_signal.h>
+#include <generic/apt/download_install_manager.h>
+#include <generic/apt/download_update_manager.h>
#include <generic/apt/download_signal_log.h>
#include <generic/apt/resolver_manager.h>
@@ -94,7 +96,6 @@
#include <generic/util/util.h>
#include "dep_item.h"
-#include "download.h"
#include "download_bar.h"
#include "download_list.h"
#include "download_screen.h"
@@ -1013,86 +1014,94 @@
}
};
+/** This class self-destructs when it's finished; don't try to delete
+ * one on your own.
+ */
+class ui_install_manager : public download_install_manager
+{
+ download_thread *t;
-static void finish_install_or_remove_packages(download_thread *t,
- pkgAcquire::RunResult res,
- pkgAcquire *acq,
- pkgPackageManager *pm,
- download_signal_log *m,
- background_status *st,
- downloader *abort_state);
+ downloader abort_state;
-void install_or_remove_packages()
-{
- active_download=true;
+ download_signal_log *log;
- if(apt_cache_file != NULL)
- (*apt_cache_file)->set_read_only(true);
+ background_status st;
+public:
+ ui_install_manager()
+ : t(NULL),
+ log(gen_download_progress(false, false,
+ _("Downloading packages"),
+ _("View the progress of the package download"),
+ _("Package Download"),
+ arg(sigc::mem_fun(abort_state,
+ &downloader::abort)))),
+ st(log)
+ {
+ active_download = true;
- if(active_preview.valid())
- active_preview->destroy();
+ if(apt_cache_file != NULL)
+ (*apt_cache_file)->set_read_only(true);
- vs_progress_ref p = gen_progress_bar();
+ if(active_preview.valid())
+ active_preview->destroy();
+ }
- downloader *abort_state = new downloader;
+ ~ui_install_manager()
+ {
+ log->Complete();
+ active_download = false;
+ if(apt_cache_file != NULL)
+ (*apt_cache_file)->set_read_only(true);
+
+ abort_state.abort();
+
+ // This assumes that either t is still NULL or we got here via a
+ // download-complete callback (i.e., t was automatically joined).
+ delete t;
+ delete log;
+ }
- download_signal_log *m = gen_download_progress(false, false,
- _("Downloading packages"),
- _("View the progress of the package download"),
- _("Package Download"),
- arg(sigc::mem_fun(abort_state,
- &downloader::abort)));
-
- pkgAcquire *acq;
- pkgPackageManager *pm;
- background_status *st = new background_status(m);
- bool ok = prepare_install_run(p.unsafe_get_ref(),
- false, false, st, acq, pm);
+ void start()
+ {
+ vs_progress_ref p = gen_progress_bar();
- p->destroy();
+ bool ok = prepare(*p.unsafe_get_ref(),
+ false, &st, log);
- if(ok)
- (new download_thread(acq,
- sigc::bind(sigc::ptr_fun(&finish_install_or_remove_packages),
- acq, pm, m, st, abort_state)))->start();
- else
- {
- m->Complete();
- active_download = false;
- }
-}
+ p->destroy();
-static void finish_install_or_remove_packages(download_thread *t,
- pkgAcquire::RunResult res,
- pkgAcquire *acq,
- pkgPackageManager *pm,
- download_signal_log *m,
- background_status *st,
- downloader *abort_state)
-{
- vs_progress_ref p = gen_progress_bar();
+ if(ok)
+ (new download_thread(this,
+ sigc::mem_fun(this,
+ (void (ui_install_manager::*)(download_thread *, pkgAcquire::RunResult)) &ui_install_manager::finish)))->start();
+ else
+ delete this;
+ }
+
+ void finish(download_thread *, pkgAcquire::RunResult res)
+ {
+ vs_progress_ref p = gen_progress_bar();
- install_run_result run_res = finish_install_run(p.unsafe_get_ref(),
- false, false, m,
- acq, pm, res);
+ result run_res = download_install_manager::finish(res, *p.unsafe_get_ref());
- p->destroy();
+ p->destroy();
- delete t;
+ delete t;
+ t = NULL;
- if(run_res == install_do_again && !abort_state->get_aborted())
- (new download_thread(acq,
- sigc::bind(sigc::ptr_fun(&finish_install_or_remove_packages),
- acq, pm, m, st, abort_state)))->start();
- else
- {
- delete acq;
- delete pm;
- delete st;
- delete abort_state;
+ if(run_res == do_again && !abort_state.get_aborted())
+ (new download_thread(this,
+ sigc::mem_fun(this,
+ &ui_install_manager::finish)))->start();
+ else
+ delete this;
+ }
+};
- active_download=false;
- }
+
+void install_or_remove_packages()
+{
+ (new ui_install_manager)->start();
}
/** Make sure that no trust violations are about to be committed. If
@@ -1401,62 +1410,67 @@
}
}
-static void finish_update_lists(download_thread *t,
- pkgAcquire::RunResult res,
- pkgAcquire *acq,
- download_signal_log *m,
- background_status *st);
-
-static void really_do_update_lists()
+class ui_update_manager : public download_update_manager
{
- active_download = true;
+ download_signal_log *log;
- if(apt_cache_file != NULL)
- (*apt_cache_file)->set_read_only(true);
+ background_status st;
+public:
+ ui_update_manager()
+ : log(gen_download_progress(false, true,
+ _("Updating package lists"),
+ _("View the progress of the package list update"),
+ _("List Update"),
+ NULL)),
+ st(log)
+ {
+ active_download = true;
- vs_progress_ref p = gen_progress_bar();
+ if(apt_cache_file != NULL)
+ (*apt_cache_file)->set_read_only(true);
+ }
- download_signal_log *m = gen_download_progress(false, true,
- _("Updating package lists"),
- _("View the progress of the package list update"),
- _("List Update"),
- NULL);
+ ~ui_update_manager()
+ {
+ active_download = false;
- background_status *st = new background_status(m);
+ if(apt_cache_file != NULL)
+ (*apt_cache_file)->set_read_only(false);
- pkgAcquire *acq = prepare_pkglist_update(p.unsafe_get_ref(), false,
- st);
+ log->Complete();
+ delete log;
+ }
- if(acq != NULL)
- (new download_thread(acq, sigc::bind(sigc::ptr_fun(&finish_update_lists),
- acq, m, st)))->start();
- else
- {
- m->Complete();
- active_download = false;
- }
+ void start()
+ {
+ vs_progress_ref p = gen_progress_bar();
- p->destroy();
-}
+ bool ok = prepare(*p.unsafe_get_ref(),
+ st, log);
-static void finish_update_lists(download_thread *t,
- pkgAcquire::RunResult res,
- pkgAcquire *acq,
- download_signal_log *m,
- background_status *st)
-{
- vs_progress_ref p = gen_progress_bar();
+ p->destroy();
+
+ if(ok)
+ (new download_thread(this, sigc::mem_fun(this, (void (ui_update_manager::*)(download_thread *, pkgAcquire::RunResult)) &ui_update_manager::finish)))->start();
+ else
+ delete this;
+ }
- finish_pkglist_update(p.unsafe_get_ref(), false, m, acq, res);
+ void finish(download_thread *, pkgAcquire::RunResult res)
+ {
+ vs_progress_ref p = gen_progress_bar();
- delete t;
- delete acq;
- delete m;
- delete st;
+ download_update_manager::finish(res, *p.unsafe_get_ref());
- p->destroy();
+ p->destroy();
- active_download = false;
+ delete this;
+ }
+};
+
+void really_do_update_lists()
+{
+ (new ui_update_manager)->start();
}
void do_update_lists()
More information about the Aptitude-svn-commit
mailing list