1 /* $Id: makeimage.hh,v 1.7 2003/09/16 23:32:10 atterer Exp $ -*- C++ -*-
3 |_) /| Copyright (C) 2003 | richard@
4 | \/¯| Richard Atterer | atterer.net
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License, version 2. See
8 the file COPYING for details.
10 Download & interpret .jigdo, download parts, assemble image
20 #include <jigdoconfig.hh>
22 //______________________________________________________________________
24 /** Download & interpret .jigdo, download parts, assemble image. MakeImage is
25 the "core" class, other components use it for part of the work, e.g.
26 MakeImageDl uses SingleUrls for file downloads, then passes the data to
29 Below, arrow "A->B" means "A uses B"
32 GtkMakeImage(GTK GUI) CursesMakeImage(curses GUI)[0]
35 MakeImageDl "jigdo-file make-image"[1]
40 [0] Curses GUI non-existent so far
41 [1] ATM, jigdo-file uses its own implementation of MakeImage's
42 functionality, TODO fix that.
45 MakeImage: Everything for turning many data sources into one final image
48 <li>Maintains .jigdo file contents, but does not download the .jigdo
49 data - someone else must do this and pass the file to MakeImage.
51 <li>Stores name of .template file once present, opens & reads it.
53 <li>Access to list of MD5 sums which are still needed to complete the
54 image, i.e. list of parts left to download.
56 <li>Lookup of MD5 sum, gives list of URLs for file, with indication WRT
57 which server is preferred by the user.
59 <li>Stores name of output image, creates image and writes to it.
61 <li>You can give it chunks of downloaded data from *any* part, it'll
62 write the output image as far as necessary (with zero areas for as yet
63 non-downloaded data) and write out the downloaded data.
65 <li>For resuming partial downloads of files in the image, can query how
66 many bytes of the data for a part have been passed to MakeImage, and
67 request some of those bytes for the checks of an overlapping resume.
69 <li>Non-blocking operation for .template unpacking: If it needs to
70 write lots of data to disc, will not do this during one long-lasting
71 call to it, but will queue the disc-intensive request and expect you to
72 call it back whenever it should do the next chunk of work.
74 <li>While a disc request is active, downloaded data from any part can
75 still be given to MakeImage. If the respective section of the image has
76 already been written out (filled with zeroes), writes the data to disc.
77 Otherwise, buffers the data. It'll indicate when the amount of buffered
78 data exceeds a certain limit (=> the downloader *should* pause
79 downloading), but will continue to accept and buffer further data.
81 <li>Blocking operation when writing downloaded data: Usually,
82 downloaded data of parts is not buffered in memory. In this case, will
83 always write out the complete supplied data to disc in one go,
84 regardless of the size of the downloaded chunk of data.
88 MakeImageDl: Everything related to downloads
91 <li>Downloads and interprets .jigdo file contents
93 <li>Downloads .template via SingleURL, notifies MakeImage once done
95 <li>"Owner" of the layout of the temporary directory, only component
96 that directly makes modifications to this dir. (MakeImage only writes
99 <li>Does simple cache management; if requested file already downloaded,
100 immediately returns its data, or does an If-Modified-Since request; if
101 partially downloaded, resumes.
103 <li>Starts further SingleURLs for download of individual parts.
105 <li>Automatic server selection: For servers which were rated equally
106 acceptable by the user, measures their speed, then prefers the faster
107 ones (but does not completely stop using the slower ones).
111 GtkMakeImage: Is notified by MakeImageDl when anything interesting
112 happens, updates GTK+ widgets. Also pauses, continues etc. the
114 class MakeImage : NoCopy {
117 /** jigdoFile argument is only used for displaying error messages when
118 scanning the .jigdo file contents.
119 @param destDir destination directory that the final image should be
120 written to. Initially, MakeImage will create a temporary dir (name
121 based on jigdoFile leafname) to store administrative data in. */
122 inline explicit MakeImage();
125 /** Set where to report JigdoConfig errors, overwriting any value passed as
126 jigdoErrors to the ctor. */
127 // inline void setReporter(JigdoConfig::ProgressReporter* jigdoErrors);
129 /** Public data member: Contents of .jigdo file. The component using this
130 MakeImage should retrieve the .jigdo data and add it here with
131 configFile().push_back(line) for each line of the file. Call
132 config.rescan() when done. */
133 // JigdoConfig config;
134 // ConfigFile& configFile() { return config.configFile(); }
136 //______________________________________________________________________
138 MakeImage::MakeImage() { }
140 MakeImage::~MakeImage() { }