[Aptitude-svn-commit] r4336 - in branches/aptitude-0.3/aptitude: .
src
Daniel Burrows
dburrows at costa.debian.org
Thu Sep 29 22:28:49 UTC 2005
Author: dburrows
Date: Thu Sep 29 22:28:46 2005
New Revision: 4336
Modified:
branches/aptitude-0.3/aptitude/ChangeLog
branches/aptitude-0.3/aptitude/src/ui.cc
Log:
Use a generic wrapper object instead of subclassing download managers.
Modified: branches/aptitude-0.3/aptitude/ChangeLog
==============================================================================
--- branches/aptitude-0.3/aptitude/ChangeLog (original)
+++ branches/aptitude-0.3/aptitude/ChangeLog Thu Sep 29 22:28:46 2005
@@ -1,5 +1,10 @@
2005-09-29 Daniel Burrows <dburrows at debian.org>
+ * src/ui.cc:
+
+ Instead of subclassing the download managers, use a generic
+ wrapper class that takes a manager as a constructor parameter.
+
* src/generic/apt/download_manager.h, src/generic/apt/download_install_manager.h, src/generic/apt/download_install_manager.cc, src/ui.cc:
Make prepare() part of the generic download_manager interface
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 22:28:46 2005
@@ -1014,11 +1014,14 @@
}
};
-/** This class self-destructs when it's finished; don't try to delete
- * one on your own.
+/** Represents the UI end of a download process. This object
+ * completely handles its own memory management -- you don't have to
+ * delete it and you shouldn't try.
*/
-class ui_install_manager : public download_install_manager
+class ui_download_manager : public sigc::trackable
{
+ download_manager *manager;
+
download_thread *t;
downloader abort_state;
@@ -1027,8 +1030,8 @@
background_status st;
public:
- ui_install_manager()
- : download_install_manager(false),
+ ui_download_manager(download_manager *_manager)
+ : manager(_manager),
t(NULL),
log(gen_download_progress(false, false,
_("Downloading packages"),
@@ -1047,17 +1050,17 @@
active_preview->destroy();
}
- ~ui_install_manager()
+ ~ui_download_manager()
{
log->Complete();
+ delete manager;
+
active_download = false;
if(apt_cache_file != NULL)
- (*apt_cache_file)->set_read_only(true);
+ (*apt_cache_file)->set_read_only(false);
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;
}
@@ -1066,33 +1069,33 @@
{
vs_progress_ref p = gen_progress_bar();
- bool ok = prepare(*p.unsafe_get_ref(), st, log);
+ bool ok = manager->prepare(*p.unsafe_get_ref(), st, log);
p->destroy();
if(ok)
- (new download_thread(this,
+ (new download_thread(manager,
sigc::mem_fun(this,
- (void (ui_install_manager::*)(download_thread *, pkgAcquire::RunResult)) &ui_install_manager::finish)))->start();
+ &ui_download_manager::done)))->start();
else
delete this;
}
- void finish(download_thread *, pkgAcquire::RunResult res)
+ void done(download_thread *, pkgAcquire::RunResult res)
{
vs_progress_ref p = gen_progress_bar();
- result run_res = download_install_manager::finish(res, *p.unsafe_get_ref());
+ download_manager::result run_res = manager->finish(res, *p.unsafe_get_ref());
p->destroy();
delete t;
t = NULL;
- if(run_res == do_again && !abort_state.get_aborted())
- (new download_thread(this,
+ if(run_res == download_manager::do_again && !abort_state.get_aborted())
+ (new download_thread(manager,
sigc::mem_fun(this,
- &ui_install_manager::finish)))->start();
+ &ui_download_manager::done)))->start();
else
delete this;
}
@@ -1101,7 +1104,7 @@
void install_or_remove_packages()
{
- (new ui_install_manager)->start();
+ (new ui_download_manager(new download_install_manager(false)))->start();
}
/** Make sure that no trust violations are about to be committed. If
@@ -1410,67 +1413,9 @@
}
}
-class ui_update_manager : public download_update_manager
-{
- download_signal_log *log;
-
- 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;
-
- if(apt_cache_file != NULL)
- (*apt_cache_file)->set_read_only(true);
- }
-
- ~ui_update_manager()
- {
- active_download = false;
-
- if(apt_cache_file != NULL)
- (*apt_cache_file)->set_read_only(false);
-
- log->Complete();
- delete log;
- }
-
- void start()
- {
- vs_progress_ref p = gen_progress_bar();
-
- bool ok = prepare(*p.unsafe_get_ref(),
- st, log);
-
- 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;
- }
-
- void finish(download_thread *, pkgAcquire::RunResult res)
- {
- vs_progress_ref p = gen_progress_bar();
-
- download_update_manager::finish(res, *p.unsafe_get_ref());
-
- p->destroy();
-
- delete this;
- }
-};
-
void really_do_update_lists()
{
- (new ui_update_manager)->start();
+ (new ui_download_manager(new download_update_manager))->start();
}
void do_update_lists()
More information about the Aptitude-svn-commit
mailing list