1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>LCOV - lcov.info - /usr/include/apt-pkg/acquire.h</title>
<link rel="stylesheet" type="text/css" href="../../../gcov.css">
</head>
<body>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="title">LTP GCOV extension - code coverage report</td></tr>
<tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
<tr>
<td width="100%">
<table cellpadding=1 border=0 width="100%">
<tr>
<td class="headerItem" width="20%">Current view:</td>
<td class="headerValue" width="80%" colspan=4><a href="../../../index.html">directory</a> - <a href="index.html">usr/include/apt-pkg</a> - acquire.h</td>
</tr>
<tr>
<td class="headerItem" width="20%">Test:</td>
<td class="headerValue" width="80%" colspan=4>lcov.info</td>
</tr>
<tr>
<td class="headerItem" width="20%">Date:</td>
<td class="headerValue" width="20%">2008-08-14</td>
<td width="20%"></td>
<td class="headerItem" width="20%">Instrumented lines:</td>
<td class="headerValue" width="20%">5</td>
</tr>
<tr>
<td class="headerItem" width="20%">Code covered:</td>
<td class="headerValue" width="20%">0.0 %</td>
<td width="20%"></td>
<td class="headerItem" width="20%">Executed lines:</td>
<td class="headerValue" width="20%">0</td>
</tr>
</table>
</td>
</tr>
<tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
</table>
<table cellpadding=0 cellspacing=0 border=0>
<tr>
<td><br></td>
</tr>
<tr>
<td><pre class="source">
<span class="lineNum"> 1 </span> : // -*- mode: cpp; mode: fold -*-
<span class="lineNum"> 2 </span> : // Description /*{{{*/
<span class="lineNum"> 3 </span> : // $Id: acquire.h,v 1.29.2.1 2003/12/24 23:09:17 mdz Exp $
<span class="lineNum"> 4 </span> : /* ######################################################################
<span class="lineNum"> 5 </span> :
<span class="lineNum"> 6 </span> : Acquire - File Acquiration
<span class="lineNum"> 7 </span> :
<span class="lineNum"> 8 </span> : This module contians the Acquire system. It is responsible for bringing
<span class="lineNum"> 9 </span> : files into the local pathname space. It deals with URIs for files and
<span class="lineNum"> 10 </span> : URI handlers responsible for downloading or finding the URIs.
<span class="lineNum"> 11 </span> :
<span class="lineNum"> 12 </span> : Each file to download is represented by an Acquire::Item class subclassed
<span class="lineNum"> 13 </span> : into a specialization. The Item class can add itself to several URI
<span class="lineNum"> 14 </span> : acquire queues each prioritized by the download scheduler. When the
<span class="lineNum"> 15 </span> : system is run the proper URI handlers are spawned and the the acquire
<span class="lineNum"> 16 </span> : queues are fed into the handlers by the schedular until the queues are
<span class="lineNum"> 17 </span> : empty. This allows for an Item to be downloaded from an alternate source
<span class="lineNum"> 18 </span> : if the first try turns out to fail. It also alows concurrent downloading
<span class="lineNum"> 19 </span> : of multiple items from multiple sources as well as dynamic balancing
<span class="lineNum"> 20 </span> : of load between the sources.
<span class="lineNum"> 21 </span> :
<span class="lineNum"> 22 </span> : Schedualing of downloads is done on a first ask first get basis. This
<span class="lineNum"> 23 </span> : preserves the order of the download as much as possible. And means the
<span class="lineNum"> 24 </span> : fastest source will tend to process the largest number of files.
<span class="lineNum"> 25 </span> :
<span class="lineNum"> 26 </span> : Internal methods and queues for performing gzip decompression,
<span class="lineNum"> 27 </span> : md5sum hashing and file copying are provided to allow items to apply
<span class="lineNum"> 28 </span> : a number of transformations to the data files they are working with.
<span class="lineNum"> 29 </span> :
<span class="lineNum"> 30 </span> : ##################################################################### */
<span class="lineNum"> 31 </span> : /*}}}*/
<span class="lineNum"> 32 </span> :
<span class="lineNum"> 33 </span> : /** \defgroup acquire Acquire system
<span class="lineNum"> 34 </span> : *
<span class="lineNum"> 35 </span> : * \brief The Acquire system is responsible for retrieving files from
<span class="lineNum"> 36 </span> : * local or remote URIs and postprocessing them (for instance,
<span class="lineNum"> 37 </span> : * verifying their authenticity). The core class in this system is
<span class="lineNum"> 38 </span> : * pkgAcquire, which is responsible for managing the download queues
<span class="lineNum"> 39 </span> : * during the download. There is at least one download queue for
<span class="lineNum"> 40 </span> : * each supported protocol; protocols such as http may provide one
<span class="lineNum"> 41 </span> : * queue per host.
<span class="lineNum"> 42 </span> : *
<span class="lineNum"> 43 </span> : * Each file to download is represented by a subclass of
<span class="lineNum"> 44 </span> : * pkgAcquire::Item. The files add themselves to the download
<span class="lineNum"> 45 </span> : * queue(s) by providing their URI information to
<span class="lineNum"> 46 </span> : * pkgAcquire::Item::QueueURI, which calls pkgAcquire::Enqueue.
<span class="lineNum"> 47 </span> : *
<span class="lineNum"> 48 </span> : * Once the system is set up, the Run method will spawn subprocesses
<span class="lineNum"> 49 </span> : * to handle the enqueued URIs; the scheduler will then take items
<span class="lineNum"> 50 </span> : * from the queues and feed them into the handlers until the queues
<span class="lineNum"> 51 </span> : * are empty.
<span class="lineNum"> 52 </span> : *
<span class="lineNum"> 53 </span> : * \todo Acquire supports inserting an object into several queues at
<span class="lineNum"> 54 </span> : * once, but it is not clear what its behavior in this case is, and
<span class="lineNum"> 55 </span> : * no subclass of pkgAcquire::Item seems to actually use this
<span class="lineNum"> 56 </span> : * capability.
<span class="lineNum"> 57 </span> : */
<span class="lineNum"> 58 </span> :
<span class="lineNum"> 59 </span> : /** \addtogroup acquire
<span class="lineNum"> 60 </span> : *
<span class="lineNum"> 61 </span> : * @{
<span class="lineNum"> 62 </span> : *
<span class="lineNum"> 63 </span> : * \file acquire.h
<span class="lineNum"> 64 </span> : */
<span class="lineNum"> 65 </span> :
<span class="lineNum"> 66 </span> : #ifndef PKGLIB_ACQUIRE_H
<span class="lineNum"> 67 </span> : #define PKGLIB_ACQUIRE_H
<span class="lineNum"> 68 </span> :
<span class="lineNum"> 69 </span> : #include <vector>
<span class="lineNum"> 70 </span> : #include <string>
<span class="lineNum"> 71 </span> :
<span class="lineNum"> 72 </span> : using std::vector;
<span class="lineNum"> 73 </span> : using std::string;
<span class="lineNum"> 74 </span> :
<span class="lineNum"> 75 </span> :
<span class="lineNum"> 76 </span> : #include <sys/time.h>
<span class="lineNum"> 77 </span> : #include <unistd.h>
<span class="lineNum"> 78 </span> :
<span class="lineNum"> 79 </span> : class pkgAcquireStatus;
<span class="lineNum"> 80 </span> :
<span class="lineNum"> 81 </span> : /** \brief The core download scheduler.
<span class="lineNum"> 82 </span> : *
<span class="lineNum"> 83 </span> : * This class represents an ongoing download. It manages the lists
<span class="lineNum"> 84 </span> : * of active and pending downloads and handles setting up and tearing
<span class="lineNum"> 85 </span> : * down download-related structures.
<span class="lineNum"> 86 </span> : *
<span class="lineNum"> 87 </span> : * \todo Why all the protected data items and methods?
<span class="lineNum"> 88 </span> : */
<span class="lineNum"> 89 </span> : class pkgAcquire
<span class="lineNum"> 90 </span> : {
<span class="lineNum"> 91 </span> : public:
<span class="lineNum"> 92 </span> :
<span class="lineNum"> 93 </span> : class Item;
<span class="lineNum"> 94 </span> : class Queue;
<span class="lineNum"> 95 </span> : class Worker;
<span class="lineNum"> 96 </span> : struct MethodConfig;
<span class="lineNum"> 97 </span> : struct ItemDesc;
<span class="lineNum"> 98 </span> : friend class Item;
<span class="lineNum"> 99 </span> : friend class Queue;
<span class="lineNum"> 100 </span> :
<span class="lineNum"> 101 </span> : typedef vector<Item *>::iterator ItemIterator;
<span class="lineNum"> 102 </span> : typedef vector<Item *>::const_iterator ItemCIterator;
<span class="lineNum"> 103 </span> :
<span class="lineNum"> 104 </span> : protected:
<span class="lineNum"> 105 </span> :
<span class="lineNum"> 106 </span> : /** \brief A list of items to download.
<span class="lineNum"> 107 </span> : *
<span class="lineNum"> 108 </span> : * This is built monotonically as items are created and only
<span class="lineNum"> 109 </span> : * emptied when the download shuts down.
<span class="lineNum"> 110 </span> : */
<span class="lineNum"> 111 </span> : vector<Item *> Items;
<span class="lineNum"> 112 </span> :
<span class="lineNum"> 113 </span> : /** \brief The head of the list of active queues.
<span class="lineNum"> 114 </span> : *
<span class="lineNum"> 115 </span> : * \todo why a hand-managed list of queues instead of std::list or
<span class="lineNum"> 116 </span> : * std::set?
<span class="lineNum"> 117 </span> : */
<span class="lineNum"> 118 </span> : Queue *Queues;
<span class="lineNum"> 119 </span> :
<span class="lineNum"> 120 </span> : /** \brief The head of the list of active workers.
<span class="lineNum"> 121 </span> : *
<span class="lineNum"> 122 </span> : * \todo why a hand-managed list of workers instead of std::list
<span class="lineNum"> 123 </span> : * or std::set?
<span class="lineNum"> 124 </span> : */
<span class="lineNum"> 125 </span> : Worker *Workers;
<span class="lineNum"> 126 </span> :
<span class="lineNum"> 127 </span> : /** \brief The head of the list of acquire method configurations.
<span class="lineNum"> 128 </span> : *
<span class="lineNum"> 129 </span> : * Each protocol (http, ftp, gzip, etc) via which files can be
<span class="lineNum"> 130 </span> : * fetched can have a representation in this list. The
<span class="lineNum"> 131 </span> : * configuration data is filled in by parsing the 100 Capabilities
<span class="lineNum"> 132 </span> : * string output by a method on startup (see
<span class="lineNum"> 133 </span> : * pkgAcqMethod::pkgAcqMethod and pkgAcquire::GetConfig).
<span class="lineNum"> 134 </span> : *
<span class="lineNum"> 135 </span> : * \todo why a hand-managed config dictionary instead of std::map?
<span class="lineNum"> 136 </span> : */
<span class="lineNum"> 137 </span> : MethodConfig *Configs;
<span class="lineNum"> 138 </span> :
<span class="lineNum"> 139 </span> : /** \brief The progress indicator for this download. */
<span class="lineNum"> 140 </span> : pkgAcquireStatus *Log;
<span class="lineNum"> 141 </span> :
<span class="lineNum"> 142 </span> : /** \brief The total size of the files which are to be fetched.
<span class="lineNum"> 143 </span> : *
<span class="lineNum"> 144 </span> : * This is not necessarily the total number of bytes to download
<span class="lineNum"> 145 </span> : * when, e.g., download resumption and list updates via patches
<span class="lineNum"> 146 </span> : * are taken into account.
<span class="lineNum"> 147 </span> : */
<span class="lineNum"> 148 </span> : unsigned long ToFetch;
<span class="lineNum"> 149 </span> :
<span class="lineNum"> 150 </span> : // Configurable parameters for the scheduler
<span class="lineNum"> 151 </span> :
<span class="lineNum"> 152 </span> : /** \brief Represents the queuing strategy for remote URIs. */
<span class="lineNum"> 153 </span> : enum QueueStrategy {
<span class="lineNum"> 154 </span> : /** \brief Generate one queue for each protocol/host combination; downloads from
<span class="lineNum"> 155 </span> : * multiple hosts can proceed in parallel.
<span class="lineNum"> 156 </span> : */
<span class="lineNum"> 157 </span> : QueueHost,
<span class="lineNum"> 158 </span> : /** \brief Generate a single queue for each protocol; serialize
<span class="lineNum"> 159 </span> : * downloads from multiple hosts.
<span class="lineNum"> 160 </span> : */
<span class="lineNum"> 161 </span> : QueueAccess} QueueMode;
<span class="lineNum"> 162 </span> :
<span class="lineNum"> 163 </span> : /** \brief If \b true, debugging information will be dumped to std::clog. */
<span class="lineNum"> 164 </span> : bool Debug;
<span class="lineNum"> 165 </span> : /** \brief If \b true, a download is currently in progress. */
<span class="lineNum"> 166 </span> : bool Running;
<span class="lineNum"> 167 </span> :
<span class="lineNum"> 168 </span> : /** \brief Add the given item to the list of items. */
<span class="lineNum"> 169 </span> : void Add(Item *Item);
<span class="lineNum"> 170 </span> :
<span class="lineNum"> 171 </span> : /** \brief Remove the given item from the list of items. */
<span class="lineNum"> 172 </span> : void Remove(Item *Item);
<span class="lineNum"> 173 </span> :
<span class="lineNum"> 174 </span> : /** \brief Add the given worker to the list of workers. */
<span class="lineNum"> 175 </span> : void Add(Worker *Work);
<span class="lineNum"> 176 </span> :
<span class="lineNum"> 177 </span> : /** \brief Remove the given worker from the list of workers. */
<span class="lineNum"> 178 </span> : void Remove(Worker *Work);
<span class="lineNum"> 179 </span> :
<span class="lineNum"> 180 </span> : /** \brief Insert the given fetch request into the appropriate queue.
<span class="lineNum"> 181 </span> : *
<span class="lineNum"> 182 </span> : * \param Item The URI to download and the item to download it
<span class="lineNum"> 183 </span> : * for. Copied by value into the queue; no reference to Item is
<span class="lineNum"> 184 </span> : * retained.
<span class="lineNum"> 185 </span> : */
<span class="lineNum"> 186 </span> : void Enqueue(ItemDesc &Item);
<span class="lineNum"> 187 </span> :
<span class="lineNum"> 188 </span> : /** \brief Remove all fetch requests for this item from all queues. */
<span class="lineNum"> 189 </span> : void Dequeue(Item *Item);
<span class="lineNum"> 190 </span> :
<span class="lineNum"> 191 </span> : /** \brief Determine the fetch method and queue of a URI.
<span class="lineNum"> 192 </span> : *
<span class="lineNum"> 193 </span> : * \param URI The URI to fetch.
<span class="lineNum"> 194 </span> : *
<span class="lineNum"> 195 </span> : * \param[out] Config A location in which to place the method via
<span class="lineNum"> 196 </span> : * which the URI is to be fetched.
<span class="lineNum"> 197 </span> : *
<span class="lineNum"> 198 </span> : * \return the string-name of the queue in which a fetch request
<span class="lineNum"> 199 </span> : * for the given URI should be placed.
<span class="lineNum"> 200 </span> : */
<span class="lineNum"> 201 </span> : string QueueName(string URI,MethodConfig const *&Config);
<span class="lineNum"> 202 </span> :
<span class="lineNum"> 203 </span> : /** \brief Build up the set of file descriptors upon which select() should
<span class="lineNum"> 204 </span> : * block.
<span class="lineNum"> 205 </span> : *
<span class="lineNum"> 206 </span> : * The default implementation inserts the file descriptors
<span class="lineNum"> 207 </span> : * corresponding to active downloads.
<span class="lineNum"> 208 </span> : *
<span class="lineNum"> 209 </span> : * \param[out] Fd The largest file descriptor in the generated sets.
<span class="lineNum"> 210 </span> : *
<span class="lineNum"> 211 </span> : * \param[out] RSet The set of file descriptors that should be
<span class="lineNum"> 212 </span> : * watched for input.
<span class="lineNum"> 213 </span> : *
<span class="lineNum"> 214 </span> : * \param[out] WSet The set of file descriptors that should be
<span class="lineNum"> 215 </span> : * watched for output.
<span class="lineNum"> 216 </span> : */
<span class="lineNum"> 217 </span> : virtual void SetFds(int &Fd,fd_set *RSet,fd_set *WSet);
<span class="lineNum"> 218 </span> :
<span class="lineNum"> 219 </span> : /** Handle input from and output to file descriptors which select()
<span class="lineNum"> 220 </span> : * has determined are ready. The default implementation
<span class="lineNum"> 221 </span> : * dispatches to all active downloads.
<span class="lineNum"> 222 </span> : *
<span class="lineNum"> 223 </span> : * \param RSet The set of file descriptors that are ready for
<span class="lineNum"> 224 </span> : * input.
<span class="lineNum"> 225 </span> : *
<span class="lineNum"> 226 </span> : * \param WSet The set of file descriptors that are ready for
<span class="lineNum"> 227 </span> : * output.
<span class="lineNum"> 228 </span> : */
<span class="lineNum"> 229 </span> : virtual void RunFds(fd_set *RSet,fd_set *WSet);
<span class="lineNum"> 230 </span> :
<span class="lineNum"> 231 </span> : /** \brief Check for idle queues with ready-to-fetch items.
<span class="lineNum"> 232 </span> : *
<span class="lineNum"> 233 </span> : * Called by pkgAcquire::Queue::Done each time an item is dequeued
<span class="lineNum"> 234 </span> : * but remains on some queues; i.e., another queue should start
<span class="lineNum"> 235 </span> : * fetching it.
<span class="lineNum"> 236 </span> : */
<span class="lineNum"> 237 </span> : void Bump();
<span class="lineNum"> 238 </span> :
<span class="lineNum"> 239 </span> : public:
<span class="lineNum"> 240 </span> :
<span class="lineNum"> 241 </span> : /** \brief Retrieve information about a fetch method by name.
<span class="lineNum"> 242 </span> : *
<span class="lineNum"> 243 </span> : * \param Access The name of the method to look up.
<span class="lineNum"> 244 </span> : *
<span class="lineNum"> 245 </span> : * \return the method whose name is Access, or \b NULL if no such method exists.
<span class="lineNum"> 246 </span> : */
<span class="lineNum"> 247 </span> : MethodConfig *GetConfig(string Access);
<span class="lineNum"> 248 </span> :
<span class="lineNum"> 249 </span> : /** \brief Provides information on how a download terminated. */
<span class="lineNum"> 250 </span> : enum RunResult {
<span class="lineNum"> 251 </span> : /** \brief All files were fetched successfully. */
<span class="lineNum"> 252 </span> : Continue,
<span class="lineNum"> 253 </span> :
<span class="lineNum"> 254 </span> : /** \brief Some files failed to download. */
<span class="lineNum"> 255 </span> : Failed,
<span class="lineNum"> 256 </span> :
<span class="lineNum"> 257 </span> : /** \brief The download was cancelled by the user (i.e., #Log's
<span class="lineNum"> 258 </span> : * pkgAcquireStatus::Pulse() method returned \b false).
<span class="lineNum"> 259 </span> : */
<span class="lineNum"> 260 </span> : Cancelled};
<span class="lineNum"> 261 </span> :
<span class="lineNum"> 262 </span> : /** \brief Download all the items that have been Add()ed to this
<span class="lineNum"> 263 </span> : * download process.
<span class="lineNum"> 264 </span> : *
<span class="lineNum"> 265 </span> : * This method will block until the download completes, invoking
<span class="lineNum"> 266 </span> : * methods on #Log to report on the progress of the download.
<span class="lineNum"> 267 </span> : *
<span class="lineNum"> 268 </span> : * \param PulseInterval The method pkgAcquireStatus::Pulse will be
<span class="lineNum"> 269 </span> : * invoked on #Log at intervals of PulseInterval milliseconds.
<span class="lineNum"> 270 </span> : *
<span class="lineNum"> 271 </span> : * \return the result of the download.
<span class="lineNum"> 272 </span> : */
<span class="lineNum"> 273 </span> : RunResult Run(int PulseInterval=500000);
<span class="lineNum"> 274 </span> :
<span class="lineNum"> 275 </span> : /** \brief Remove all items from this download process, terminate
<span class="lineNum"> 276 </span> : * all download workers, and empty all queues.
<span class="lineNum"> 277 </span> : */
<span class="lineNum"> 278 </span> : void Shutdown();
<span class="lineNum"> 279 </span> :
<span class="lineNum"> 280 </span> : /** \brief Get the first #Worker object.
<span class="lineNum"> 281 </span> : *
<span class="lineNum"> 282 </span> : * \return the first active worker in this download process.
<span class="lineNum"> 283 </span> : */
<span class="lineNum"> 284 </span> : inline Worker *WorkersBegin() {return Workers;};
<span class="lineNum"> 285 </span> :
<span class="lineNum"> 286 </span> : /** \brief Advance to the next #Worker object.
<span class="lineNum"> 287 </span> : *
<span class="lineNum"> 288 </span> : * \return the worker immediately following I, or \b NULL if none
<span class="lineNum"> 289 </span> : * exists.
<span class="lineNum"> 290 </span> : */
<span class="lineNum"> 291 </span> : Worker *WorkerStep(Worker *I);
<span class="lineNum"> 292 </span> :
<span class="lineNum"> 293 </span> : /** \brief Get the head of the list of items. */
<span class="lineNum"> 294 </span> : inline ItemIterator ItemsBegin() {return Items.begin();};
<span class="lineNum"> 295 </span> :
<span class="lineNum"> 296 </span> : /** \brief Get the end iterator of the list of items. */
<span class="lineNum"> 297 </span> : inline ItemIterator ItemsEnd() {return Items.end();};
<span class="lineNum"> 298 </span> :
<span class="lineNum"> 299 </span> : // Iterate over queued Item URIs
<span class="lineNum"> 300 </span> : class UriIterator;
<span class="lineNum"> 301 </span> : /** \brief Get the head of the list of enqueued item URIs.
<span class="lineNum"> 302 </span> : *
<span class="lineNum"> 303 </span> : * This iterator will step over every element of every active
<span class="lineNum"> 304 </span> : * queue.
<span class="lineNum"> 305 </span> : */
<span class="lineNum"> 306 </span> : UriIterator UriBegin();
<span class="lineNum"> 307 </span> : /** \brief Get the end iterator of the list of enqueued item URIs. */
<span class="lineNum"> 308 </span> : UriIterator UriEnd();
<span class="lineNum"> 309 </span> :
<span class="lineNum"> 310 </span> : /** Deletes each entry in the given directory that is not being
<span class="lineNum"> 311 </span> : * downloaded by this object. For instance, when downloading new
<span class="lineNum"> 312 </span> : * list files, calling Clean() will delete the old ones.
<span class="lineNum"> 313 </span> : *
<span class="lineNum"> 314 </span> : * \param Dir The directory to be cleaned out.
<span class="lineNum"> 315 </span> : *
<span class="lineNum"> 316 </span> : * \return \b true if the directory exists and is readable.
<span class="lineNum"> 317 </span> : */
<span class="lineNum"> 318 </span> : bool Clean(string Dir);
<span class="lineNum"> 319 </span> :
<span class="lineNum"> 320 </span> : /** \return the total size in bytes of all the items included in
<span class="lineNum"> 321 </span> : * this download.
<span class="lineNum"> 322 </span> : */
<span class="lineNum"> 323 </span> : double TotalNeeded();
<span class="lineNum"> 324 </span> :
<span class="lineNum"> 325 </span> : /** \return the size in bytes of all non-local items included in
<span class="lineNum"> 326 </span> : * this download.
<span class="lineNum"> 327 </span> : */
<span class="lineNum"> 328 </span> : double FetchNeeded();
<span class="lineNum"> 329 </span> :
<span class="lineNum"> 330 </span> : /** \return the amount of data to be fetched that is already
<span class="lineNum"> 331 </span> : * present on the filesystem.
<span class="lineNum"> 332 </span> : */
<span class="lineNum"> 333 </span> : double PartialPresent();
<span class="lineNum"> 334 </span> :
<span class="lineNum"> 335 </span> : /** \brief Construct a new pkgAcquire.
<span class="lineNum"> 336 </span> : *
<span class="lineNum"> 337 </span> : * \param Log The progress indicator associated with this
<span class="lineNum"> 338 </span> : * download, or \b NULL for none. This object is not owned by the
<span class="lineNum"> 339 </span> : * download process and will not be deleted when the pkgAcquire
<span class="lineNum"> 340 </span> : * object is destroyed. Naturally, it should live for at least as
<span class="lineNum"> 341 </span> : * long as the pkgAcquire object does.
<span class="lineNum"> 342 </span> : */
<span class="lineNum"> 343 </span> : pkgAcquire(pkgAcquireStatus *Log = 0);
<span class="lineNum"> 344 </span> :
<span class="lineNum"> 345 </span> : /** \brief Destroy this pkgAcquire object.
<span class="lineNum"> 346 </span> : *
<span class="lineNum"> 347 </span> : * Destroys all queue, method, and item objects associated with
<span class="lineNum"> 348 </span> : * this download.
<span class="lineNum"> 349 </span> : */
<span class="lineNum"> 350 </span> : virtual ~pkgAcquire();
<span class="lineNum"> 351 </span> : };
<span class="lineNum"> 352 </span> :
<span class="lineNum"> 353 </span> : /** \brief Represents a single download source from which an item
<span class="lineNum"> 354 </span> : * should be downloaded.
<span class="lineNum"> 355 </span> : *
<span class="lineNum"> 356 </span> : * An item may have several assocated ItemDescs over its lifetime.
<span class="lineNum"> 357 </span> : */
<span class="lineNum"> 358 </span> : struct pkgAcquire::ItemDesc
<span class="lineNum"> 359 </span> : {
<span class="lineNum"> 360 </span> : /** \brief The URI from which to download this item. */
<span class="lineNum"> 361 </span> : string URI;
<span class="lineNum"> 362 </span> : /** brief A description of this item. */
<span class="lineNum"> 363 </span> : string Description;
<span class="lineNum"> 364 </span> : /** brief A shorter description of this item. */
<span class="lineNum"> 365 </span> : string ShortDesc;
<span class="lineNum"> 366 </span> : /** brief The underlying item which is to be downloaded. */
<span class="lineNum"> 367 </span> : Item *Owner;
<span class="lineNum"> 368 </span> : };
<span class="lineNum"> 369 </span> :
<span class="lineNum"> 370 </span> : /** \brief A single download queue in a pkgAcquire object.
<span class="lineNum"> 371 </span> : *
<span class="lineNum"> 372 </span> : * \todo Why so many protected values?
<span class="lineNum"> 373 </span> : */
<span class="lineNum"> 374 </span> : class pkgAcquire::Queue
<span class="lineNum"> 375 </span> : {
<span class="lineNum"> 376 </span> : friend class pkgAcquire;
<span class="lineNum"> 377 </span> : friend class pkgAcquire::UriIterator;
<span class="lineNum"> 378 </span> : friend class pkgAcquire::Worker;
<span class="lineNum"> 379 </span> :
<span class="lineNum"> 380 </span> : /** \brief The next queue in the pkgAcquire object's list of queues. */
<span class="lineNum"> 381 </span> : Queue *Next;
<span class="lineNum"> 382 </span> :
<span class="lineNum"> 383 </span> : protected:
<span class="lineNum"> 384 </span> :
<span class="lineNum"> 385 </span> : /** \brief A single item placed in this queue. */
<span class="lineNum"> 386 </span> : struct QItem : pkgAcquire::ItemDesc
<span class="lineNum"> 387 </span> : {
<span class="lineNum"> 388 </span> : /** \brief The next item in the queue. */
<span class="lineNum"> 389 </span> : QItem *Next;
<span class="lineNum"> 390 </span> : /** \brief The worker associated with this item, if any. */
<span class="lineNum"> 391 </span> : pkgAcquire::Worker *Worker;
<span class="lineNum"> 392 </span> :
<span class="lineNum"> 393 </span> : /** \brief Assign the ItemDesc portion of this QItem from
<span class="lineNum"> 394 </span> : * another ItemDesc
<span class="lineNum"> 395 </span> : */
<span class="lineNum"> 396 </span> : void operator =(pkgAcquire::ItemDesc const &I)
<span class="lineNum"> 397 </span> : {
<span class="lineNum"> 398 </span> : URI = I.URI;
<span class="lineNum"> 399 </span> : Description = I.Description;
<span class="lineNum"> 400 </span> : ShortDesc = I.ShortDesc;
<span class="lineNum"> 401 </span> : Owner = I.Owner;
<span class="lineNum"> 402 </span> : };
<span class="lineNum"> 403 </span> : };
<span class="lineNum"> 404 </span> :
<span class="lineNum"> 405 </span> : /** \brief The name of this queue. */
<span class="lineNum"> 406 </span> : string Name;
<span class="lineNum"> 407 </span> :
<span class="lineNum"> 408 </span> : /** \brief The head of the list of items contained in this queue.
<span class="lineNum"> 409 </span> : *
<span class="lineNum"> 410 </span> : * \todo why a by-hand list instead of an STL structure?
<span class="lineNum"> 411 </span> : */
<span class="lineNum"> 412 </span> : QItem *Items;
<span class="lineNum"> 413 </span> :
<span class="lineNum"> 414 </span> : /** \brief The head of the list of workers associated with this queue.
<span class="lineNum"> 415 </span> : *
<span class="lineNum"> 416 </span> : * \todo This is plural because support exists in Queue for
<span class="lineNum"> 417 </span> : * multiple workers. However, it does not appear that there is
<span class="lineNum"> 418 </span> : * any way to actually associate more than one worker with a
<span class="lineNum"> 419 </span> : * queue.
<span class="lineNum"> 420 </span> : *
<span class="lineNum"> 421 </span> : * \todo Why not just use a std::set?
<span class="lineNum"> 422 </span> : */
<span class="lineNum"> 423 </span> : pkgAcquire::Worker *Workers;
<span class="lineNum"> 424 </span> :
<span class="lineNum"> 425 </span> : /** \brief the download scheduler with which this queue is associated. */
<span class="lineNum"> 426 </span> : pkgAcquire *Owner;
<span class="lineNum"> 427 </span> :
<span class="lineNum"> 428 </span> : /** \brief The number of entries in this queue that are currently
<span class="lineNum"> 429 </span> : * being downloaded.
<span class="lineNum"> 430 </span> : */
<span class="lineNum"> 431 </span> : signed long PipeDepth;
<span class="lineNum"> 432 </span> :
<span class="lineNum"> 433 </span> : /** \brief The maximum number of entries that this queue will
<span class="lineNum"> 434 </span> : * attempt to download at once.
<span class="lineNum"> 435 </span> : */
<span class="lineNum"> 436 </span> : unsigned long MaxPipeDepth;
<span class="lineNum"> 437 </span> :
<span class="lineNum"> 438 </span> : public:
<span class="lineNum"> 439 </span> :
<span class="lineNum"> 440 </span> : /** \brief Insert the given fetch request into this queue.
<span class="lineNum"> 441 </span> : *
<span class="lineNum"> 442 </span> : * \return \b true if the queuing was successful. May return
<span class="lineNum"> 443 </span> : * \b false if the Item is already in the queue
<span class="lineNum"> 444 </span> : */
<span class="lineNum"> 445 </span> : bool Enqueue(ItemDesc &Item);
<span class="lineNum"> 446 </span> :
<span class="lineNum"> 447 </span> : /** \brief Remove all fetch requests for the given item from this queue.
<span class="lineNum"> 448 </span> : *
<span class="lineNum"> 449 </span> : * \return \b true if at least one request was removed from the queue.
<span class="lineNum"> 450 </span> : */
<span class="lineNum"> 451 </span> : bool Dequeue(Item *Owner);
<span class="lineNum"> 452 </span> :
<span class="lineNum"> 453 </span> : /** \brief Locate an item in this queue.
<span class="lineNum"> 454 </span> : *
<span class="lineNum"> 455 </span> : * \param URI A URI to match against.
<span class="lineNum"> 456 </span> : * \param Owner A pkgAcquire::Worker to match against.
<span class="lineNum"> 457 </span> : *
<span class="lineNum"> 458 </span> : * \return the first item in the queue whose URI is #URI and that
<span class="lineNum"> 459 </span> : * is being downloaded by #Owner.
<span class="lineNum"> 460 </span> : */
<span class="lineNum"> 461 </span> : QItem *FindItem(string URI,pkgAcquire::Worker *Owner);
<span class="lineNum"> 462 </span> :
<span class="lineNum"> 463 </span> : /** Presumably this should start downloading an item?
<span class="lineNum"> 464 </span> : *
<span class="lineNum"> 465 </span> : * \todo Unimplemented. Implement it or remove?
<span class="lineNum"> 466 </span> : */
<span class="lineNum"> 467 </span> : bool ItemStart(QItem *Itm,unsigned long Size);
<span class="lineNum"> 468 </span> :
<span class="lineNum"> 469 </span> : /** \brief Remove the given item from this queue and set its state
<span class="lineNum"> 470 </span> : * to pkgAcquire::Item::StatDone.
<span class="lineNum"> 471 </span> : *
<span class="lineNum"> 472 </span> : * If this is the only queue containing the item, the item is also
<span class="lineNum"> 473 </span> : * removed from the main queue by calling pkgAcquire::Dequeue.
<span class="lineNum"> 474 </span> : *
<span class="lineNum"> 475 </span> : * \param Itm The item to remove.
<span class="lineNum"> 476 </span> : *
<span class="lineNum"> 477 </span> : * \return \b true if no errors are encountered.
<span class="lineNum"> 478 </span> : */
<span class="lineNum"> 479 </span> : bool ItemDone(QItem *Itm);
<span class="lineNum"> 480 </span> :
<span class="lineNum"> 481 </span> : /** \brief Start the worker process associated with this queue.
<span class="lineNum"> 482 </span> : *
<span class="lineNum"> 483 </span> : * If a worker process is already associated with this queue,
<span class="lineNum"> 484 </span> : * this is equivalent to calling Cycle().
<span class="lineNum"> 485 </span> : *
<span class="lineNum"> 486 </span> : * \return \b true if the startup was successful.
<span class="lineNum"> 487 </span> : */
<span class="lineNum"> 488 </span> : bool Startup();
<span class="lineNum"> 489 </span> :
<span class="lineNum"> 490 </span> : /** \brief Shut down the worker process associated with this queue.
<span class="lineNum"> 491 </span> : *
<span class="lineNum"> 492 </span> : * \param Final If \b true, then the process is stopped unconditionally.
<span class="lineNum"> 493 </span> : * Otherwise, it is only stopped if it does not need cleanup
<span class="lineNum"> 494 </span> : * as indicated by the pkgAcqMethod::NeedsCleanup member of
<span class="lineNum"> 495 </span> : * its configuration.
<span class="lineNum"> 496 </span> : *
<span class="lineNum"> 497 </span> : * \return \b true.
<span class="lineNum"> 498 </span> : */
<span class="lineNum"> 499 </span> : bool Shutdown(bool Final);
<span class="lineNum"> 500 </span> :
<span class="lineNum"> 501 </span> : /** \brief Send idle items to the worker process.
<span class="lineNum"> 502 </span> : *
<span class="lineNum"> 503 </span> : * Fills up the pipeline by inserting idle items into the worker's queue.
<span class="lineNum"> 504 </span> : */
<span class="lineNum"> 505 </span> : bool Cycle();
<span class="lineNum"> 506 </span> :
<span class="lineNum"> 507 </span> : /** \brief Check for items that could be enqueued.
<span class="lineNum"> 508 </span> : *
<span class="lineNum"> 509 </span> : * Call this after an item placed in multiple queues has gone from
<span class="lineNum"> 510 </span> : * the pkgAcquire::Item::StatFetching state to the
<span class="lineNum"> 511 </span> : * pkgAcquire::Item::StatIdle state, to possibly refill an empty queue.
<span class="lineNum"> 512 </span> : * This is an alias for Cycle().
<span class="lineNum"> 513 </span> : *
<span class="lineNum"> 514 </span> : * \todo Why both this and Cycle()? Are they expected to be
<span class="lineNum"> 515 </span> : * different someday?
<span class="lineNum"> 516 </span> : */
<span class="lineNum"> 517 </span> : void Bump();
<span class="lineNum"> 518 </span> :
<span class="lineNum"> 519 </span> : /** \brief Create a new Queue.
<span class="lineNum"> 520 </span> : *
<span class="lineNum"> 521 </span> : * \param Name The name of the new queue.
<span class="lineNum"> 522 </span> : * \param Owner The download process that owns the new queue.
<span class="lineNum"> 523 </span> : */
<span class="lineNum"> 524 </span> : Queue(string Name,pkgAcquire *Owner);
<span class="lineNum"> 525 </span> :
<span class="lineNum"> 526 </span> : /** Shut down all the worker processes associated with this queue
<span class="lineNum"> 527 </span> : * and empty the queue.
<span class="lineNum"> 528 </span> : */
<span class="lineNum"> 529 </span> : ~Queue();
<span class="lineNum"> 530 </span> : };
<span class="lineNum"> 531 </span> :
<span class="lineNum"> 532 </span> : /** \brief Iterates over all the URIs being fetched by a pkgAcquire object. */
<span class="lineNum"> 533 </span> : class pkgAcquire::UriIterator
<span class="lineNum"> 534 </span> : {
<span class="lineNum"> 535 </span> : /** The next queue to iterate over. */
<span class="lineNum"> 536 </span> : pkgAcquire::Queue *CurQ;
<span class="lineNum"> 537 </span> : /** The item that we currently point at. */
<span class="lineNum"> 538 </span> : pkgAcquire::Queue::QItem *CurItem;
<span class="lineNum"> 539 </span> :
<span class="lineNum"> 540 </span> : public:
<span class="lineNum"> 541 </span> :
<span class="lineNum"> 542 </span> : inline void operator ++() {operator ++();};
<span class="lineNum"> 543 </span> :
<span class="lineNum"> 544 </span> : void operator ++(int)
<span class="lineNum"> 545 </span> : {
<span class="lineNum"> 546 </span> : CurItem = CurItem->Next;
<span class="lineNum"> 547 </span> : while (CurItem == 0 && CurQ != 0)
<span class="lineNum"> 548 </span> : {
<span class="lineNum"> 549 </span> : CurItem = CurQ->Items;
<span class="lineNum"> 550 </span> : CurQ = CurQ->Next;
<span class="lineNum"> 551 </span> : }
<span class="lineNum"> 552 </span> : };
<span class="lineNum"> 553 </span> :
<span class="lineNum"> 554 </span> : inline pkgAcquire::ItemDesc const *operator ->() const {return CurItem;};
<span class="lineNum"> 555 </span> : inline bool operator !=(UriIterator const &rhs) const {return rhs.CurQ != CurQ || rhs.CurItem != CurItem;};
<span class="lineNum"> 556 </span> : inline bool operator ==(UriIterator const &rhs) const {return rhs.CurQ == CurQ && rhs.CurItem == CurItem;};
<span class="lineNum"> 557 </span> :
<span class="lineNum"> 558 </span> : /** \brief Create a new UriIterator.
<span class="lineNum"> 559 </span> : *
<span class="lineNum"> 560 </span> : * \param Q The queue over which this UriIterator should iterate.
<span class="lineNum"> 561 </span> : */
<span class="lineNum"> 562 </span> : UriIterator(pkgAcquire::Queue *Q) : CurQ(Q), CurItem(0)
<span class="lineNum"> 563 </span> : {
<span class="lineNum"> 564 </span> : while (CurItem == 0 && CurQ != 0)
<span class="lineNum"> 565 </span> : {
<span class="lineNum"> 566 </span> : CurItem = CurQ->Items;
<span class="lineNum"> 567 </span> : CurQ = CurQ->Next;
<span class="lineNum"> 568 </span> : }
<span class="lineNum"> 569 </span> : }
<span class="lineNum"> 570 </span> : };
<span class="lineNum"> 571 </span> :
<span class="lineNum"> 572 </span> : /** \brief Information about the properties of a single acquire method. */
<span class="lineNum"> 573 </span> : struct pkgAcquire::MethodConfig
<span class="lineNum"> 574 </span> : {
<span class="lineNum"> 575 </span> : /** \brief The next link on the acquire method list.
<span class="lineNum"> 576 </span> : *
<span class="lineNum"> 577 </span> : * \todo Why not an STL container?
<span class="lineNum"> 578 </span> : */
<span class="lineNum"> 579 </span> : MethodConfig *Next;
<span class="lineNum"> 580 </span> :
<span class="lineNum"> 581 </span> : /** \brief The name of this acquire method (e.g., http). */
<span class="lineNum"> 582 </span> : string Access;
<span class="lineNum"> 583 </span> :
<span class="lineNum"> 584 </span> : /** \brief The implementation version of this acquire method. */
<span class="lineNum"> 585 </span> : string Version;
<span class="lineNum"> 586 </span> :
<span class="lineNum"> 587 </span> : /** \brief If \b true, only one download queue should be created for this
<span class="lineNum"> 588 </span> : * method.
<span class="lineNum"> 589 </span> : */
<span class="lineNum"> 590 </span> : bool SingleInstance;
<span class="lineNum"> 591 </span> :
<span class="lineNum"> 592 </span> : /** \brief If \b true, this method supports pipelined downloading. */
<span class="lineNum"> 593 </span> : bool Pipeline;
<span class="lineNum"> 594 </span> :
<span class="lineNum"> 595 </span> : /** \brief If \b true, the worker process should send the entire
<span class="lineNum"> 596 </span> : * APT configuration tree to the fetch subprocess when it starts
<span class="lineNum"> 597 </span> : * up.
<span class="lineNum"> 598 </span> : */
<span class="lineNum"> 599 </span> : bool SendConfig;
<span class="lineNum"> 600 </span> :
<span class="lineNum"> 601 </span> : /** \brief If \b true, this fetch method does not require network access;
<span class="lineNum"> 602 </span> : * all files are to be acquired from the local disk.
<span class="lineNum"> 603 </span> : */
<span class="lineNum"> 604 </span> : bool LocalOnly;
<span class="lineNum"> 605 </span> :
<span class="lineNum"> 606 </span> : /** \brief If \b true, the subprocess has to carry out some cleanup
<span class="lineNum"> 607 </span> : * actions before shutting down.
<span class="lineNum"> 608 </span> : *
<span class="lineNum"> 609 </span> : * For instance, the cdrom method needs to unmount the CD after it
<span class="lineNum"> 610 </span> : * finishes.
<span class="lineNum"> 611 </span> : */
<span class="lineNum"> 612 </span> : bool NeedsCleanup;
<span class="lineNum"> 613 </span> :
<span class="lineNum"> 614 </span> : /** \brief If \b true, this fetch method acquires files from removable media. */
<span class="lineNum"> 615 </span> : bool Removable;
<span class="lineNum"> 616 </span> :
<span class="lineNum"> 617 </span> : /** \brief Set up the default method parameters.
<span class="lineNum"> 618 </span> : *
<span class="lineNum"> 619 </span> : * All fields are initialized to NULL, "", or \b false as
<span class="lineNum"> 620 </span> : * appropriate.
<span class="lineNum"> 621 </span> : */
<span class="lineNum"> 622 </span> : MethodConfig();
<span class="lineNum"> 623 </span> : };
<span class="lineNum"> 624 </span> :
<span class="lineNum"> 625 </span> : /** \brief A monitor object for downloads controlled by the pkgAcquire class.
<span class="lineNum"> 626 </span> : *
<span class="lineNum"> 627 </span> : * \todo Why protected members?
<span class="lineNum"> 628 </span> : *
<span class="lineNum"> 629 </span> : * \todo Should the double members be uint64_t?
<span class="lineNum"> 630 </span> : */
<span class="lineNum"> 631 </span> : class pkgAcquireStatus
<span class="lineNum"> 632 </span> : {
<span class="lineNum"> 633 </span> : protected:
<span class="lineNum"> 634 </span> :
<span class="lineNum"> 635 </span> : /** \brief The last time at which this monitor object was updated. */
<span class="lineNum"> 636 </span> : struct timeval Time;
<span class="lineNum"> 637 </span> :
<span class="lineNum"> 638 </span> : /** \brief The time at which the download started. */
<span class="lineNum"> 639 </span> : struct timeval StartTime;
<span class="lineNum"> 640 </span> :
<span class="lineNum"> 641 </span> : /** \brief The number of bytes fetched as of the previous call to
<span class="lineNum"> 642 </span> : * pkgAcquireStatus::Pulse, including local items.
<span class="lineNum"> 643 </span> : */
<span class="lineNum"> 644 </span> : double LastBytes;
<span class="lineNum"> 645 </span> :
<span class="lineNum"> 646 </span> : /** \brief The current rate of download as of the most recent call
<span class="lineNum"> 647 </span> : * to pkgAcquireStatus::Pulse, in bytes per second.
<span class="lineNum"> 648 </span> : */
<span class="lineNum"> 649 </span> : double CurrentCPS;
<span class="lineNum"> 650 </span> :
<span class="lineNum"> 651 </span> : /** \brief The number of bytes fetched as of the most recent call
<span class="lineNum"> 652 </span> : * to pkgAcquireStatus::Pulse, including local items.
<span class="lineNum"> 653 </span> : */
<span class="lineNum"> 654 </span> : double CurrentBytes;
<span class="lineNum"> 655 </span> :
<span class="lineNum"> 656 </span> : /** \brief The total number of bytes that need to be fetched.
<span class="lineNum"> 657 </span> : *
<span class="lineNum"> 658 </span> : * \warning This member is inaccurate, as new items might be
<span class="lineNum"> 659 </span> : * enqueued while the download is in progress!
<span class="lineNum"> 660 </span> : */
<span class="lineNum"> 661 </span> : double TotalBytes;
<span class="lineNum"> 662 </span> :
<span class="lineNum"> 663 </span> : /** \brief The total number of bytes accounted for by items that
<span class="lineNum"> 664 </span> : * were successfully fetched.
<span class="lineNum"> 665 </span> : */
<span class="lineNum"> 666 </span> : double FetchedBytes;
<span class="lineNum"> 667 </span> :
<span class="lineNum"> 668 </span> : /** \brief The amount of time that has elapsed since the download
<span class="lineNum"> 669 </span> : * started.
<span class="lineNum"> 670 </span> : */
<span class="lineNum"> 671 </span> : unsigned long ElapsedTime;
<span class="lineNum"> 672 </span> :
<span class="lineNum"> 673 </span> : /** \brief The total number of items that need to be fetched.
<span class="lineNum"> 674 </span> : *
<span class="lineNum"> 675 </span> : * \warning This member is inaccurate, as new items might be
<span class="lineNum"> 676 </span> : * enqueued while the download is in progress!
<span class="lineNum"> 677 </span> : */
<span class="lineNum"> 678 </span> : unsigned long TotalItems;
<span class="lineNum"> 679 </span> :
<span class="lineNum"> 680 </span> : /** \brief The number of items that have been successfully downloaded. */
<span class="lineNum"> 681 </span> : unsigned long CurrentItems;
<span class="lineNum"> 682 </span> :
<span class="lineNum"> 683 </span> : public:
<span class="lineNum"> 684 </span> :
<span class="lineNum"> 685 </span> : /** \brief If \b true, the download scheduler should call Pulse()
<span class="lineNum"> 686 </span> : * at the next available opportunity.
<span class="lineNum"> 687 </span> : */
<span class="lineNum"> 688 </span> : bool Update;
<span class="lineNum"> 689 </span> :
<span class="lineNum"> 690 </span> : /** \brief If \b true, extra Pulse() invocations will be performed.
<span class="lineNum"> 691 </span> : *
<span class="lineNum"> 692 </span> : * With this option set, Pulse() will be called every time that a
<span class="lineNum"> 693 </span> : * download item starts downloading, finishes downloading, or
<span class="lineNum"> 694 </span> : * terminates with an error.
<span class="lineNum"> 695 </span> : */
<span class="lineNum"> 696 </span> : bool MorePulses;
<span class="lineNum"> 697 </span> :
<span class="lineNum"> 698 </span> : /** \brief Invoked when a local or remote file has been completely fetched.
<span class="lineNum"> 699 </span> : *
<span class="lineNum"> 700 </span> : * \param Size The size of the file fetched.
<span class="lineNum"> 701 </span> : *
<span class="lineNum"> 702 </span> : * \param ResumePoint How much of the file was already fetched.
<span class="lineNum"> 703 </span> : */
<span class="lineNum"> 704 </span> : virtual void Fetched(unsigned long Size,unsigned long ResumePoint);
<span class="lineNum"> 705 </span> :
<span class="lineNum"> 706 </span> : /** \brief Invoked when the user should be prompted to change the
<span class="lineNum"> 707 </span> : * inserted removable media.
<span class="lineNum"> 708 </span> : *
<span class="lineNum"> 709 </span> : * This method should not return until the user has confirmed to
<span class="lineNum"> 710 </span> : * the user interface that the media change is complete.
<span class="lineNum"> 711 </span> : *
<span class="lineNum"> 712 </span> : * \param Media The name of the media type that should be changed.
<span class="lineNum"> 713 </span> : *
<span class="lineNum"> 714 </span> : * \param Drive The identifying name of the drive whose media
<span class="lineNum"> 715 </span> : * should be changed.
<span class="lineNum"> 716 </span> : *
<span class="lineNum"> 717 </span> : * \return \b true if the user confirms the media change, \b
<span class="lineNum"> 718 </span> : * false if it is cancelled.
<span class="lineNum"> 719 </span> : *
<span class="lineNum"> 720 </span> : * \todo This is a horrible blocking monster; it should be CPSed
<span class="lineNum"> 721 </span> : * with prejudice.
<span class="lineNum"> 722 </span> : */
<span class="lineNum"> 723 </span> : virtual bool MediaChange(string Media,string Drive) = 0;
<span class="lineNum"> 724 </span> :
<span class="lineNum"> 725 </span> : /** \brief Invoked when an item is confirmed to be up-to-date.
<span class="lineNum"> 726 </span> :
<span class="lineNum"> 727 </span> : * For instance, when an HTTP download is informed that the file on
<span class="lineNum"> 728 </span> : * the server was not modified.
<span class="lineNum"> 729 </span> : */
<span class="lineNum"> 730 </span><span class="lineNoCov"> 0 : virtual void IMSHit(pkgAcquire::ItemDesc &/*Itm*/) {};</span>
<span class="lineNum"> 731 </span> :
<span class="lineNum"> 732 </span> : /** \brief Invoked when some of an item's data is fetched. */
<span class="lineNum"> 733 </span><span class="lineNoCov"> 0 : virtual void Fetch(pkgAcquire::ItemDesc &/*Itm*/) {};</span>
<span class="lineNum"> 734 </span> :
<span class="lineNum"> 735 </span> : /** \brief Invoked when an item is successfully and completely fetched. */
<span class="lineNum"> 736 </span><span class="lineNoCov"> 0 : virtual void Done(pkgAcquire::ItemDesc &/*Itm*/) {};</span>
<span class="lineNum"> 737 </span> :
<span class="lineNum"> 738 </span> : /** \brief Invoked when the process of fetching an item encounters
<span class="lineNum"> 739 </span> : * a fatal error.
<span class="lineNum"> 740 </span> : */
<span class="lineNum"> 741 </span><span class="lineNoCov"> 0 : virtual void Fail(pkgAcquire::ItemDesc &/*Itm*/) {};</span>
<span class="lineNum"> 742 </span> :
<span class="lineNum"> 743 </span> : /** \brief Periodically invoked while the Acquire process is underway.
<span class="lineNum"> 744 </span> : *
<span class="lineNum"> 745 </span> : * Subclasses should first call pkgAcquireStatus::Pulse(), then
<span class="lineNum"> 746 </span> : * update their status output. The download process is blocked
<span class="lineNum"> 747 </span> : * while Pulse() is being called.
<span class="lineNum"> 748 </span> : *
<span class="lineNum"> 749 </span> : * \return \b false if the user asked to cancel the whole Acquire process.
<span class="lineNum"> 750 </span> : *
<span class="lineNum"> 751 </span> : * \see pkgAcquire::Run
<span class="lineNum"> 752 </span> : */
<span class="lineNum"> 753 </span> : virtual bool Pulse(pkgAcquire *Owner);
<span class="lineNum"> 754 </span> :
<span class="lineNum"> 755 </span> : /** \brief Invoked when the Acquire process starts running. */
<span class="lineNum"> 756 </span> : virtual void Start();
<span class="lineNum"> 757 </span> :
<span class="lineNum"> 758 </span> : /** \brief Invoked when the Acquire process stops running. */
<span class="lineNum"> 759 </span> : virtual void Stop();
<span class="lineNum"> 760 </span> :
<span class="lineNum"> 761 </span> : /** \brief Initialize all counters to 0 and the time to the current time. */
<span class="lineNum"> 762 </span> : pkgAcquireStatus();
<span class="lineNum"> 763 </span><span class="lineNoCov"> 0 : virtual ~pkgAcquireStatus() {};</span>
<span class="lineNum"> 764 </span> : };
<span class="lineNum"> 765 </span> :
<span class="lineNum"> 766 </span> : /** @} */
<span class="lineNum"> 767 </span> :
<span class="lineNum"> 768 </span> : #endif
</pre>
</td>
</tr>
</table>
<br>
<table width="100%" border=0 cellspacing=0 cellpadding=0>
<tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
<tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LTP GCOV extension version 1.6</a></td></tr>
</table>
<br>
</body>
</html>
|